   function ShowHide(id) {
      $("#submenu"+id).animate({"height": "toggle"}, { duration: 500 });
  	  var roller = $("#roller"+id).attr("src");
	  if(roller == 'http://uspeh-spb.com/images/sidebar-roller.png') {
            $("#roller"+id).attr("src","http://uspeh-spb.com/images/sidebar-roller-up.png");
	  } else {
            $("#roller"+id).attr("src","http://uspeh-spb.com/images/sidebar-roller.png");
	  }
   }

   $(function() {
	var tr_bg = -1;
	$('div.sub-item')
		.mouseover(function(){
			$(this).css("background", "URL('http://uspeh-spb.com/images/submenu-over.gif')");
		})
		.mouseout(function(){
			$(this).css("background", '');
		});
   });



   function HideDiv(id) {
     $('#'+id).hide();
   }

   function ShowMenu(id){
     HideDiv("menu-sub-about");HideDiv("menu-sub-prod");HideDiv("menu-sub-serv");
     $("#"+id).animate({"height": "toggle"}, { duration: 0 }, function() { $(this).hide(); });
   }

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function add2cart(item) {
  if(item != -1) {
    var inCart = parseFloat(document.getElementById ('cart-items-count').innerHTML);
    if(!inCart) 
      inCart = 0; 
    else 
      inCart++;
    if(cart = getCookie("uspeh-cart")) {
	  document.getElementById ('cart-items-count').innerHTML = inCart;
 	  document.cookie = "uspeh-cart=" + cart + ":" + item + "; path=/";
    } else {
	  document.getElementById ('cart-items-count').innerHTML = 1;
	  document.cookie = "uspeh-cart=" + item + "; path=/";
    }
  }
  $("#ok-"+item).animate({"height": "toggle"}, { duration: 600 }, function() { $(this).hide(); });
  $("#ok-"+item).animate({"height": "toggle"}, { duration: 1600 }, function() { $(this).hide(); });
  ajaxrequest();
}

function ajaxrequest() {
	$.ajax ({
		type: "post",
		url: 'http://www.uspeh-spb.com/cart',
		data: "item_string=1",
		success: function(msg) {
			  if(msg <= 0) {
			     $('#total_cost_line').html('<td colspan="3" align="center"><b>Корзина пуста</b></td>');
			  }		
			  $("#total_cost").html(format_cur(msg) + " руб.");
			  $("#total_cost_side").html(format_cur(msg) + " руб.");
			}
		});
}

function delItem (item, id) {
  var cookie = getCookie('uspeh-cart');
  var itemsInCart = cookie.split(':');
  var remove_current = true;
  var new_cookie = '';
  var items_counter = 0;
  for (var key in itemsInCart) {
    var val = itemsInCart [key];
    if(val == item && remove_current == true) {
      remove_current = false;
      continue;
    }
    if(val != '') {
      if(new_cookie == '') new_cookie = val;
      else new_cookie = new_cookie + ':' + val;
      items_counter++;
    }
  }
  document.getElementById ('item-'+id).style.display = "none";
  document.getElementById ('cart-items-count').innerHTML = items_counter;
  document.cookie = "uspeh-cart=" + new_cookie;
  ajaxrequest();
}

function chunk_split (body, chunklen, end) {
    chunklen = parseInt(chunklen, 10) || 76;
    end = end || '\r\n';

    if (chunklen < 1) {
        return false;
    }

    return body.match(new RegExp(".{0," + chunklen + "}", "g")).join(end);

}
function strrev (string) {
    string = string + '';
    var grapheme_extend = /(.)([\uDC00-\uDFFF\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065E\u0670\u06D6-\u06DC\u06DE-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0901-\u0903\u093C\u093E-\u094D\u0951-\u0954\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D02\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F90-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B6-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAA\u1C24-\u1C37\u1DC0-\u1DE6\u1DFE\u1DFF\u20D0-\u20F0\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA67C\uA67D\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA926-\uA92D\uA947-\uA953\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uFB1E\uFE00-\uFE0F\uFE20-\uFE26]+)/g;
    string = string.replace(grapheme_extend, '$2$1'); // Temporarily reverse
    return string.split('').reverse().join('');
}


function format_cur(value) {
	return strrev(chunk_split(strrev(parseFloat(value)),3," "));
}

       window.onload = function init () {
            var map = new YMaps.Map(document.getElementById("YMapsID"));
			// Start coord. + zoom + type
            map.setCenter(new YMaps.GeoPoint
			(30.362853,59.923793), // start coord
			20, // zoom
			YMaps.MapType.MAP);
			//map.addControl(new YMaps.SmallZoom());
            map.addControl(new YMaps.ToolBar());
            map.addControl(new YMaps.TypeControl());
 	    var point = new YMaps.GeoPoint(30.362853,59.923793);
  	    var placemark = new YMaps.Placemark(point, {style: "example#map_point_0"});
			placemark.name = 'Офис ООО Успех';
			newvar = "'";
			placemark.description = 'Офис "Успех"';
			map.addOverlay(placemark);
        };

