function IsNumeric(field)
{
   var text = field.value;
   var ValidChars = "0123456789.";
   if (!CheckContents(ValidChars,text))
	 {
	     alert('You did not enter a number, please try again');
			 field.focus();
	 }   
}
//****************************************************************************************
function IsAlphaNumeric(text)
{
   
	 var ValidChars = "abcdefghijklmnopqrstuvwxyz1234567890_-";
   if (!CheckContents(ValidChars,text.toLowerCase()))
	 {
			 return false;
	 }
	 else
	 {
	     return true;
	 }   
}
//*************************************************************************************
function CheckContents(ValidChars,text)
{
   var contentsgood=true;
   var letter;

   for (i = 0; i < text.length && contentsgood == true; i++) 
      { 
      letter = text.charAt(i); 
      if (ValidChars.indexOf(letter) == -1) 
      {
         contentsgood = false;
      }
   }
   return contentsgood;
}
//*************************************************************************************
function chksam()
{
     daform = document.forms['order'];
		 if (daform.name.value=="")
		 {
		        alert("You must provide your name.");
						daform.name.focus();
		 }
		 else if (daform.address.value=="")
		 {
		        alert("You must provide your address.");
						daform.address.focus();
		 }
		 else if (daform.tel.value=="")
		 {
		        alert("You must provide a contact number.");
						daform.tel.focus();
		 }
		 else  
		 {
						daform.submit();
		 }
}
//*************************************************************************************
function chkcontact()
{
     daform = document.forms['contact'];
		 if (daform.name.value=="")
		 {
		        alert("You must provide your name.");
						daform.name.focus();
		 }
		 else if (daform.address.value=="")
		 {
		        alert("You must provide your address.");
						daform.address.focus();
		 }
		 else if (daform.tel.value=="")
		 {
		        alert("You must provide a contact number.");
						daform.tel.focus();
		 }
		 else  
		 {
						daform.submit();
		 }
}
//*************************************************************************************
function chkcontact2()
{
     daform = document.forms['contact'];
		 if (daform.name.value=="")
		 {
		        alert("You must provide your name.");
						daform.name.focus();
		 }
		 else if (daform.address.value=="")
		 {
		        alert("You must enter an enquiry.");
						daform.address.focus();
		 }
		 else if (daform.tel.value=="")
		 {
		        alert("You must provide a contact number.");
						daform.tel.focus();
		 }
		 else  
		 {
						daform.submit();
		 }
}
//***********************************************************
function chkpc()
{
		 if (document.forms['pc'].postcode.value=="")
		 {
		        alert("You must provide your postcode.");
						document.forms['pc'].postcode.focus();
		 				return false;
		 }
		 else if (document.forms['pc'].postcode.value.indexOf(" ") <= 2)
		 {
		        alert("Please include the space in your postcode.");
						document.forms['pc'].postcode.focus();
						return false;
		 }
		 else  
		 {
						//document.forms['pc'].submit();
		 				return true;
		 }
}
//***********************************************************
function chkfulldetails()
{
     daform = document.forms['fd'];
		 if (daform.name.value=="")
		 {
		        alert("You must provide your name.");
						daform.name.focus();
		 }
		 else if (daform.address.value=="")
		 {
		        alert("You must provide your address.");
						daform.address.focus();
		 }
		 else if (daform.tel.value=="")
		 {
		        alert("You must provide a contact number.");
						daform.tel.focus();
		 }
		 else  if (daform.pday.selectedIndex==0)
		 {
		        alert("You must give a prefered day for the visit.");
						daform.pday.focus();
		 }
		 else  if (daform.ptime.selectedIndex==0)
		 {
		        alert("You must give a prefered time for the visit.");
						daform.ptime.focus();
		 }
		 else  
		 {
						daform.submit();
		 }
}
//******************************************************************************
function getoption(layer)
{
     document.getElementById('swb').style.display='none';
		 document.getElementById('co').style.display='none';
		 document.getElementById('cowp').style.display='none';
		 document.getElementById('cowe').style.display='none';
		 if (layer!="") document.getElementById(layer).style.display='block';
}
//******************************************************************************
function getpull(sel)
{
     for (x=1;x < sel.options.length; x++)
		 {
		    lname = sel.options[x].value;
		 		document.getElementById(lname).style.display='none';
		 }
		 if (sel.options[sel.selectedIndex].value!="") document.getElementById(sel.options[sel.selectedIndex].value).style.display='block';
}
//******************************************************************************
function checknorm(std_width,std_drop,max_width,max_drop)
{
		daform =  document.forms['configblind'];
		daform.width.style.backgroundColor='#ffffff';
		daform.drop.style.backgroundColor='#ffffff';
		if (daform.width.value!="")
		{
				 var ValidChars = "0123456789.";
   			 if (!CheckContents(ValidChars,daform.width.value))
	 			 {
				      alert("The width has not been typed correctly.\nPlease try again.");
							daform.width.value="";
							daform.width.focus(); 
				 } 
				 else if (daform.width.value > max_width)
				 {
				      popmsg(0,"Your width is over our maximum size of "+max_width+"cm. Please amend your width or call us on 0845 600 6499.");
				 			daform.width.style.backgroundColor='#ff3333';
							daform.width.focus(); 
				 }
				 else if ((daform.width.value > std_width)&&(daform.width_surcharge_notice.value=="0")&&(daform.drop_surcharge_notice.value=="0"))
				 {
				      popmsg(0,"Your width is over our standard size of "+std_width+"cm.\nA surcharge of £9.99 will be added to this blind.");
							daform.width_surcharge_notice.value="1";
				 }
				 else if ((daform.width.value > std_width)&&(daform.width_surcharge_notice.value=="0")&&(daform.drop_surcharge_notice.value=="1"))
				 {
				 			daform.width_surcharge_notice.value="1";
				 }
				 else if (daform.width.value <= std_width)
				 {
				      daform.width_surcharge_notice.value="0";
				 }		 
		}
		if (daform.drop.value!="")
		{
				 var ValidChars = "0123456789.";
   			 if (!CheckContents(ValidChars,daform.drop.value))
	 			 {
				      alert("The width has not been typed correctly.\nPlease try again.");
							daform.drop.value="";
							daform.drop.focus(); 
				 } 
				 else if (daform.drop.value > max_drop)
				 {
				      popmsg(0,"Your drop is over our maximum size of "+max_drop+"cm. Please amend your drop or call us on 0845 600 6499.");
				 		  daform.drop.style.backgroundColor='#ff3333';
							daform.drop.focus(); 
				 }
				 else if ((daform.drop.value > std_drop)&&(daform.width_surcharge_notice.value=="0")&&(daform.drop_surcharge_notice.value=="0"))
				 {
				      popmsg(0,"Your drop is over our standard size of "+std_drop+"cm.\nA surcharge of £9.99 will be added to this blind.");
							daform.drop_surcharge_notice.value="1";
				 }
				 else if ((daform.drop.value > std_drop)&&(daform.width_surcharge_notice.value=="1")&&(daform.drop_surcharge_notice.value=="0"))
				 {
				      daform.drop_surcharge_notice.value="1";
				 }
				 else if (daform.drop.value <= std_drop)
				 {
				      daform.drop_surcharge_notice.value="0";
				 }		 
		}		
	  if (daform.drop_surcharge_notice.value+daform.width_surcharge_notice.value!=0)
    {
						 			document.getElementById('osa').innerHTML="<font class=\"red\">&pound;9.99 oversize surcharge</font>";
    }
		else
		{
						 			document.getElementById('osa').innerHTML="";
    }
}
//******************************************************************************
function checkother(max_width,max_drop,bsize)
{
		daform =  document.forms['configblind'];
		daform.width.style.backgroundColor='#ffffff';
		daform.drop.style.backgroundColor='#ffffff';
		if (daform.width.value!="")
		{
				 var ValidChars = "0123456789.";
   			 if (!CheckContents(ValidChars,daform.width.value))
	 			 {
				      alert("The width has not been typed correctly.\nPlease try again.");
							daform.width.value="";
							daform.width.focus(); 
				 } 
				 else if (daform.width.value > max_width)
				 {
				      msg = "The maximum width for this price-band is "+max_width+"cm. Your width is over this size.";
							if (bsize==1)
							{
							    msg += "<br />Please go back and select a blind from the Medium or Large price-band";
							}
							else if (bsize==2)
							{
							    msg += "<br />Please go back and select a blind from the Large price-band.";
							}
							else
							{
							    msg += "<br />Please call us on 0845 600 6499.";
							} 
							popmsg(0,msg);
							daform.width.style.backgroundColor='#ff3333';
							daform.width.focus();
				 } 
		}
		if (daform.drop.value!="")
		{
				 var ValidChars = "0123456789.";
   			 if (!CheckContents(ValidChars,daform.drop.value))
	 			 {
				      alert("The width has not been typed correctly.\nPlease try again.");
							daform.drop.value="";
							daform.drop.focus(); 
				 } 
				 else if (daform.drop.value > max_drop)
				 {
				      msg = "The maximum drop for this price-band is "+max_drop+"cm. Your drop is over this size.";
							if (bsize==1)
							{
							    msg += "Please go back and select a blind from the Medium or Large price-band";
							}
							else if (bsize==2)
							{
							    msg += "Please go back and select a blind from the Large price-band.";
							}
							else
							{
							    msg += "Please call us on 0845 600 6499.";
							} 
							popmsg(0,msg);
							daform.drop.style.backgroundColor='#ff3333';
							daform.drop.focus();
				 } 
		}		
}
//******************************************************************************
function chkbdcfgnorm(max_width,max_drop)
{
    daform =  document.forms['configblind'];
		daform.width.style.backgroundColor='#ffffff';
		daform.drop.style.backgroundColor='#ffffff';
    //**Check finishing options for roller blinds first to set up boolean values
		if ((daform.range_id.value==2)&&(daform.finish_option.selectedIndex!=0))
		{
		         if (daform.finish_option[daform.finish_option.selectedIndex].value=="swb")
						 {
						 	       style_is_checked=false;
						         for (x=0;x < daform.swb_style.length; x++)
										 {
										     if (daform.swb_style[x].checked)
												 {
												     style_is_checked=true;
												 }
										 }
										
										 color_is_checked=false;
						         for (x=0;x < daform.swb_color.length; x++)
										 {
										     if (daform.swb_color[x].checked)
												 {
												     color_is_checked=true;
												 }
										 }
			
						 }
						 else if (daform.finish_option[daform.finish_option.selectedIndex].value=="co")
						 {
						 	       style_is_checked=false;
						         for (x=0;x < daform.co_style.length; x++)
										 {
										     if (daform.co_style[x].checked)
												 {
												     style_is_checked=true;
												 }
										 }
										 color_is_checked=true;
	
						 }
						 else if (daform.finish_option[daform.finish_option.selectedIndex].value=="cowp")
						 {
						 	       style_is_checked=false;
						         for (x=0;x < daform.cowp_style.length; x++)
										 {
										     if (daform.cowp_style[x].checked)
												 {
												     style_is_checked=true;
												 }
										 }
								
										
										 color_is_checked=false;
						         for (x=0;x < daform.cowp_color.length; x++)
										 {
										     if (daform.cowp_color[x].checked)
												 {
												     color_is_checked=true;
												 }
										 }
						 }
						 else if (daform.finish_option[daform.finish_option.selectedIndex].value=="cowe")
						 {
						 	       style_is_checked=false;
						             if (daform.cowe_style.checked)
												 {
												     style_is_checked=true;
												 }
										
								
										
										 color_is_checked=false;
						         for (x=0;x < daform.cowe_color.length; x++)
										 {
										     if (daform.cowe_color[x].checked)
												 {
												     color_is_checked=true;
												 }
										 }
						 }
		}					
    //**Check pull options for roller blinds first to set up boolean values
		if ((daform.range_id.value==2)&&(daform.pull_option.selectedIndex!=0))
		{
		         oname = daform.pull_option[daform.pull_option.selectedIndex].value+"_color";
		 	       pull_color_is_checked=false;
		         for (x=0;x < eval("daform."+oname+".length"); x++)
						 {
						     if (eval("daform."+oname+"[x].checked"))
								 {
								     pull_color_is_checked=true;
								 }
						 }
		
		}
		
		if (daform.width.value=="")
		{
				      alert("You must provide the blind width");
				 			daform.width.focus(); 
							
		}
		else if (daform.width.value > max_width)
		{
				      popmsg(0,"Your width is over our maximum size of "+max_width+"cm. Please amend your width or call us on 0845 600 6499.");
				 			daform.width.style.backgroundColor='#ff3333';
							daform.width.focus(); 
		}		
    else if (daform.drop.value=="")
    {
      	     alert("You must provide the drop");
     				 daform.drop.focus(); 
						 
    }				
    else if (daform.drop.value > max_drop)
    {
				      popmsg(0,"Your drop is over our maximum size of "+max_drop+"cm. Please amend your drop or call us on 0845 600 6499.");
				 		  daform.drop.style.backgroundColor='#ff3333';
							daform.drop.focus(); 
    }		
		else if (daform.measurement_type.selectedIndex==0)
		{
		         alert("Please tell us what measurement is being used.");
						 daform.measurement_type.focus();
		}
		else if (daform.fixing_type.selectedIndex==0)
		{
		         alert("Please tell us what fixing is required.");
						 daform.fixing_type.focus();
		}		
		else if (daform.control.selectedIndex==0)
		{
		         alert("Please tell us what side you require the control on");
						 daform.control.focus();
		}		
		else if ((daform.range_id.value==1)&&(daform.split.selectedIndex==0))
		{
		         alert("Please tell us if you require a split.");
						 daform.control.focus();
		}		
		else if ((daform.range_id.value==2)&&(daform.finish_option.selectedIndex!=0)&&(!style_is_checked))
		{
		         alert("Please select a finish option style.");
		}			
		else if ((daform.range_id.value==2)&&(daform.finish_option.selectedIndex!=0)&&(!color_is_checked))
		{
		         alert("Please select a finish option colour.");
		}		
		else if ((daform.range_id.value==2)&&(daform.pull_option.selectedIndex!=0)&&(!pull_color_is_checked))
		{
		         alert("Please select a pull option colour.");
		}						
		else
		{
		         daform.submit();
		}
}
//******************************************************************************
function chkbdcfgother(max_width,max_drop,bsize)
{
    daform =  document.forms['configblind'];
 		daform.width.style.backgroundColor='#ffffff';
		daform.drop.style.backgroundColor='#ffffff';
    daform =  document.forms['configblind'];
		if (daform.width.value=="")
		{
				      alert("You must provide the blind width");
				 			daform.width.focus(); 
							
		}
		else if (daform.width.value > max_width)
    {
				      msg = "The maximum width for this price-band is "+max_width+"cm. Your width is over this size.";
							if (bsize==1)
							{
							    msg += "<br />Please go back and select a blind from the Medium or Large price-band";
							}
							else if (bsize==2)
							{
							    msg += "<br />Please go back and select a blind from the Large price-band.";
							}
							else
							{
							    msg += "<br />Please call us on 0845 600 6499.";
							} 
							popmsg(0,msg);
							daform.width.style.backgroundColor='#ff3333';
							daform.width.focus();
    } 	
    else if (daform.drop.value=="")
    {
      	     alert("You must provide the drop");
     				 daform.drop.focus(); 
						 
    }				
    else if (daform.drop.value > max_drop)
    {
				      msg = "The maximum drop for this price-band is "+max_drop+"cm. Your drop is over this size.";
							if (bsize==1)
							{
							    msg += "Please go back and select a blind from the Medium or Large price-band";
							}
							else if (bsize==2)
							{
							    msg += "Please go back and select a blind from the Large price-band.";
							}
							else
							{
							    msg += "Please call us on 0845 600 6499.";
							} 
							popmsg(0,msg);
							daform.drop.style.backgroundColor='#ff3333';
							daform.drop.focus();
    } 
		else if (daform.measurement_type.selectedIndex==0)
		{
		         alert("Please tell us what measurement is being used.");
						 daform.measurement_type.focus();
		}
		else if (daform.fixing_type.selectedIndex==0)
		{
		         alert("Please tell us what fixing is required.");
						 daform.fixing_type.focus();
		}		
		else if (daform.control.selectedIndex==0)
		{
		         alert("Please tell us what side you require the control on");
						 daform.control.focus();
		}		
		else if ((daform.range_id.value==1)&&(daform.split.selectedIndex==0))
		{
		         alert("Please tell us if you require a split.");
						 daform.control.focus();
		}		
		else if ((daform.range_id.value==2)&&(daform.finish_option.selectedIndex!=0)&&(!style_is_checked))
		{
		         alert("Please select a finish option style.");
		}			
		else if ((daform.range_id.value==2)&&(daform.finish_option.selectedIndex!=0)&&(!color_is_checked))
		{
		         alert("Please select a finish option colour.");
		}						
		else
		{
		         daform.submit();
		}
}
//*************************************************************************************************
function chk1()
{
    daform = document.forms['form1'];
		if (daform.customername.value=="")
		{
		     alert("You must provide your name")
				 daform.customername.focus();
		}
		else if (daform.add1.value=="")
		{
		     alert("You must provide your full address")
				 daform.add1.focus();
		}
		else if (daform.town_city.value=="")
		{
		     alert("You must provide your town/city of residence")
				 daform.town_city.focus();
		}
		else if (daform.postcode.value=="")
		{
		     alert("You must provide your postcode")
				 daform.postcode.focus();
		}
		else if (daform.tel.value=="")
		{
		     alert("You must provide a contact number")
				 daform.tel.focus();
		}
		else if (daform.email.value=="")
		{
		     alert("You must provide your email address")
				 daform.email.focus();
		}
		else if ((daform.email.value.indexOf(".") <= 2) || (daform.email.value.indexOf("@") <= 0))
		{
		     alert("Your email address appears to be incorrect. Please check and re-type.");
				 daform.email.focus();
		}		
		else
		{
		     daform.submit();
		}
}
//*************************************************************************************************
function chk2()
{
        daform = document.forms['form2'];
        if (daform.dcustomername.value=="")
        {
             alert("You must provide your name")
        		 daform.dcustomername.focus();
        }
        else if (daform.dadd1.value=="")
        {
             alert("You must provide your full address")
        		 daform.dadd1.focus();
        }
        else if (daform.dtown_city.value=="")
        {
             alert("You must provide your town/city of residence")
        		 daform.dtown_city.focus();
        }
				else if (daform.dpostcode.value=="")
				{
		         alert("You must provide your postcode")
				 		 daform.dpostcode.focus();
				}
        else if (daform.dcountry.selectedIndex==0)
        {
             alert("You must select your delivery zone")
        		 daform.dcountry.focus();
        }
        else if (daform.dcountry.selectedIndex==7)
        {
             alert("For all other delivery enquiries including Channel Islands please contact our customer services department for a quote.")
        		 daform.dcountry.focus();
        }
        else
        {
             daform.submit();
        }
}
//******************************************************************************
function blockout()
{
    daform = document.forms['form2'];
		if (daform.same.checked)
		{
    		for (x=1;x<(daform.elements.length-2);x++)
    		{
    		       daform.elements[x].disabled=true;
    		}
	  }
		else
		{
    		for (x=1;x<(daform.elements.length-2);x++)
    		{
    		       daform.elements[x].disabled=false;
    		}
		}			
}
//******************************************************************************
function popmsg(id,txt)
{
		if (id==0)
		{
		    msg="<table width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"><tr><td align=\"left\" bgcolor=\"#D1232A\" style=\"color:#FFFFFF;\">";
				msg+=txt;
				msg+="</td></tr><tr><td align=\"right\"><a href=\"javascript:popclose();\">Close</a></td></tr></table>";
		}
		else 
		{
		    msg="<table width=\"100%\" cellpadding=\"3\" cellspacing=\"3\"><tr><td align=\"left\" bgcolor=\"#0085CA\" style=\"color:#FFFFFF;\">";
				if (id==1)
				{
				    msg+="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis pulvinar porttitor odio. Integer scelerisque convallis eros.";
				}
				else if (id==2)
				{
				    msg+="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis pulvinar porttitor odio. Integer scelerisque convallis eros.";
				}
				else if (id==3)
				{
				    msg+="<b>What measurement is being used?</b><br /><br />All our blinds can be fitted into the face of your window frame, wall or into the top of the lintel. This gives you complete control over the fitting of your new blind. There are generally two fitting options for your new window blind, recess or exact.<ul><li><b>Recess:</b> This is the measurement you need to take if you want your blind to fit inside the window recess.<br /><br /></li><li><b>Exact:</b> This is the measurement you need to take if you want your blind to hang outside the recess overlapping the window.</li></ul><br />Please read our <a href='http://www.shades-blinds.co.uk/measurement-guide/' target='_blank'>measuring guide</a> for more details on how to measure your blinds or call one of our Customer Service advisors on 0845 600 6499 if you require further assistance with your order.";
				}
				else if (id==4)
				{
				    msg+="<b>What fixing type is needed?</b><br /><br />Our blinds can be either face fixed or top fixed (where applicable). You will need to specify which method you will use so that we may supply the correct brackets to you in your delivery.<ul><li><b>Top Fixing:</b> through the top of the brackets into the window lintel or ceiling<br /><br /></li><li><b>Face Fixing:</b> into the window frame or wall</li></ul>";
				}
				else if (id==5)
				{
				    msg+="<b>Do you require a split?</b><br /><br />Vertical blinds can be split down the centre. This feature is an optional extra with an additional cost of £9.99.";
				}
				else if (id==6)
				{
				    msg+="<b>Would you like a Finishing Option with your blind?</b><br /><br />You can choose to have a variety of special finishing options added to your roller blinds. These finishes are all optional extras and the price you pay will depend on the width of your blind – the lower price is for roller blinds sized up to 180cms wide – the higher price for roller blinds sized from 181 cms to 200cms, our maximum width.";
				}
				else if (id==7)
				{
				    msg+="<b>Would you like a Pull Option with your blind?</b><br /><br />You can choose to have a variety of pull options added to your roller blind. These pull options are all optional.";
				}
				msg+="</td></tr><tr><td align=\"right\"><a href=\"javascript:popclose();\">Close</a></td></tr></table>";		
		}
		
		document.getElementById('popup').innerHTML=msg;
		document.getElementById('popup').style.display='block';
}
//******************************************************************************
function popclose()
{
		document.getElementById('popup').style.display='none';
}
//******************************************************************************
function chkdel(daobj)
{
      if (daobj.selectedIndex==7)
      {
             alert("For all other delivery enquiries including Channel Islands please contact our customer services department for a quote.")
        		 daobj.focus();
      }
}
//****************************************************************************************
function poppic(pic)
{
		 window.open("http://www.shades-blinds.co.uk/pop.php?pic="+pic,"popup","scrollbars=1,location=0,toolbar=0,directories=0,menubar=0,resizable=0,status=0,width=40,height=32");
}
