if (document.images) {
nav_1_f2 = new Image(164 ,20); nav_1_f2.src = "images/main_nav/nav_1_f2.gif";
nav_1_f1 = new Image(164 ,20); nav_1_f1.src = "images/main_nav/nav_1.gif";
nav_2_f2 = new Image(164 ,20); nav_2_f2.src = "images/main_nav/nav_2_f2.gif";
nav_2_f1 = new Image(164 ,20); nav_2_f1.src = "images/main_nav/nav_2.gif";
nav_3_f2 = new Image(164 ,20); nav_3_f2.src = "images/main_nav/nav_3_f2.gif";
nav_3_f1 = new Image(164 ,20); nav_3_f1.src = "images/main_nav/nav_3.gif";
nav_4_f2 = new Image(164 ,20); nav_4_f2.src = "images/main_nav/nav_4_f2.gif";
nav_4_f1 = new Image(164 ,20); nav_4_f1.src = "images/main_nav/nav_4.gif";
}
function MM_findObj(n, d) { //v3.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); return x;
}
/* Functions that swaps images. */
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 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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//used on forgotpassword.asp
function ValidateEmailAddress()  {
	//alert(document.form1.username.value);
	if (document.form1.username.value == "") {
		alert("Please enter a valid email address");
	}
	else {
		document.form1.submit();
	}		
}

//used on my_details.asp
function checkForm() { 
vFail=0
Failstr=""

	if (document.myform.firstname.value == "")
	{
		Failstr=Failstr+"Please enter your name in the \"Name\" field.\n";
		vFail=1;
	}
	if (document.myform.surname.value == "")
	{
		Failstr=Failstr+"Please enter your surname in the \"Surname\" field.\n";
		vFail=1;
	}
	if (document.myform.uname.value =="")
	{
		Failstr=Failstr+"Please enter your email in the \"Email (username)\" field.\n";
		vFail=1;
	}
	else 
	{
		if (document.myform.uname.value.indexOf("@")==-1 || document.myform.uname.value.indexOf(".")==-1) 
		{
			Failstr=Failstr+"Please enter a valid email in the \"Email (username)\" field.\n";
			vFail=1;
		}
	}
	if (document.myform.phone.value != "") 
	{
		var ReplacedString = document.myform.phone.value.replace(/ /g, '');
		if (isNaN(ReplacedString)) 
		{
			Failstr=Failstr+"Please enter a valid telephone number (numbers only) in the \"Phone\" field.\n";
			vFail=1;
		}

	}
	if (document.myform.fax.value != "") 
	{
		var ReplacedString = document.myform.fax.value.replace(/ /g, '');
		if (isNaN(ReplacedString)) 
		{
			Failstr=Failstr+"Please enter a valid fax number (numbers only) in the \"Fax\" field.\n";
			vFail=1;
		}

	}
	if (document.myform.mobile.value != "") 
	{
		var ReplacedString = document.myform.mobile.value.replace(/ /g, '');
		if (isNaN(ReplacedString)) 
		{
			Failstr=Failstr+"Please enter a valid mobile number (numbers only) in the \"Mobile\" field.\n";
			vFail=1;
		}

	}
	if (document.myform.newpassword.value !="" && document.myform.newpasswordconfirm.value =="")
	{
		Failstr=Failstr+"Please confirm your new password in the \"Confirm password\" field.\n";
		vFail=1;
	}
	if (document.myform.newpasswordconfirm.value !="" && document.myform.newpassword.value =="")
	{
		Failstr=Failstr+"Please enter your new password in the \"New password\" field.\n";
		vFail=1;
	}
	if (document.myform.newpassword.value !="" && document.myform.newpasswordconfirm.value !="")
	{
		if (document.myform.newpassword.value != document.myform.newpasswordconfirm.value)
		{
			Failstr=Failstr+"Your passwords do NOT match, please enter the same password in the \"New password\" and \"Confirm password\" fields.\n";
			vFail=1;
		}
	}
	if (vFail == 0) {
		document.myform.submit();
	}
	else{
		alert (Failstr)
	}

}

//used on order2.asp
function doform() { 
vFail=0
Failstr=""
	if (document.form1.ponumber.value =='')  { 
		Failstr=Failstr+"PO Number Required.\n";
		vFail=1;
	}
	if (document.form1.delfao.value =='') {
		Failstr=Failstr+"FAO Required.\n";
		vFail=1;
	}
	if (document.form1.deladdress1.value =='') {
		Failstr=Failstr+"Delivery address line 1 Required.\n";
		vFail=1;
	}
	if (document.form1.delpostcode.value =='') {
		Failstr=Failstr+"Delivery postcode Required.\n";
		vFail=1;
	}
	if (vFail == 0) {
		document.form1.submit();
	}
	else{
		alert (Failstr)
	}
}

//used on admin/edit_image.asp
function ValidateModelTrim() {
	if (document.FrmEditImage.newModel.value == "0") {
		alert("Please select a Category from the list provided.");
	}
	else {
			//if (document.FrmEditImage.newTrim.value == "0") {
			//	alert("Please select a Trim from the list provided.");
			//}
			//else {
				document.FrmEditImage.doThis.value = "addMT"
				document.FrmEditImage.submit();
			//}
	}
}
function ValidateCategory() {
	if (document.FrmEditImage.newCat.value == "0") {
		alert("Please select a Classification from the list provided.");
	}
	else {
		document.FrmEditImage.doThis.value = "addCat"
		document.FrmEditImage.submit();
	}
}
function ValidateColour() {
	if (document.FrmEditImage.newCol.value == "0") {
		alert("Please select an Asset type from the list provided.");
	}
	else {
		document.FrmEditImage.doThis.value = "addCol"
		document.FrmEditImage.submit();
	}
}
function UpdImg(iid,url,dcnt) {
	document.form2.doThis.value = "updImg"
	document.form2.iid.value = iid
	if (dcnt == "") {
		document.form2.displaycount.value = "5"
	}
	else {
		document.form2.displaycount.value = dcnt
	}
	document.form2.action = 'default.asp' + url
	document.form2.submit();
}
function ValidateUser() {
vFail=0
Failstr=""
	if (document.forms[0].person_name.value == "")
	{
		Failstr=Failstr+"Please enter the first name into the \"Name\" field.\n";
		vFail=1;
	}
	if (document.forms[0].person_surname.value == "")
	{
		Failstr=Failstr+"Please enter the surname into the \"Surname\" field.\n";
		vFail=1;
	}
	if (document.forms[0].person_email.value =="")
	{
		Failstr=Failstr+"Please enter the email into the \"Email (Username)\" field.\n";
		vFail=1;
	}
	else 
	{
		if (document.forms[0].person_email.value.indexOf("@")==-1 || document.forms[0].person_email.value.indexOf(".")==-1) 
		{
			Failstr=Failstr+"Please enter a valid email into the \"Email (Username)\" field.\n";
			vFail=1;
		}
	}
	if (document.forms[0].person_password.value =="")
	{
		Failstr=Failstr+"Please enter the password into the \"Password\" field.\n";
		vFail=1;
	}
	if (vFail == 0) {
		document.forms[0].FrmSubmitted.value = "Y"
		document.forms[0].submit();
	}
	else{
		alert ("Sorry. can not continue for the following reason(s):\n"+Failstr)
	}
}
function decision(msg){
	if(confirm(msg)){
   		document.forms[0].delThis.value='yes';
		document.forms[0].submit();
	}
}
function Remdecision(id,action,msg){
	if(confirm(msg)){
		document.forms[0].item_id.value=id;
		document.forms[0].doThis.value=action;
		document.forms[0].submit();
	}
}
function updItem(id,action){
	document.forms[0].item_id.value=id;
	document.forms[0].doThis.value=action;
	document.forms[0].submit();
}
function addItem(additem,dothis) {
vFail=0
Failstr=""
	if (dothis == 'addMT')
	{
		if (document.forms[1].model_id.value == "")
		{
			Failstr=Failstr+"Please select a Model name from the \"Model\" field.\n";
			vFail=1;
		}
		if (document.forms[1].trim_id.value == "")
		{
			Failstr=Failstr+"Please select a Trim from the \"Trim\" field.\n";
			vFail=1;
		}
	}
	else
	{
		if (document.forms[1].itemname.value == "")
		{
			Failstr=Failstr+"Please enter the "+additem+" name into the \""+additem+"\" field.\n";
			vFail=1;
		}
		if (document.forms[1].priority.value == "")
		{
			Failstr=Failstr+"Please enter the Priority into the \"Priority\" field.\n";
			vFail=1;
		}
	}
	if (vFail == 0) {
		document.forms[1].doThis.value = dothis
		document.forms[1].submit();
	}
	else{
		alert ("Sorry. can not continue for the following reason(s):\n"+Failstr)
	}
}
function chkCbo(qstring) {
vFail=0
Failstr=""
	if (document.form1.Model.value == '' && document.form1.brochureType.value == '' && document.form1.refNumber.value == 'Ref Number')
	{
		Failstr=Failstr+"Please select a category, brochure type or enter a reference number.\n";
		//vFail=1;
	}
	if (vFail == 0) {
		document.form1.action = "brochure_results.asp"+qstring;
		document.form1.submit();
	}
	else{
		alert (Failstr)
	}

}
function chkIframeCbo(model,brochureType,qstring) {
vFail=0
Failstr=""
	if (model == '' && brochureType == '')
	{
		Failstr=Failstr+"Please select a category, brochure type or enter a reference number.\n";
		vFail=1;
	}
	if (vFail == 0) {
		document.form1.action = "brochure_results.asp"+qstring;
		document.form1.submit();
	}
	else{
		alert (Failstr)
	}

}





function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete")) {
    document.location = delUrl;
  }
}

