
function sendQuickEnquiry(contactname,tel){
	
	arr_contact_details = new Array();
	arr_contact_details[0] = contactname;
	arr_contact_details[1] = tel;

	$.ajax({
		url: 'scripts/php/emailer.php',
		type: 'GET',
		data: 'x=eDetails&y='+arr_contact_details,
		dataType: 'text',
		timeout: 20000,
		error: function(){
			
			
			
		},
		success: function(xml){
			
			
		}
	});
}





function checkPhone(str) 
{
	var regEx = /\d{5}\s\d{6}/; 
	if (str.match(regEx)) {
   		return true;
 	} else {
 		return false;
 	}
}

$(document).ready(function(){
	
	/* Modal Login Dialog */
	$("#login-dialog").dialog({
		autoOpen: false,
		height: 300,
		width: 350,
		modal: true,
		draggable: false,
		resizable: false,
		show: 'clip',
		title: 'Marandy Customer Login',
		close: function() {
			//allFields.val('').removeClass('ui-state-error');
		}
	});
	
	$('#hl-login').click(function(){
		$('#login-dialog').dialog('open');
	});
	/* End Modal Login Dialog */
	
	/* Quick Enquiry Capture */
	$('#txt-phoneno').focus(function(){
		if ($(this).val() == "Enter phone number"){ 
			$(this).val(""); 
		}
	});
	
	$('#txt-phoneno').blur(function(){ 
		if ($(this).val() == ""){ 
			$(this).val("Enter phone number"); 
		}
	});
	
	$('#txt-name').focus(function(){ 
			if ($(this).val() == "Enter name"){ 
			$(this).val(""); 
		}
	});
	
	$('#txt-name').blur(function(){ 
		if ($(this).val() == ""){ 
			$(this).val("Enter name"); 
		}
	});
		
	$('#btn-submit-enquiry').click(function(){
		if (checkPhone($('#txt-phoneno').val())){
			sendQuickEnquiry($('#txt-phoneno').val(),$('#txt-name').val());
		} else {
			alert("The phone number you typed was not valid, please try again.");
		}
	});
	/* End Quick Enquiry Capture */
	
});


