$(document).ready(function() {
						   
		$("#txtdate").datepicker({
		dateFormat: 'dd/mm/yy'						 
		});
		
//very simple client side validation

//$('.error').hide();

$("#reset").click(function() {
$('.error').hide();
});

$("#submit").click(function() {
	var formerror
	formerror = 0;
     if ($("input#txtname").val() == "") {
        $("label#txtnameerror").show();
        //$("input#txtname").focus();
		formerror = 1;
      } else {
		 $("label#txtnameerror").hide(); 
	  }
	  
	  if (($("input#txtemail").val() == "" && $("input#txtphone").val() == "")) {
        $("label#txtemailerror").show();
		$("label#txtphoneerror").show();
		$("label#txtemailregexerror").hide();
        //$("input#name").focus();
		formerror = 1;
      }
	  
	  if ($("input#txtemail").val() != "") {
	var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
	if (emailRegxp.test($("input#txtemail").val()) != true) {
	formerror = 1;
	$("label#txtemailregexerror").show();
	$("label#txtemailerror").hide();
	}
	  }
	  
	  if (formerror == 1) {
		$("#formerror").show(); 
		return false;
	  }
});
		

//set up style for tooltips

$.fn.qtip.styles.mlstyle = {
		width: 100,
		padding: 5,
		background: '#999',
		color: 'black',
		textAlign: 'center',
		border: {
		width: 3,
		radius: 3,
		color: '#990000'
		},
	tip: {
		corner: 'leftMiddle'
		}
};

/*//Name
$("#txtname").qtip({
   content: 'Here\'s a tip for inputting your name...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//Address
$("#txtaddress").qtip({
   content: 'Here\'s a tip for inputting your address...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

*/
//Phone
$("#txtphone").qtip({
   content: 'Preferably a mobile number so we can contact you during the day.',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//Email
$("#txtemail").qtip({
   content: 'All quotes and confirmations will be sent to this address.',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//Passengers
$("#txtpassno").qtip({
   content: 'If you are not sure on exact numbers then please enter your best guess.',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//1stFrom
$("#txt1stfrom").qtip({
   content: 'If the same as your home address then please enter "<b>Home address</b>"',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

/*//1stPickupTime
$("#txtpicktime").qtip({
   content: 'Here\'s a tip for inputting 1st pickup time...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//WhereTo
$("#txttakeyou").qtip({
   content: 'Here\'s a tip for inputting destination...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//Basis
$("#txthire").qtip({
   content: 'Here\'s a tip for inputting hire basis...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//ReturnTime
$("#txtrtime").qtip({
   content: 'Here\'s a tip for inputting return time...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//Event
$("#txtevent").qtip({
   content: 'Here\'s a tip for inputting event...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});
//Advert
$("#txtad").qtip({
   content: 'Here\'s a tip for inputting advert...',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});

//Info
$("#txtinfo").qtip({
   content: 'Here\'s a tip for inputting extra info...<br />Blah blah',
   style: 'mlstyle', 
   	show: {
		when: 'focus'
		},
	hide: {
		when: 'blur'
		},
		position: {
	corner: {
	target: 'rightMiddle',
	tooltip: 'leftMiddle'
		}
   }
});
		
*/
});
