var combowidth='';
var comboheight='';

// Месага о добавлении товара в корзину
function initialize(){
if (document.all){
combowidth=cartwindow.offsetWidth;
comboheight=cartwindow.offsetHeight;
setInterval("staticit_ie()",50);
try{
cartwindow.filters.revealTrans.Apply();
cartwindow.filters.revealTrans.Play();
cartwindow.style.visibility="visible";
}
catch(e){}
}
else if (document.layers){
combowidth=document.cartwindow.document.width;
comboheight=document.cartwindow.document.height;
setInterval("staticit_ns()",50);
document.cartwindow.visibility="show";
}
}

function initialize_off(){
if (document.all){
combowidth=cartwindow.offsetWidth;
comboheight=cartwindow.offsetHeight;
setInterval("staticit_ie()",50);
cartwindow.style.visibility="hidden";
}
else if (document.layers){
combowidth=document.cartwindow.document.width;
comboheight=document.cartwindow.document.height;
setInterval("staticit_ns()",50);
document.cartwindow.visibility="hide";
}
}

function staticit_ie(){
cartwindow.style.pixelLeft=document.body.scrollLeft+document.body.clientWidth-combowidth-30;
cartwindow.style.pixelTop=document.body.scrollTop+document.body.clientHeight-comboheight;
}

function staticit_ns(){
document.cartwindow.left=pageXOffset+window.innerWidth-combowidth-30;
document.cartwindow.top=pageYOffset+window.innerHeight-comboheight;
}


function setCookie(name, value)
{
   var today = new Date()
   var expires = new Date()
   expires.setTime(today.getTime() + 1000*24*60*60)
   document.cookie = name + "=" +escape(value)+ ((expires == null) ? "" : ("; expires=" +expires))+";path=/";
}



function getCookie(Name)
{
   var search = Name + "="
   if (document.cookie.length > 0)
   { // если есть какие-либо куки
      offset = document.cookie.indexOf(search)
      if (offset != -1)
      { // если кука существует
         offset += search.length
         // установить индекс начала значения
         end = document.cookie.indexOf(";", offset)
         // установить индекс конца значения куки
         if (end == -1)
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
      else return(false);
   }
}


/* поиск в строке*/
function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}


function addorder(pagelink,modname,formname)
{
  var i=0,str,tempstr,newstr="",isorder="false",calc=0,num=0,price,j=1,temp,getprice,qwert
  var massive=""
  var f, num
  var tkan1,tkan2
// if(confirm("Добавить товар в корзину?")) {
	
  var present, options;
	
  tempstr=pagelink.split(",")
  num=str_replace("calck", "", formname);
  
  if (num==""){
		if (document.getElementById('cost_valuemain').innerHTML=='') 
			getprice=document.getElementById('cost_valuemain').value;
		else
			getprice=document.getElementById('cost_valuemain').innerHTML;
		
	}else{
		getprice=document.getElementById('cost_value'+num).value;
		
	}
	
  
  
  if(tempstr[1]=="k")
  {
	
	
	
	
	if(document[formname].sizenum.value) temp=document[formname].sizenum.value
    
    temp-=0
    temp+=1
    tempstr[4]=temp
    pagelink=tempstr[0]
    while(tempstr[j])
    {
      pagelink+=","+tempstr[j]
      j+=1
    }
  }
  if(tempstr[1]=="m")
  {
	
    tempstr[3]=document.all('sel_tgr').value
    tempstr[4]=document.all('szn').value
    tempstr[5]=document.all('mht').value
    pagelink=tempstr[0]
	
    for(j=1;j<6;j++)
    {
      if(tempstr[j]==""){ tempstr[j] = ""}
      pagelink+=","+tempstr[j]
    }
	
	
  }

  // дополнительные опции
  if (document.all('options')) {
	options = document.all('options').value;
  }

  str=getCookie(cookiname)
  
  if(str)
  {
        massive=str.split(";")
        while(massive[i])
        {
          tempstr=massive[i].split("|")
	
          if(pagelink==tempstr[0])
          {
            tempstr[2]-=0
            tempstr[2]+=1
            isorder="true"
            massive[i]=tempstr.join("|")
          }
          i+=1
        }
        newstr=massive.join(";")
		
        if(isorder!="true")
        {
			
          
		  
		  			
   			qwert=getprice.split(" ")
			
             try{
	            tkan1=document.all('main_tk').value
				tkan2=document.all('dop_tk').value
			  }
			  catch(e){}
          	newstr+=";"+pagelink+"|"+modname+"|1|"+qwert[0]+"|"+tkan1+"|"+tkan2+"|"+options+"|"+present
			

        }
        setCookie(cookiname,newstr);
	
  }
  else
  {
  	
	//getprice=document.all('cost').innerHTML;
  	qwert=getprice.split(" ")
   			try{
              	tkan1=document.all('main_tk').value
			  	tkan2=document.all('dop_tk').value
			}catch(e){}
          	str=pagelink+"|"+modname+"|1|"+qwert[0]+"|"+tkan1+"|"+tkan2+"|"+options+"|"+present
  	setCookie(cookiname,str)
  }
	
 i=0
  str=getCookie(cookiname)
  massive=str.split(";")
  while(massive[i])
  {
    tempstr=massive[i].split("|")
    tempstr[2]-=0
    price=tempstr[3].split(" ")
    price[0]-=0
    num+=tempstr[2]
    calc+=tempstr[2]*price[0]
    i+=1
  }
  //document.write(getCookie("order"))
  colvo.innerHTML="Товаров: "+num;
  summa.innerHTML="Заказ на сумму: <div>"+calc+" руб.</div>";
  //initialize()
  //setTimeout("initialize_off()",3000)
//} // конец confirm




// открываем окно с корзиной
NewWindow('/rec_window.php?'+num+calc,'_blank',300,150,'no');
//window.open('/rec_window.php?'+num+calc,'_blank','width=300, height=150, scrollbars=no, resizable=no, location=0, left=300, top=250');

}
