﻿// bongs script
function initPage()
{
	var navRoot;
	var lis; 
	
	try
	{
	    navRoot = document.getElementById("bongs");
	    lis = navRoot.getElementsByTagName("li");
	    
	    for (var i=0; i<lis.length; i++)
	    {
		    lis[i].onmouseover = function()
		    {
			    this.className += " hover";
            }
		    
		    lis[i].onmouseout = function()
		    {
    			this.className = this.className.replace(" hover","");
	    	}
	    }	
	}
	catch (e)
	{
	}
}

if (window.attachEvent && !window.opera)
	attachEvent("onload", initPage);
	


// winkelwagen functies
var addtocart = false;

function AddToCart(productid, currentindex)
{   
    try
    {
        var aantalElem = window.document.getElementById("aantal_" + productid);
        var aantal = aantalElem.value;
        
        document.location.href = "shop.aspx?addtocart=" + productid + "&quantity=" + aantal + "&currentindex=" + currentindex;
    }
    catch (e)
    {
        Alert(e.message);
    }
}

function AddToCart(productid)
{   
    try
    {
        var aantalElem = window.document.getElementById("aantal_" + productid);
        var aantal = aantalElem.value;
        addtocart = true;
        document.location.href = "/shop.aspx?addtocart=" + productid + "&quantity=" + aantal + "&ShowProdID=" + productid;
    }
    catch (e)
    {
        Alert(e.message);
    }
}

function AddToCart_s(productid)
{   
    try
    {
        var aantalElem = window.document.getElementById("aantal_s_" + productid);
        var aantal = aantalElem.value;
        addtocart = true;
        document.location.href = "/shop.aspx?addtocart=" + productid + "&quantity=" + aantal + "&ShowProdID=" + productid;
    }
    catch (e)
    {
        Alert(e.message);
    }
}

function AdjustQuantity(productid, quantity)
{
    try
    {        
        document.location.href = "/checkout.aspx?changequantity=" + productid + "&quantity=" + quantity;
    }
    catch (e)
    {
        Alert(e.message);
    }
}
function ChangeQuantity()
{
    addtocart = true;
}
function initRollover()
{

   var nodes;
   
   try
   {
        nodes = document.getElementById("bongs").getElementsByTagName("li");
   }
   catch (e)
   {
        return;
   }
   
   if(nodes)
   {
      var mainHeight = document.getElementById("bongs").offsetHeight;
      for (var i=0; i<nodes.length; i++)
      {
         nodes[i].onclick = function()
         {
            links = this.getElementsByTagName("a");
                       
            if (!addtocart)           
            {
                for (var m=0; m<links.length; m++)
                {      
                                                                             
                    //window.location.href = links[m].href;                                
                }
                addtocart = false;
            }
            
         }
         nodes[i].onmouseover = function () 
         {
            if (this.className.indexOf("hover") == -1)
            {
               this.className += " hover";
            }
         }
         nodes[i].onmouseout = function ()
         {
            this.className = this.className.replace(" hover", "");
         }
         var divs = nodes[i].getElementsByTagName("div");
         if (divs)
         {
            for (var j=0; j<divs.length; j++)
            {
               if(divs[j].className.indexOf("cnt") != -1)
               {
                  divs[j].style.height = mainHeight - 22 + "px";
               }
            }
         }
      }
   }
}
if (window.addEventListener) window.addEventListener("load", initRollover, false);
else if (window.attachEvent) window.attachEvent("onload", initRollover);  
