function addToCart(guid)
{    
      document.location = '/byko/default.aspx?addproduct='+guid;
}

  function setDescription(guid)
  {            
        var objDescr = document.getElementById('description_'+guid);  
        var sDescr = objDescr.options[objDescr.selectedIndex].value;    
      
        if(sDescr.length > 100) {            
           document.write(sDescr.substring(0,100)+'..');
        }       
        else { 
           document.write(sDescr+'...');        
        }                 
  }

  function addToCartNew(guid, catId)
  {           
       if(catId.length > 0) {    
         document.location ='?addproduct='+guid+'&product_category_id='+catId;
       }
       else {
         document.location ='?addproduct='+guid;
       }       
  }
        
  function addToCart3(guid, catId, measurement, axaptaCategory, sProdName, serial)
  {

    var amount = document.getElementById('amount_'+serial).value;

    if(amount.length > 0)
    {      
       if(isNaN(amount))
       {
         alert('Þú getur bara notuð tölur í magni');
       }
       else
       {
         if(amount > 0)
         {      
      
           var p_guid = document.getElementById('sizeselect_'+guid);
           var iShipment = 1;

           iShipment = shipment(axaptaCategory);
       
           if(p_guid != null)
           {        
              arrGuid = p_guid.value.split(";");
       
              sGuid = arrGuid[0];       
              productName = arrGuid[4]; 
           } 
           else {                             
              sGuid = guid;
              productName = sProdName;
           }

           if(catId.length > 0) {    
              document.location ='?addproduct='+sGuid+'='+amount+'%2bcomm='+measurement+'<>'+iShipment+'<>'+productName+'&product_category_id='+catId;
           }
           else {
              document.location ='?addproduct='+sGuid+'='+amount+'%2bcomm='+measurement+'<>'+iShipment+'<>'+productName;   
           }
         }
       }
    }   
  }


  function shipment(sCat)
  {
      if((sCat.indexOf("/Not Processed/Timbur") == -1) && (sCat.indexOf("/Not Processed/byggingarvörur") == -1)) {
        return 1; 
      }
      else {
        return 0;
      }         
  }
  
 function addRelatedProduct(sUrl, sAxaptaCategory, sProdName) {    
    var sPath = '';
    var iShipment = 1;
    iShipment = shipment(sAxaptaCategory);

    sPath = document.location.pathname;
    sPath = sPath+sUrl+'<>'+iShipment+'<>'+sProdName;   

    document.location = sPath;
  } 
   
      
 function InsertCart_ProductDetails(guid, url, measurement, axaptaCategory, sProdName)
 {   
     //var amount = '1';

     amount = document.getElementById('amount').value;

     var iShipment = 1;

     iShipment = shipment(axaptaCategory);  
        
    if(amount.length > 0)
    {      
       if(isNaN(amount))
       {
         alert('Þú getur bara notuð tölur í magni');
       }
       else
       {
        if(amount > 0)
         {      
           var p_guid = document.getElementById('sizeselect_'+guid)
           var sno_guid;

           if(p_guid != null)
           {
              //sno_guid=p_guid.value;
              var temp = p_guid.value;
              var temp1 = temp.split(';');
              sno_guid = temp1[0];
              
              productName = temp1[4]; 
           }
           else if(p_guid =='undefined')
           {
              sno_guid=guid;
              productName = sProdName;
           }
           else
           {
             sno_guid=guid;
             productName = sProdName;
           }                      
                                                                                           
           var assign1='addproduct='+sno_guid+'='+amount;
           var assign=assign1;
           
           document.location = file_name+url+'&'+assign+'%2bcomm='+measurement+'<>'+iShipment+'<>'+productName;

          }
       }      
    }   
   
  }
   

   var newWindow = null;
   function DetectImageSize(picName,picTitle)
   {
         if (newWindow != null) 
         {
            try 
            {
               //alert(newWindow);
               newWindow.close();
            }
            catch(e)
            {
            }
         }
       
         var objImage = document.getElementById('largeimg_'+picTitle);        
         newWindow=window.open(picName,'newWin','toolbar=no, width='+objImage.width+', height='+objImage.height+';')                 
         newWindow.document.write('<html><head><title>'+picTitle+'</title></head><body style="margin:0px"><center><img src="'+picName+'"></center></body></html>')   
         newWindow.focus()
   }
