
	function MyItem()
	{
		this.ProductName;
		this.Quantity;
		this.ColorIndex = "none";
		this.SizeIndex = "none";
	}
	
	function basketQtyValidate(qty)
	{
	alert("Tom to validate basket");
	}
				
	function ClientValidate()
	{
		var MyItems = new Array();
		var message = "Please correct the following errors:\r";
		var IsQuantity = false;
		var IsColor = false;
		var IsSize = false;
		
		for(i=0;i<document.Main.length;i++)
		{
			var index = parseInt(document.Main[i].name.substr(13,1));
			if(MyItems.length-1 != index) MyItems[index] = new MyItem();
			if(document.Main[i].name.indexOf("ProductQuantity") != -1)
			{
				if(isNaN(document.Main[i].value)) document.Main[i].value = "0";
				MyItems[index].Quantity = parseInt(document.Main[i].value);
			}
			if(document.Main[i].name.indexOf("ProductName") != -1)
			{
				MyItems[index].ProductName = document.Main[i].value;
			}
			if(document.Main[i].name.indexOf("dropSize") != -1)
			{
				MyItems[index].SizeIndex = parseInt(document.Main[i].value);
				
			}
			if(document.Main[i].name.indexOf("dropColor") != -1)
			{
				MyItems[index].ColorIndex = parseInt(document.Main[i].value);
			}
			
		}
		for(i=0;i<MyItems.length;i++)
		{	
			if(MyItems[i].Quantity > 0)
			{
				IsQuantity = true;
				if(MyItems[i].ColorIndex == "none" && MyItems[i].SizeIndex == "none")
				{
					IsColor = true;
					IsSize = true;
					continue;
				}
				if(MyItems[i].ColorIndex == "none")
				{
					IsColor = true;
					//continue;
				}
				else
				{
					if(MyItems[i].ColorIndex > 0)
					{
						IsColor = true;
					}
					else
					{
						IsColor = false;
						message = message + " - In order to add the product \"" + MyItems[i].ProductName + "\" to the shopping cart, please choose " + colorString + "\r"
					}
				}
				if(MyItems[i].SizeIndex == "none")
				{
					IsSize = true;
					//continue;
				}
				else
				{
					if(MyItems[i].SizeIndex > 0)
					{
						IsSize = true;
					}
					else
					{
						IsSize = false;
						message = message + " - In order to add the product \"" + MyItems[i].ProductName + "\" to the shopping cart, please choose " + sizeString + "\r"
					}
				}
			}
		}

		if(IsQuantity == false)
		{
			alert(message = message + " - Please specify quantity greater than 0 (zero) in the product before the \"add to shopping bag\" button");
			return false;
		}
		
		if(IsColor == false || IsSize == false)
		{
			alert(message);
			return false;
		}
		
		if(IsQuantity == true && IsColor == true && IsSize == true)
		{
			return true;
		}	
		return false;
	}
	
	function popUp(url, width, height, scrolls) 
	{
		winOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + scrolls + ",resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",screenX=20,screenY=20";
		var win = window.open(url, 'Horchow', winOptions);
		win.moveTo(screen.availWidth/2-(width/2),screen.availHeight/2-(height/2));
		if (!win.opener) win.opener = self; 
		if (win.focus) win.focus();
	}
	
	function ShippingInformation()
	{
		popUp("contentno.aspx?id=34", 531, 600, "yes");
	}
	
	function ReturnPolicy()
	{
		popUp("contentno.aspx?id=35", 531, 350, "yes");
	}
	
	function SizeGuides()
	{
		popUp("contentno.aspx?id=36", 615, 300, "yes");
	}
	
	function PopContent(cID)
	{
		popUp("contentno.aspx?id=" + cID, 531, 400, "yes");
	}
	
	function EmailToFriend(cID)
	{
		popUp("emailtofriend.aspx?cID=" + cID, 322, 380, false);
	}
	
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function open_popup(page) {
    window.open(page);
    return false;
}

function newGalleryWin(theURL) {
	var wintImages=window.open(theURL,'wintImages','height=470,width=610,status=no,toolbar=no,scrollbars=yes');
	wintImages.moveTo(screen.availWidth/2-(610/2),screen.availHeight/2-(470/2));
	return false;
}
	
function addSearchTextToUrl (txt) 
{
	if(document.form1.txtSearch.value == "") return false;
	document.form1.action =	document.form1.action + "?search=" + document.form1.txtSearch.value;
	return true;
}


