

//OPen Custom Window

	function open_Custom_Window(page,Dims) {
		OpenWin = this.open(page, "new",Dims )
	}



//Show or Hide the div
	function displayDiv(div){
		var divstyle = new String();
		divstyle = document.getElementById(div).style.display;
		if(divstyle.toLowerCase()=="block" || divstyle == ""){
		    document.getElementById(div).style.display = "none";
		}else{
			document.getElementById(div).style.display = "block";
		}
	}

//Remove Prodct Fro basket
	function delBasketProd(delthis) {
		if(confirm("Attention!\nDo you really want to remove this product?"))
		window.location=delthis;
	}


//Member Delete basket
	function delBasket(delthis) {
		if(confirm("Attention!\nDo you really want to delete this basket?"))
		window.location=delthis;
	}






//Clear search
	function clearSearch(el) {
	  if (el.defaultValue==el.value) el.value = ""
	  
	  el.focus();
	  el.value='';	  
	}


	function checkSearch(){
	
		var myString=document.searchForm.search.value;
		var length = myString.length;	
	
		if (document.searchForm.search.value == "" ) {
			alert("Please add your search");
			document.searchForm.search.focus();
			return false;
		}
		


		if (length<2){
			alert("You cannot search with less than 2 characters\nPlease add to your search");
			document.searchForm.search.focus();
			return false;
		}

		
		
		
		
		
		
	}




//Find if numeric or not
	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;
	   }


//Check link bar number
	function linkBars(winNum) {
		numchk=IsNumeric(winNum);
		//alert(numchk);

		if(numchk==true){
			  if (winNum > 1) {
				document.productOptions.linkbars.value = winNum-1;
				document.productOptions.linkBarsOption.disabled=false;
				document.productOptions.quantity1.value = winNum;
			  }else{
				document.productOptions.linkbars.value = 0;
				document.productOptions.linkBarsOption.disabled=true;
				document.productOptions.linkBarsOption.checked=false;
				document.productOptions.quantity1.value = winNum;
			  }
		}else if (numchk==false){

			alert('Please only use numbers for quantity');
			document.productOptions.quantity.value = 1;
			document.productOptions.linkbars.value = 0;
			document.productOptions.quantity1.value = 1;

		}
		
		
	priceUpdate()	

	}




//Update quantity based on quantity1

	function exlinkBars(winNum){
		numchk=IsNumeric(winNum);
		if(numchk==true){
		
		
			  if (winNum > 1) {
				document.productOptions.linkbars.value = winNum-1;
				document.productOptions.linkBarsOption.disabled=false;
				  document.productOptions.quantity.value = winNum;
				  priceUpdate()				
			  }else{
				document.productOptions.linkbars.value = 0;
				document.productOptions.linkBarsOption.disabled=true;
				document.productOptions.linkBarsOption.checked=false;
				 document.productOptions.quantity.value = winNum;
				 priceUpdate()	
			  }
		

			 
		}else if (numchk==false){

			alert('Please only use numbers for quantity');
			document.productOptions.quantity.value = 1;
			document.productOptions.linkbars.value = 0;
			document.productOptions.quantity1.value = 1;
		}
	}





	function exquantCheck(winNum){
		numchk=IsNumeric(winNum);
		if(numchk==true){
		
		
			  if (winNum > 1) {
				  document.productOptions.quantity.value = winNum;
				  priceUpdate()				
			  }else{
				 document.productOptions.quantity.value = winNum;
				 priceUpdate()	
			  }
		

			
		}else if (numchk==false){

			alert('Please only use numbers for quantity');
			document.productOptions.quantity.value = 1;
			document.productOptions.quantity1.value = 1;
		}
	}











//Check quantity is a number
	function quantCheck(winNum) {
		numchk=IsNumeric(winNum);
		//alert(numchk);
		if (numchk==false){
			alert('Please only use numbers for quantity');
			document.productOptions.quantity.value = 1;
			document.productOptions.quantity1.value = 1;
			
		}else{
		
			document.productOptions.quantity1.value = winNum;		
			//alert(document.productOptions.quantity.value);
			priceUpdate()
		
		}
		

}
	
	
	
//Update product price
	function priceUpdate(){
		
		
		//alert('HIT!');
		
		//alert(productOptions.optCount.value);

		//alert(document.productOptions.quantity.value);
		//alert(document.productOptions.quantity1.value);

		//alert(document.productOptions.optCount.value);

		var lbStr = '';		
		var str = '';
		
		str = document.productOptions.quantity.value+",";
		str += document.productOptions.product_id.value+",";
		
		numchk=IsNumeric(document.productOptions.optCount.value);
		if (numchk==false){
			str +="0,";	
		}else{	
			str += document.productOptions.optCount.value+",";
		}
		
		
		
		
		//alert('First '+str);
		
		
		
		if (document.productOptions.linkBarsOption){
		/* do something */
			if (document.productOptions.linkBarsOption.checked == 1){
				//alert('checkme');
				str +=document.productOptions.linkbars.value+",";
			}else{
				str +=0+",";
			}

		}
		
		
		
		//alert('Second '+str);
		
		
		var elem = document.getElementById('productOptions').elements;
		for(var i = 0; i < elem.length; i++){

			//alert('Select Loop '+str);


			if (elem[i].type=='select-one'){

			//alert('Select Loop HIT! '+str);

			//str += "<b>Type:</b>" + elem[i].type + "&nbsp&nbsp";
			str += elem[i].name + "|";
			str += elem[i].value + ",";
			
			//alert('Loop '+str);
			
			
			//str += "<BR>";
			
			}

		}
		
		//alert('Here'+str);
		
		getTotals(str)




	}
	
	


//Check Email String

	function echeck(str) {

			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail Address")
			   return false
			}

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert("Invalid E-mail Address")
			   return false
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    alert("Invalid E-mail Address")
			    return false
			}

			 if (str.indexOf(at,(lat+1))!=-1){
			    alert("Invalid E-mail Address")
			    return false
			 }

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			    alert("Invalid E-mail Address")
			    return false
			 }

			 if (str.indexOf(dot,(lat+2))==-1){
			    alert("Invalid E-mail Address")
			    return false
			 }

			 if (str.indexOf(" ")!=-1){
			    alert("Invalid E-mail Address")
			    return false
			 }

			 return true
		}

	
	
//Customer Form	
	
	
	function copyAddress(){
		document.customerForm.delTitle.value=document.customerForm.invTitle.value;
		document.customerForm.delName.value=document.customerForm.invName.value;
		document.customerForm.delAddress1.value=document.customerForm.invAddress1.value;
		document.customerForm.delAddress2.value=document.customerForm.invAddress2.value;
		document.customerForm.delAddress3.value=document.customerForm.invAddress3.value;
		document.customerForm.delTown.value=document.customerForm.invTown.value;
		document.customerForm.delCounty.value=document.customerForm.invCounty.value;
		document.customerForm.delPostCode.value=document.customerForm.invPostCode.value;
		//document.customerForm.invCountry.selectedIndex = document.customerForm.invCountry.selectedIndex;
		document.customerForm.delTelephone.value=document.customerForm.invTelephone.value;


		for (var i=0; i< document.customerForm.length; i++) {
			document.customerForm[i].selectedIndex = document.customerForm.invCountry.selectedIndex;
		}


	}



	function checkContact(){

		var emailID=document.customerForm.invEmail

		if (document.customerForm.invName.value == "" ) {
			alert("Please add your name");
			document.customerForm.invName.focus();
			return false;
		}

		if (document.customerForm.invAddress1.value == "" ) {
			alert("Please add your address");
			document.customerForm.invAddress1.focus();
			return false;
		}else if(document.customerForm.invAddress1.value.length<4){
			alert("Your address appears to be incorrect");
			document.customerForm.invAddress1.focus();
			return false;
		}

		if (document.customerForm.invTown.value == "" ) {
			alert("Please add your town");
			document.customerForm.invTown.focus();
			return false;
		}else if(document.customerForm.invTown.value.length<4){
			alert("Your town appears to be incorrect");
			document.customerForm.invTown.focus();
			return false;
		}

		if (document.customerForm.invCounty.value == "" ) {
			alert("Please add your county");
			document.customerForm.invCounty.focus();
			return false;
		}else if(document.customerForm.invCounty.value.length<4){
			alert("Your county appears to be incorrect");
			document.customerForm.invCounty.focus();
			return false;
		}

		if (document.customerForm.invPostCode.value == "" ) {
			alert("Please add your postcode");
			document.customerForm.invPostCode.focus();
			return false;
		}else if(document.customerForm.invPostCode.value.length<5){
			alert("Your post code appears to be incorrect");
			document.customerForm.invPostCode.focus();
			return false;
		}

		var selObj = document.getElementById('invCountry');
		var selIndex = selObj.selectedIndex;

		if (selObj.options[selIndex].value == "" ) {
			//alert(selObj.options[selIndex].value);
			alert("Please select your country");
			document.customerForm.invCountry.focus();
			return false;
		}

		if (document.customerForm.invTelephone.value == 0) {
			alert("Please enter your telephone number.");
			document.customerForm.invTelephone.focus();
			return false;
		} else if (IsNumeric(document.customerForm.invTelephone.value) == false) {
			alert("Please enter a correct telephone number\nNumbers Only No Spaces!");
			document.customerForm.invTelephone.focus();
				document.customerForm.invTelephone.value='';
			return false;
		}



		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email Address")
			emailID.focus()
			return false;
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false;
		}


		if (document.customerForm.conEmail.value != emailID.value ) {
			alert("Email addresses do not match!");
			document.customerForm.invEmail.focus();
			return false;
		}


	//Delivery Validations


		if (document.customerForm.delName.value == "" ) {
			alert("Please add a delivery name\nOr use the copy from invoice button");
			document.customerForm.delName.focus();
			return false;
		}else if(document.customerForm.delName.value.length<2){
			alert("Your delivery name appears to be incorrect");
			document.customerForm.delName.focus();
			return false;
		}

		if (document.customerForm.delAddress1.value == "" ) {
			alert("Please add a delivery address\nOr use the copy from invoice button");
			document.customerForm.delAddress1.focus();
			return false;
		}else if(document.customerForm.delAddress1.value.length<4){
			alert("Your delivery address appears to be incorrect");
			document.customerForm.delAddress1.focus();
			return false;
		}

		if (document.customerForm.delTown.value == "" ) {
			alert("Please add a delivery town\nOr use the copy from invoice button");
			document.customerForm.delTown.focus();
			return false;
		}else if(document.customerForm.delTown.value.length<4){
			alert("Your delivery town appears to be incorrect");
			document.customerForm.delTown.focus();
			return false;
		}

		if (document.customerForm.delCounty.value == "" ) {
			alert("Please add a delivery county\nOr use the copy from invoice button");
			document.customerForm.delCounty.focus();
			return false;
		}else if(document.customerForm.delCounty.value.length<4){
			alert("Your delivery county appears to be incorrect");
			document.customerForm.delCounty.focus();
			return false;
		}

		if (document.customerForm.delPostCode.value == "" ) {
			alert("Please add a delivery postcode\nOr use the copy from invoice button");
			document.customerForm.delPostCode.focus();
			return false;
		}else if(document.customerForm.delPostCode.value.length<5){
			alert("Your delivery post code appears to be incorrect");
			document.customerForm.delPostCode.focus();
			return false;
		}


		var delObj = document.getElementById('delCountry');
		var delIndex = delObj.selectedIndex;

		if (delObj.options[delIndex].value == "" ) {
			//alert(delObj.options[delIndex].value);
			alert("Please select a delivery country\nOr use the copy from invoice button");
			document.customerForm.delCountry.focus();
			return false;
		}


		return true;
	}
	
	
	
	function checkBrochureRequest(){

		var emailID=document.brochureForm.email


		if (document.brochureForm.contact_name.value == "" ) {
			alert("Please add your name");
			document.brochureForm.contact_name.focus();
			return false;
		}



		if (document.brochureForm.telephone.value == 0) {
			alert("Please enter your telephone number.");
			document.brochureForm.telephone.focus();
			return false;
		} else if (IsNumeric(document.brochureForm.telephone.value) == false) {
			alert("Please enter a correct telephone number\nNumbers Only No Spaces!");
			document.brochureForm.telephone.focus();
			document.brochureForm.telephone.value='';
			return false;
		}


		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email Address")
			emailID.focus()
			return false;
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false;
		}



		if (document.brochureForm.enquiry.value == "" ) {
			alert("Please add your enquiry");
			document.brochureForm.enquiry.focus();
			return false;
		}



	}
	
	
	
	function checkContactForm(){

		var emailID=document.contactForm.email


		if (document.contactForm.contact_name.value == "" ) {
			alert("Please add your name");
			document.contactForm.contact_name.focus();
			return false;
		}



		if (document.contactForm.telephone.value == 0) {
			alert("Please enter your telephone number.");
			document.contactForm.telephone.focus();
			return false;
		} else if (IsNumeric(document.contactForm.telephone.value) == false) {
			alert("Please enter a correct telephone number\nNumbers Only No Spaces!");
			document.contactForm.telephone.focus();
			document.contactForm.telephone.value='';
			return false;
		}


		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email Address")
			emailID.focus()
			return false;
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false;
		}



		if (document.contactForm.enquiry.value == "" ) {
			alert("Please add your enquiry");
			document.contactForm.enquiry.focus();
			return false;
		}



	}
	
	
	
//Membership Checks

	function loginCheck(){


		if (document.loginForm.username.value == "" ) {
			alert("Please add your user name");
			document.loginForm.username.focus();
			return false;
		}

		if (document.loginForm.password.value == "" ) {
			alert("Please add your password");
			document.loginForm.password.focus();
			return false;
		}



	}
	
	
	function registerCheck(){	
	
		var emailID=document.registerForm.regEmail

		if (document.registerForm.regName.value == "" ) {
			alert("Please add your name");
			document.registerForm.regName.focus();
			return false;
		}


		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email Address")
			emailID.focus()
			return false;
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false;
		}


		if (document.registerForm.conEmail.value != emailID.value ) {
			alert("Email addresses do not match!");
			document.registerForm.regEmail.focus();
			return false;
		}
	
	}
	
	
	function checkMember(){	
	
		var emailID=document.memberForm.client_email;

		if (document.memberForm.client_name.value == "" ) {
			alert("Please add your name");
			document.memberForm.client_name.focus();
			return false;
		}


		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email Address")
			emailID.focus()
			return false;
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false;
		}



	
	}	
	
	

//Gallery

	//Highlight image script- By Dynamic Drive
	//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
	//This credit MUST stay intact for use

	function makevisible(cur,which){
		strength=(which==0)? 1 : 0.2

		if (cur.style.MozOpacity)
			cur.style.MozOpacity=strength
		else if (cur.filters)
			cur.filters.alpha.opacity=strength*100
	}	