  var arrProducts = new Array();

  function addProduct(name, value, url, guid)
  {
      arrProducts[arrProducts.length] = name+'###'+value+'###'+url+'###'+guid;
  }
  

  function getProductName()
  {
	arrContent = document.cookie.split("<<<<");            
	sContent = arrContent[1];  
     
    return sContent;
  }
  

  function deleteCookie(name)
  {   
    var date = new Date();

    date.setTime(date.getTime()+(-1*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();

    document.cookie = name+"="+"delete"+expires;
  }

  function setCookie(name, value)
  {
      var date = new Date();

      date.setTime(date.getTime()+(1*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
                  
      document.cookie = name+"="+value+ '; path=/byko;' + expires;                                                                  
  }


  function getRelproducts(prodVal)
  {
     var sValues = '><><';

     for(i=0; i<arrProducts.length; i++)
     {
         arrProdVal = arrProducts[i].split("###");
                                              
         if(arrProdVal[1] == prodVal)
         {                            
            sValues = sValues+arrProducts[i]+"$$$";
         }          
     }
     sValues = sValues+'><><';  

     return sValues;
  }


  function submitForm(objForm, path, prodVal)
  {        
    deleteCookie("selProducts"); 
    var sProducts = getRelproducts(prodVal);
    setCookie("selProducts", sProducts);
                                                  
    arrID = path.split("&");

    arrCatID = arrID[0].split("=");
    arrPID = arrID[1].split("=");

    document.getElementById('ew_0_cat_id').value = arrCatID[1];
    document.getElementById('ew_0_p_id').value = arrPID[1];
                  
    objForm.action = '/byko/vara/default.aspx';      
    objForm.submit();     

    return true;
  }
  /** Next **/
  
   function popup(path, catId, pId, pName)
   { 
     /*        
	 setCookie("prodName", "<<<<"+pName+"<<<<");	   	 
   	 alert(getProductName());
   	 */   	              
     window.open("http://verslun.byko.is/byko/popups/sendavoru?showxml=true&"+"catId="+catId+"&"+"prodID="+pId+"&"+"pName="+pName+"&"+path,"","width=555,height=695,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes");
   }
   
   function changeProduct()
   {                    
      var objSel = document.getElementById("selProduct");
      var sValue = objSel.value;
      sValue = sValue.replace("?",""); 
                        
      arrSel = sValue.split("&");

      arrCat = arrSel[0].split("=");
      arrID = arrSel[1].split("=");
               
      document.getElementById('ew_0_cat_id').value = arrCat[1];
      document.getElementById('ew_0_p_id').value = arrID[1];

      document.prodForm.action = "/byko/vara/default.aspx";       
      document.prodForm.submit();                        
   }
   
               
   function setRelProducts(curProduct)
   { 
     
     dc = document.cookie;
     var prefix = "selProduct";
     var begin = dc.indexOf(prefix);
          
     if(begin != -1)
     {     	  			                                                                                
		arrContent = document.cookie.split("><><");            
		sContent = arrContent[1];                                 		                                                        
		var objSel = document.getElementById("selProduct");
						   	                             
		arrProd = sContent.split("$$$");
	    
		for(var i=0; i<arrProd.length-1; i++) 
		{
				arrOption = arrProd[i].split("###");
				var selOption = document.createElement("OPTION");
				selOption.text = arrOption[0];
	             
				objSel.options.add(selOption);

				selOption.innerText = arrOption[0];
				selOption.value = arrOption[2];

				if(arrOption[3] == curProduct)
				{ 
					objSel.selectedIndex = i;                                        
				}    
		}
	  }	                                                        
   }



