var clipTop = 0;
var clipWidth = 380;
var clipBottom = 440;
var topper = 0;
var lyrheight = 0;
var ua = 0;
var ud = 0;
var time,amount,theTime,theHeight,DHTML;
var preview = 0;

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function showLayer(id)
{
	for (var v=0;v<5;v++)
	{
		hideLayer(v);
	}
	new getObj('s'+id).style.display = "block";
	new getObj('o'+id).style.color = "#fff";
}

function hideLayer(id)
{
  new getObj('s'+id).style.display = "none";
  if (id>0) { new getObj('o'+id).style.color = "#888"; }
}




function init()
{
DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('items');
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	}
	if (lyrheight>clipBottom) { ud=1; updatearrows(); }
}

function updatearrows()
{

	if (ua=="0") { new getObj('topscrollblock').style.visibility='hidden'; }
	if (ua=="1") { new getObj('topscrollblock').style.visibility='visible'; }
	if (ud=="0") { new getObj('bottomscrollblock').style.visibility='hidden'; }
	if (ud=="1") { new getObj('bottomscrollblock').style.visibility='visible'; }
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}

	if (ua+ud<2)
	{
		if ( (clipTop>=2) && (clipBottom<=(lyrheight-5)) ) { ua=1; ud=1; updatearrows(); }
	}


	if (clipBottom>=(lyrheight-5))
	{
		ua=1; ud=0; updatearrows();
	}

	if (clipTop<2)
	{
		ua=0; ud=1; updatearrows();
	}

	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function stopscroll()
{
	if (time) clearTimeout(time);
}

function vp(i)
{
	if (preview>0) { var x=new getObj("i"+preview); x.style.display="none"; }
	if (i>0)
	{
		var x=new getObj("i"+i);
		x.style.display="block";
	}
	preview=i;
}


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 PBA_swapImage(a,b,c,d,e,f)
{
	MM_swapImage(a,b,c,d)
//	document.ProductImage.height=140;
//	document.ProductImage.width=140;
}

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 ExpandAdvice(thistag)
{
	CloseAdvice();
	document.getElementById("text"+thistag).style.display='';
}
function CloseAdvice()
{
	for(i=1;i<=27;i++)
	{
		document.getElementById("text"+i).style.display='none';
	}
}

function ValidateAddToBasket(VarName)
{
//	MyString=document.AddToBasketForm.Variation.options[document.AddToBasketForm.Variation.selectedIndex].text;

	if (document.AddToBasketForm.Variation.selectedIndex==0)
	{
		alert("Please choose which "+VarName+" you want to purchase");
	}
////	else if (document.AddToBasketForm.Size.selectedIndex==0)
//	{
//		alert("Please choose a size");
//	}
//	else if (MyString.match(/out of stock/))
//	{
//		alert("The selected colour is currently out of stock");
//	}
	else
	{
		document.AddToBasketForm.submit();
	}
}

function ClearTrolley(PBA)
{
  window.location.replace("RemoveAllItemsFromCart.html")
}
function RemoveItem(ResItemID,PVID)
{
	window.location.replace("RemoveItemFromCart.html?ID="+ResItemID+"&PVID="+PVID)
}

function ReloadBasketPage()
{
	var NewPage="DisplayBasket.html?Country="+document.form1.Country.options[document.form1.Country.selectedIndex].text
	self.location.href=NewPage;
}

function ReloadBasketPage()
{
	var NewPage="DisplayBasket.html?CountryShipID="+document.form1.CountryID.options[document.form1.CountryID.selectedIndex].value
	self.location.href=NewPage;
}

function SRS1VerifyForm()
{
var x = document.SubmitMe.Email.value;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x))
	{
	}
	else 
	{
		themessage = themessage + " \nAn invalid e-mail address was entered.";
	}
	var themessage = "You are required to complete the following fields: ";
	if (document.SubmitMe.Email.value=="")
	{
		themessage = themessage + " \nEmail";
	}
	if (document.SubmitMe.Password.value=="")
	{
		themessage = themessage + " \nPassword";
	}
	if (document.SubmitMe.Password.value!=document.SubmitMe.Password2.value)
	{
		themessage = themessage + " \nPasswords do not match";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ")
	{
		//document.SubmitMe.Submit.disabled=true;
		document.SubmitMe.submit();
		return true;
	}
	else
	{
		alert(themessage);
		return false;
   }
}


function MemberLoginCheckFields()
{
	var themessage = "You must fill out the following fields: ";
	if (document.form.MemberEmail.value=="")
	{
		themessage = themessage + "\nYour email";
	}
	if (document.form.MemberPassword.value=="")
	{
		themessage = themessage + "\nYour password";
	}
	if (themessage == "You must fill out the following fields: ")
	{
		document.form.submit();
		return true;
	}
	else
	{
		alert(themessage);
		return false;
   }
}


function MemberLoginCheckForgottenFields()
{
	var themessage2 = "You must fill out the following field: ";
	if (document.form1.MemberEmail.value=="")
	{
		themessage2 = themessage2 + "\nYour email in the forgotten password section.";
	}
//alert if fields are empty and cancel form submit
	if (themessage2 == "You must fill out the following field: ")
	{
		document.form1.submit();
		return true;
	}
	else
	{
		alert(themessage2);
		return false;
   }
}

function UDS1VerifyForm()
{
	var themessage = "You must check the following: ";






if (document.SubmitMe.Password.value=="") {
themessage = themessage + "\nPassword";
}
if (document.SubmitMe.Password2.value=="") {
themessage = themessage + "\nRetype password";
}




	if (document.SubmitMe.Password.value!=document.SubmitMe.Password2.value)
	{
		themessage = themessage + "\nYour passwords are not the same";
	}
	if ((document.SubmitMe.LandLineNumber.value=="")&&(document.SubmitMe.MobilePhoneNumber.value=="")) {
	themessage = themessage + " \nEither your home or mobile telephone number";
	}
	if (themessage == "You must check the following: ")
	{
		document.SubmitMe.submit();
		return true;
	}
	else
	{
		alert(themessage);
		return false;
   }
}