function expandadvice(thistag)
{
	closeadvice(20);
	document.getElementById("text"+thistag).style.display='';
}
function closeadvice(Counter)
{
	for(i=1;i<=Counter;i++)
	{
		document.getElementById("text"+i).style.display='none';
	}
}

function MoreInfoWindow(URL)
{
  window.open(URL,"POPUPWindow","width=500,height=660,scrollbars")
}

function AddMoreOfThisItem(PBA)
{
	var ValuetoAddToBasket=PBA.options[PBA.selectedIndex].value;

	window.location.replace("AddQtyToBasket.html?Vars="+ValuetoAddToBasket)
}

function sizes()
{
	if(parseInt(navigator.appVersion)>3)
	{
		if(navigator.appName.indexOf("Microsoft")!=-1)
		{
 			winW = document.documentElement.clientWidth;
 			winH = (document.documentElement.clientHeight)+16;
		}
		else
		{
 			winW = window.innerWidth;
 			winH = window.innerHeight;
		}

	}

	divW = document.getElementById('contents').offsetWidth;
	divH = document.getElementById('contents').offsetHeight;

	if(divH > winH)
	{
		document.getElementById("bg_image1").height = divH;
		document.getElementById("Img1").height = divH;
	}
	else
	{
		document.getElementById("bg_image1").height = winH;
		document.getElementById("Img1").height = winH;
	}

	document.getElementById("bg_image1").width = winW;
	document.getElementById("Img1").width = winW;

	newHeight = (winH - divH) / 2;

	if (newHeight<0)
	{
		newHeight=0;
	}

	document.getElementById('contents').style.top = newHeight + "px";
}

function sizesSmall()
{
	if(parseInt(navigator.appVersion)>3)
	{
		if(navigator.appName.indexOf("Microsoft")!=-1)
		{
 			winW = document.documentElement.clientWidth;
 			winH = (document.documentElement.clientHeight)+16;
		}
		else
		{
 			winW = window.innerWidth;
 			winH = window.innerHeight;
		}

	}

	divW = document.getElementById('contentsSmall').offsetWidth;
	divH = document.getElementById('contentsSmall').offsetHeight;

	if(divH > winH)
	{
		document.getElementById("bg_image1").height = divH;
		document.getElementById("Img1").height = divH;
	}
	else
	{
		document.getElementById("bg_image1").height = winH;
		document.getElementById("Img1").height = winH;
	}

	document.getElementById("bg_image1").width = winW;
	document.getElementById("Img1").width = winW;

	newHeight = (winH - divH) / 2;

	if (newHeight<0)
	{
		newHeight=0;
	}

	document.getElementById('contentsSmall').style.top = newHeight + "px";
}

function ClearTrolley(PBA)
{
  window.location.replace("RemoveAllItemsFromCart.html")
}
function RemoveItem(ResItemID,PVID)
{
	window.location.replace("RemoveItemFromCart.html?ID="+ResItemID+"&PVID="+PVID)
}


function numericOnly(eventObj, obj)
{
	var numberOfElements = document.form1.elements.length;
	for (x=0; x<numberOfElements; x++)  
	{
	// replace all the single, double quotes:
		var curElement = window.document.form1.elements[x];
		curElement.value = curElement.value.replace(/\'/g, "&#39;");
		curElement.value = curElement.value.replace(/\"/g, "&#34;");
	}

	NumChanges++;
	var keyCode
	// Check For Browser Type
	if (document.all)
	{ 
		keyCode=eventObj.keyCode
	}
	else
	{
		keyCode=eventObj.which
	}
	var str=obj.value

	if((keyCode>47 && keyCode <59) || keyCode==46 || keyCode==8) // Allow only integers
	{
		return true;
	}
	return false
}

function CheckDownloadPrice(SID, MID, MV)
{
	Pounds=parseInt(document.form1.Pounds.value);
	Pence=parseInt(document.form1.Pence.value);

	if ((Pounds<100 && Pence< 100))
	{
		window.location.replace("https://secure.xurbiaxendless.com/Store/SelectCountry.html?SID="+SID+"&MID="+MID+"&MV="+MV);
		return true;
	}
	else
	{
		alert("You need to enter an amount in pounds and pence for your download");
		return false;
	}
}

function AJAXcreateRequestObject()
{
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
	{
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		ro = new XMLHttpRequest();
	}
	return ro;
}

function AJAXUpdatePriceExec(PBA)
{
	if(http.readyState == 4 && http.status == 200)
	{
		var response = http.responseText;
		return false;	
	}
}


function AJAXUpdatePrice(Pounds,Pence,MID,MV)
{

	Pence=document.form1.Pence.value;

	http.open('GET', "/AJAX/UpdateDownloadPrice.html?MID="+ MID +"&MV="+ MV +"&Pounds="+ Pounds +"&Pence="+ Pence , true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.send(null);
//	http.onreadystatechange = AJAXUpdatePriceExec("PBA");
}

function MemberLoginCheckFields()
{
	var themessage = "You must fill out the following fields: ";
	if (document.form.MemberEmail.value=="")
	{
		themessage = themessage + "\email";
	}
	if (document.form.MemberPassword.value=="")
	{
		themessage = themessage + "\password";
	}
	if (themessage == "You must fill out the following fields: ")
	{
		document.form.submit();
		return true;
	}
	else
	{
		alert(themessage);
		return false;
   }
}