function loadQuoteForm(oSrc){


	//This is the main function for when the top of the Quotes form is clicked
	
	// Here we want to get the quotes full form to load
	//document.getElementById('quote-bottom').style.display = 'block';
	
	$('#quote-bottom').slideDown('slow');
	
	strURI = $('#frmURI').val();
	strHeading = $('#frmHeading').val();
	switch(strHeading){
		case 'Plumbers':
			fileForm ='/quote_form.php';
			break;
		case 'Carpet Cleaners':
			fileForm ='/quote_form_carpet_cleaners.php';
		break;
	}
	//var fileForm= '/quote_form.php';
   $.get(fileForm, { uri: urlEncode(strURI), heading: strHeading},
   function(data){
     process(data);
   });

}
//-----------------------------------
function process(data){
	
	document.getElementById('quote-bottom').innerHTML = data;
	
}
//-----------------------------------
function submitQuoteForm(){
	if(validateQuoteForm()){
		
		frmNeedA = $('input:radio[name=frmNeedA]:checked').val();
		frmQuoteFor = $('input:radio[name=frmWorkOn]:checked').val();
		frmEmail 	= $('#frmEmail').val();
		frmPhone	= $('#frmPhone').val();
		frmName		= $('#frmName').val();
		frmJobStart	= $('#frmJobStart').val();
		frmBriefDesc= $('#frmBriefDesc').val();
		frmAddress	= $('#frmAddress').val();
		frmURI		= $('#frmURI').val();
		
		$.post(
			'/query_submit.php', 
			{Heading: 'Plumber', NeedA: frmNeedA, quoteFor: frmQuoteFor, Email: frmEmail, Phone: frmPhone, Name: frmName, JobStart: frmJobStart, BriefDesc: frmBriefDesc, Address:frmAddress, URI: frmURI}
		);
		
		$('#quote-bottom').html('<p class="thankyou">Thank you for submitting the form.<br />Your request will be passed on to Plumbers near your address</p><div id="quoteclose"><a href="#" onclick="closeQuotesFrame();return false">close</a></div>');
		$('#quote-forma').css('display', 'none');
		setTimeout(function(){$('#quote').css('display', 'none')}, 5000);
		
		//alert("Lets post the data to email");

	}
	return false;
}
//-----------------------------------
function validateQuoteForm(){
	frmQuoteFor = $('input:radio[name=frmWorkOn]:checked').val();
	frmEmail 	= $('#frmEmail').val();
	frmPhone	= $('#frmPhone').val();
	frmName		= $('#frmName').val();
	frmJobStart	= $('#frmJobStart').val();
	frmBriefDesc= $('#frmBriefDesc').val();
	frmAddress	= $('#frmAddress').val();
	
	strMissingFields = '';
	if(frmQuoteFor == undefined || frmQuoteFor == ''){
		strMissingFields += 'Please select what the quote is for\n';
	
	}
	if(frmEmail == ''){
		strMissingFields += 'Please tell us your email address\n';
	}else if(!validateEmail(frmEmail)){
		strMissingFields += 'Please enter a valid email address\n';
	}
	if(frmName == ''){
		strMissingFields += 'Please tell us your name\n';
	}
	if(frmAddress == ''){
		strMissingFields += 'Please tell us your address\n';
	}
	
	if(strMissingFields == ''){
		return true;
	}else{
		alert('Please enter the missing information:\n'+strMissingFields);
		return false;
	}
	
	
	
	return false;
}
//-----------------------------------
function submitCarpetCleaningQuoteForm(){
	if(validateCarpetCleaningQuoteForm()){
		frmNeedA = $('input:radio[name=frmNeedA]:checked').val();

		frmNumRooms		= $('#frmNumRooms').val();
		frmNumHallways 	= $('#frmNumHallways').val();
		frmNumStairways	= $('#frmNumStairways').val();
		frmEmail		= $('#frmEmail').val();
		frmPhone		= $('#frmPhone').val();
		frmName			= $('#frmName').val();
		frmJobStart		= $('#frmJobStart').val();
		frmBriefDesc	= $('#frmBriefDesc').val();
		frmAddress		= $('#frmAddress').val();
		
		frmURI		= $('#frmURI').val();
		
		$.post('/query_submit.php', {Heading: 'Carpet Cleaning', NeedA: frmNeedA, NumRooms: frmNumRooms, NumHallways: frmNumHallways, NumStairways: frmNumStairways, Email: frmEmail, Phone: frmPhone, Name: frmName, JobStart:frmJobStart, BriefDesc: frmBriefDesc, Address:frmAddress, uri:frmURI}
		);
		
		$('#quote-bottom').html('<p class="thankyou">Thank you for submitting the form.<br />Your request will be passed on to Plumbers near your address</p><div id="quoteclose"><a href="#" onclick="closeQuotesFrame();return false">close</a></div>');
		$('#quote-forma').css('display', 'none');
		
		setTimeout(function(){$('#quote').css('display', 'none')}, 5000);
		
	}
	return false;
}
//-----------------------------------
function validateCarpetCleaningQuoteForm(){
		frmNumRooms		= $('#frmNumRooms').val();
		frmNumHallways 	= $('#frmNumHallways').val();
		frmNumStairways	= $('#frmNumStairways').val();
		frmEmail		= $('#frmEmail').val();
		frmPhone		= $('#frmPhone').val();
		frmName			= $('#frmName').val();
		frmJobStart		= $('#frmJobStart').val();
		frmBriefDesc	= $('#frmBreifDesc').val();
		frmAddress		= $('#frmAddress').val();
		
		strMissingFields = '';
		if(frmEmail == ''){
			strMissingFields += 'Please tell us your email address\n';
		}else if(!validateEmail(frmEmail)){
			strMissingFields += 'Please enter a valid email address\n';
		}
		if(frmName == ''){
			strMissingFields += 'Please tell us your name\n';
		}
		if(frmAddress == ''){
			strMissingFields += 'Please tell us your address\n';
		}
		
		if(strMissingFields == ''){
			return true;
		}else{
			alert('Please enter the missing information:\n'+strMissingFields);
			return false;
		}
}

//-----------------------------------
function submitDrivingSchoolQuoteForm(){
	if(validateDrivingSchoolQuoteForm()){
		frmTransmission	= $('input:radio[name=frmTransmission]:checked').val()
		frmPostcode 	= $('#frmPostcode').val();
		frmEmail		= $('#frmEmail').val();
		frmPhone		= $('#frmPhone').val();
		frmName			= $('#frmName').val();
		
		frmURI			= $('#frmURI').val();
		
		$.post('/query_submit.php', {Heading: 'Driving School', Transmission: frmTransmission, Postcode: frmPostcode, Email: frmEmail, Phone: frmPhone, Name: frmName, uri:frmURI}
		);
		
		$('#quote-bottom').html('<p class="thankyou">Thank you for submitting the form.<br />Your request will be passed on to Driving Schools near your address</p>');
		$('#quote-forma').css('display', 'none');
		
		setTimeout(function(){$('#quote').css('display', 'none')}, 5000);
		
	}
	return false;
}
//-----------------------------------
function validateDrivingSchoolQuoteForm(){
		frmTransmission	= $('input:radio[name=frmTransmission]:checked').length;
		frmPostcode 	= $('#frmPostcode').val();
		frmEmail		= $('#frmEmail').val();
		frmPhone		= $('#frmPhone').val();
		frmName			= $('#frmName').val();
		
		strMissingFields = '';
		if(frmTransmission == 0){
			strMissingFields += 'Please tell us the transmission type\n';
		}
		if(frmPostcode == ''){
			strMissingFields += 'Please tell us your postcode\n';
		}
		if(frmEmail == ''){
			strMissingFields += 'Please tell us your email address\n';
		}else if(!validateEmail(frmEmail)){
			strMissingFields += 'Please enter a valid email address\n';
		}
		if(frmPhone == ''){
			strMissingFields += 'Please tell us your phone number\n';
		}
		if(frmName == ''){
			strMissingFields += 'Please tell us your name\n';
		}
		
		if(strMissingFields == ''){
			return true;
		}else{
			alert('Please enter the missing information:\n'+strMissingFields);
			return false;
		}
}

//-----------------------------------
function submitPlumbersQuoteForm(){
	if(validatePlumbersQuoteForm()){
		frmJobType		= $('#frmJobType').val();
		frmJobStart		= $('#frmJobStart').val();
		frmPostcode 	= $('#frmPostcode').val();
		frmEmail		= $('#frmEmail').val();
		frmPhone		= $('#frmPhone').val();
		frmName			= $('#frmName').val();
		
		frmURI			= $('#frmURI').val();
		
		$.post('/query_submit.php', {Heading: 'Plumbers', JobType: frmJobType, JobStart: frmJobStart, Postcode: frmPostcode, Email: frmEmail, Phone: frmPhone, Name: frmName, uri:frmURI}
		);
		
		$('#quote-bottom').html('<p class="thankyou">Thank you for submitting the form.<br />Your request will be passed on to Plumbers near your address</p>');
		$('#quote-forma').css('display', 'none');
		
		setTimeout(function(){$('#quote').css('display', 'none')}, 5000);
		
	}
	return false;
}
//-----------------------------------

function validatePlumbersQuoteForm(){
		frmPostcode 	= $('#frmPostcode').val();
		frmEmail		= $('#frmEmail').val();
		frmPhone		= $('#frmPhone').val();
		frmName			= $('#frmName').val();
		
		strMissingFields = '';
		if(frmPostcode == ''){
			strMissingFields += 'Please tell us your postcode\n';
		}
		if(frmEmail == ''){
			strMissingFields += 'Please tell us your email address\n';
		}else if(!validateEmail(frmEmail)){
			strMissingFields += 'Please enter a valid email address\n';
		}
		if(frmPhone == ''){
			strMissingFields += 'Please tell us your phone number\n';
		}
		if(frmName == ''){
			strMissingFields += 'Please tell us your name\n';
		}
		
		if(strMissingFields == ''){
			return true;
		}else{
			alert('Please enter the missing information:\n'+strMissingFields);
			return false;
		}
}

//-----------------------------------

//-----------------------------------

function closeQuotesFrame(){
	
	$('#quote-bottom').slideUp('slow');
}

//----------------------------------------------------
function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) {
      return false;
   }else{
	   return true;
   }
}
//----------------------------------------------------
//----------------------------------------------------

function urlEncode( s )
{
      return encodeURIComponent( s ).replace( /\%20/g, '+' ).replace( /[!'()*~]/g, urlEncodeCharacter );
};

function urlDecode (s) 
{
      return decodeURIComponent(s.replace( /\+/g, '%20' )).replace( /\%([0-9a-f]{2})/g, urlDecodeCharacter);
};

function urlEncodeCharacter(c)
{
	return '%' + c.charCodeAt(0).toString(16);
};

function  urlDecodeCharacter(str, c)
{
	return String.fromCharCode(parseInt(c, 16));
};
