
var oCart="";

function KaWai_Eval( Obj , sCmd, sValue, sParent )
{
	if ( sParent )
		sParent += ".";
	else
		sParent="";

	switch ( typeof(Obj) )
	{
		case "string":
			break;
		case "object":
			Obj=eval( sParent+"document.getElementById('"+Obj+"').id");
			if (Obj==null) return;
			break;
		default:
			return;
			break;
	}

	if ( typeof(eval( sParent+"document.getElementById('"+Obj+"')")) == "object" )
	{
		try{
			switch ( typeof(sValue) )
			{
				case "string":
					return eval( sParent+'document.getElementById("'+ Obj +'").'+sCmd+' ="'+sValue+'"' );
					break;
				case "boolean":
					return eval( sParent+'document.getElementById("'+ Obj +'").'+sCmd+' ='+sValue );
					break;
				default:
					if ( sCmd )
						return eval( sParent+'document.getElementById("'+ Obj +'").'+sCmd );
					break;
			}
		}catch(e){  }
	}

}


function Show_Hide_Object( pShow, pHide )
{
	var aShow = pShow.split(',');
	var aHide = pHide.split(',');
	var si = "";

		
	for ( i in aShow)
	{
		if ( aShow[i] != "" )
			KaWai_Eval(aShow[i], "style.display", "" );
	}
	for ( i in aHide )
		if ( aHide[i] != "" )
			KaWai_Eval(aHide[i], "style.display", "none" );
	
}

function sShow_ShoppingCart(sPara)
{	

	if ( oCart )
	{
		if ( oCart.closed )
			oCart=window.open('index.php?ACTION=Cart'+sPara,'','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=797, height=550');
		else
			oCart.location.href= "index.php?ACTION=Cart"+sPara;
			
			oCart.focus();
	}else{
		oCart=window.open('index.php?ACTION=Cart'+sPara,'','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=797, height=550');
	}
	
	
}


function Click_AddtoCart(oObject)
{
/*
	var nIndex = oObject.selectedIndex;
	var sButtonName = (oObject.id).replace('oSelect_Size', 'oBn_AddtoCart');
	
	KaWai_Eval( sButtonName, 'disabled', ( oObject.options[nIndex].value == "" ) );
*/
}


function AddtoCart(sObjName)
{
	var nIndex = KaWai_Eval( sObjName, 'selectedIndex');
	var nSubItemID =KaWai_Eval( sObjName, 'options['+nIndex+'].value');
//	if ( document.getElementById(sObjName).options[nIndex].value == "")
	if ( nSubItemID == "")
	{
//		alert("Please select a size!");	
	}else{
		sShow_ShoppingCart("&MODE=ADD&SID="+nSubItemID);
	}
}


function GetSelectValue(sObjName)
{
	var nIndex = KaWai_Eval( sObjName, 'selectedIndex'); 
//	return document.getElementById(pObject).options[nIndex].value;
	return KaWai_Eval( sObjName, 'options['+nIndex+'].value');
}

function Unload_Body()
{
	if ( oCart )
	{
		if ( !oCart.closed )
			oCart.close();
	}
}


function Check_Agreement( oObject )
{
	var oAgree = document.getElementById("oAgree");
	var oCountry = document.getElementById("oCountry");
		
	if ( oAgree.checked && oCountry.value != "" )
	{ 
		KaWai_Eval('oCheckOut', 'disabled=false');
	}else{
		KaWai_Eval('oCheckOut', 'disabled=true');
		if ( oObject.id == "oAgree" )
			KaWai_Eval('oCountry', 'focus()');
		else
			KaWai_Eval('oAgree', 'focus()');		
	}
	
}

function bLoad_LargeImage( sPath_Image, bType )
{
//	var oImg = new Image();
//	oImg.src = sPath_Image;

	if ( bType = 1 )
		document.getElementById('oImgLargeB').src= sPath_Image;
	else
		document.getElementById('oImgLarge').style.backgroundImage='url("'+ sPath_Image +'")';
	
}



var KaWaiShadow={}
KaWaiShadow.depth=4 //Depth of shadow in pixels
KaWaiShadow.containers=[]
KaWaiShadow.LayerColor="black"

KaWaiShadow.create=function()
{
	var a = document.all ? document.all : document.getElementsByTagName('*')
	for (var i = 0;i < a.length;i++) 
	{
		if ( (a[i].className).search("KaWai_Shadow") != -1) {
			for (var x=0; x<KaWaiShadow.depth; x++){
				var newSd = document.createElement("DIV")
				newSd.className = "Shadow_Layer"
				newSd.id="shadow"+KaWaiShadow.containers.length+"_"+x 
				if (a[i].getAttribute("rel"))
					newSd.style.background = a[i].getAttribute("rel")
				else
					newSd.style.background = KaWaiShadow.LayerColor
				document.body.appendChild(newSd)
			}
			KaWaiShadow.containers[KaWaiShadow.containers.length]=a[i]
		}
	}
	KaWaiShadow.position()
	
	window.onresize=function(){
		KaWaiShadow.position()
	}
}

KaWaiShadow.position=function(){
	if (KaWaiShadow.containers.length>0){
		for (var i=0; i<KaWaiShadow.containers.length; i++){
			for (var x=0; x<KaWaiShadow.depth; x++){
				var shadowdiv=document.getElementById("shadow"+i+"_"+x)
				shadowdiv.style.width = KaWaiShadow.containers[i].offsetWidth + "px"
				shadowdiv.style.height = KaWaiShadow.containers[i].offsetHeight + "px"
				shadowdiv.style.left = KaWaiShadow.containers[i].offsetLeft + x + "px"
				shadowdiv.style.top = KaWaiShadow.containers[i].offsetTop + x + "px"
			}
		}
	}
}

if (window.addEventListener)
	window.addEventListener("load", KaWaiShadow.create, false)
else if (window.attachEvent)
	window.attachEvent("onload", KaWaiShadow.create)
else if (document.getElementById)
	window.onload=KaWaiShadow.create

