function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function update_basket(){
	document.form.ordersubmit.value="false";
	//document.form.ordersubmit.value="true";

	//alert('updating basket...');
	document.form.submit();
}


function insure(objSelect){
	if (objSelect.checked)
	{
		if(!Element.visible('insure'))
		{
		new Effect.BlindDown('insure');
		}

	}
	else
	{
		if(Element.visible('insure'))
		{
		new Effect.BlindUp('insure');
		}

	}
	return false;
}

function insureOther(objSelect){
	if (objSelect.selectedIndex<=0) return false;
	var objOpt = objSelect.options[objSelect.selectedIndex];
	if (objOpt.value == "other")
	{
		if(!Element.visible('insure-other'))
		{
		new Effect.Appear('insure-other');
		}

	}
	else
	{
		if(Element.visible('insure-other'))
		{
		new Effect.Fade('insure-other');
		}

	}
	return false;
}

function nextProcess(){
	// 11/12/2008 improved by dtw
	f= document.forms['form'];
	petcounter= f.petcount.value;


	if(f.tc[0].checked) {
	  alert("Well, we're sorry about that. Let's go back to the Cart!");
	  location.href="/basket.asp";
	  return false;
	}

	if(!f.tc[1].checked) {
	  alert("Please ensure you have read the terms and conditions and the Important Legal Notice.");
	  return false;
	}



	errorval="";
	xstr="";
	ival = f.insurance.checked;
	if(ival!="")
	{
		if (f.insurer_select.value == "")
		{
		  alert("Please Select an Insurance Company!");
	    return false;
		}
		if (f.insurer_select.value == "other" && f.insurer_other.value == "")
		{
			alert("Please input your \"other\" Insurance Company");
			return false;
		}

		xstr="insurer_select="+f.insurer_select.value+"&";
		xstr=xstr+"insurer_other="+f.insurer_other.value+"&";
		xstr=xstr+"insurer_number="+f.insurer_number.value+"&";
	}


	vselect=true;
	  var petData= new Array();
	  petData[0]= "pet_name";
	  petData[1]= "pet_species";
	  petData[2]= "pet_age";
	  petData[3]= "pet_breed";
	  petData[4]= "pet_lactating";



	  if(petcounter>0) { //Check pet selection
		for (var x = 1; x <= petcounter; x++) {
		  for (var y = 0; y < petData.length; y++) {
			if (f.elements[petData[y]+x]) {
				if (f.elements[petData[y]+x].value=='') {
					vselect=false;
				}
			  }
			}
		}
	  }


  if(xstr!="") xstr=xstr+"petcount="+petcounter;

	if(!(vselect)) {
		alert("ANIMAL DETAILS MISSING:\n\nPlease enter the animal(s) details next to the medication ordered.");
		location.href="#confirm";
		return false;
	}
	else{
		f.ordersubmit.value="complete";
		//alert('cool');
		return true;
	}
}




function change_price(passval,mess_id){
	passval;
	var m_array=passval.split(";&;");
	show_price(m_array[0],mess_id);

}

function show_price(pass_price,mess_id){
	messagelayer = document.all["message"+mess_id];
	messagelayer.innerHTML="£"+pass_price;
}

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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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 main_image(picref)
{
window.open("show_image.asp?id="+picref,"displayWindow","menubar=no,scrollbars=yes,status=yes,width=450,height=450")
}
//-->

function check_basket(){
document.basket.submit();
}

function prescription()
{
	window.open('prescription_popup.asp','jav','width=650,height=670,resizable=no,scrollbars=yes');
}



function userreg(){
	//alert('userreg');
	errorval="";
	if(document.form2.title.value=="")
		errorval=errorval+"Please select a Title.\n\n"

	if(document.form2.firstname.value=="")
		errorval=errorval+"Please enter your Firstname.\n\n"

	if(document.form2.surname.value=="")
		errorval=errorval+"Please enter your Surname.\n\n"

	//alert('a4');

	if(document.form2.email.value=="")
		errorval=errorval+"Please enter your Email address.\n\n"
	else{
		if(!(document.form2.email.value== checkout1EmailCheck))
			if(!(isEmail(document.form2.email.value)))
				errorval=errorval+"Please ensure your Email address is in the correct format.\n\n";
	}
	//alert('a5');
	if(document.form2.password.value=="")
		errorval=errorval+"Please enter your Password.\n\n"
	if(document.form2.password2.value=="")
		errorval=errorval+"Please re-type your Password.\n\n"

	//alert('a1');

	if(!(document.form2.password2.value=="" && document.form2.password.value=="")){
	if(!(document.form2.password.value==document.form2.password2.value))
		errorval=errorval+"Your password and password re-type do not match.\n\n";
		}

	if(document.form2.tel.value=="")
		errorval=errorval+"Please enter your Telephone number.\n\n"


	if(!(document.form2.terms.checked))
		errorval=errorval+"Please read the terms and conditions.\n\n"

	if(errorval=="")
	{
		//alert('cool');
		return true;
	}
	else
	{
		alert(errorval);
		return false;
	}
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function number(string) {
    if (!string) return false;
    var Chars = "0123456789";

    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
}

function userlogin(){
errorval="";
if(document.form.Email.value=="")
	errorval=errorval+"Please enter your username.\n\n"
if(document.form.Password.value=="")
	errorval=errorval+"Please enter your password.\n\n"
if(errorval=="")
{
return true;
}
else{
alert(errorval);
return false;
}
}

function check1(){
if(document.form2.CPH1.value.length==2) document.form2.CPH2.focus();
}
function check2(){
if(document.form2.CPH2.value.length==3) document.form2.CPH3.focus();
}



function terms()
{
window.open("terms_popup.asp","displayWindow","menubar=no,scrollbars=yes,status=yes,width=500,height=650")
}


////////////////

//// basket


//// checkout2
function hideLayer(whichLayer) {
	//alert('hideLayer')
	if (document.getElementById) {
	// this is the way the standards work
	document.getElementById(whichLayer).style.visibility = "hidden";
	}
	else if (document.all) {
	// this is the way old msie versions work
	document.all[whichlayer].style.visibility = "hidden";
	}
	else if (document.layers) {
	// this is the way nn4 works
	document.layers[whichLayer].visibility = "hidden";
	}
}

function showLayer(whichLayer) {
	//alert('showLayer')
	if (document.getElementById) {
	// this is the way the standards work
	document.getElementById(whichLayer).style.visibility = "visible";
	}
	else if (document.all) {
	// this is the way old msie versions work
	document.all[whichlayer].style.visibility = "visible";
	}
	else if (document.layers) {
	// this is the way nn4 works
	document.layers[whichLayer].visibility = "visible";
	}
}


function userlogin(){
errorval="";
if(document.form.Email.value=="")
	errorval=errorval+"Please enter your username.\n\n"
if(document.form.Password.value=="")
	errorval=errorval+"Please enter your password.\n\n"
if(errorval=="")
{
document.form.submit();
}
else{
alert(errorval);
}
}

function addoneactive(){
document.form.pflookone.value="1";
}
function addtwoactive(){
document.form.pflooktwo.value="1";
}

function killupdate_basket(){
document.form.submit();
}


function copyaddress(){
if(document.form.contact_name.value!="" && document.form.house.value!="" && document.form.del1.value!="" && document.form.town.value!="" && document.form.postcode.value!="" && document.form.country.value!=""){
document.form.two_contact_name.value=document.form.contact_name.value;
document.form.two_house.value=document.form.house.value;
document.form.two_del1.value=document.form.del1.value;
document.form.two_del2.value=document.form.del2.value;
document.form.two_del3.value=document.form.del3.value;
document.form.two_town.value=document.form.town.value;
document.form.two_district.value=document.form.district.value;
document.form.two_postcode.value=document.form.postcode.value;
document.form.two_country.value=document.form.country.value;
addtwoactive();
showLayer("addtable2");
}
else{
	alert("Please complete the mandatory Payment Card Holder Address fields first.")
}
}



function promptpostcode()
{
if(document.form.postcode.value=="" || document.form.pflookone.value=="")
{
	alert("Please enter your postcode above then click 'Find Address'");
	//document.form.house.value="";
	document.form.del1.value="";
	document.form.del2.value="";
	document.form.del3.value="";
	document.form.town.value="";
	document.form.country.value="";
	document.form.district.value="";
}
}


function promptpostcodetwo()
{
if(document.form.two_postcode.value=="" || document.form.pflooktwo.value=="")
{
	alert("Please enter your postcode above then click 'Find Address'");
//	document.form.two_house.value="";
	document.form.two_del1.value="";
	document.form.two_del2.value="";
	document.form.two_del3.value="";
	document.form.two_town.value="";
	document.form.two_country.value="";
	document.form.two_district.value="";
}
}

function password_check(f){
	errorval="";
	if(f.Email.value=="")
		errorval=errorval+"Please enter your email address.\n\n"
	if(errorval=="")
	{
	return true;
	}
	else{
	alert(errorval);
	return false;
	}
}





function change_price(passval,mess_id){
passval;
var m_array=passval.split(";&;");
show_price(m_array[0],mess_id);
}

function show_price(pass_price,mess_id){
messagelayer = document.all["message"];
messagelayer.innerHTML="£"+pass_price;
}



function main_image(picref)
{
window.open("show_image.asp?id="+picref,"displayWindow","menubar=no,scrollbars=yes,status=yes,width=450,height=450")
}

