var xmlHttp1 = createXmlHttpRequestObject();
var xmlHttp2 = createXmlHttpRequestObject();
var xmlHttp3 = createXmlHttpRequestObject();
var xmlHttp4 = createXmlHttpRequestObject();

function createXmlHttpRequestObject() 
{
	var xmlHttp;
	try
	{	
		xmlHttp = new XMLHttpRequest();
	}
	catch( e )
	{
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
		// try every prog id until one works !
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
		{
		try 
		{ 
			xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
		} 
		catch (e) {}
		}
	}
	if (!xmlHttp) alert("Error creating the XMLHttpRequest object.");
	else return xmlHttp;
}

function handleRequestStateChange1() 
{
	if (xmlHttp1.readyState == 4) 
	{
		if (xmlHttp1.status == 200) 
		{
			var Resp = xmlHttp1.responseText;
				
			var IDName = new String( Resp.substring(4) ); //<!--
			var ID = IDName.substring( 0, IDName.indexOf("-->", 0));
						
			try
			{				
				if (ID != '')
				{
					if  (ID == 'COMMAND')
					{
						xmlHttp1.onreadystatechange = function () {}
						try	{ xmlHttp1.abort(); } catch (e) { }
						
						document.location.href = Resp.substring( 7 + ID.length );
					}
					else
					{
						var lbControl = document.getElementById( ID );
						lbControl.innerHTML = Resp;
															
						xmlHttp1.onreadystatechange = function () {}
						try	{ xmlHttp1.abort(); } catch (e) { }
								
						setupRollovers();
					}
				}
			}
			catch(e)
			{
				alert("handleRequestStateChange1:" + e.toString());
			}		
		} 
		else 
		{
			alert(xmlHttp1.statusText);
		}
	}
}

function handleRequestStateChange2() 
{
	if (xmlHttp2.readyState == 4) 
	{
		if (xmlHttp2.status == 200) 
		{
			var Resp = xmlHttp2.responseText;
				
			var IDName = new String( Resp.substring(4) ); //<!--
			var ID = IDName.substring( 0, IDName.indexOf("-->", 0));
			
			try
			{	
				if (ID != '')
				{
					var lbControl = document.getElementById( ID );
					lbControl.innerHTML = Resp;
					
					xmlHttp2.onreadystatechange = function () {}
					try	{ xmlHttp2.abort(); } catch (e) { }
								
					setupRollovers();
				}
			}
			catch(e)
			{
				alert("handleRequestStateChange2:" + e.toString());
			}		
		} 
		else 
		{
			alert(xmlHttp2.statusText);
		}
	}
}


function handleRequestStateChange3() 
{
	if (xmlHttp3.readyState == 4) 
	{
		if (xmlHttp3.status == 200) 
		{					
			try
			{
				var Resp = xmlHttp3.responseText;
				
				var IDName = new String( Resp.substring(4) ); //<!--
				var ID = IDName.substring( 0, IDName.indexOf("-->", 0));
				
				if (ID != '')
				{
					var lbControl = document.getElementById( ID );
					lbControl.innerHTML = Resp;
				
					xmlHttp3.onreadystatechange = function () {}
					try	{ xmlHttp3.abort(); } catch (e) { }
				}
			}
			catch(e)
			{
				alert("handleRequestStateChange3: " + e.toString());
			}		
		} 
		else 
		{
			alert(xmlHttp3.statusText);
		}
	}
}

function handleRequestStateChange4() 
{
	if (xmlHttp4.readyState == 4) 
	{
		if (xmlHttp4.status == 200) 
		{					
			try
			{
				var Resp = xmlHttp4.responseText;
				
				var IDName = new String( Resp.substring(4) ); //<!--
				var ID = IDName.substring( 0, IDName.indexOf("-->", 0));
				
				if (ID != '')
				{
					var lbControl = document.getElementById( ID );
					lbControl.innerHTML = Resp;
				
					xmlHttp4.onreadystatechange = function () {}
					try	{ xmlHttp4.abort(); } catch (e) { }
				}
			}
			catch(e)
			{
				alert("handleRequestStateChange4: " + e.toString());
			}		
		} 
		else 
		{
			alert(xmlHttp4.statusText);
		}
	}
}

function process1( acontrol, action, ItemType, ItemID, CompID, ItemQty, APage )
{
	if (xmlHttp1)
	{
		try
		{
			if (xmlHttp1.readyState == 4 || xmlHttp1.readyState == 0) 
			{
				var ADate = new Date(); //Gets rid of Caching Issues
				xmlHttp1.open("GET", "AjaxCart.aspx?AControl=" + acontrol + "&Action=" + action + "&Type=" + ItemType + "&ID=" + ItemID + "&CID=" + CompID + "&Qty=" + ItemQty + "&Pg=" + APage + "&TID=" + ADate.getTime(), true);
				xmlHttp1.onreadystatechange = handleRequestStateChange1;
				xmlHttp1.send(null);				
			}
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}

function process2( acontrol, action, ItemType, ItemID, CompID, ItemQty, APage )
{
	if (xmlHttp2)
	{
		try
		{
			if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == 0) 
			{
				var ADate = new Date(); //Gets rid of Caching Issues
				xmlHttp2.open("GET", "AjaxCart.aspx?AControl=" + acontrol + "&Action=" + action + "&Type=" + ItemType + "&ID=" + ItemID + "&CID=" + CompID + "&Qty=" + ItemQty + "&Pg=" + APage + "&TID=" + ADate.getTime(), true);
				xmlHttp2.onreadystatechange = handleRequestStateChange2;
				xmlHttp2.send(null);
			}
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}

function process3( acontrol, action, ItemType, ItemID, CompID, ItemQty, APage )
{
	if (xmlHttp3)
	{
		try
		{
			if (xmlHttp3.readyState == 4 || xmlHttp3.readyState == 0) 
			{
				var ADate = new Date(); //Gets rid of Caching Issues
				xmlHttp3.open("GET", "AjaxCart.aspx?AControl=" + acontrol + "&Action=" + action + "&Type=" + ItemType + "&ID=" + ItemID + "&CID=" + CompID + "&Qty=" + ItemQty + "&Pg=" + APage + "&TID=" + ADate.getTime(), true);
				xmlHttp3.onreadystatechange = handleRequestStateChange3;
				xmlHttp3.send(null);
			}
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}

function process4( acontrol, action, ItemType, ItemID, CompID, ItemQty, APage )
{
	if (xmlHttp4)
	{
		try
		{
			if (xmlHttp4.readyState == 4 || xmlHttp4.readyState == 0) 
			{
				var ADate = new Date(); //Gets rid of Caching Issues
				xmlHttp4.open("GET", "AjaxCart.aspx?AControl=" + acontrol + "&Action=" + action + "&Type=" + ItemType + "&ID=" + ItemID + "&CID=" + CompID + "&Qty=" + ItemQty + "&Pg=" + APage + "&TID=" + ADate.getTime(), true);
				xmlHttp4.onreadystatechange = handleRequestStateChange4;
				xmlHttp4.send(null);
			}
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}

function NewList( Filter, Var, Page )
{
	process4( "ListDisp", "NewList", Filter, Var, "0", "0", Page );
}

function ShowMore( Control, ProdID, ID )
{
	//var A = "./reviews.aspx?ID=" + ID;
	//location.href= A;	
	process1( Control, "FullReview", "0", ProdID, ID, "0", "0" );
}

function HideMore( Control, ProdID, ID )
{
	process1( Control, "HalfReview", "0", ProdID, ID, "0", "0" );
}

function NewList2( Filter, ListID, Page )
{
	var ddSelect = document.getElementById( "ddSelect" );
	var SelID	   = "0";
	
	if (ddSelect)
	{
		for (var i=0; i < ddSelect.options.length; i++ )
		{
			if (ddSelect.options[i].selected)
			{
				SelID = ddSelect.options[i].value;
				break;
			}
		}
	}
	
	var ddFilter = document.getElementById( "ddFilter" );
	var FilID	   = "0";
	
	if (ddFilter)
	{
		for (var i=0; i < ddFilter.options.length; i++ )
		{
			if (ddFilter.options[i].selected)
			{
				FilID = ddFilter.options[i].value;
				break;
			}
		}
	}
	
	var tbID = document.getElementById( "ListID" );
	var ID = "0";
	if (tbID) ID = tbID.value;
	
	//alert( Filter + ' - ' + FilID  + ' - ' +  SelID  + ' - ' +  ID  + ' - ' + Page );
			
	process4( "ListDisp", "NewList2", Filter, FilID, SelID, ID, Page );	
}

function ListSelect( ID )
{
	var ddSelect = document.getElementById( "ddSelect" );
	var SelID	   = "1";
	for (var i=0; i < ddSelect.options.length; i++ )
	{
		if (ddSelect.options[i].selected)
		{
			SelID = ddSelect.options[i].value;
			break;
		}
	}
	
	var ddFilter = document.getElementById( "ddFilter" );
	var FilID	   = "1";
	for (var i=0; i < ddFilter.options.length; i++ )
	{
		if (ddFilter.options[i].selected)
		{
			FilID = ddFilter.options[i].value;
			break;
		}
	}
	
	var ListPage = document.getElementById( "ListPage" );
	var PageNo   = ListPage.value;
	
	var MainCat  = document.getElementById( "tbCat" );
	var Filter   = MainCat.value;
	
	//alert( Filter + ' - ' + FilID  + ' - ' +  SelID  + ' - ' +  ID  + ' - ' + PageNo );
	
	process4( "ListDisp", "NewList2", Filter, FilID, SelID, ID, PageNo );
}

function RemoveLine( ItemType, ItemID, CompID )
{
	process1( "lbCart", "RemoveLine", ItemType, ItemID, CompID, "0" );
}

function UpdateLine( ItemType, ItemID, CompID, Control )
{
	var AQty = document.getElementById( Control ).value;
	process1( "lbCart", "UpdateLine", ItemType, ItemID, CompID, AQty );
}

function RemoveLine2( ItemType, ItemID, CompID )
{
	process1( "lbCart", "RemoveLine2", ItemType, ItemID, CompID, "0" );
}

function UpdateLine2( ItemType, ItemID, CompID, Control )
{
	var AQty = document.getElementById( Control ).value;
	process1( "lbCart", "UpdateLine2", ItemType, ItemID, CompID, AQty );
}

function RemoveLine4( ItemType, ItemID, CompID )
{
	process1( "lbCart", "RemoveLine4", ItemType, ItemID, CompID, "0" );
	UpdateShipping();
}

function UpdateLine4( ItemType, ItemID, CompID, Control )
{
	var AQty = document.getElementById( Control ).value;
	process1( "lbCart", "UpdateLine4", ItemType, ItemID, CompID, AQty );
	UpdateShipping();
}

function UpdateShipping()
{
	//alert('UpdateShipping' );
	var ddShip = document.getElementById( "ddShipping" );
	var SID	   = "1";
	for (var i=0; i < ddShip.options.length; i++ )
	{
		if (ddShip.options[i].selected)
		{
			SID = ddShip.options[i].value;
			break;
		}
	}
	process2( "lbFooter", "GetFooter", "", SID, "", "" );
}

function BuyBag( ID )
{
	var P = "CM" + ID;	
	var PWait = document.getElementById( P );
	PWait.src = "./images/wait.gif";
	BuySetCMTimeOut( ID );
	
	var AQty = document.getElementById( "BAddQty" + ID );
	var TheQty = AQty.value;
	
	AQty.value = "1";
		
	process1( "lbCart", "AddBag", "1", ID, "0", TheQty );
	UpdateShipping();
}

function BuyNow( ID, CompID )
{
	var AQty   = igedit_getById( "tbQty" );
	var TheQty = AQty.getValue();
			
	process1( "lbCart", "Add", "1", ID, CompID, TheQty );
			
	AQty.setValue( 1 );
}

//Used on the Special Offer Image on the Front Page		
function BuyNow4( ID )
{
	var CompID="0";
	
	var ADate = new Date();
	location.href = "AjaxCart.aspx?Action=ECAdd&Type=1&ID=" + ID + "&CID=" + CompID + "&Qty=1&TID=" + ADate.getTime();		
}

//Used in Golden Ads Box
function BuyNow_Ads( ID, CompID )
{
	process1( "lbCart", "AddExtra", "1", ID, CompID, "1" );
}

function ShowBig( ID )
{
	popupWindow('BigImage.aspx?ID=' + ID)
}
function ShowBigAdd( ID )
{
	popupWindow('BigAddImage.aspx?ID=' + ID)
}
function Goto( ID )
{
	location.href="Product.aspx?ID=" + ID;
}
function TellAFriend( ID )
{
	location.href="TellAFriend.aspx?ID=" + ID;
}
function ShowCallBacks()
{
	window.open( 'AgentCallBacks.aspx','popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=860,height=680,screenX=50,screenY=50,top=50,left=50');
}
function AddReview( ID )
{
	window.open( 'AddReview.aspx?ID=' + ID,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=630,height=520,screenX=50,screenY=50,top=50,left=50');
}
function Continue(){ location.href="Default.aspx"; }
function EditCart(){ location.href="EditCart.aspx"; } 
function CheckOut(){ location.href="CheckOut.aspx"; } 
function ECheckOut(){ location.href="EditCart.aspx"; } 
function DrawCart(){ process1( "lbCart", "Render", "0", "0", "0", "0" ); } 
function MergeCart(){ process1( "lbCart", "Merge", "0", "0", "0", "0" ); }
function ClearCart(){ process1( "", "Clear", "0", "0", "0", "0" ); }
function Shipping( ID, Item, A, B )
{ 
	process1( "lbCart", "Ship", "0", ID, "0", "0" );
	
	var RBL = "";
	for( var i=A; i <= B; i++ ) 
	{
		RBL = "rbShip" + i;
		document.getElementById( RBL ).checked = false;
	}
	
	var RB = document.getElementById( Item );
	RB.checked = true;
	
	var TB = document.getElementById( 'tbShip' );
	TB.value = ID;
} 
function Insurance()
{
	var Ins = document.getElementById( 'cbInsure' );
	
	if (Ins.checked) process1( "lbCart", "Insure", "0", "1", "0", "0" );
	else process1( "lbCart", "Insure", "0", "0", "0", "0" );	
}

function GetZip( ZIP )
{
	process1( "", "GetZip", ZIP, "", "", "" );
}

function InsuranceCart()
{
	var Ins = document.getElementById( 'cbInsure' );
	
	if (Ins.checked)
	{
		process1( "", "InsureCart", "0", "1", "0", "0" );
	}
	else
	{
		process1( "", "InsureCart", "0", "0", "0", "0" );
		
	}
	UpdateShipping();
}
function Payment( ID, Item, A, B )
{
	var RBL = "";
	for( var i=A; i <= B; i++ ) 
	{
		RBL = "rbPay" + i;
		document.getElementById( RBL ).checked = false;
	}
	
	var RB = document.getElementById( Item );
	RB.checked = true;
	
	var TB = document.getElementById( 'tbPay' );
	TB.value = ID;
}

function ClearShipping(){ process1( "lbCart", "Ship", "0", "0", "0", "0" ); } 
function ClearInsurance(){ process1( "lbCart", "Insure", "0", "0", "0", "0" ); } 

function popupWindow(url)
{
	window.open( url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=120,height=120,screenX=150,screenY=150,top=150,left=150');
}


function ShowPants()
{
	var newWin = window.open( './Pants.html', 'LipoPants', 'width=408,height=340,top=100,left=100' );
	newWin.focus();
}


function ShowSpa()
{
	var newWin = window.open( './SpaWrap.html', 'SpaWrap', 'width=408,height=340,top=100,left=100' );
	newWin.focus();
}

function ToggleDisplay(elemId)
{
    var elem = document.getElementById(elemId);
    elem.style.display = (elem.style.display != 'none') ? 'none' : '';
}

function $()
{
   var elements = new Array();
   for (var i = 0; i < arguments.length; i++)
   {
      var element = arguments[i];
      if (typeof element == 'string') element = document.getElementById(element);
      if (arguments.length == 1) return element;
      elements.push(element);
   }
   return elements;
   
   //var elem = document.getElementById('TextBox1'); == var elem = $('TextBox1');
   //or array with var elemArr = $('TextBox1', 'TextBox2');
}

function SelectImage( ID )
{
    location.href = "Product.aspx?ID=" + ID;				
}

function RollOverGoldenAds()
{
	var Tbl = document.getElementById( "TableAds" );
	Tbl.style.backgroundColor = "#A0F4F6";
}
			   
function RollOutGoldenAds()
{	   
	var Tbl = document.getElementById( "TableAds" );
	Tbl.style.backgroundColor = "#ffffff";
}

function CoopsBtn_Click(oButton, oEvent)
{
	window.open( "./Coops.aspx",'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=345,height=405,screenX=50,screenY=50,top=50,left=500');
}
function StatsBtn_Click(oButton, oEvent)
{
	window.open( "./ShopMgr/Stats.aspx",'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=960,height=700,screenX=50,screenY=50,top=50,left=50');
}
function AdminStatsBtn_Click(oButton, oEvent)
{
	window.open( "./ShopMgr/Stats.aspx",'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=960,height=700,screenX=50,screenY=50,top=50,left=50');
}
function HistBtn_Click(oButton, oEvent)
{
	window.open( "./History.aspx",'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=960,height=600,screenX=50,screenY=50,top=50,left=50');
}
function AdminHistBtn_Click(oButton, oEvent)
{
	window.open( "./History.aspx",'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=960,height=600,screenX=50,screenY=50,top=50,left=50');
}

function setupRollovers()
{ 
	if (!document.getElementsByTagName) return; 
	
	var all_links = document.getElementsByTagName('a'); 
	for (var i = 0; i < all_links.length; i++)
	{ 
		var link = all_links[i]; 
		if (link.className && (' ' + link.className + ' ').indexOf(' rollover ') != -1) 
		{ 
			if (link.childNodes && link.childNodes.length == 1 && link.childNodes[0].nodeName.toLowerCase() == 'img')
			{ 
				link.onmouseover = mouseover; 
				link.onmouseout = mouseout;
				link.onmousedown = mousedown;
			} 
		}
		
		if (link.className && (' ' + link.className + ' ').indexOf(' addimageover ') != -1) 
		{ 
			if (link.childNodes && link.childNodes.length == 1 && link.childNodes[0].nodeName.toLowerCase() == 'img')
			{ 
				link.onmouseover = Imagemouseover; 
				link.onmouseout = Imagemouseout;
				link.onmousedown = Imagemousedown;
			} 
		}
	}	
} 

function doClick(buttonName,e)
{
	//the purpose of this function is to allow the enter key to 
	//point to the correct button to click.
    var key;

    if(window.event) key = window.event.keyCode;     //IE
    else key = e.which;     //firefox
    
    if (key == 13)
    {
		var btn = document.getElementById(buttonName);
        if (btn != null)
        { 
			btn.click();
            event.keyCode = 0
        }
    }
}

function BuySetTimeOut( ImageID )
{
	var A = "./images/small/" + ImageID + ".jpg";
	var P = "P" + ImageID;	
	
	function bar() 
	{ 
		document.getElementById( P ).src= A; 				
	}
	window.setTimeout( bar, 1800 );
	
	location.href = "#Basket";
}

function BuySetRecTimeOut( ImageID )
{
	var A = "./images/Tiny/" + ImageID + ".jpg";
	var P = "R" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetBuddyTimeOut( ImageID )
{
	var A = "./images/small/" + ImageID + ".jpg";
	var P = "Y" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetPMTimeOut( ImageID )
{
	var A = "./images/small/" + ImageID + ".jpg";
	var P = "PM" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetCLTimeOut( ImageID )
{
	var A = "./images/small/" + ImageID + ".jpg";
	var P = "CL" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetPUTimeOut( ImageID )
{
	var A = "./images/small/" + ImageID + ".jpg";
	var P = "PU" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetCMTimeOut( ImageID )
{
	var A = "./images/tiny/" + ImageID + ".jpg";	
	var P = "CM" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetXBTimeOut( ImageID )
{
	var A = "./images/tiny/" + ImageID + ".jpg";	
	var P = "XB" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetCDTimeOut( ImageID )
{
	var A = "./images/Comps/" + ImageID + ".jpg";	
	var P = "CD" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function BuySetPDTimeOut( ImageID )
{
	var A = "./images/large/" + ImageID + ".jpg";	
	var P = "PD" + ImageID;	
	
	function bar() { document.getElementById( P ).src= A; }
	window.setTimeout( bar, 1800 );
}

function findTarget(e) 
{ 
	var target; 

	if (window.event && window.event.srcElement) target = window.event.srcElement; 
	else
		if (e && e.target) target = e.target; 
	
	if (!target) return null; 

	while (target != document.body && target.nodeName.toLowerCase() != 'a') target = target.parentNode; 

	if (target.nodeName.toLowerCase() != 'a') return null; 

	return target; 
} 

function mouseover(e)
{ 
	var target = findTarget(e); 
	if (!target) return; 
	
	var img_tag = target.childNodes[0]; 
	img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '_over$1'); 
} 

function Imagemouseover(e)
{ 
	var target = findTarget(e); 
	if (!target) return; 
	
	var img_tag = target.childNodes[0]; 
	
	var IDName = new String( img_tag.name.substring(1) );
	var ID = IDName.substring( 0, IDName.indexOf("P", 0));
	var ProdID = IDName.substring( IDName.indexOf("P", 0) + 1 );
	
	var P = "PD" + ProdID;	
		
	var PWait = document.getElementById( P );
			
	PWait.src = "./images/AddLarge/" + ID + ".jpg";
} 

function Imagemousedown(e)
{ 
	var target = findTarget(e); 
	if (!target) return; 
	
	var img_tag = target.childNodes[0];
	
	var IDName = new String( img_tag.name.substring(1) );
	var ID = IDName.substring( 0, IDName.indexOf("P", 0));
	
	ShowBigAdd( ID );
}

function Imagemouseout(e)
{ 
	var target = findTarget(e); 
	if (!target) return; 
	
	var img_tag = target.childNodes[0]; 
	
	var IDName = new String( img_tag.name.substring(1) );
	var ID = IDName.substring( 0, IDName.indexOf("P", 0));
	var ProdID = IDName.substring( IDName.indexOf("P", 0) + 1 );
	
	var P = "PD" + ProdID;	
		
	var PWait = document.getElementById( P );
			
	PWait.src = "./images/Large/" + ProdID + ".jpg";	
} 

function BuyNow( ID, CompID )
{
	var P = "P" + ID;	
	var PWait = document.getElementById( P );
	PWait.src = "./images/BagAdd.gif";
	BuySetTimeOut( ID );
	
	process1( "lbCart", "Add", "1", ID, CompID, "1" );	
}

function FPBuyNow( ID, CompID )
{	
	var P = "P" + ID;	
	var PWait = document.getElementById( P );
	PWait.src = "./images/BagAdd.gif";
	BuySetTimeOut( ID );
		
	process1( "lbCart", "AddFP", "1", ID, CompID, "1" );
	
	location.href = "#Basket";
}

function XSBuyNow( ID, CompID )
{	
	var P = "P" + ID;	
	var PWait = document.getElementById( P );
	PWait.src = "./images/BagAdd.gif";
	BuySetTimeOut( ID );
		
	process1( "lbCart", "AddXS", "1", ID, CompID, "1" );			
}

function RecBuyNow( ID, CompID )
{	
	var P = "R" + ID;	
	var PWait = document.getElementById( P );
	PWait.src = "./images/Wait.gif";
	BuySetRecTimeOut( ID );
		
	process1( "lbCart", "AddRec", "1", ID, CompID, "1" );			
}

function BuddyBuyNow( ID, CompID )
{	
	var P = "Y" + ID;	
	var PWait = document.getElementById( P );
	PWait.src = "./images/BagAdd.gif";
	BuySetBuddyTimeOut( ID );
		
	process1( "lbCart", "AddBuddy", "1", ID, CompID, "1" );			
}

function mousedown(e)
{ 

	var target = findTarget(e); 
	if (!target) return; 
		
	var img_tag = target.childNodes[0]; 
	var BtnType = new String( img_tag.name.substring(0,3) );
	
	if (BtnType == 'CHK')
	{
		location.href="CheckOut.aspx";
	}
	
	var IDName = new String( img_tag.name.substring(3) );
	var ID = IDName.substring( 0, IDName.indexOf(":", 0));
	var CompID = IDName.substring( IDName.indexOf(":", 0) + 1 );
	
	
	                         
	//Used on the Product Listing Page
	if (BtnType == 'BNB')
	{
		var P = "P" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BagAdd.gif";
		BuySetTimeOut( ID );
	
		process1( "lbCart", "Add", "1", ID, CompID, "1" );
				
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
				
		var QQ = document.getElementById("tbQ");
		var QType = document.getElementById("tbType");
		var Pg = document.getElementById("tbPage");
			
		var A = QType.value;
		var B = QQ.value;
		var C = Pg.value;
	
		process1( "", "NewList", A, B, CompID, "1", C );		
	}
	
	if (BtnType == 'BNX')
	{
		var P = "P" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BagAdd.gif";
		BuySetTimeOut( ID );
	
		process1( "lbCart", "AddExtra", "1", ID, CompID, "1" );
				
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
				
		//var QQ = document.getElementById("tbQ");
		//var QType = document.getElementById("tbType");
		//var Pg = document.getElementById("tbPage");
			
		//var A = QType.value;
		//var B = QQ.value;
		//var C = Pg.value;
	
		//process1( "", "NewList", A, B, CompID, "1", C );		
	}
	
	//Used on the Product Detail Page
	if (BtnType == 'ADD')
	{
		var P = "CM" + CompID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/wait.gif";
		BuySetCMTimeOut( CompID );
		
		var QtyEdit = "CartQtyEdit" + CompID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		process1( "lbCart", "Add", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//Used on the Product Detail Page for an extra button at the bottom
	if (BtnType == 'AXB')
	{
		var P = "XB" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/wait.gif";
		BuySetXBTimeOut( ID );
		
		var QtyEdit = "CartQtyEditX" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		process1( "lbCart", "Add", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//Used on the Product Detail Page (Dual Buttons Bit)
	if (BtnType == 'ADU')
	{
		var P = "CD" + CompID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/wait.gif";
		BuySetCDTimeOut( CompID );
		
		var QtyEdit = "CartQtyEditD" + CompID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		process1( "lbCart", "Add", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//Used on the Product Detail Page
	if (BtnType == 'APD')
	{
		var P = "PD" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BigBagAdd.gif";
		BuySetPDTimeOut( ID );
		
		
		var QtyEdit = "CartQtyEdit" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
				
		process1( "lbCart", "Add", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//Used on the BUDDY Product Detail Page (Main Product)
	if (BtnType == 'APY')
	{
	
		var P = "PD" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BigBagAdd.gif";
		BuySetPDTimeOut( ID );
		
		
		var QtyEdit = "CartQtyEdit" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
				
		process1( "lbCart", "AddBuddy", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//When A Product is a component of a product
	if (BtnType == 'APM')
	{
		var P = "PM" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/wait.gif";
		BuySetPMTimeOut( ID );
		
		var QtyEdit = "CartQtyEdit" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		process1( "lbCart", "Add", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//When A Product is a component of a product
	if (BtnType == 'APU')
	{
		var P = "PU" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/wait.gif";
		BuySetPUTimeOut( ID );
		
		var QtyEdit = "CartQtyEditD" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		process1( "lbCart", "Add", "1", ID, CompID, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
	//Used for the Buy Now Button on the FrontPage
	if (BtnType == 'FPG')
	{	
		var P = "P" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BagAdd.gif";
		BuySetTimeOut( ID );
		
		process1( "lbCart", "AddFP", "1", ID, CompID, "1" );
				
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1');				
	}
	
	//Used for the Buy Now Button on the FrontPage
	if (BtnType == 'MRI')
	{
		var ADate = new Date();
		location.href = "Product.aspx?ID=" + ID + "&TID=" + ADate.getTime();
	}
	
	if (BtnType == 'ENL')
	{
		ShowBig( ID );
	}
	
	//Clothing Top
	if (BtnType == 'CLT')
	{
		var P = "PD" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BigBagAdd.gif";
		BuySetPDTimeOut( ID );
		
		var QtyEdit = "CartQtyEdit" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		var CMID = "Size" + ID;
		var ASize = document.getElementById( CMID );
		
		var Logo = "";
		var LogoSel = document.getElementById( "ddPerson" );
		
		if (LogoSel)
		{
			for (var i=0; i < LogoSel.options.length; i++ )
			{
				if (LogoSel.options[i].selected)
				{
					Logo = LogoSel.options[i].value;
					break;
				}
			}
			if (Logo == "") Logo = LogoSel.options[0].value;
		}
		process1( "lbCart", "Add", "1", ID, ASize.value, AQty );
		process2( "lbCart", "AddNote", "1", ID, ASize.value, Logo );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
		
	if (BtnType == 'CLL')
	{
		var P = "CL" + ID;	
		var PWait = document.getElementById( P );
		PWait.src = "./images/BigBagAdd.gif";
		BuySetCLTimeOut( ID );
		
		var QtyEdit = "CartQtyEdit" + ID;
		var AQty = document.getElementById( QtyEdit ).value;
		document.getElementById( QtyEdit ).value = "1";
		
		var CMID = "Size" + ID;
		var ASize = document.getElementById( CMID );
		
		process1( "lbCart", "Add", "1", ID, ASize.value, AQty );
		
		img_tag.src = img_tag.src.replace(/_down(\.[^.]+)$/, '$1'); 
	}
	
}

function mouseout(e)
{ 
	var target = findTarget(e); 
	if (!target) return; 

	var img_tag = target.childNodes[0]; 
	img_tag.src = img_tag.src.replace(/_over(\.[^.]+)$/, '$1'); 	
}

function ClearText(e)
{
	var tb = document.getElementById( e );
	tb.value = "";
} 