
function addLoadEvent(func) 
{


  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
    {
	window.onload = func;
    } 
    else 
    {
      window.onload = function() 
      {
        if (oldonload) 
    	 {
	    oldonload();
	  } 

          func();
      }
   }



}



primen = 0;

function writefilter(catname, classname)
{



//var re = new RegExp("=(.{1,4}).>(.*?)<\/a>", "g");

var re = new RegExp("=(.[0-9]{1,2}).>(.*?)<", "g");

//var pattern = /18.*?=(.*?).>(.*?)<\/a>/g;

classname = classname ? classname : "large";


if (catname == "sezon") { catid = 13; defaultname = "Любой"; }
if (catname == "proizv") { catid = 19; defaultname = "Все производители";  }
if (catname == "shirina") { catid = 16; defaultname = "Все";  }
if (catname == "vysota") { catid = 17; defaultname = "Все"; }
if (catname == "diametr") { catid = 18; defaultname = "Все"; }
if (catname == "category") { catid = 1200; defaultname = "Все"; }
if (catname == "diskproizv") { catid = 1184; defaultname = "Все"; }
if (catname == "disktip") { catid = 1183; defaultname = "Все"; }
if (catname == "diskdiametr") { catid = 1182; defaultname = "Все"; }
if (catname == "diskvylet") { catid = 1186; defaultname = "Все"; }

if (catname == "diskpcd") { catid = 1185; defaultname = "Все"; }
if (catname == "diskdiametrotverstiya") { catid = 1188; defaultname = "Все"; }
if (catname == "diskshirinaoboda") { catid = 1187; defaultname = "Все"; }

if (catname == "akbproizv") { catid = 1190; defaultname = "Все"; }
if (catname == "akbemkost") { catid = 1191; defaultname = "Все"; }
if (catname == "akbpolarnost") { catid = 1192; defaultname = "Все"; }
if (catname == "akbpuskovoitok") { catid = 1193; defaultname = "Все"; }



//alert (catname);

if (catname == "diametr")
{
	document.write ('<select onchange="fixr()" id=' + catid + ' class=' + classname + ' name=v[' + catid + ']>'); 	

}
else
{
	document.write ('<select  id=' + catid + ' class=' + classname + ' name=v[' + catid + ']>');	
}

defopt = '<option value="" name="defopt">'  + defaultname + '</option>';
document.write (defopt);

//ale

while (s = re.exec(document.getElementById(catname).innerHTML))

{



if (s[1] != "")
	{
		document.write ("<option value=" + s[1] + ">" + s[2] + "</option>");
	}

}



document.write ("</select>");


ts = document.getElementsByName("defopt"); 
	
	for (i=0; i< ts.length; i++)	
	{	        
	 ts[i].selected = 'true';
	}






}


if (document.getElementsByName("login")[0])
{	


    document.getElementsByName("login")[0].onclick = clearlp;
    document.getElementsByName("password")[0].onclick = clearlp;

    document.getElementsByName("login")[0].value = "Логин";
    document.getElementsByName("password")[0].value = "aaaaa";                     

}



function clearlp()
{
    this.value = "";
}

//window.history.forward(1);




function GetSortAllMorda()
{// Сортировка всех v2

	var url;
	if (document.location.href.match(/CID_9094167/)) { url = "http://kolesomarket.ru/shop/CID_9094167.html?"; }
	else if (document.location.href.match(/CID_9094166/)) { url = "http://kolesomarket.ru/shop/CID_9094166.html?"; }
	else { url = "http://kolesomarket.ru/shop/CID_1752.html?"; }

	


	var i=0;
	var c=arguments.length;



	for(i=0; i<c; i++)
	 { 


		 if(document.getElementById(arguments[i])) url=url+ReturnSortUrl(arguments[i]); 



	 }


	if (document.getElementById('prange') && document.getElementById('prange').selectedIndex) url=url+'&prange='+  document.getElementById('prange').options[document.getElementById('prange').selectedIndex].value;



//	alert (url);
	location.replace(url);
}



if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
{

	document.getElementById ("shinilabel").style.height = "88px";
	document.getElementById ("shinipodbor1").style.height = "130px";  

}





function fixclass1()
{


    var leftcol1 = document.getElementById ("leftcol1");
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
    {
//    leftcol1.style.width = "280px";    
    }
    

    
}





function updatefilters()
{

 if (document.getElementById('catcateg1') && document.getElementById('catcateg1').innerHTML.match(/диски/) && document.getElementById("kartinka55")) 

{

document.getElementById("kartinka55").style.display = "none";


}





var u1 = document.location.href;
var querystring = u1.split ("?")[1];

 if (u1.match(/amtel.html/)) querystring = "v[19]=43";
 if (u1.match(/barum.html/)) querystring = "v[19]=44";
 if (u1.match(/bridgestone.html/)) querystring = "v[19]=45";
 if (u1.match(/continental.html/)) querystring = "v[19]=46";
 if (u1.match(/cordiant.html/)) querystring = "v[19]=153";
 if (u1.match(/contyre.html/)) querystring = "v[19]=47";
 if (u1.match(/dunlop.html/)) querystring = "v[19]=48";
 if (u1.match(/gislaved.html/)) querystring = "v[19]=49";
 if (u1.match(/goodyear.html/)) querystring = "v[19]=50";
 if (u1.match(/hankook.html/)) querystring = "v[19]=51";
 if (u1.match(/matador.html/)) querystring = "v[19]=182";
 if (u1.match(/michelin.html/)) querystring = "v[19]=53";
 if (u1.match(/nexen.html/)) querystring = "v[19]=54";
 if (u1.match(/nokian.html/)) querystring = "v[19]=55";
 if (u1.match(/maxxis.html/)) querystring = "v[19]=157";
 if (u1.match(/pirelli.html/)) querystring = "v[19]=56";
 if (u1.match(/tunga.html/)) querystring = "v[19]=158";
 if (u1.match(/yokohama.html/)) querystring = "v[19]=57"; 
 if (u1.match(/barnaul.html/)) querystring = "v[19]=58";
 if (u1.match(/bc.html/)) querystring = "v[19]=59";
 if (u1.match(/kshz.html/)) querystring = "v[19]=60";
 if (u1.match(/mshz.html/)) querystring = "v[19]=61";
 if (u1.match(/nkshz.html/)) querystring = "v[19]=64";
 if (u1.match(/omsk.html/)) querystring = "v[19]=65";
 if (u1.match(/ural.html/)) querystring = "v[19]=66";
 if (u1.match(/yashz.html/)) querystring = "v[19]=67";
 if (u1.match(/marshal.html/)) querystring = "v[19]=389";
 if (u1.match(/toyo.html/)) querystring = "v[19]=390";
 if (u1.match(/trayal.html/)) querystring = "v[19]=393";
 if (u1.match(/kumho.html/)) querystring = "v[19]=399";
 if (u1.match(/austone.html/)) querystring = "v[19]=431";
 if (u1.match(/nankang.html/)) querystring = "v[19]=432";
 if (u1.match(/bfgoodrich.html/)) querystring = "v[19]=433";
 if (u1.match(/kormoran.html/)) querystring = "v[19]=434";
 if (u1.match(/linglong.html/)) querystring = "v[19]=374";





if (!querystring) { return 0; }

var qspairs = new Array();
qspairs = querystring.split ("&");



var is_something_selected =0;
var f1 = 0;
var count = 0;


	for (i1=0; i1<qspairs.length; i1++)
	{
		p1 = unescape ( qspairs[i1].split("=")[0] );
		v1 = qspairs[i1].split("=")[1];

	        t1sel = document.getElementsByName(p1)

		if (t1sel[0] && p1 && v1)
		{



	 		for (i2=0; i2 < t1sel[0].length; i2++)	
			{



				 	if (t1sel[0].options[i2].value == v1)	
					{


						var prefix = "";
						if (count != 0) { prefix = "&mdash; "; }
				
						count++;
						is_something_selected = 1;				
						if  (is_something_selected == 1 && !f1)
						{
							if (document.getElementById("otborparam")) document.getElementById("otborparam").innerHTML = "<b>Отбор осуществлен по параметрам:</b><br>" + document.getElementById("otborparam").innerHTML;
							f1 = 1;
						}

	
						var nadpis;
				


						if (t1sel[0].id == "13") { nadpis = prefix + "Сезон:";}
						if (t1sel[0].id == "19" || t1sel[0].id == "1184") { nadpis = prefix + "Производитель:"; }
						if (t1sel[0].id == "16") { nadpis = prefix + "Ширина:"; }
						if (t1sel[0].id == "17") { nadpis = prefix + "Высота:"; }
						if (t1sel[0].id == "18" || t1sel[0].id == "1182") { nadpis = prefix + "Диаметр:"; }
						if (t1sel[0].id == "1200") { nadpis = prefix + "Тип шины:"; }
						if (t1sel[0].id == "1183") { nadpis = prefix + "Тип:"; }
						if (t1sel[0].id == "1186") { nadpis = prefix + "Вылет:"; }

						if (t1sel[0].id == "1190") { nadpis = prefix + "Производитель:"; }
						if (t1sel[0].id == "1191") { nadpis = prefix + "Емкость:"; }
						if (t1sel[0].id == "1192") { nadpis = prefix + "Полярность:"; }
						if (t1sel[0].id == "1193") { nadpis = prefix + "Пусковой ток:"; }


						if (t1sel[0].id == "1185") { nadpis = prefix + "PCD:"; }
						if (t1sel[0].id == "1187") { nadpis = prefix + "Ширина обода:"; }
						if (t1sel[0].id == "1188") { nadpis = prefix + "Диаметр отверстия:"; }




						if (t1sel[0].id == "prange") { nadpis = prefix + "Диапазон цены:"; }

								
						

				
						if (document.getElementById("otborparam"))
						{
							eval ('document.getElementById("otborparam").innerHTML = document.getElementById("otborparam").innerHTML + nadpis + t1sel[0].options[i2].innerHTML + " ";');
							eval ('t1sel[0].options[i2].selected = "true";');	
						}


			
					}

		
		                            	

			}
		
			




		}	
	



	}








}





function changelinks ()
{




var time = new Date()
var hour = time.getHours()
var min = time.getMinutes()






if (hour<=9 || hour>=20) 
{ 
	var allpics = document.getElementsByName("phonepic");
	for (i=0; i<allpics.length; i++) 
	{ 
		allpics[i].src = "http://kolesomarket.ru/img/phonepic_red.png"; 
	}

}



if (hour<=8 || hour>=18 || time.getDay()%6==0 || time.getDay()%7==0) 
{ 
	var allpics = document.getElementsByName("phonepicoffice");
	for (i=0; i<allpics.length; i++) 
	{ 
		allpics[i].src = "http://kolesomarket.ru/img/phonepic_red.png"; 
	}

}







var alltks = document.getElementsByName("tovarcurrentsklad1");
for (i=0; i<alltks.length; i++)
	{


		var re1 = /(\d+)/;
		var found;
	        


		if (found = alltks[i].innerHTML.match(re1)) 
		{

//			alert (found[1]);

			var ckolvo;
			if (found[1] > 4 && found[1]<20)  ckolvo = "более 4";
			else if (found[1] > 20		) ckolvo = "более 20";
			else if (found[1] <4) ckolvo = found[1];
			else ckolvo = found[1];
		
			alltks[i].innerHTML = "<b>В наличии:</b> <span class='tovarcurrentsklad1kolvo'>" + ckolvo + "</span>";
		}
		
		

	}

                                                                                                                                                                         




if (

		document.location.href.match(/CID_9094167/) || 
		document.title.match(/Диски/) || 
		(document.getElementById("catcateg1") && document.getElementById("catcateg1").href.match(/CID_9094167/))

    ) 
{




document.getElementById('podbordiv1').style.display = 'none'; 
document.getElementById('podbordiv_diski1').style.display = 'block'; 
document.getElementById('shinilabel5').id='diskilabel5'; 
if (document.getElementById('vendorlist1'))  document.getElementById('vendorlist1').innerHTML = "<li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=255&'>Диски Alcasta</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=254&'>Диски REPLIKA</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=256&'>Диски TREBL</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=258&'>Диски ГАЗ</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=259&'>Диски Кременчуг</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=257&'>Диски Нижний Новгород</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=387&'>Диски IJI</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=394&'>Диски Евродиск</a></li><li><a href='http://kolesomarket.ru/shop/CID_9094167.html?v[1184]=403&'>Диски NZ(Китай)</a></li>";  // DLYA DISKOV


if (document.getElementById('disklink1')) { document.getElementById('disklink1').className = "diskc";   }

}




else if  (

		document.location.href.match(/CID_9094166/) || 
		document.title.match(/аккумуляторы/) || 
		(document.getElementById("catcateg1") && document.getElementById("catcateg1").href.match(/CID_9094166/))

    ) 

{ 



if (document.getElementById('podbordiv_akb1')) document.getElementById('podbordiv_akb1').style.display = 'block'; 
if (document.getElementById('podbordiv1')) document.getElementById('podbordiv1').style.display = 'none'; 
if (document.getElementById('podbordiv_diski1')) document.getElementById('podbordiv_diski1').style.display = 'none'; 

if (document.getElementById('akblink1')) { document.getElementById('akblink1').className = "akbc";   }


if (document.getElementById('vendorlist1')) document.getElementById('vendorlist1').innerHTML = "CONTENT_VLIST";  // DLYA AKB




}





else { 

if (document.getElementById('podbordiv1')) document.getElementById('podbordiv1').style.display = 'block'; 
if (document.getElementById('podbordiv_diski1')) document.getElementById('podbordiv_diski1').style.display = 'none'; 

if (document.getElementById('shinilink1')) { document.getElementById('shinilink1').className = "shinc";   }

}





    alllinks = document.getElementsByTagName ("li");

    for (i = 0; i< alllinks.length; i++)
    {
    //    alert (alllinks[i].innerHTML);

        alllinks[i].innerHTML  = alllinks[i].innerHTML.replace ("/page/catalog.html", "/shop/CID_1752.html?");

        alllinks[i].innerHTML  = alllinks[i].innerHTML.replace ("/page/page10.html", "/news/");
//        alllinks[i].innerHTML  = alllinks[i].innerHTML.replace ("/page/page13.html", "/pricelist/price.xls");

       if (/Категория шины/.exec (alllinks[i].innerHTML))
	{
		
	 	//alllinks[i].style.display = "none";
	}
	
    }


 if (/CID_1752.html(?!\?v)/.exec (document.location) || /CID_9094167.html(?!\?v)/.exec (document.location)  || /CID_9094166.html(?!\?v)/.exec (document.location))
 {
  	 allh1 = document.getElementsByTagName ("h1"); 
	 for (i=0; i<allh1.length; i++)
	 {
	
	   if (/Каталог шин/.exec(allh1[i].innerHTML))
	   {
	     allh1[i].innerHTML = "Каталог шин / <a href='http://www.kolesomarket.ru/shop/CID_9094167.html' style='text-decoration:underline;font-size:17px;font-family:arial;font-weight:normal;'>Каталог Дисков</a> / <a href='http://www.kolesomarket.ru/shop/CID_9094166.html' style='text-decoration:underline;font-size:17px;font-family:arial;font-weight:normal;'>Каталог АКБ</a>";
	   }

	   if (/диски/.exec(allh1[i].innerHTML))
	   {
	     allh1[i].innerHTML = "Каталог дисков / <a href='http://www.kolesomarket.ru/shop/CID_1752.html' style='text-decoration:underline;font-size:17px;font-family:arial;font-weight:normal;'>Каталог Шин</a> / <a href='http://www.kolesomarket.ru/shop/CID_9094166.html' style='text-decoration:underline;font-size:17px;font-family:arial;font-weight:normal;'>Каталог АКБ</a>";
	   }

	   if (/аккумуляторы/.exec(allh1[i].innerHTML))
	   {
	     allh1[i].innerHTML = "Каталог АКБ / <a href='http://www.kolesomarket.ru/shop/CID_1752.html' style='text-decoration:underline;font-size:17px;font-family:arial;font-weight:normal;'>Каталог Шин</a> / <a href='http://www.kolesomarket.ru/shop/CID_9094166.html' style='text-decoration:underline;font-size:17px;font-family:arial;font-weight:normal;'>Каталог Дисков</a>";
	   }


	 }

  }




}




function insertsortfilter (){



	sfilterdiv = document.getElementById ("sortfilter");


	if (sfilterdiv)
	{
	 	

	var n1label = 'changesorttype("name");';
	var p1label = 'changesorttype("price");';
	sfilterdiv.innerHTML = '<a href=# onclick=' + n1label +'>Названию</a>&nbsp;|&nbsp;<a href=# onclick=' + p1label + '>Цене</a>';

	}


}

function changesorttype(stype)
{

 
 var url = window.location.toString();

 if (url.match(/amtel.html/)) url = "/shop/CID_1752.html?v[19]=43";
 if (url.match(/barum.html/)) url = "/shop/CID_1752.html?v[19]=44";
 if (url.match(/bridgestone.html/)) url = "/shop/CID_1752.html?v[19]=45";
 if (url.match(/continental.html/)) url = "/shop/CID_1752.html?v[19]=46";
 if (url.match(/cordiant.html/)) url = "/shop/CID_1752.html?v[19]=153";
 if (url.match(/contyre.html/)) url = "/shop/CID_1752.html?v[19]=47";
 if (url.match(/dunlop.html/)) url = "/shop/CID_1752.html?v[19]=48";
 if (url.match(/gislaved.html/)) url = "/shop/CID_1752.html?v[19]=49";
 if (url.match(/goodyear.html/)) url = "/shop/CID_1752.html?v[19]=50";
 if (url.match(/hankook.html/)) url = "/shop/CID_1752.html?v[19]=51";
 if (url.match(/matador.html/)) url = "/shop/CID_1752.html?v[19]=182";
 if (url.match(/michelin.html/)) url = "/shop/CID_1752.html?v[19]=53";
 if (url.match(/nexen.html/)) url = "/shop/CID_1752.html?v[19]=54";
 if (url.match(/nokian.html/)) url = "/shop/CID_1752.html?v[19]=55";
 if (url.match(/maxxis.html/)) url = "/shop/CID_1752.html?v[19]=157";
 if (url.match(/pirelli.html/)) url = "/shop/CID_1752.html?v[19]=56";
 if (url.match(/tunga.html/)) url = "/shop/CID_1752.html?v[19]=158";
 if (url.match(/yokohama.html/)) url = "/shop/CID_1752.html?v[19]=57"; 
 if (url.match(/barnaul.html/)) url = "/shop/CID_1752.html?v[19]=58";
 if (url.match(/bc.html/)) url = "/shop/CID_1752.html?v[19]=59";
 if (url.match(/kshz.html/)) url = "/shop/CID_1752.html?v[19]=60";
 if (url.match(/mshz.html/)) url = "/shop/CID_1752.html?v[19]=61";
 if (url.match(/nkshz.html/)) url = "/shop/CID_1752.html?v[19]=64";
 if (url.match(/omsk.html/)) url = "/shop/CID_1752.html?v[19]=65";
 if (url.match(/ural.html/)) url = "/shop/CID_1752.html?v[19]=66";
 if (url.match(/yashz.html/)) url = "/shop/CID_1752.html?v[19]=67";
 if (url.match(/marshal.html/)) url = "/shop/CID_1752.html?v[19]=389";
 if (url.match(/toyo.html/)) url = "/shop/CID_1752.html?v[19]=390";
 if (url.match(/trayal.html/)) url = "/shop/CID_1752.html?v[19]=393";
 if (url.match(/kumho.html/)) url= "/shop/CID_1752.html?v[19]=399";
 if (url.match(/austone.html/)) url = "/shop/CID_1752.html?v[19]=431";
 if (url.match(/nankang.html/)) url = "/shop/CID_1752.html?v[19]=432";
 if (url.match(/bfgoodrich.html/)) url = "/shop/CID_1752.html?v[19]=433";
 if (url.match(/kormoran.html/)) url = "/shop/CID_1752.html?v[19]=434";
 if (url.match(/linglong.html/)) url = "/shop/CID_1752.html?v[19]=374";



 url.match(/(.*?)\?(.+)$/);
 var params = RegExp.$2;
 var mainurl = RegExp.$1;

 //alert ("url=" + url + " mainurl=" + mainurl);

 var params = params.split("&");
 var queryStringList = {};


for(var i=0;i<params.length;i++)
 {
 	var tmp = params[i].split("=");
 	queryStringList[tmp[0]] = unescape(tmp[1]);
 }

 
 // print all querystring in key value pairs

 






 mainurl = mainurl + "?";



 for(var i in queryStringList)	
 {
	if (i && i!="#")
	{
        	
        	if (/price/.exec(queryStringList[i]) && stype != "price")	
		 	{		
				continue;
			}

        	if (/name/.exec(queryStringList[i]) && stype != "name")	
		 	{
				continue;
			}

		
		var newparam = queryStringList[i];
		if (i == "sortby")
		{

			if (/asc/.exec(queryStringList[i]))
			{
				newparam = queryStringList[i].replace ("asc", "desc");

			}
			if (/desc/.exec(queryStringList[i]))
			{
				newparam = queryStringList[i].replace ("desc", "asc");
			}
	        }

		mainurl +=  i+ "=" + newparam + "&";

	}
	

 }

  var re = new RegExp( stype );
  var m = mainurl.match(re);
  if (!m)
  { 	

	mainurl += "sortby=" + stype + "_asc";

  }
	



 document.location = mainurl;

}


function otborparam()
{
var op = document.getElementById ("otborparam1");
}


function fixr()
{

document.getElementById ("brendph1").innerHTML = "&nbsp;&nbsp;";

}

function removeElementById(elem) 
{
	elem = document.getElementById(elem);

	if (elem.parentNode && elem.parentNode.removeChild(elem)) 
	{

	//eval ( "elem.parentNode.removeChild(elem);" );

	}


}


function removediv()
{

	
	//alert (document.getElementById ("oldprice").innerHTML);
	var m = /\d/.exec (document.getElementById ("oldprice").innerHTML);

	

	if (m == null)
	{

		removeElementById ("oldprice");
		//document.getElementById ("oldprice").innerHTML = "";

	}
	else
	{
	   document.getElementById ("oldprice").innerHTML = document.getElementById ("oldprice").innerHTML.replace (" руб", "");

	}

	

	if (/камеры|диски|аккум/.exec (document.title))
	{
	    document.getElementById ("kartinka55").innerHTML = "";
	}
	
}




//changelinks ();





function getImgSize(pic){
var h = pic.offsetHeight;
var w = pic.offsetWidth;
return w;
}



function kolvo100() {


var k1 = document.getElementById ("kolvo1");

if (k1)
{     

	var re1 = /(\d+) шт/;
	var found;
	if (found = k1.innerHTML.match(re1))
	{

		if ( found[1] > 4 && found[1] < 20)
		{
		 	k1.innerHTML = k1.innerHTML.replace (found[1], "более 4");
			if (document.getElementById("kolvotoadd")) document.getElementById("kolvotoadd").value = "4";
		}
		if (found[1] >20)
		{
	     		k1.innerHTML = k1.innerHTML.replace (found[1], "более 20");
			if (document.getElementById("kolvotoadd")) document.getElementById("kolvotoadd").value = "4";
		}


		if (found[1] >= 4)
		{

			if (document.getElementById("kolvotoadd")) document.getElementById("kolvotoadd").value = "4";
		}
	
		if (found[1] < 4)
		{
	
			if (document.getElementById("kolvotoadd")) document.getElementById("kolvotoadd").value = "1";
		}
	}


	else { document.getElementById('currentPrice1').innerHTML = '<span id="tovarnosklad">ТОВАРА НЕТ В НАЛИЧИИ</span>'; }

}




}










function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}



 var current_date = new Date;
 var cookie_year = current_date.getFullYear ( );
 var cookie_month = current_date.getMonth ( );
 var cookie_day = current_date.getDate ( ) + 1;



if (!get_cookie ("initref"))
{

	set_cookie ("initref", document.referrer,  cookie_year, cookie_month, cookie_day);


}





if (!get_cookie ("directref") && /openstat/.exec (document.location)){

        var ref1 = document.referrer ? document.referrer : "Bookmark";
	set_cookie ("directref", ref1,  cookie_year, cookie_month, cookie_day);

}





function changeval()
{

var k1 = document.getElementById ("kolvo1"); 
if (k1) 
	{ 

		var re1 = /(\d+) шт/;
		var found = k1.innerHTML.match(re1); 
		if (parseInt(document.getElementById('kolvotoadd').value)<found[1] || (k1.innerHTML.match(/более 4/) && parseInt(document.getElementById('kolvotoadd').value)<20) || k1.innerHTML.match(/более 20/))  document.getElementById('kolvotoadd').value=parseInt(document.getElementById('kolvotoadd').value)+1; 

	}
}                                                          


function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
