// JavaScript Document
window.onload = function () {
	bodyFont ();
	colHeights ();
};


function bodyFont (){
if (navigator.userAgent.indexOf('MSIE') !=-1)
{
	window.document.body.style.fontSize = '1em';
}
};

function colHeights () {
	
	document.getElementById('lhs_col').style.height = 'auto';
	var x = document.getElementById('main_content').offsetHeight;
	x += 'px';
	document.getElementById('lhs_col').style.height = x;
	
	};
	
	
function popwindow (id) {
	
	var object = document.getElementById(id);
	if(object.style.display == 'block'){
		object.style.display = 'none';

	} else {
		
		document.getElementById('service_wardAnal').style.display = 'none';
		document.getElementById('service_accShop').style.display = 'none';
		document.getElementById('service_colourAnal').style.display = 'none';
		document.getElementById('service_wardMan').style.display = 'none';
		document.getElementById('service_addServe').style.display = 'none';
		object.style.display = 'block';

	};
	
	
	};
	
function testimonialsDrop (id) {
	
	var object = document.getElementById(id);
	if(object.style.display == 'block'){
		object.style.display = 'none';

	} else {
		
		document.getElementById('testimonialsDrop_001').style.display = 'none';
		document.getElementById('testimonialsDrop_002').style.display = 'none';
		document.getElementById('testimonialsDrop_003').style.display = 'none';
		document.getElementById('testimonialsDrop_004').style.display = 'none';
		document.getElementById('testimonialsDrop_005').style.display = 'none';
		document.getElementById('testimonialsDrop_006').style.display = 'none';
		document.getElementById('testimonialsDrop_007').style.display = 'none';
		document.getElementById('testimonialsDrop_008').style.display = 'none';		
		document.getElementById('testimonialsDrop_009').style.display = 'none';
		object.style.display = 'block';

	};
	
	
	};
	

function isthisyouDrop (id) {
	
	var object = document.getElementById(id);
	if(object.style.display == 'block'){
		object.style.display = 'none';

	} else {
		
		document.getElementById('isthisyouDrop_001').style.display = 'none';
		document.getElementById('isthisyouDrop_002').style.display = 'none';
		document.getElementById('isthisyouDrop_003').style.display = 'none';
		document.getElementById('isthisyouDrop_004').style.display = 'none';
		document.getElementById('isthisyouDrop_005').style.display = 'none';
		document.getElementById('isthisyouDrop_006').style.display = 'none';
		document.getElementById('isthisyouDrop_007').style.display = 'none';
		object.style.display = 'block';

	};
	
	
	};
	
function howitworksDrop (id) {
	
	var object = document.getElementById(id);
	if(object.style.display == 'block'){
		object.style.display = 'none';

	} else {
		
		document.getElementById('howitworksDrop_001').style.display = 'none';
		document.getElementById('howitworksDrop_002').style.display = 'none';
		document.getElementById('howitworksDrop_003').style.display = 'none';
		object.style.display = 'block';

	};
	
	
	};

function validate_required(field,alerttxt,defaultValue)
{
with (field)
{
if (value==null||value==""||value==defaultValue)
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_checkBoxes(alerttxt)
{

if (!document.contactForm.Interested_in_shopping.checked
							   && !document.contactForm.Interested_in_makeup.checked 
							   && !document.contactForm.Interested_in_giftvoucher.checked 
							   && !document.contactForm.Interested_in_other.checked 
							   && !document.contactForm.Interested_in_wardrobe.checked 
							   && !document.contactForm.Interested_in_colour.checked
							   && !document.contactForm.Interested_in_hair_and_makeup.checked 
							   && !document.contactForm.Interested_in_photoshoot.checked 
							   )
							 
 {alert(alerttxt); return false}
 else {return true};


};

function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name,"Please enter your name.","Your name")==false)
		{name.focus();return false};
if (validate_email(email,"It appears that you have not entered a valid email address?")==false)
		{email.focus();return false};
if (validate_required(referred_by,"How did you hear about us?","Please select")==false)
		{referred_by.focus();return false};
if (validate_required(message,"Please enter a message.")==false)
  		{message.focus();return false};
}
}

function validate_questionnaire(thisform)
{
with (thisform)
{
if (validateField(full_lenght_photo)==false){
			alert('Please upload a full length photo.');
			sendError = 1;
		};
if (validateField(face_only)==false){
			alert('Please upload your face only photo.');
			sendError = 1;
		};
if (validateField(first_nameREQUIRED)==false){
			document.getElementById("questForm").first_nameREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(last_nameREQUIRED)==false){
			document.getElementById("questForm").last_nameREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(addressREQUIRED)==false){
			document.getElementById("questForm").addressREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(ageREQUIRED)==false){
			document.getElementById("questForm").ageREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(dobREQUIRED)==false){
			document.getElementById("questForm").dobREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateEmail(emailREQUIRED)==false){
			document.getElementById("questForm").emailREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(mobileREQUIRED)==false){
			document.getElementById("questForm").mobileREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(work_phoneREQUIRED)==false){
			document.getElementById("questForm").work_phoneREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(job_titleREQUIRED)==false){
			document.getElementById("questForm").job_titleREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(relationship_statusREQUIRED)==false){
			document.getElementById("questForm").relationship_statusREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(childrenREQUIRED)==false){
			document.getElementById("questForm").childrenREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(why_have_you_decided_you_would_like_to_use_the_services_of_a_style_consultant_at_this_timeREQUIRED)==false){
			document.getElementById("questForm").why_have_you_decided_you_would_like_to_use_the_services_of_a_style_consultant_at_this_timeREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(what_is_your_current_clothes_shopping_habitREQUIRED)==false){
			document.getElementById("questForm").what_is_your_current_clothes_shopping_habitREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(what_is_your_current_clothes_shopping_habitREQUIRED)==false){
			document.getElementById("questForm").what_is_your_current_clothes_shopping_habitREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(how_would_you_describe_your_current_personal_style_and_which_shops_designers_do_you_usually_buy_fromREQUIRED)==false){
			document.getElementById("questForm").how_would_you_describe_your_current_personal_style_and_which_shops_designers_do_you_usually_buy_fromREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(whose_style_do_you_most_admireREQUIRED)==false){
			document.getElementById("questForm").whose_style_do_you_most_admireREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(what_amounts_do_you_are_you_prepared_to_spend_on_certain_items_of_clothingREQUIRED)==false){
			document.getElementById("questForm").what_amounts_do_you_are_you_prepared_to_spend_on_certain_items_of_clothingREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(do_you_have_any_body_particulars_that_you_either_love_or_dislikeREQUIRED)==false){
			document.getElementById("questForm").do_you_have_any_body_particulars_that_you_either_love_or_dislikeREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(are_there_any_particular_items_you_tend_to_have_difficulty_findingREQUIRED)==false){
			document.getElementById("questForm").are_there_any_particular_items_you_tend_to_have_difficulty_findingREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};
if (validateField(what_is_your_spending_budgetREQUIRED)==false){
			document.getElementById("questForm").what_is_your_spending_budgetREQUIRED.style.backgroundColor = '#CCCCCC';
			sendError = 1;
		};

		if (sendError == 1){
			alert('One or more fields have not been completed correctly!');
			return false;
		};
}
}

function validateField(fieldName){

	with (fieldName){
		if (value==null || value=="" ||value=='pleaseSelect'){
		return false;
  		} else {
		return true;
		}
	}

}

function validateEmail(field){

	with (field){
		
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2 || value.length > 40) {
		
		return false;
		}
		else {
		return true
		}
	}
}
