function isEmpty(textvalue) {
	textvalue=textvalue.replace(/\s/g,"");
	if(textvalue.length>0)
		return false;
	else
		return true;
}
function validURL(url){
	var elval= url.value.replace(/[\n\r\s]+/,"");
	if(elval =="") return true;
	var str=url.value;
	if(1){
		var filter=/^((ht|f)tp(s?))(:((\/\/)(?!\/)))(((w){3}\.)?)([a-zA-Z0-9\-_\.]+(\.(com|edu|gov|int|mil|net|org|biz|info|name|pro|museum|co\.uk|in)))((?!\/))(([a-zA-Z0-9\-_\/]*)?)$/i      
	}
	if (filter.test(str))
		testresults=true;
	else
		testresults=false;
		
	return (testresults);
}

function viewToolTip(id,parentId,posX,posY)
{
	
	it = document.getElementById(id);
	 if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';
        
        img = document.getElementById(parentId); 
    
        // if tooltip is too wide, shift left to be within parent 
        if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0; 
        
        x = xstooltip_findPosX(img) + posX;
        y = xstooltip_findPosY(img) + posY;
        
        it.style.top = y + 'px';
        it.style.left = x + 'px';
    }
    


	it.style.visibility = 'visible'; 
}

function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}


function hideToolTip(id)
{
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}

function get_subcategories(){
	var d=document.getElementById('subcategories');
	 d.style.display = 'block'; 
}
/*
function get_subknife(){
	var d=document.getElementById('subknife');
	 d.style.display = 'block'; 
}
*/


 function checkAll(chk) {

 	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if (e.type == "checkbox")
		{
			e.checked = chk.checked;
		}
	}
 }
 
function checkAllNew(chk,frm,frm2) {

	var formelements = eval("document."+frm+".elements");
 	
 	//alert(formelements.length);
 	for (var i=0;i < formelements.length;i++)
	{
		//alert(formelements[i].type);
		var e = formelements[i];
		if (e.type == "checkbox")
		{
			e.checked = chk.checked;
		}
	}
 } 
 
 
 
 function selectActionNew(frm1,frm2) {
 	
	var formelements1 = eval("document."+frm1);
	var formelements2 = eval("document."+frm2);
 	
	
 	
 	if (isEmpty(document.getElementById('selAction').value)) {
		 alert("Please select the action to be performed.");
		 document.getElementById('selAction').focus();
		 return false;
	 }
	

	 if (checkFormNew(frm1 ,frm2) == true) {
		formelements1.selectedAction.value = formelements2.selAction.value;
		//document.forms[0].mode.value = "performAction";
		
		if (formelements1.selectedAction.value != "delete") {
			formelements1.mode.value = "performAction";
		}
		else {
			formelements1.mode.value = "performDelete";
		}
		
		formelements1.submit();
	 }
	 else {
		 return false;
	 }
 }

function checkFormNew(frm1, frm2)
{
	
	var formelements1 = eval("document."+frm1);
	var formelements2 = eval("document."+frm2);

	var count=0;
	var msg;
	for (var i=0;i < formelements1.elements.length;i++)
	{
		var e = formelements1.elements[i];
		if (e.type == "checkbox")
		{
			if(e.checked)
				count=count+1;
		}
	}

	if(count==0)
	{
		alert("Please select atleast one record");	
		return false;	
	}
	else
	{
		if (formelements2.selAction.value != "delete"){
			msg="Are you sure that you want to change the status?";
		}
		else {
			msg="Are you sure that you want to delete the selected record(s)?";
		}
		return confirm(msg);
	}

}//checkform

function selectAction() {
	 if (isEmpty(document.getElementById('selAction').value)) {
		 alert("Please select the action to be performed.");
		 document.getElementById('selAction').focus();
		 return false;
	 }


	 if (checkForm() == true) {
		document.forms[0].selectedAction.value = document.forms[1].selAction.value;
		//document.forms[0].mode.value = "performAction";
		
		if (document.forms[0].selectedAction.value != "delete") {
			document.forms[0].mode.value = "performAction";
		}
		else {
			document.forms[0].mode.value = "performDelete";
		}
		
		document.forms[0].submit();
	 }
	 else {
		 return false;
	 }
 }

function checkForm()
{
	var count=0;
	var msg;
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if (e.type == "checkbox")
		{
			if(e.checked)
				count=count+1;
		}
	}

	if(count==0)
	{
		alert("Please select atleast one record");	
		return false;	
	}
	else
	{
		if (document.forms[1].selAction.value != "delete"){
			msg="Are you sure that you want to change the status?";
		}
		else {
			msg="Are you sure that you want to delete the selected record(s)?";
		}
		return confirm(msg);
	}

}//checkform




function setUsageCharge() {
	newKnifeCost = parseFloat(document.getElementById('KniferegisterNewCost').value);
	oneTwentithCost = parseFloat(newKnifeCost/20);
	// 25 is hardcoded as per the client's document Knife Register Brief 3.
	// if 1/20th cost of new knife is less than 25 then the minimum usage charge will be $25;
	if (oneTwentithCost > 25) {
		document.getElementById('KniferegisterUsageCharge').value = oneTwentithCost;
	}
	else {
		document.getElementById('KniferegisterUsageCharge').value = 25;
	}
}

function hideShowKnifeAdvanceSearch()
{
	showStatus = document.getElementById('searchKnifeDiv').style.display;
	if(showStatus == 'block')
	{	
		document.getElementById('hidIsDivBlock').value = "No";
		document.getElementById('advanceSearch').innerHTML = "Advance Search";
		document.getElementById('advanceSearch').title = "Advance Search";
		document.getElementById('searchKnifeDiv').style.display = "none";
	}	
	else
	{
		document.getElementById('hidIsDivBlock').value = "Yes";
		document.getElementById('advanceSearch').innerHTML = "Simple Search";
		document.getElementById('advanceSearch').title = "Simple Search";
		document.getElementById('searchKnifeDiv').style.display = "block";        
	}	
}

function hideShowProcurementAdvanceSearch()
{
	showStatus = document.getElementById('searchProcurementDiv').style.display;
	if(showStatus == 'block')
	{	
		document.getElementById('hidIsDivBlock').value = "No";
		document.getElementById('advanceSearch').innerHTML = "Advance Search";
		document.getElementById('advanceSearch').title = "Advance Search";
		document.getElementById('searchProcurementDiv').style.display = "none";
	}	
	else
	{
		document.getElementById('hidIsDivBlock').value = "Yes";
		document.getElementById('advanceSearch').innerHTML = "Simple Search";
		document.getElementById('advanceSearch').title = "Simple Search";
		document.getElementById('searchProcurementDiv').style.display = "block";        
	}	
}


//----------------------- Miscellaneous functions ---------------------//

// This function is used to validate a given e-mail 
// address for the proper syntax

function validateEmail(email)
{
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}

//The function is to check the extension of the file.

function checkFileExtension(file)
{
	
	if(file != "") {
		extArray = new Array(".pdf", ".indd");
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();

		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) {
				allowSubmit =1 ; break;
			}
			else {	
				allowSubmit=2;
			}
	}

	if(allowSubmit==2) {
		alert("Only files with following extensions are allowed:  " 
		+ (extArray.join("  ")));
		return false;
	}
	  return true;
	}
	else {
		return false;
	}
}


//The function is to check the specified extension of the file.

function checkFileExtensionArray(file, extArray)
{
	
	if(file != "") {
		//extArray = new Array(".pdf", ".indd");
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();

		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) {
				allowSubmit =1 ; break;
			}
			else {	
				allowSubmit=2;
			}
	}

	if(allowSubmit==2) {
		alert("Only files with following extensions are allowed:  " 
		+ (extArray.join("  ")));
		return false;
	}
	  return true;
	}
	else {
		return false;
	}
}

//The function is to open the popup window of given width and height for a given URL

function openPopUpWindow(url, width, height) {
	window.open(url, 'popupwindow', 'width=' + width + ', height=' + height + ', scrollbars = yes, statusbar = no');
}

// The function add the option in a drop down list.

function addOption(selectBoxId, text, value) {
	 var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	elementId = eval("document.getElementById('" + selectBoxId + "')");
	elementId.options.add(optn);
}


function redirectToPage(pagePath) {
	window.location.href = pagePath;
}

function validate_finishingstatus(){
	
	if (isEmpty(document.getElementById('FinishingProcessId').value)) {
		alert("Please select the process.");
		document.getElementById('FinishingProcessId').focus();
		return false;
	}	
	if (isEmpty(document.getElementById('FinishingMcodes').value)) {
		alert("Please select machine code.");
		document.getElementById('FinishingMcodes').focus();
		return false;
	}	
	if (isEmpty(document.getElementById('FinishingWorkstatus').value)) {
		alert("Please select Status.");
		document.getElementById('FinishingWorkstatus').focus();
		return false;
	}	

	alert("Work status will be saved when clicked.");
	return false;

}

/*function validate_jobeditdetails(){
	
	if (isEmpty(document.getElementById('JobdetailWidth').value)) {
		alert("Please enter the width.");
		document.getElementById('JobdetailWidth').focus();
		return false;
	}
	if(isNaN(document.getElementById('JobdetailWidth').value) || (document.getElementById('JobdetailWidth').value < 0)) {
		alert("Please enter numeric values for width");
		document.getElementById('JobdetailWidth').focus();
		return false;
	}
	if (isEmpty(document.getElementById('JobdetailHeight').value)) {
		alert("Please select the height.");
		document.getElementById('JobdetailHeight').focus();
		return false;
	}
	if(isNaN(document.getElementById('JobdetailHeight').value) || (document.getElementById('JobdetailHeight').value < 0)) {
		alert("Please enter numeric values for height");
		document.getElementById('JobdetailHeight').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailJobCategory').value)) {
		alert("Please select the job category.");
		document.getElementById('JobdetailJobCategory').focus();
		return false;
	}
	if (isEmpty(document.getElementById('JobdetailJobSubcategory').value)) {
		alert("Please select the sub category.");
		document.getElementById('JobdetailJobSubcategory').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailJobGroup').value)) {
		alert("Please select the knife group.");
		document.getElementById('JobdetailJobGroup').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailQuantity').value)) {
		alert("Please enter the quantity.");
		document.getElementById('JobdetailQuantity').focus();
		return false;
	}
	if(isNaN(document.getElementById('JobdetailQuantity').value) || (document.getElementById('JobdetailQuantity').value < 0)) {
		alert("Please enter numeric values for quantity");
		document.getElementById('JobdetailQuantity').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailNumberOfUps').value)) {
		alert("Please enter the number of ups.");
		document.getElementById('JobdetailNumberOfUps').focus();
		return false;
	}
	if(isNaN(document.getElementById('JobdetailNumberOfUps').value) || (document.getElementById('JobdetailNumberOfUps').value < 0)) {
		alert("Please enter numeric values for number of ups");
		document.getElementById('JobdetailNumberOfUps').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailJobStatus').value)) {
		alert("Please select the job status.");
		document.getElementById('JobdetailJobStatus').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailJobPriority').value)) {
		alert("Please select the job priority.");
		document.getElementById('JobdetailJobPriority').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('JobdetailJobForStatus').value)) {
		alert("Please select the job for.");
		document.getElementById('JobdetailJobForStatus').focus();
		return false;
	}

	
	if (isEmpty(document.getElementById('JobdetailJobTitle').value)) {
		alert("Please enter the job title.");
		document.getElementById('JobdetailJobTitle').focus();
		return false;
	}
	
	//showSuccessMessage("sales");
	//return false;
	return true;
}*/

function getGoingTOPoscodesForCity(path,cityId)
{
	new Ajax.Updater('going_postcode_div',''+ path +'/bookingdetails/getpostcodeforcity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getCollectionPoscodesForCity(path,cityId)
{
	new Ajax.Updater('colection_postcode_div',''+ path +'/bookingdetails/getpostcodeforcollectioncity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getGoingTOPoscodesForCityForHome(path,cityId)
{
	new Ajax.Updater('going_postcode_div',''+ path +'/chauffeurs/getpostcodeforcity/'+cityId, {asynchronous:true, evalScripts:true});
}

function getCollectionPoscodesForCityForHome(path,cityId)
{
	new Ajax.Updater('colection_postcode_div',''+ path +'/chauffeurs/getpostcodeforcollectioncity/'+cityId, {asynchronous:true, evalScripts:true});
}

function validate_bookings(){
		
	//Validations for Passenger Details
	if (isEmpty(document.getElementById('BookingdetailsPassengerFirstName').value)) {
		alert("Passenger Details : Please enter first name.");
		document.getElementById('BookingdetailsPassengerFirstName').focus();
		return false;
	}	
	
	if (isEmpty(document.getElementById('BookingdetailsPassengerLastName').value)) {
		alert("Passenger Details : Please enter last name.");
		document.getElementById('BookingdetailsPassengerLastName').focus();
		return false;
	}
		
	if (isEmpty(document.getElementById('BookingdetailsPassengerCountryId').value)) {
		alert("Passenger Details : Please select country.");
		document.getElementById('BookingdetailsPassengerCountryId').focus();
		return false;
	}
		
	if (isEmpty(document.getElementById('BookingdetailsPassengerEmail').value)) {
		alert("Passenger Details : Please enter email address.");
		document.getElementById('BookingdetailsPassengerEmail').focus();
		return false;
	}
	
	if(!validateEmail(document.getElementById('BookingdetailsPassengerEmail').value)) {
		alert("Passenger Details : Please enter valid email address.");
		document.getElementById('BookingdetailsPassengerEmail').focus();
		return false;
	}
		
	if (isEmpty(document.getElementById('BookingdetailsPassengerTelephone').value)) {
		alert("Passenger Details : Please enter telephone number.");
		document.getElementById('BookingdetailsPassengerTelephone').focus();
		return false;
	}
		
	if (isEmpty(document.getElementById('BookingdetailsPassengerBookingEnquiry').value)) {
		alert("Passenger Details : Please select booking/enquiry.");
		document.getElementById('BookingdetailsPassengerBookingEnquiry').focus();
		return false;
	}
		
	if (isEmpty(document.getElementById('BookingdetailsPassengerNumber').value)) {
		alert("Passenger Details : Please select number of passengers.");
		document.getElementById('BookingdetailsPassengerNumber').focus();
		return false;
	}

	if(document.getElementById('BookingdetailsAirportCollectionCheck').checked == true)
	{
		//Validations for Airport Collection Only
		if (isEmpty(document.getElementById('BookingdetailsCollectionFlightNumber').value)) {
			alert("Airport Collection : Please enter flight number.");
			document.getElementById('BookingdetailsCollectionFlightNumber').focus();
			return false;
		}		
		
		if (isEmpty(document.getElementById('BookingdetailsCollectionAirline').value)) {
			alert("Airport Collection : Please enter airline.");
			document.getElementById('BookingdetailsCollectionAirline').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('collection_date_required').value)) {
			alert("Airport Collection : Please enter date required.");
			document.getElementById('collection_date_required').focus();
			return false;
		}		
		
		//Validations for airport collection time required start here.
		if ((isEmpty(document.getElementById('BookingdetailsCollectionTimeHourRequired').value)) && (isEmpty(document.getElementById('BookingdetailsCollectionTimeMinuteRequired').value))) 
		{
			alert("Airport Collection : Please select time required.");
			document.getElementById('BookingdetailsCollectionTimeHourRequired').focus();
			return false;
		}	
		
		if ((isEmpty(document.getElementById('BookingdetailsCollectionTimeHourRequired').value)) && (!isEmpty(document.getElementById('BookingdetailsCollectionTimeMinuteRequired').value))) 
		{
			alert("Airport Collection : Please select valid time.");
			document.getElementById('BookingdetailsCollectionTimeHourRequired').focus();
			return false;
		}
	
		if ((!isEmpty(document.getElementById('BookingdetailsCollectionTimeHourRequired').value)) && (isEmpty(document.getElementById('BookingdetailsCollectionTimeMinuteRequired').value))) 
		{
			alert("Airport Collection : Please select valid time.");
			document.getElementById('BookingdetailsCollectionTimeHourRequired').focus();
			return false;
		}
		//Validations for airport collection time required end here.
		
		if (isEmpty(document.getElementById('BookingdetailsCollectionPassengerName').value)) {
			alert("Airport Collection : Please enter passenger name.");
			document.getElementById('BookingdetailsCollectionPassengerName').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionPassengerNumber').value)) {
			alert("Airport Collection : Please enter passenger number.");
			document.getElementById('BookingdetailsCollectionPassengerNumber').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionDriverMeet').value)) {
			alert("Airport Collection : Please select driver meeting place.");
			document.getElementById('BookingdetailsCollectionDriverMeet').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionHandPassengers').value)) {
			alert("Airport Collection : Please select number of hand luggages.");
			document.getElementById('BookingdetailsCollectionHandPassengers').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionLargePassengers').value)) {
			alert("Airport Collection : Please select number of large luggages.");
			document.getElementById('BookingdetailsCollectionLargePassengers').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionDestinationAddress').value)) {
			alert("Airport Collection : Please enter destination address.");
			document.getElementById('BookingdetailsCollectionDestinationAddress').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionDestinationArea').value)) {
			alert("Airport Collection : Please enter destination area.");
			document.getElementById('BookingdetailsCollectionDestinationArea').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionPostcode').value)) {
			alert("Airport Collection : Please enter postcode.");
			document.getElementById('BookingdetailsCollectionPostcode').focus();
			return false;
		}		
		if (isEmpty(document.getElementById('BookingdetailsCollectionPassengerVehicleRequiredId').value)) {
			alert("Airport Collection : Please select vehicle required.");
			document.getElementById('BookingdetailsCollectionPassengerVehicleRequiredId').focus();
			return false;
		}		
	}	
	
	
	if(document.getElementById('BookingdetailsGoingToAirportCheck').checked == true)
	{
		//Validations for Going to airport only.
		if (isEmpty(document.getElementById('BookingdetailsAirportCollectionAddress').value)) {
			alert("Going to Airport : Please enter collection address.");
			document.getElementById('BookingdetailsAirportCollectionAddress').focus();
			return false;
		}			
			
		if (isEmpty(document.getElementById('BookingdetailsAirportPickupArea').value)) {
			alert("Going to Airport : Please enter pickup area.");
			document.getElementById('BookingdetailsAirportPickupArea').focus();
			return false;
		}
		
		if (isEmpty(document.getElementById('BookingdetailsAirportPostcode').value)) {
			alert("Going to Airport : Please enter postcode.");
			document.getElementById('BookingdetailsAirportPostcode').focus();
			return false;
		}	
		
		if (isEmpty(document.getElementById('BookingdetailsAirportAirportId').value)) {
			alert("Going to Airport : Please select airport.");
			document.getElementById('BookingdetailsAirportAirportId').focus();
			return false;
		}	
		
		if (isEmpty(document.getElementById('BookingdetailsAirportAirline').value)) {
			alert("Going to Airport : Please enter airline.");
			document.getElementById('BookingdetailsAirportAirline').focus();
			return false;
		}	
		
		if (isEmpty(document.getElementById('BookingdetailsAirportFlightNumber').value)) {
			alert("Going to Airport : Please enter flight number.");
			document.getElementById('BookingdetailsAirportFlightNumber').focus();
			return false;
		}	
		
		if (isEmpty(document.getElementById('airport_date_required').value)) {
			alert("Going to Airport : Please enter date required.");
			document.getElementById('airport_date_required').focus();
			return false;
		}	
		
		//Validations for going to airport time required start here.
		if ((isEmpty(document.getElementById('BookingdetailsAirportTimeHourRequired').value)) && (isEmpty(document.getElementById('BookingdetailsAirportTimeMinuteRequired').value))) 
		{
			alert("Going to Airport : Please select time required.");
			document.getElementById('BookingdetailsAirportTimeHourRequired').focus();
			return false;
		}	
		
		if ((isEmpty(document.getElementById('BookingdetailsAirportTimeHourRequired').value)) && (!isEmpty(document.getElementById('BookingdetailsAirportTimeMinuteRequired').value))) 
		{
			alert("Going to Airport : Please select valid time.");
			document.getElementById('BookingdetailsAirportTimeHourRequired').focus();
			return false;
		}
	
		if ((!isEmpty(document.getElementById('BookingdetailsAirportTimeHourRequired').value)) && (isEmpty(document.getElementById('BookingdetailsAirportTimeMinuteRequired').value))) 
		{
			alert("Going to Airport : Please select valid time.");
			document.getElementById('BookingdetailsAirportTimeHourRequired').focus();
			return false;
		}
		//Validations for going to airport time required end here.	
		
		if (isEmpty(document.getElementById('BookingdetailsAirportPassengerVehicleRequiredId').value)) {
			alert("Going to Airport : Please select vehicle required.");
			document.getElementById('BookingdetailsAirportPassengerVehicleRequiredId').focus();
			return false;
		}		
	}
	
	if(document.getElementById('BookingdetailsForAllOtherBookingCheck').checked == true)
	{
		//Validations for all other bookings.
		if (isEmpty(document.getElementById('forall_date_required').value)) {
			alert("For All Other Booking : Please enter date required.");
			document.getElementById('forall_date_required').focus();
			return false;
		}	
		
		//Validations for all other booking time required start here.
		if ((isEmpty(document.getElementById('BookingdetailsForallTimeHourRequired').value)) && (isEmpty(document.getElementById('BookingdetailsForallTimeMinuteRequired').value))) 
		{
			alert("For All Other Booking : Please select time required.");
			document.getElementById('BookingdetailsForallTimeHourRequired').focus();
			return false;
		}	
		
		if ((isEmpty(document.getElementById('BookingdetailsForallTimeHourRequired').value)) && (!isEmpty(document.getElementById('BookingdetailsForallTimeMinuteRequired').value))) 
		{
			alert("For All Other Booking : Please select valid time.");
			document.getElementById('BookingdetailsForallTimeHourRequired').focus();
			return false;
		}
	
		if ((!isEmpty(document.getElementById('BookingdetailsForallTimeHourRequired').value)) && (isEmpty(document.getElementById('BookingdetailsForallTimeMinuteRequired').value))) 
		{
			alert("For All Other Booking : Please select valid time.");
			document.getElementById('BookingdetailsForallTimeHourRequired').focus();
			return false;
		}
		//Validations for going to airport time required end here.	
		
		if (isEmpty(document.getElementById('BookingdetailsForallPickupAddress').value)) {
			alert("For All Other Booking : Please enter pickup address.");
			document.getElementById('BookingdetailsForallPickupAddress').focus();
			return false;
		}	
	
		if (isEmpty(document.getElementById('BookingdetailsForallPickupPostcode').value)) {
			alert("For All Other Booking : Please enter pickup postcode.");
			document.getElementById('BookingdetailsForallPickupPostcode').focus();
			return false;
		}	
		
		if (isEmpty(document.getElementById('BookingdetailsForallDestinationAddress').value)) {
			alert("For All Other Booking : Please enter destination address.");
			document.getElementById('BookingdetailsForallDestinationAddress').focus();
			return false;
		}	
		
		if (isEmpty(document.getElementById('BookingdetailsForallDestinationPostcode').value)) {
			alert("For All Other Booking : Please enter destination postcode.");
			document.getElementById('BookingdetailsForallDestinationPostcode').focus();
			return false;
		}	
	}	
	
	//return false;

}

//Validation for quick quote on home page and price page.
function validate_quickquote(){

	//Validations for quick quote Going to Airport.
	if(!isEmpty(document.getElementById('QuickquoteGoingToCity').value) || !isEmpty(document.getElementById('QuickquoteGoingToPostcode').value) || !isEmpty(document.getElementById('QuickquoteGoingToAirport').value))
	{	
		if(!isEmpty(document.getElementById('QuickquoteGoingToCity').value) && !isEmpty(document.getElementById('QuickquoteGoingToPostcode').value) && !isEmpty(document.getElementById('QuickquoteGoingToAirport').value))
		{
			//No Action
			//return true;
		}
		else
		{
			if (isEmpty(document.getElementById('QuickquoteGoingToCity').value)) {
				alert("Please select city.");
				document.getElementById('QuickquoteGoingToCity').focus();
				return false;
			}	
			
			if (isEmpty(document.getElementById('QuickquoteGoingToPostcode').value)) {
				alert("Please select postcode.");
				document.getElementById('QuickquoteGoingToPostcode').focus();
				return false;
			}	
			
			if (isEmpty(document.getElementById('QuickquoteGoingToAirport').value)) {
				alert("Please select airport.");
				document.getElementById('QuickquoteGoingToAirport').focus();
				return false;
			}	
		}
	}	
	
	//Validations for quick quote Airport Collection.
	if(!isEmpty(document.getElementById('QuickquoteAirportAirport').value) || !isEmpty(document.getElementById('QuickquoteAirportCity').value) || !isEmpty(document.getElementById('QuickquoteAirportPostcode').value))
	{	
		if(!isEmpty(document.getElementById('QuickquoteAirportAirport').value) && !isEmpty(document.getElementById('QuickquoteAirportCity').value) && !isEmpty(document.getElementById('QuickquoteAirportPostcode').value))
		{
			//No Action
			//return true;
		}
		else
		{
			if (isEmpty(document.getElementById('QuickquoteAirportAirport').value)) {
				alert("Please select city.");
				document.getElementById('QuickquoteAirportAirport').focus();
				return false;
			}	
			
			if (isEmpty(document.getElementById('QuickquoteAirportCity').value)) {
				alert("Please select postcode.");
				document.getElementById('QuickquoteAirportCity').focus();
				return false;
			}	
			
			if (isEmpty(document.getElementById('QuickquoteAirportPostcode').value)) {
				alert("Please select airport.");
				document.getElementById('QuickquoteAirportPostcode').focus();
				return false;
			}	
		}
	}	
	
	
	return true;
	
}


//This function will enable or disable passenger details section.
function enableDisablePassengerDetails()
{
	checkboxClick = document.getElementById('BookingdetailsPassengerCheck').checked;
	
	if(checkboxClick == true)
	{	
		document.getElementById('BookingdetailsPassengerTitle').disabled = false;
		document.getElementById('BookingdetailsPassengerFirstName').disabled = false;
		document.getElementById('BookingdetailsPassengerLastName').disabled = false;
		document.getElementById('BookingdetailsPassengerCountryId').disabled = false;
		document.getElementById('BookingdetailsPassengerEmail').disabled = false;
		document.getElementById('BookingdetailsPassengerTelephone').disabled = false;
		document.getElementById('BookingdetailsPassengerBookingEnquiry').disabled = false;
		document.getElementById('BookingdetailsPassengerNumber').disabled = false;
	}	
	else
	{
		document.getElementById('BookingdetailsPassengerTitle').disabled = true;
		document.getElementById('BookingdetailsPassengerFirstName').disabled = true;
		document.getElementById('BookingdetailsPassengerLastName').disabled = true;
		document.getElementById('BookingdetailsPassengerCountryId').disabled = true;
		document.getElementById('BookingdetailsPassengerEmail').disabled = true;
		document.getElementById('BookingdetailsPassengerTelephone').disabled = true;
		document.getElementById('BookingdetailsPassengerBookingEnquiry').disabled = true;
		document.getElementById('BookingdetailsPassengerNumber').disabled = true;
	}
}


//This function will enable or disable airport collection section.
function enableDisableAirportCollectionOnly()
{
	checkboxClick = document.getElementById('BookingdetailsAirportCollectionCheck').checked;
	
	if(checkboxClick == true)
	{	
		document.getElementById('BookingdetailsIsAirportCollectionChecked').value = 'Yes'
		
		document.getElementById('BookingdetailsCollectionAirportId').disabled = false;
		document.getElementById('BookingdetailsCollectionFlightNumber').disabled = false;
		document.getElementById('BookingdetailsCollectionAirline').disabled = false;
		document.getElementById('collection_date_required').disabled = false;
		document.getElementById('BookingdetailsCollectionTimeHourRequired').disabled = false;
		document.getElementById('BookingdetailsCollectionTimeMinuteRequired').disabled = false;
		document.getElementById('BookingdetailsCollectionPassengerName').disabled = false;
		document.getElementById('BookingdetailsCollectionPassengerNumber').disabled = false;		
		document.getElementById('BookingdetailsCollectionDriverMeet').disabled = false;
		document.getElementById('BookingdetailsCollectionHandPassengers').disabled = false;
		document.getElementById('BookingdetailsCollectionLargePassengers').disabled = false;
		document.getElementById('BookingdetailsCollectionSpacialRequirements').disabled = false;
		document.getElementById('BookingdetailsCollectionDestinationAddress').disabled = false;
		document.getElementById('BookingdetailsCollectionDestinationArea').disabled = false;
		document.getElementById('BookingdetailsCollectionPostcode').disabled = false;
		document.getElementById('BookingdetailsCollectionPassengerVehicleRequiredId').disabled = false;
	}	
	else
	{
		document.getElementById('BookingdetailsIsAirportCollectionChecked').value = 'No'
		
		document.getElementById('BookingdetailsCollectionAirportId').disabled = true;
		document.getElementById('BookingdetailsCollectionFlightNumber').disabled = true;
		document.getElementById('BookingdetailsCollectionAirline').disabled = true;
		document.getElementById('collection_date_required').disabled = true;
		document.getElementById('BookingdetailsCollectionTimeHourRequired').disabled = true;
		document.getElementById('BookingdetailsCollectionTimeMinuteRequired').disabled = true;
		document.getElementById('BookingdetailsCollectionPassengerName').disabled = true;
		document.getElementById('BookingdetailsCollectionPassengerNumber').disabled = true;
		document.getElementById('BookingdetailsCollectionDriverMeet').disabled = true;
		document.getElementById('BookingdetailsCollectionHandPassengers').disabled = true;
		document.getElementById('BookingdetailsCollectionLargePassengers').disabled = true;
		document.getElementById('BookingdetailsCollectionSpacialRequirements').disabled = true;
		document.getElementById('BookingdetailsCollectionDestinationAddress').disabled = true;
		document.getElementById('BookingdetailsCollectionDestinationArea').disabled = true;
		document.getElementById('BookingdetailsCollectionPostcode').disabled = true;
		document.getElementById('BookingdetailsCollectionPassengerVehicleRequiredId').disabled = true;
	}
}

//This function will enable or disable going to airport section.
function enableDisableGoingToAirportOnly()
{
	checkboxClick = document.getElementById('BookingdetailsGoingToAirportCheck').checked;
	
	if(checkboxClick == true)
	{	
		document.getElementById('BookingdetailsIsGoingToAirportChecked').value = 'Yes'
		
		document.getElementById('BookingdetailsAirportCollectionAddress').disabled = false;
		document.getElementById('BookingdetailsAirportPickupArea').disabled = false;
		document.getElementById('BookingdetailsAirportPostcode').disabled = false;
		document.getElementById('BookingdetailsAirportAirportId').disabled = false;
		document.getElementById('BookingdetailsAirportAirline').disabled = false;
		document.getElementById('BookingdetailsAirportFlightNumber').disabled = false;
		document.getElementById('airport_date_required').disabled = false;
		document.getElementById('BookingdetailsAirportTimeHourRequired').disabled = false;
		document.getElementById('BookingdetailsAirportTimeMinuteRequired').disabled = false;
		document.getElementById('BookingdetailsAirportPassengerVehicleRequiredId').disabled = false;
	}	
	else
	{
		document.getElementById('BookingdetailsIsGoingToAirportChecked').value = 'No'
		
		document.getElementById('BookingdetailsAirportCollectionAddress').disabled = true;
		document.getElementById('BookingdetailsAirportPickupArea').disabled = true;
		document.getElementById('BookingdetailsAirportPostcode').disabled = true;
		document.getElementById('BookingdetailsAirportAirportId').disabled = true;
		document.getElementById('BookingdetailsAirportAirline').disabled = true;
		document.getElementById('BookingdetailsAirportFlightNumber').disabled = true;
		document.getElementById('airport_date_required').disabled = true;
		document.getElementById('BookingdetailsAirportTimeHourRequired').disabled = true;
		document.getElementById('BookingdetailsAirportTimeMinuteRequired').disabled = true;
		document.getElementById('BookingdetailsAirportPassengerVehicleRequiredId').disabled = true;
	}
}

//This function will enable or disable For Other Booking section.
function enableDisableForAllOtherBooking()
{
	checkboxClick = document.getElementById('BookingdetailsForAllOtherBookingCheck').checked;
	
	if(checkboxClick == true)
	{	
		document.getElementById('BookingdetailsIsForAllOtherBookingChecked').value = 'Yes'
		
		document.getElementById('forall_date_required').disabled = false;
		document.getElementById('BookingdetailsForallTimeHourRequired').disabled = false;
		document.getElementById('BookingdetailsForallTimeMinuteRequired').disabled = false;
		document.getElementById('BookingdetailsForallPickupAddress').disabled = false;
		document.getElementById('BookingdetailsForallPickupPostcode').disabled = false;
		document.getElementById('BookingdetailsForallDestinationAddress').disabled = false;
		document.getElementById('BookingdetailsForallDestinationPostcode').disabled = false;
	}	
	else
	{
		document.getElementById('BookingdetailsIsForAllOtherBookingChecked').value = 'No'
		
		document.getElementById('forall_date_required').disabled = true;
		document.getElementById('BookingdetailsForallTimeHourRequired').disabled = true;
		document.getElementById('BookingdetailsForallTimeMinuteRequired').disabled = true;
		document.getElementById('BookingdetailsForallPickupAddress').disabled = true;
		document.getElementById('BookingdetailsForallPickupPostcode').disabled = true;
		document.getElementById('BookingdetailsForallDestinationAddress').disabled = true;
		document.getElementById('BookingdetailsForallDestinationPostcode').disabled = true;
	}
}

//This function will check the checkboxes on page load, on basis of condition satisfied.
function defaultCheckboxesSelectionForBooking()
{
	//Check Airport Collection Checkbox if condition is satisfied.
	if(document.getElementById('BookingdetailsIsAirportCollectionChecked').value == 'Yes' || isEmpty(document.getElementById('BookingdetailsIsAirportCollectionChecked').value))
	{
		document.getElementById('BookingdetailsAirportCollectionCheck').checked = true;
	}	
	else
	{
		document.getElementById('BookingdetailsAirportCollectionCheck').checked = false;
	}	
		
		
	//Check Going To Airport Checkbox if condition is satisfied.
	if(document.getElementById('BookingdetailsIsGoingToAirportChecked').value == 'Yes' || isEmpty(document.getElementById('BookingdetailsIsGoingToAirportChecked').value))
	{
		document.getElementById('BookingdetailsGoingToAirportCheck').checked = true;
	}	
	else
	{
		document.getElementById('BookingdetailsGoingToAirportCheck').checked = false;
	}	
		
	//Check For All Other Booking Checkbox if condition is satisfied.
	if(document.getElementById('BookingdetailsIsForAllOtherBookingChecked').value == 'Yes' || isEmpty(document.getElementById('BookingdetailsIsForAllOtherBookingChecked').value))
	{
		document.getElementById('BookingdetailsForAllOtherBookingCheck').checked = true;
	}	
	else
	{
		document.getElementById('BookingdetailsForAllOtherBookingCheck').checked = false;
	}	
	
	enableDisableAirportCollectionOnly();
	enableDisableGoingToAirportOnly();
	enableDisableForAllOtherBooking();

}

/**
	This function will for client side validation for Contact Us page.
*/

function validate_contactus(){
		
	//Validations for Passenger Details
	if (isEmpty(document.getElementById('ContactName').value)) 
	{
		alert("Please enter your name.");
		document.getElementById('ContactName').focus();
		return false;
	}	
	
	if (isEmpty(document.getElementById('ContactEmail').value)) 
	{
		alert("Please enter your email address.");
		document.getElementById('ContactEmail').focus();
		return false;
	}
	
	if(!validateEmail(document.getElementById('ContactEmail').value)) 
	{
		alert("Please enter valid email address.");
		document.getElementById('ContactEmail').focus();
		return false;
	}
	
	if (isEmpty(document.getElementById('ContactEnquiryFeedback').value)) 
	{
		alert("Please enter your enquiry/comments.");
		document.getElementById('ContactEnquiryFeedback').focus();
		return false;
	}	

}