function setPage(pageNum)
{
	window.document.NavForm.MyPage.value=pageNum;
	window.document.NavForm.submit();
}

function checkCookie()
{
	myCookie=getCookie('check')
	if (myCookie==null)
	{
		alert('Cookies not enabled. Please check')
	}
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{ 
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1 
	    c_end=document.cookie.indexOf(";",c_start)
	    if (c_end==-1) c_end=document.cookie.length
	    return unescape(document.cookie.substring(c_start,c_end))
	    } 
	 }
	return null
}

function getBasket()
{
	myBasket=getCookie('basket')
	if (myBasket!=null)
	{
		return (myBasket)
	}
	return (null)
}

var divOpen=false;
var currentID=0;

function ShowDiv(ID)
{
	if (divOpen==false || currentID!=ID)
	{
		if (divOpen==true) resetDiv();
		document.body.style.cursor = "wait";
		window.frames['itemdisplay'].location.href="showitem.asp?ID="+ID;
		window.document.getElementById('invisible').style.top=getCoordinate()+1+"px";
		window.document.getElementById('invisible').style.visibility='visible';
		window.document.getElementById('itemdisplay').style.visibility='visible';
		currentID=ID;
		divOpen=true;
	}
}

function resetDiv()
{
	divOpen=false;
	window.document.getElementById('itemdisplay').style.height = '0px';
	window.document.getElementById('itemdisplay').style.width = '0px';			
}

function getCoordinate()
{
    var y = 0;

    if( typeof(window.pageYOffset ) == 'number' ) 
    {
        // Netscape
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
    {
        // DOM
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
    {
        // IE6 standards compliant mode
        y = document.documentElement.scrollTop;
    }
    return(y);
}

function finishPage()
{
	currTab();
	fillWindow();
	checkCookie();
	processCookie();
}

function processCookie()
{
	var entries; var totQty=0; var totPrice=0;
	var entry; var theQty; var thePrice; var e;		
	var basket = getBasket()
	if (basket!=null)
	{
		entries = basket.split("&");
		for (i=0;i<entries.length;i++)
		{
			entry=entries[i].split("|");
			theQty = entry[1];
			thePrice = entry[2];
			totQty = totQty+parseInt(theQty);
			totPrice = totPrice+(thePrice*theQty);
		}
		e = window.document.getElementById('items');
		e.innerHTML = totQty;		
		e = window.document.getElementById('total');
		e.innerHTML = totPrice.toFixed(2);
		if (totQty!=0)
		{
			window.document.Basket.B1.disabled=false;
			window.document.Basket.B2.disabled=false;
		}
	}
}

function clearCookie()
{
    setCookie("basket","0|0|0",0);
}

function emptyBasket()
{
	var doIt = confirm("Do you really want to empty shopping basket?" + '\n' + "OK to continue; otherwise Cancel")
	if (doIt)
	{
		setCookie("basket","0|0|0",0);
		var e;
		e = window.document.getElementById('items');
		e.innerHTML = 0;		
		e = window.document.getElementById('total');
		e.innerHTML = "0.00";
		window.document.Basket.B1.disabled=true;
		window.document.Basket.B2.disabled=true;
	}
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}