          $(document).ready(function () {
            $('#cart')
              .html('<center><img src="/i/loading.gif" style="margin:10px;"><br>загрузка корзины...</center>')
              .load(encodeURI("/shop/listcart.php?r="+Math.random()))
              .scrollFollow({
                speed: 1000,
                offset: 5,
                killSwitch: 'exampleLink',
                onText: 'Disable Follow',
                offText: 'Enable Follow',
                easing: 'easeOutBounce'
               
              });
          });


function togglelist(idDiv,idImg){
	
        eTarget = document.getElementById(idDiv);
	eTarget.style.display == "none" ? eTarget.style.display = "block":eTarget.style.display = "none";
	eTarget.display == "none" ? eTarget.display = "block":eTarget.display = "none";

	iTarget = document.getElementById(idImg);
	eTarget.style.display == "none" ? iTarget.src = '../i/plus.gif':iTarget.src = '../i/minus.gif' ;

}



function AddToCart(id)
{
  //$.add2cart('img'+id, 'cart');
  $("#cart").html("<center><img src=\"/i/loading.gif\" style=\"margin:10px;\"><BR>добавляем товар в корзину...</center>");
  //alert(queryString);
  $.post(
    '/shop/listcart.php',
    $("#addtocart"+id).formSerialize(),
    function(data){
      $("#cart").html(data);
    }
  );
  return false;
}

function ItemUpdate(id, action)
{
$("#cart")
  .html("<center><img src=\"/i/loading.gif\" style=\"margin:10px;\"><BR>пересчет корзины...</center>")
  .load(encodeURI("/shop/listcart.php?action="+action+"&id="+id+"&r="+Math.random()));
return false;
}

function ItemMinus(id)
{
ItemUpdate(id, 'itemminus');
return false;
}

function ItemPlus(id)
{
ItemUpdate(id, 'itemplus');
return false;
}

g_stores = null;

function get_stores() {
  if (g_stores === null) {
    $.ajax({
      url:  '/shop/get_stores.php',
      async:false,
      dataType:'json',
      success: function(data) {
        g_stores = [];
        if (data.stores)
          for (var i in data.stores)
            g_stores[ data.stores[i].id ] = data.stores[i];
      }
    });
  }
  return g_stores;
}

$(document).ready(function() {


           
          

  // Сразу после загрузки страницы
  $('.tovar_params_selector,.tovar_param_selector').each(function() {
    var tbl = $(this),
        avail_status = $('.avail_status', tbl),
        id = tbl.attr('id').replace('params_selector_', ''),
        btn = $('#basketbtn_' + id);
    $('input[avail]', this).click(function() {
      $('.cur', tbl).removeClass('cur');
      var avail = $(this).attr('avail');
      var mes = '<font color="red">нет в наличии</font>';
      if (avail == '-') {
        btn.hide();
      }
      else if (avail == '#') {
        mes = '<font color="green">в наличии</font>';
        btn.show();
      }
      else {
        avail = avail.split(',');
        mes = [];
        var stores = get_stores();
        for (i in avail) {
          if (stores[ avail[i] ])
            mes.push('<a href="/docs/proezd.html#map' + avail[i] + '">' + stores[ avail[i] ].short_name + '</a>');
        }
        mes = '<font color="green">в наличии:</font> ' + mes.join(', ');
        btn.show();
      }
      avail_status.html(mes);
      $(this).parent().parent('td').addClass('cur');
    });
    var first = $('.avail:first INPUT[avail]', this);
    if (!first.size()) {
      first = $('INPUT[avail]:first', this);
    }
    first.click();//.triggerHandler('change');
  });

});

function	imgOpacity (classname)
{
	opacity = 20;
  for (i = 0; i < document.all.length; ++i) {
		if (document.all[i].className == classname) {
			document.all[i].onload = opacity_hideImg;
			document.all[i].onmouseover = opacity_showImg;
			document.all[i].onmouseout = opacity_hideImg;
			document.all[i].style.filter='alpha(opacity=' + opacity + ')';
		};
	}
  return;
}

function	opacity_hideImg ()
{
	opacity = 20;
	this.style.filter='alpha(opacity=' + opacity + ')';
}


function	opacity_showImg ()
{
	opacity = 100;
	this.style.filter='alpha(opacity=' + opacity + ')';
}
imgOpacity ('cImg');

function ImageWindow( uri ) {
	myWin = open(uri, "linkWindow", "width=530,height=400,status=no,toolbar=no,menubar=no, titlebar=no, scrollbars=yes, resizable=yes")
}


function LinkWindowWide( uri,w,h) {
	myWin = open(uri, "linkWindow", "width="+w+",height="+h+",status=no,toolbar=no,menubar=no, titlebar=no, scrollbars=yes, resizable=yes")
}

function del_str( del, rep , str  )
{
	res = str;

	while( res.search(del) >= 0  )
	{
		res = res.replace( del, rep );
	}

	return res;
}



function pic(img_path,iw,ih){	
var img_alt;
var str, StrBody;
img_alt='SKIMASTER.RU';

	str = 'resizable=yes,width=200,height=200,screenX=200,screenY=200,left=50,top=50';
	
	if (document.all){ 
		StrBody = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White" onblur="self.window.close();" onresize="self.window.location.reload();">';
	} else {
		StrBody = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White" onblur="self.window.close();">';
	}
		
	var win_op = window.open('','show', str);
	win_op.document.open();
	win_op.document.writeln('<html>');
	win_op.document.writeln('<head>');
	win_op.document.writeln('<title>' + del_str('<br>',' ',img_alt) + '</title>');
	win_op.document.writeln('<script>');
	win_op.document.writeln('function resize_img() {');
	win_op.document.writeln('var width = document.image.width;');
	win_op.document.writeln('var height = document.image.height;');
	win_op.document.writeln('if (!(document.all)){ self.resizeTo(width,height+61); } else { self.resizeTo((width+12),(height + 61));');
	win_op.document.writeln(' }');
	win_op.document.writeln('}');
	win_op.document.writeln('</script>');	
	win_op.document.writeln('</head>');
	win_op.document.writeln(StrBody);
	win_op.document.writeln('<img name="image" src='+ img_path + ' border=0 alt="' + del_str('<br>',' ',img_alt) + '" onload="resize_img();">');
	win_op.document.writeln('</body>');
	win_op.document.writeln('</html>');		
	win_op.document.close();
}



// Проверка броузера и установка ширины окна открываемого в нем (для фотогалереи)
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
var agent = navigator.userAgent;

if (agent.indexOf("Opera") > -1) {
	var send_height = 600;
	var send_width = 627;
}
else if ((browserVer >3) && (browserName == "Microsoft Internet Explorer")) {
	var send_height = 600;
	var send_width = 627;
}
else if ((browserVer >3) &&(browserName == "Netscape")) {
	var send_height = 600;
	var send_width = 624;
}



function GetCenterPosition()
{
   var send_left = (screen.availWidth / 2) - (send_width / 2);
   var send_top = (screen.availHeight / 2) - (send_height / 2);

   return "height="+send_height+",width="+send_width+",top="+send_top+",left="+send_left+",toolbar=0,scrollbars=2,resizable=no";
}
function GetCenterPosition_resize()
{
   var send_left = (screen.availWidth / 2) - (send_width / 2);
   var send_top = (screen.availHeight / 2) - (send_height / 2);

   return "height="+send_height+",width="+send_width+",top="+send_top+",left="+send_left+",toolbar=0,scrollbars=2,resizable=yes";
}


// Открытие IPIX в новом окне
function ipix_open(width, height, src, title){

    param = "width="+width+", height="+height;
    var win=window.open('','win',param);   
    win.focus();

	win.document.open();
	win.document.writeln('<html>');
	win.document.writeln('<head>');
	win.document.writeln('<title>' + title + '</title>');
	win.document.writeln('</head>');
	win.document.writeln('<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White">');
	win.document.writeln('<OBJECT ID="IpixX1" WIDTH="'+width+'" HEIGHT="'+height+'" CLASSID="CLSID:11260943-421B-11D0-8EAC-0000C07D88CF" CODEBASE="http://www.ipix.com/viewers/ipixx.cab#version=6,0,0,2"><PARAM NAME="IPXFILENAME" VALUE="'+src+'"><EMBED SRC="'+src+'" WIDTH="'+width+'" HEIGHT="'+height+'"  BORDER=0 PALETTE="FOREGROUND" TYPE="application/x-ipix" PLUGINSPAGE="http://www.ipix.com/cgi-bin/download.cgi"></EMBED></OBJECT>');
	win.document.writeln('</body>');
	win.document.writeln('</html>');		
	win.document.close();
}


function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}
 
function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}

