
jQuery(document).ready(function() {
	$("#popupClose").click(function() {
		disablePopup();
	});        
	$("#backgroundPopup").click(function() {
		disablePopup();
	});
	/* DATE PICKER */
	$("#datepicker").datepicker({
		showOn: 'button',
		buttonImage: BaseUrl + '/images/form/calendar.jpg',
		buttonImageOnly: true
	});	
	$("#date").datepicker({
		showOn: 'button',
		buttonImage: BaseUrl + '/images/form/calendar.jpg',
		buttonImageOnly: true
	});	

	/* FORM VALIDATE */
	
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
        phone_number = phone_number.replace(/\s+/g, ""); 
        return this.optional(element) || phone_number.length > 9 &&
            phone_number.match(/^(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
    }, "Enter a valid phone number like 777-777-7777");
	
	$("#shedule_form form").validate({		
		rules: {
			fname:{		
				required: true,
				minlength: 2,
				remote: BaseUrl + "/service/jsonfirstname"
			},
			lname:{
				required: true,
				minlength: 2,
				remote: BaseUrl + "/service/jsonlastname"
			},				
/*			phone:{
				required: true,
				phoneUS: true                
			},			
			email: {
				required: true,
				email: true
			},*/
			year:{
				required: true,
				number: true,
				minlength: 4,
				remote: BaseUrl + "/service/jsonyear"
			},
			make:{
				required: true,
				remote: BaseUrl + "/service/jsonmake"
			},
			model:{
				required: true,
				remote: BaseUrl + "/service/jsonmodel"
			},
		},
		messages: {
			fname: "Enter your name",			
			lname: "Enter your last name",
			email: "Enter a valid email address",
			phone: {
				required: "Fill in num of phone",
			},				
			year: {
					required: "Enter a year",
					minlength: "Code consist min 4 characters",
					number: "Only numbers allowed"			
					},				
			make: "Enter make",
			model: "Enter model",
		}		
	});
	
	$("#Phone1").attr("checked", "checked");
	$('#Email').attr('class', 'text2');		
	$('#Email').attr('disabled', true);		
	
	$("#Phone1").click(function() {
		$(this).next("input").removeAttr("disabled").attr('class', 'text');		
		$('#Email').attr('class', 'text2');		
		$('#Email').attr('disabled', true);		
	});
	$("#Email1").click(function() {
		$('#Phone').attr('class', 'text2');
		$('#Phone').attr('disabled', true);
		$(this).next("input").removeAttr("disabled").attr('class', 'text');
	});		
		
});  
function openwindow() {
	loadPopup();
	centerPopup();
}
function openCopy(url){	
	window.open(url,'mywindow','width=400,height=200');
}
function openlivetext(){	
	window.open('https://server.iad.liveperson.net/hc/73540723/?cmd=file&file=visitorWantsToChat&site=73540723&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/2a&referrer=http://www.hoodford.com/&__utma=146334765.1819668306.1283807928.1283807928.1283807928.1&__utmb=146334765.4.10.1283807928&__utmc=146334765&__utmx=-&__utmz=146334765.1281022098.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)&__utmv=-&__utmk=11740724','mywindow','width=400,height=400');
}

