function show()
{
	var theList = "list";
	var thehiddenList = "hiddenList";
	
	var list = document.getElementById(theList);
	var hiddenList = document.getElementById(thehiddenList);
	
	if(hiddenList.style.display == "none") 
	{
		hiddenList.style.display = '';
		list.style.background = "url('../images/bg_menuGrey.jpg') #d9e3ed no-repeat";
	}else{
		hiddenList.style.display = 'none';
		list.style.background = "#d9e3ed";
	}
}


function show1()
{
	var theList = "list1";
	var thehiddenList = "hiddenList1";
	
	var list = document.getElementById(theList);
	var hiddenList = document.getElementById(thehiddenList);
	
	if(hiddenList.style.display == "none") 
	{
		hiddenList.style.display = '';
		list.style.background = "url('images/bg_menuGrey.jpg') #d9e3ed no-repeat";
	}else{
		hiddenList.style.display = 'none';
		list.style.background = "#d9e3ed";
	}
}

function showFaq(obj)
{
	var theAnswer = "answer" + obj;
	var theQuestion = "question" + obj;
	
	var answer = document.getElementById(theAnswer);
	var question = document.getElementById(theQuestion);
	
	if ( answer.style.display == "none" ) 
	{
		answer.style.display = '';
	}else {
		answer.style.display = 'none';
	}
}

function showFaqs(obj)
{
	var theAnswer = "answer" + obj;
	var theQuestion = "question" + obj;
	
	var answer = document.getElementById(theAnswer);
	var question = document.getElementById(theQuestion);
	
	if ( answer.style.display == "none" ) 
	{
		answer.style.display = '';
		question.style.backgroundImage = "url('images/faqlist-.jpg')";
	}else {
		answer.style.display = 'none';
		question.style.backgroundImage = "url('images/faqlist+.jpg')";
	}
}

function showHide(num)
{
	var card = document.getElementById('malse');
	var delivery = document.getElementById('payDelivery');
	var account = document.getElementById('payAccount');
	
	if(num == 0)
	{
		card.style.display = '';
		delivery.style.display = 'none';
		account.style.display = 'none';
	}else if(num == 1)
	{
		card.style.display = 'none';
		delivery.style.display = '';
		account.style.display = 'none';
	}else{
		card.style.display = 'none';
		delivery.style.display = 'none';
		account.style.display = '';
	}
}

function showHideElement(obj)
{
	var formObj = document.getElementById(obj);
	
	if ( formObj.style.display == "none" ) 
	{
		formObj.style.display = '';
	}else {
		formObj.style.display = 'none';
	}
}

function showFrame(num)
{
	for(i=1;i<=5;i++)
	{
		if(num == i)
		{
			if(i != 5)
			{
				document.getElementById('item'+i).style.background = "#ffffff";
				document.getElementById('item'+i).style.borderBottomColor = "#ffffff";
			}
			document.getElementById('frame'+i).style.display = "block";
		}else{
			if(i != 5)
			{
				document.getElementById('item'+i).style.background = "#E7E7E8";
				document.getElementById('item'+i).style.borderBottomColor = "#bbbbbb";
			}
			document.getElementById('frame'+i).style.display = "none";
		}	
	}	
}

function confirmUnsubscribe() 
{
	var agree=confirm("You are about to unsubscribe from the Clinivet system,\n\rare you sure you want to continue?");
	if (agree)
		return true ;
	else
		return false ;
}// end function confirmDelete()

function setLanguage(sel)
{
	var updateString;
	
	if(sel == 1)
	{
		updateString = "<label for='chooseLanguage'><img src='images/uk-flag.jpg' alt='UK' title='UK' width='30' height='20' /></label>";
		
	}else if(sel == 2)
	{
		updateString = "<label for='chooseLanguage'><img src='images/german.jpg' alt='Germany' title='Germany' width='30' height='20' /></label>";
		document.getElementById('languageForm').action = "http://www.clinivet.de"
		document.getElementById('languageForm').target = "_blank";
		document.getElementById('languageForm').submit();
		
	}else if(sel == 3)
	{
		updateString = "<label for='chooseLanguage'><img src='images/cz.jpg' alt='Czech Republic' title='Czech Republic' width='30' height='20' /></label>";
		document.getElementById('languageForm').action = "http://www.clinivet.cz"
		document.getElementById('languageForm').target = "_blank";
		document.getElementById('languageForm').submit();
	}else if(sel == 4)
	{
		updateString = "<label for='chooseLanguage'><img src='images/greek-flag.jpg' alt='Greece' title='Greece' width='30' height='20' /></label>";
		document.getElementById('languageForm').action = "http://www.clinivet.gr"
		document.getElementById('languageForm').target = "_blank";
		document.getElementById('languageForm').submit();
	}else if(sel == 5)
	{
		updateString = "<label for='chooseLanguage'><img src='images/french-flag.jpg' alt='France' title='France' width='30' height='20' /></label>";
		
		document.getElementById('languageForm').action = "http://www.clinivet-croquettes.fr"
		document.getElementById('languageForm').target = "_blank";
		document.getElementById('languageForm').submit();
	}else if(sel == 6)
	{
		updateString = "<label for='chooseLanguage'><img src='images/switzerland.jpg' alt='Switzerland' title='Switzerland' width='30' height='20' /></label>";
		
		document.getElementById('languageForm').action = "http://www.suttervertrieb.ch/clinivet.html"
		document.getElementById('languageForm').target = "_blank";
		document.getElementById('languageForm').submit();
	}else{
		updateString = "<label for='chooseLanguage'><img src='images/uk-flag.jpg' alt='UK' title='UK' width='30' height='20' /></label>";
	}
	
	document.getElementById('languageLabel').innerHTML = updateString;
	
}

function useInvoiceAddress()
{
	if(document.getElementById('useAddress').checked)
	{
		document.getElementById('del_name').value = document.getElementById('inv_name').value;
		document.getElementById('del_addr1').value = document.getElementById('inv_addr1').value;
		document.getElementById('del_addr2').value = document.getElementById('inv_addr2').value;
		document.getElementById('del_state').value = document.getElementById('inv_state').value;
		document.getElementById('del_zip').value = document.getElementById('inv_zip').value;
		document.getElementById('del_country').value = document.getElementById('inv_country').value;
	}else{
		document.getElementById('del_name').value = '';
		document.getElementById('del_addr1').value = '';
		document.getElementById('del_addr2').value = '';
		document.getElementById('del_state').value = '';
		document.getElementById('del_zip').value = '';
		document.getElementById('del_country').value = '';
	}
}

// function to check that the required fields have been completed on the enquiry form
function checkEnquiryForm()
{
	
	var theFirstname, theSurname, theEmail, theNature;

		
	with(window.document.enquiryForm)
	{
		theFirstname = firstname;
		theSurname = surname;
		theEmail = email;
		theNature = natureOfEnquiry;
	}

	if(trim(theFirstname.value) == '')
	{
		alert('Please enter your name');
		theFirstname.focus();
		return false;
	}
	else if(trim(theSurname.value) == '')
	{
		alert('Please enter your name');
		theSurname.focus();
		return false;
	}
	else if(trim(theNature.value) == 'Not Selected')
	{
		alert('Please specify the nature of the enquiry');
		theNature.focus();
		return false;
	}
	else if(trim(theEmail.value) == '')
	{
		alert('Please enter your email address');
		theEmail.focus();
		return false;
	}
	else if(!isEmail(trim(theEmail.value)))
	{
		alert('Email address is not valid');
		theEmail.focus();
		return false;
	}
	else
	{ 
		theFirstname.value = trim(theFirstname.value);
		theSurname.value = trim(theSurname.value);
		theEmail.value = trim(theEmail.value);
		theNature.value = trim(theNature.value);
		return true;
	}
}// end function checkEnquiryForm()

function checkPasswords()
{
	
	var theUserhash, theConfirm;

		
	with(window.document.passForm)
	{
		theUserhash = userhash;
		theConfirm = userhashC;
	}

	if(trim(theUserhash.value) == '')
	{
		alert('Please enter your new password');
		theUserhash.focus();
		return false;
	}
	else if(trim(theConfirm.value) == '')
	{
		alert('Please enter your confirmation password');
		theConfirm.focus();
		return false;
	}
	else if(trim(theConfirm.value) != trim(theUserhash.value))
	{
		alert('Passwords do not match, please reenter confirmation password');
		theConfirm.focus();
		return false;
	}
	else
	{ 
		theUserhash.value = trim(theUserhash.value);
		theConfirm.value = trim(theConfirm.value);
		return true;
	}
}// end function checkEnquiryForm()


function checkPetForm()
{
	
	var theName, theBreederNumber, theEmail, theAddress, theCity, theCounty, thePostcode, theTelephone, theBreed, theFatherName, theMotherName, thePetName, theSex, theNewOwnerTitle, theNewOwnerName, theNewOwnerEmail, theNewOwnerAddress, theNewOwnerCity, theNewOwnerCounty, theNewOwnerPostcode, theNewOwnerTelephone;

		
	with(window.document.enquiryForm)
	{
		theName = name;
		theBreederNumber = breederNumber;
		theEmail = email;
		theAddress = address;
		theCity = city;
		theCounty = county;
		thePostcode = postcode;
		theTelephone = telephone;
		theBreed = breed;
		theFatherName = fatherName;
		theMotherName = motherName;
		thePetName = petName;
		theSex = sex;
		theNewOwnerTitle = newOwnerTitle;
		theNewOwnerName = newOwnerName;
		theNewOwnerEmail = newOwnerEmail;
		theNewOwnerAddress = newOwnerAddress;
		theNewOwnerCity = newOwnerCity;
		theNewOwnerCounty = newOwnerCounty;
		theNewOwnerPostcode = newOwnerPostcode;
		theNewOwnerTelephone = newOwnerTelephone;
	}

	if(trim(theName.value) == '')
	{
		alert('Please enter your name');
		theName.focus();
		return false;
	}
	else if(trim(theBreederNumber.value) == '')
	{
		alert('Please enter your breeder number');
		theBreederNumber.focus();
		return false;
	}
	else if(trim(theEmail.value) == '')
	{
		alert('Please enter your email address');
		theEmail.focus();
		return false;
	}
	else if(!isEmail(trim(theEmail.value)))
	{
		alert('Email address is not valid');
		theEmail.focus();
		return false;
	}
	else if(trim(theAddress.value) == '')
	{
		alert('Please enter your address');
		theAddress.focus();
		return false;
	}
	else if(trim(theCity.value) == '')
	{
		alert('Please enter your town / city');
		theCity.focus();
		return false;
	}
	else if(trim(theCounty.value) == '')
	{
		alert('Please enter your county');
		theCounty.focus();
		return false;
	}
	else if(trim(thePostcode.value) == '')
	{
		alert('Please enter your postcode');
		thePostcode.focus();
		return false;
	}
	else if(trim(theTelephone.value) == '')
	{
		alert('Please enter your telephone number');
		theTelephone.focus();
		return false;
	}
	else if(trim(theBreed.value) == '')
	{
		alert('Please enter the breed');
		theBreed.focus();
		return false;
	}
	else if(trim(theFatherName.value) == '')
	{
		alert('Please enter the pets fathers name');
		theFatherName.focus();
		return false;
	}
	else if(trim(theMotherName.value) == '')
	{
		alert('Please enter the pets mothers name');
		theMotherName.focus();
		return false;
	}
	else if(trim(thePetName.value) == '')
	{
		alert('Please enter the pets name');
		thePetName.focus();
		return false;
	}
	else if(trim(theSex.value) == '')
	{
		alert('Please select the pets sex');
		theSex.focus();
		return false;
	}
	else if(trim(theNewOwnerTitle.value) == '')
	{
		alert('Please select the new owners title');
		theNewOwnerTitle.focus();
		return false;
	}
	else if(trim(theNewOwnerName.value) == '')
	{
		alert('Please enter the new owners name');
		theNewOwnerName.focus();
		return false;
	}
	else if(trim(theNewOwnerEmail.value) == '')
	{
		alert('Please enter the new owners email');
		theNewOwnerEmail.focus();
		return false;
	}
	else if(!isEmail(trim(theNewOwnerEmail.value)))
	{
		alert('New owners email address is not valid');
		theNewOwnerEmail.focus();
		return false;
	}
	else if(trim(theNewOwnerAddress.value) == '')
	{
		alert('Please enter the new owners address');
		theNewOwnerAddress.focus();
		return false;
	}
	else if(trim(theNewOwnerCity.value) == '')
	{
		alert('Please enter the new owners town / city');
		theNewOwnerCity.focus();
		return false;
	}
	else if(trim(theNewOwnerCounty.value) == '')
	{
		alert('Please enter the new owners county');
		theNewOwnerCounty.focus();
		return false;
	}
	else if(trim(theNewOwnerPostcode.value) == '')
	{
		alert('Please enter the new owners postcode');
		theNewOwnerPostcode.focus();
		return false;
	}
	else if(trim(theNewOwnerTelephone.value) == '')
	{
		alert('Please enter the new owners telephone');
		theNewOwnerTelephone.focus();
		return false;
	}
	else
	{ 
		theName.value = trim(theName.value);
		theBreederNumber.value = trim(theBreederNumber.value);
		theEmail.value = trim(theEmail.value);
		theAddress.value = trim(theAddress.value);
		theCity.value = trim(theCity.value);
		theCounty.value = trim(theCounty.value);
		thePostcode.value = trim(thePostcode.value);
		theTelephone.value = trim(theTelephone.value);
		theBreed.value = trim(theBreed.value);
		theFatherName.value = trim(theFatherName.value);
		theMotherName.value = trim(theMotherName.value);
		thePetName.value = trim(thePetName.value);
		theSex.value = trim(theSex.value);
		theNewOwnerTitle.value = trim(theNewOwnerTitle.value);
		theNewOwnerName.value = trim(theNewOwnerName.value);
		theNewOwnerEmail.value = trim(theNewOwnerEmail.value);
		theNewOwnerAddress.value = trim(theNewOwnerAddress.value);
		theNewOwnerCity.value = trim(theNewOwnerCity.value);
		theNewOwnerCounty.value = trim(theNewOwnerCounty.value);
		theNewOwnerPostcode.value = trim(theNewOwnerPostcode.value);
		theNewOwnerTelephone.value = trim(theNewOwnerTelephone.value);
		return getNewPets();
	}
}// end function checkEnquiryForm()

function getNewPets()
{	
	if(document.getElementById('enquiryForm').elements['newpets'].length >= 2)
	{
		for(i=1; i<document.getElementById('enquiryForm').elements['newpets'].length; i++)
		{
			if(document.getElementById('enquiryForm').elements['petNameAnother'+[i]].value == '')
			{
				alert("Please enter the pets name");
				document.getElementById('enquiryForm').elements['petNameAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['sexAnother'+[i]].value == '')
			{
				alert("Please select the pets sex");
				document.getElementById('enquiryForm').elements['sexAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerTitleAnother'+[i]].value == '')
			{
				alert("Please select the new owners title");
				document.getElementById('enquiryForm').elements['newOwnerTitleAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerNameAnother'+[i]].value == '')
			{
				alert("Please enter the new owners name");
				document.getElementById('enquiryForm').elements['newOwnerNameAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerEmailAnother'+[i]].value == '')
			{
				alert("Please enter the new owners email");
				document.getElementById('enquiryForm').elements['newOwnerEmailAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerAddressAnother'+[i]].value == '')
			{
				alert("Please enter the new owners address");
				document.getElementById('enquiryForm').elements['newOwnerAddressAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerCityAnother'+[i]].value == '')
			{
				alert("Please enter the new owners town / city");
				document.getElementById('enquiryForm').elements['newOwnerCityAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerCountyAnother'+[i]].value == '')
			{
				alert("Please enter the new owners county");
				document.getElementById('enquiryForm').elements['newOwnerCountyAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerPostcodeAnother'+[i]].value == '')
			{
				alert("Please enter the new owners postcode");
				document.getElementById('enquiryForm').elements['newOwnerPostcodeAnother'+[i]].focus();
				return false;
			}else if(document.getElementById('enquiryForm').elements['newOwnerTelephoneAnother'+[i]].value == '')
			{
				alert("Please enter the new owners telephone");
				document.getElementById('enquiryForm').elements['newOwnerTelephoneAnother'+[i]].focus();
				return false;
			}
		}
		return true;
	}else{
		return true;	
	}
	
}


function checkRegisterForm()
{
	
	var theNewTitle, theNewFirstname, theNewSurname, theNewAddress, theNewCity, theNewCounty, theNewCountry, theNewPostcode, theNewEmail, theConfirmEmail, theNewPassword, theConfirmPassword;

		
	with(window.document.enquiryForm)
	{
		theNewTitle = newTitle;
		theNewFirstname = newFirstname;
		theNewSurname = newSurname;
		theNewAddress = newAddress;
		theNewCity = newCity;
		theNewCounty = newCounty;
		theNewCountry = newCountry;
		theNewPostcode = newPostcode;
		theNewEmail = newEmail;
		theConfirmEmail = confirmEmail;
		theNewPassword = newPassword;
		theConfirmPassword = confirmPassword;
	}

	if(trim(theNewTitle.value) == '')
	{
		alert('Please select your title');
		theNewTitle.focus();
		return false;
	}
	else if(trim(theNewFirstname.value) == '')
	{
		alert('Please enter your firstname');
		theNewFirstname.focus();
		return false;
	}
	else if(trim(theNewSurname.value) == '')
	{
		alert('Please enter your surname');
		theNewSurname.focus();
		return false;
	}
	else if(trim(theNewAddress.value) == '')
	{
		alert('Please enter your address');
		theNewAddress.focus();
		return false;
	}
	else if(trim(theNewCity.value) == '')
	{
		alert('Please enter your town / city');
		theNewCity.focus();
		return false;
	}
	else if(trim(theNewCounty.value) == '')
	{
		alert('Please enter your county');
		theNewCounty.focus();
		return false;
	}
	else if(trim(theNewCountry.value) == '')
	{
		alert('Please enter your country');
		theNewCountry.focus();
		return false;
	}
	else if(trim(theNewPostcode.value) == '')
	{
		alert('Please enter your postcode');
		theNewPostcode.focus();
		return false;
	}
	else if(trim(theNewEmail.value) == '')
	{
		alert('Please enter your email address');
		theNewEmail.focus();
		return false;
	}
	else if(!isEmail(trim(theNewEmail.value)))
	{
		alert('Email address is not valid');
		theNewEmail.focus();
		return false;
	}
	else if(trim(theConfirmEmail.value) == '')
	{
		alert('Please confirm your email address');
		theConfirmEmail.focus();
		return false;
	}
	else if(!isEmail(trim(theConfirmEmail.value)))
	{
		alert('Confirmation email address is not valid');
		theConfirmEmail.focus();
		return false;
	}
	else if(trim(theNewEmail.value) != trim(theConfirmEmail.value))
	{
		alert('Email addresses do not match!');
		theConfirmEmail.focus();
		return false;
	}
	else if(trim(theNewPassword.value) == '')
	{
		alert('Please enter your password');
		theNewPassword.focus();
		return false;
	}
	else if(trim(theConfirmPassword.value) == '')
	{
		alert('Please enter your confirmation password');
		theConfirmPassword.focus();
		return false;
	}
	else if(trim(theNewPassword.value) != trim(theConfirmPassword.value))
	{
		alert('Passwords do not match!');
		theConfirmPassword.focus();
		return false;
	}
	else
	{ 
		theNewTitle.value = trim(theNewTitle.value);
		theNewFirstname.value = trim(theNewFirstname.value);
		theNewSurname.value = trim(theNewSurname.value);
		theNewAddress.value = trim(theNewAddress.value);
		theNewCity.value = trim(theNewCity.value);
		theNewCounty.value = trim(theNewCounty.value);
		theNewCountry.value = trim(theNewCountry.value);
		theNewPostcode.value = trim(theNewPostcode.value);
		theNewEmail.value = trim(theNewEmail.value);
		theConfirmEmail.value = trim(theConfirmEmail.value);
		theNewPassword.value = trim(theNewPassword.value);
		theConfirmPassword.value = trim(theConfirmPassword.value);
		return true;
	}
}// end function checkEnquiryForm()


// function to trim a string			
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}// end function trim()
				
// function to test if a string is a valid email address
function isEmail(str)
{
	var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
	return regex.test(str);
}// end function isEmail()


