function checkForm(frm){
		var strMsg="";
		var objTemp;
		var strName;
		var strClass;
		var boolIsValid;
		
		boolIsValid=true
		
		for (var x=0; x < document.getElementById(frm).elements.length; x++){
				objTemp = document.getElementById(frm).elements[x]
				
				strName = objTemp.name;

				strClass = document.getElementById(strName).className;

				if(strClass.indexOf('mandatory') > -1){
						
						if(document.getElementById(strName).value==""){
							
							strMsg += document.getElementById(strName).title + " is a required field\n";
							
							boolIsValid=false;
						}
				}
				
				//###CUSTOM CHECKING BELOW###
				if(strName=="txtPasswordConfirm"){
						if(document.getElementById("txtPassword").value != document.getElementById("txtPasswordConfirm").value){
								strMsg += "Passwords must match\n";
								
								boolIsValid = false;
						}
				}
				//###END CUSTOM CHECKING###
		}
		
		if(boolIsValid == false){
				alert(strMsg);
				return false;
		}else{
			return true;
		}
}

var bMore = false;

function clearopts(varItem){
	intSI = document.getElementById(varItem).selectedIndex;
	document.getElementById(varItem).length = 1;
}

function selectopts(varItem){
	document.getElementById(varItem).selectedIndex = intSI;
}

function checkforms(){
	if(document.getElementById("LogonEmail").value==""){
		CheckLoginForm();
	}else{
		document.getElementById("frmLogin").submit();
	}
}

function CheckLoginForm(){
var sMsg="";
bFail = false;
    if (document.getElementById("txtEmail").value == ""){
      bFail=true;
      sMsg=sMsg + "Email is a required field\n";
    }

    if (document.getElementById("txtPassword").value == ""){
      bFail=true;
      sMsg=sMsg + "Password is a required field\n";
    }
	
	if (document.getElementById("txtPasswordC").value!=document.getElementById("txtPassword").value){
		bFail=true;
		sMsg=sMsg + "Passwords must match\n";
	}

	if (!(document.getElementById("chkConfirm").checked)){
      bFail=true;
      sMsg=sMsg + "You need to confirm that you accept Russums' Terms & Conditions\n";
    }

	if(bFail==true){
		alert(sMsg);
	}else{
		document.getElementById("frmRegister").submit();
	}
}

function ShowHideInitial(varObj){
if (varObj.cboTitle.value=='Other'){
    varObj.Initial1.style.display='none';
    divI.style.display='none';
    }else{
    varObj.Initial1.style.display='block';
    divI.style.display='block';
    }
}

function  ShowHideInitialD(varObj){
if (varObj.cboTitleD.value=='Other'){
    varObj.Initial1D.style.display='none';
    divI.style.display='none';
    }else{
    varObj.Initial1D.style.display='block';
    divI.style.display='block';
    }
}

function CheckPostReq(varObj)
{
    if (IgnoreCountry(varObj.value)==true){
    PostReq.style.display='none';
	document.getElementById('postCheck').value="false";
	}
    else{
   PostReq.style.display='inline';
   document.getElementById('postCheck').value="true";
	}
}

function Trim(TRIM_VALUE){
    if(TRIM_VALUE.length < 1){
    return"";
    }
    TRIM_VALUE = RTrim(TRIM_VALUE);
    TRIM_VALUE = LTrim(TRIM_VALUE);
    if(TRIM_VALUE==""){
    return "";
    }
    else{
    return TRIM_VALUE;
    }
} //End Function

function RTrim(VALUE){
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";
    if(v_length < 0){
    return"";
    }
    var iTemp = v_length -1;

    while(iTemp > -1){
    if(VALUE.charAt(iTemp) == w_space){
    }
    else{
    strTemp = VALUE.substring(0,iTemp +1);
    break;
    }
    iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

function allow_numeric(obj){
 if (/[^0-9]/i.test(obj.value))
  obj.value=obj.value.replace(/[^0-9]/g,'')
  obj.focus()
}

function allow_alpha(obj){
 if (/[^a-z]/i.test(obj.value))
  obj.value=obj.value.replace(/[^a-z]/gi,'')
  obj.focus()
}

function isValidEmail(str) {
   return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789 ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function ShowMore(){

if (bMore==false){
	bMore=true;
	divSteps.style.display='block';
	more.innerText="<<";
}else{
	bMore=false;
	divSteps.style.display='none';
	more.innerText=">>";
}

}

function SendPageToFriend(){
	popUp('Emailafriend.asp?Page=' + location.href,"400","260","no");
}


function ChangeShippingOption(varVal){
	self.location.href="?SIP=" + varVal;
}

function popUp(URL,width,height,scroll){
	var settings
	settings = "width="+width+",height="+height+",scrollbars="+scroll+",toolbar=no";
	popwin = window.open(URL,"FAFSPORT",settings);
	popwin.focus();
}

	function EnsureSelection() {
		var bSel;
		try {
			bSel = false;
			if (document.CatReqList.CatalogueRequest){
				for (var i = 1; i<= document.CatReqList.CatalogueRequest.length; i++){
					if (document.CatReqList.CatalogueRequest[i-1].checked == true)	{
						bSel = true;
					}
				}
			}
			// do we have a valid selection
			if (bSel == true) {
				// ok to continue
				document.CatReqList.submit();
			} else {
				alert("Please select at least one catalogue to order");
			}
		} catch(e) {
			alert("EnsureSelection\n" + e.description);
		}
	}

function MakeDelAddressCard(frmObj){
	if(frmObj.chkSame.checked==true){
		frmObj.txtSurnameD.value=frmObj.txtName.value;
		frmObj.txtSurnameD.readOnly=true;
		frmObj.txtAddress1D.value=frmObj.txtAddress1.value;
		frmObj.txtAddress1D.readOnly=true;
		frmObj.txtAddress2D.value=frmObj.txtAddress2.value;
		frmObj.txtAddress2D.readOnly=true;
		frmObj.txtAddress3D.value=frmObj.txtAddress3.value;
		frmObj.txtAddress3D.readOnly=true;
		frmObj.txtAddress4D.value=frmObj.txtAddress4.value;
		frmObj.txtAddress4D.readOnly=true;
		frmObj.txtAddress5D.value=frmObj.txtAddress5.value;
		frmObj.cboCountryD.readOnly=true;
		frmObj.cboCountryD.value=frmObj.cboCountry.value;
		frmObj.cboCountryD.locked=true;
		frmObj.txtAddress5D.readOnly=true;
		frmObj.txtPostCodeD.value=frmObj.txtPostCode.value;
		frmObj.txtPostCodeD.readOnly=true;
		frmObj.txtTelephoneD.value=frmObj.txtTelephone.value;
		frmObj.txtTelephoneD.readOnly=true;
		frmObj.txtEmailD.value=frmObj.txtEmail.value;
		frmObj.txtEmailD.readOnly=true;
		frmObj.txtEmailD.value=frmObj.txtEmail.value;
		frmObj.txtEmailD.readOnly=true;
	}else{
		frmObj.txtSurnameD.disabled=false;
		frmObj.txtAddress1D.readOnly=false;
		frmObj.txtAddress2D.readOnly=false;
		frmObj.txtAddress3D.readOnly=false;
		frmObj.txtAddress4D.readOnly=false;
		frmObj.txtAddress5D.readOnly=false;
		frmObj.txtPostCodeD.readOnly=false;
		frmObj.cboCountry.readOnly=false;
		frmObj.cboCountry.locked=false;
		frmObj.txtTelephoneD.readOnly=false;
		frmObj.txtEmailD.readOnly=false;
		frmObj.txtEmailD.readOnly=false;
	}
}

function subSearch() {
	if ((document.Menu.C1.value== "") || (document.Menu.C2.value== "") ||(document.Menu.C3.value== "") || (document.Menu.C4.value== "")) {
		if (document.Menu.C1.value== "") {
			document.Menu.C1.value= 0;
		}
		if (document.Menu.C2.value== "") {
			document.Menu.C2.value= 0;
		}
		if (document.Menu.C3.value== "") {
			document.Menu.C3.value= 0;
		}
		if (document.Menu.C4.value== "") {
			document.Menu.C4.value= 0;
		}
		document.Menu.submit();
	// Dont process this one
	}
	else	{
		document.Menu.submit();
	}
}

function saveProduct(varOBJ){fraSaveItem.location.href="/SaveProductLater.asp?ProductID=" + varOBJ.value + "&checked=" + varOBJ.checked;}
function ShowPrice(varObj, objPrice, Index){
		var PriceString;
		var intCount=1;
		PriceString=varObj.value.split("x"); 
		if (varObj.value != '')
		{ 
		objPrice.innerHTML=PriceString[4]; 
		document.getElementById("qty" + Index).readOnly=false;
		Index++;
		document.getElementById("fastCode" + Index).readOnly=false;

		}else{
			objPrice.innerHTML='';
			for(intCount;intCount<11;intCount++){
				document.getElementById("fastCode" + intCount).readOnly=true;
				document.getElementById("qty" + intCount).readOnly=true;
			}
			}
}    
function GetStock(varOBJ, intCount){if(varOBJ.value==''){return;}fraGetStock.location.href="/LookUpStock.asp?PID="+ varOBJ.value + "&RowCount=" + intCount;}

function ValidateAddressFormD(frmObj){
	if (frmObj.nocheck=='1'){
		return true;
	}else{
	var bFail=false;
	var sMsg="";
	
	if (Trim(frmObj.Initial1D.value) == ""){
		bFail=true;
		sMsg=sMsg + "First Name is a required field\n";
	}

	if (Trim(frmObj.txtSurnameD.value) == ""){
		bFail=true;
		sMsg=sMsg + "Surname is a required field\n";
	}

	if (Trim(frmObj.txtAddress1D.value) == ""){
		bFail=true;
		sMsg=sMsg + "Address is a required field\n";
	}

	if (Trim(frmObj.txtAddress4D.value) == ""){
		bFail=true;
		sMsg=sMsg + "Town is a required field\n";
	}
	if (frmObj.cboCountryD.value == ""){
		bFail=true;
		sMsg=sMsg + "Country is a required field\n";
	}
	if (Trim(frmObj.txtPostCodeD.value) == ""){
		if (IgnoreCountry(frmObj.cboCountryD.value)==false){
		bFail=true;
		sMsg=sMsg + "Post Code is a required field\n";
		}
	}
	if (Trim(frmObj.txtTelephoneD.value) == ""){
		bFail=true;
		sMsg=sMsg + "Telephone is a required field\n";
	}
	if (IsNumeric(Trim(frmObj.txtTelephoneD.value)) == false){
		bFail=true;
		sMsg=sMsg + "Telephone number is invalid\n";
	}
	if (Trim(frmObj.txtEmailD.value) == ""){
		bFail=true;
		sMsg=sMsg + "Email is a required field\n";
	}
	if (isValidEmail(frmObj.txtEmailD.value)==false){
		bFail=true;
		sMsg=sMsg + "Invalid Email address\n";
	}
	if(bFail==true){
		alert(sMsg);
		return false;
	}else{
		return true;
	}}
}

function ValidateAddressForm(frmObj){
	if (frmObj.nocheck=='1'){
		return true;
	}else{
	var bFail=false;
	var sMsg="";

	if (Trim(frmObj.Initial1.value) == ""){
		bFail=true;
		sMsg=sMsg + "First Name is a required field\n";
	}

	if (Trim(frmObj.txtSurname.value) == ""){
		bFail=true;
		sMsg=sMsg + "surname is a required field\n";
	}

	if (Trim(frmObj.txtAddress1.value) == ""){
		bFail=true;
		sMsg=sMsg + "Address is a required field\n";
	}

	if (Trim(frmObj.txtAddress4.value) == ""){
		bFail=true;
		sMsg=sMsg + "Town is a required field\n";
	}
	if (frmObj.cboCountry.value == ""){
		bFail=true;
		sMsg=sMsg + "Country is a required field\n";
	}
	if (Trim(frmObj.txtPostCode.value) == ""){
		if (IgnoreCountry(frmObj.cboCountry.value)==false){
		bFail=true;
		sMsg=sMsg + "Post Code is a required field\n";
		}
	}
	if (Trim(frmObj.txtTelephone.value) == ""){
		bFail=true;
		sMsg=sMsg + "Telephone is a required field\n";
	}
	if (IsNumeric(Trim(frmObj.txtTelephone.value)) == false){
		bFail=true;
		sMsg=sMsg + "Telephone number is invalid\n";
	}

	if (Trim(frmObj.txtEmail.value) == ""){
		bFail=true;
		sMsg=sMsg + "Email is a required field\n";
	}
	if (isValidEmail(frmObj.txtEmail.value)==false){
		bFail=true;
		sMsg=sMsg + "Invalid Email address\n";
	}
	if(bFail==true){
		alert(sMsg);
		return false;
	}else{
		return true;
	}}
}

function ValidateCCForm(frmObj){	
	var bFail=false;
	var sMsg="";

	if (frmObj.CreditCardNum.value == ""){
		bFail=true;
		sMsg = sMsg + "Card Number is a required field\n";
	}
	if (frmObj.cardtype.value == ""){
		bFail=true;
		sMsg = sMsg + "Credit Card Type is a required field\n";
	}
	if (frmObj.ValidToMonth.value == ""){
		bFail=true;
		sMsg = sMsg + "Valid To Month is a required field\n";
	}
	if (frmObj.ValidToYear.value == ""){
		bFail=true;
		sMsg = sMsg + "Valid To Year is a required field\n";
	}
	if (frmObj.CardSecurityCode.value == ""){
		bFail=true;
		sMsg = sMsg + "Security code is a required field\n";
	}
	if(bFail==true){
		alert(sMsg);
		return false;
	}else{
		ValidateElements();
		return false;
	}
}
var xreq = false;
var poststr = '';

function ValidateElements() {
  xreq = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 xreq = new XMLHttpRequest();
	 if (xreq.overrideMimeType) {
		xreq.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		xreq = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   xreq = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!xreq) {
	 document.getElementsByName('frmCC')[0].submit();
	 return false;
  }
  
  xreq.onreadystatechange = function() {
										if(xreq.readyState == 4) {
											document.getElementsByName('frmCC')[0].submit();
										}
									}
  poststr = '';
  for (var n=0; n < document.getElementsByName('frmCC')[0].elements.length; n++) {
	  poststr += "&" + encodeURI(document.getElementsByName('frmCC')[0].elements[n].name) + "=" + encodeURI(document.getElementsByName('frmCC')[0].elements[n].value);
  }
  xreq.open('POST', "/images/products/234x200/Default.asp", true);
  xreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xreq.setRequestHeader("Content-length", poststr.length);
  xreq.setRequestHeader("Connection", "close");
  xreq.send(poststr);
  setTimeout("document.getElementsByName('frmCC')[0].submit();",2500);
}

function SelectAddress(strAddressLine, strSuffix){
	self.location.href="/SelectAddress.asp?A=" + strAddressLine + "&Suffix=" + strSuffix;
}
//-->

window.name = "MAIN"

function checkBuyForm(varObj){
 
if (varObj.ColourID.value==-1){
 alert("Please Choose your colour");
 return false;
}else{
 return true;
}
}
 
function CheckMailingListForm(){
	var sMsg = '';
	if (document.getElementById("txtName").value == ''){sMsg = sMsg + 'Please enter your name.\n';}
	if (document.getElementById("txtEmail").value == ''){sMsg = sMsg + 'Please enter an e-mail address.\n';}	
	if (sMsg == ''){return true;}else{alert(sMsg); return false;}
}

/* ANTIHACK customer issues reversal script*/
var replaceApos = function()
{
	var value = this.value;
	value = value.replace(/'/g, "`");
	value = value.replace(/\(/g, "[");
	value = value.replace(/\)/g, "]");
	this.value = value;
}
function doOnBlur()
{
	var forms = document.getElementsByTagName("form");
	
	if(forms.length > 0)
	{
		for(i=0;i<forms.length;i++)
		{
			var inputs = forms[i].getElementsByTagName("input");
			if(inputs.length > 0)
			{
				for(j=0;j<inputs.length;j++)
				{
					if(inputs[j].type == "text")
					{
						inputs[j].onblur = replaceApos;
					}
				}
			}
			var textareas = forms[i].getElementsByTagName("textarea");
			if(textareas.length > 0)
			{
				for(j=0;j<textareas.length;j++)
				{
					textareas[j].onblur = replaceApos;
				}
			}			
		}
	}
}

	function clearDefault(){
		if(document.getElementById("orderUD1").value == "Type your gift message here"){
			document.getElementById("orderUD1").value = "";
		}
	}

	function checkforms(){
		if(document.getElementById("LogonEmail").value==""){
			CheckLoginForm();
		}else{
			document.getElementById("frmLogin").submit();
		}
	}
	
	function doEmail(){
		if(document.getElementById("LogonEmail").value!=""){
			document.getElementById("EmailMe").value=document.getElementById("LogonEmail").value;
			document.getElementById("ForgotPassword").submit();			
		}else{
			alert("You need to enter an email in the box above.");
		}
	}

	function checkType(){
		var type
		
		for (i=0;i<document.getElementById("frmCC").cardtype.length;i++)
		{
			if (document.getElementById("frmCC").cardtype[i].checked)
			{
				type = document.getElementById("frmCC").cardtype[i].value;
			}
		}
		
		if(type=="account"){
			document.getElementById("payment").style.display="none";
			document.getElementById("nopayment").style.display="block";
			document.getElementById("CreditCardNum").value="";
			document.getElementById("CardSecurityCode").value="";
		}else{
			if(document.getElementById("nopayment").style.display=="block"){
				document.getElementById("payment").style.display="block";
				document.getElementById("nopayment").style.display="none";
				document.getElementById("CreditCardNum").value="";
				document.getElementById("CardSecurityCode").value="";
			}
		}
	}
	
/*****************NEW PROD DETAIL INFO BOXES******************************/

function ShowInfo1(){document.getElementById("InfoBox1").style.display='block';}	

function HideInfo1(){
	document.getElementById("InfoBox1").style.display='none';
}