﻿

    var numberOfLineItems=0;
    var numberOfCountItems=0;
    
   
    function add2cart(tf,q,pid,pdesc,poptions)
    {
        var oldValue=readCookie("dpps");
        if(oldValue==null)
        {
            oldValue=""
        }
        newValue = "!" + tf + "!" + q + "!" + pid + "!" + pdesc + "!" + poptions;
        var thisValue = oldValue + newValue;
        createCookie("dpps",thisValue,0);
        cartContainsShow(0);
        document.getElementById("qty").value=1;
    }
    
	function cartContainsShow(n)
	{
	    if(n==0)
	    {
    	    readItemsInCart();
	        document.getElementById("cartcontains").style.color="black";
	        document.getElementById("cartcontains").style.fontSize="10pt";
  	        document.getElementById("cartcontains").style.backgroundColor="transparent";
            setTimeout("cartContainsShow(1)",200)	   
	    } else if(n==1)
	    {
	        document.getElementById("cartcontains").style.color="white";
    	    document.getElementById("cartcontains").style.fontSize="10pt";
    	    document.getElementById("cartcontains").style.backgroundColor="darkgreen";
    	    setTimeout("cartContainsShow(2)",400)	   
	    } else if(n==2)
	    {
    	    document.getElementById("cartcontains").style.color="black";
	        document.getElementById("cartcontains").style.fontSize="10pt";
  	        document.getElementById("cartcontains").style.backgroundColor="transparent";
            setTimeout("cartContainsShow(3)",200)	   
	    } else if(n==3)
        {
            document.getElementById("cartcontains").style.color="white";
    	    document.getElementById("cartcontains").style.fontSize="10pt";
    	    document.getElementById("cartcontains").style.backgroundColor="darkgreen";
    	    setTimeout("cartContainsShow(4)",400)	   
        } else if(n==4)
        {
            document.getElementById("cartcontains").style.color="black";
	        document.getElementById("cartcontains").style.fontSize="10pt";
  	        document.getElementById("cartcontains").style.backgroundColor="transparent";
        }
	}   
	
	function readItemsInCart()
    {
        var itemsPerRecord=5;
        var thisbite=0;
        var cookie = new Array()
        var crumbs = new Array()
        var x=1;
        var i=0;
        var j=0;
        
        if(readCookie("dpps"))
        {
            cookie=readCookie("dpps").split("!")
        } else
        {
            cookie="".split("!");
        }
        
        i=parseInt((cookie.length-1)/itemsPerRecord)
        for(j=1;j<=i;j++)
        {
            crumbs[j]=new Array();
        }
        
        while(cookie[x]!=null && cookie[x]!="")
        {
            i=parseInt((x-1)/itemsPerRecord)+1
            j=(x%itemsPerRecord)
            if(j==0)
            {
                j=itemsPerRecord
            }
            crumbs[i][j]=cookie[x];
            x++;
        }
        
        numberOfLineItems=i;numberOfCountItems=0;
        for(i=1;i<=numberOfLineItems;i++)
        {
            if(crumbs[i][1]=="true")
            {
                numberOfCountItems=numberOfCountItems+parseInt(crumbs[i][2]);
            }
        }
        var cc = document.getElementById("cartcontains")
        var ccstring="";
        if(numberOfCountItems==0)
        {
            ccstring="Your shopping cart is empty."
            document.getElementById("viewit").style.display="none";
        } else if(numberOfCountItems==1)
        {            
            ccstring="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... contains 1 item.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            document.getElementById("viewit").style.display="inline";
        } else
        {
            ccstring="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... contains " + numberOfCountItems + " items.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            document.getElementById("viewit").style.display="inline";
        }
        cc.innerHTML=ccstring
    }
    
    
    
    
    
    
    
    //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''//
    
    
    
    
    
    var SlideShowSpeed = 4200;
    var CrossFadeDuration = 1;
    var preLoad = new Array();
    var tss;
    var iss;
    var jss;
    var pss;
    var Picture = new Array();
    var AltText="";
    
    
    
    
    
    
    
    
    
    
    function setSlides()
    {
        jss = 1;
	    pss = Picture.length-1;
	    for (iss = 1; iss < pss+1; iss++)
	    {
	        preLoad[iss] = new Image();
    	    preLoad[iss].src = Picture[iss];
    	    preLoad[iss].alt = AltText;
	    }
    }	


    function runSlideShow()
    {
   	    if (document.all)
        {
   		    document.images.PictureBox.style.filter="blendTrans(duration=2)";
    	    document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
	        document.images.PictureBox.filters.blendTrans.Apply();
   	    }
        document.images.PictureBox.src = preLoad[jss].src;
        if (document.all)
        {
	        document.images.PictureBox.filters.blendTrans.Play();
        }
        jss = jss + 1;
        if (jss > pss)
        {
	        jss=1;
        }
        document.images.PictureBox.alt = AltText;
        tss = setTimeout('runSlideShow("0")', SlideShowSpeed);
        
    }


    function goThumbnail()
    {
        location.href="products.aspx";
    }