SetAutoFocus()
/*
if (document.getElementById('myBooking') != null){
	HideGroup('myBooking','none')
}
if (document.getElementById('webCheckIn') != null){
	HideGroup('webCheckIn','none')
}
if (document.getElementById('AdditionalCost') != null){
	HideGroup('AdditionalCost','none')
}
*/
if (document.getElementById(goToRow) != null){
	document.getElementById(goToRow).scrollIntoView(true);
}

if (document.getElementById('CvvForm') == '[object]'){
	if (document.getElementById('ctrBooking_ctrPassengerInfosBase_CtlPaymentsBase_CtlPaymentCreditCard') != null){
		ShowCvvCode('ctrBooking_ctrPassengerInfosBase_CtlPaymentsBase_CtlPaymentCreditCard')
	}
	else if (document.getElementById('ctrBooking_ctrBookingSummery_CtrPaymentsBase_CtlPaymentCreditCard') != null){
		ShowCvvCode('ctrBooking_ctrBookingSummery_CtrPaymentsBase_CtlPaymentCreditCard')
	}
}


//if (document.getElementById('ctrHome_ctrFlightSearchBase_cmbOrigin')  != null ){
//	document.getElementById('ctrHome_ctrFlightSearchBase_cmbOrigin').selectedIndex = getSubCookie('OriginCookie',getCookie('tikAero') + '&');
//	Anthem_FireEvent('ctrHome_ctrFlightSearchBase_cmbOrigin','',function(){},null,true,true)
//}

if(document.getElementById('ctrHome_ctrFlightAvailabilityBase_ctrFlightSearchBase_tboPromotionCode') != null ){
	ShowHideButton('ctrHome_ctrFlightAvailabilityBase_ctrFlightSearchBase');
}

if (document.getElementById('ctrHome_ctrFlightSearchBase_rdoOneway') != null ) {
	if (document.getElementById('ctrHome_ctrFlightSearchBase_rdoOneway').checked == true) {
		HideGroup('FlightSearch','none')
	}
}

if (document.getElementById('ctrHome_ctrFlightSearchLeft_rdoOneway') != null ) {
	if (document.getElementById('ctrHome_ctrFlightSearchLeft_rdoOneway').checked == true) {
		HideGroup('FlightSearchHome','none')
	}
}

if (document.getElementById('ctrHome_ctrFlightAvailabilityBase_ctrFlightSearchBase_rdoOneway') != null ) {
	if (document.getElementById('ctrHome_ctrFlightAvailabilityBase_ctrFlightSearchBase_rdoOneway').checked == true) {
		HideGroup('FlightSearch','none')
	}
}

if (CcPreselect.length > 0){
	ShowCvvCode(CcPreselect)
}

function HideGroup(Name,Action){
	var NN4 = document.layers? true : false;
	var IE4 = document.all? true : false;
	var FF 	= document.getElementById? true : false;
	if (IE4){
		if(navigator.appName == 'Opera') IE4 = false;
	}
	if(Action == 'none') {
		if (Name == 'FlightSearch') SingleFlight = true;
		if (IE4) {
			document.all[Name].style.visibility = "hidden";
//			if (Name == 'FlightSearch') document.all['LowestOut'].style.visibility = "hidden";
		} else if(NN4) {
			document.layers[Name].visibility = "hidden";
//			if (Name == 'FlightSearch') document.layers['LowestOut'].visibility = "hidden";
		} else if(FF) {
			document.getElementById(Name).style.display = "none";
//			document.getElementById(Name).style.visibility = "hidden";
//			if (Name == 'FlightSearch') document.getElementById('LowestOut').style.visibility = "hidden";
		} else {
			alert('Unknown browser category.');
		}
	} else {
		if (Name == 'FlightSearch') SingleFlight = false;
		if (IE4) {
			document.all[Name].style.visibility = "visible";
//			if (Name == 'FlightSearch') document.all['LowestOut'].style.visibility = "visible";
		} else if(NN4) {
			document.layers[Name].visibility = "show";
//			if (Name == 'FlightSearch') document.layers['LowestOut'].visibility = "show";
		} else if(FF) {
			document.getElementById(Name).style.display = "";
//			document.getElementById(Name).style.visibility = "visible";
//			if (Name == 'FlightSearch') document.getElementById('LowestOut').style.visibility = "visible";
		} else {
			alert('Unknown browser category.');
		}
	}
/*	
	var col = document.getElementsByName(Name)
	for (var i=0;i <= col.length - 1;i++){
		col[i].style.visibility = (Action == 'none') ? 'hidden' : 'visible';
		SingleFlight = (Action == 'none') ? true : false;
	}
*/
}

function CheckAdultInfant(o){
	var iA = document.getElementById(o + '_cmbAdult').options[document.getElementById(o + '_cmbAdult').selectedIndex].value
	var iI = document.getElementById(o + '_cmbInfant').options[document.getElementById(o + '_cmbInfant').selectedIndex].value
	if (iA<iI){
		alert('It is not possible to book more Infants than Adults!')
		document.getElementById(o + '_cmbInfant').selectedIndex = 0
	}
}

function ValidSDate(o){
	Status =  true;
	if (document.getElementById(o + '_rdoOneway').checked != true) {
		if (LibDaysDiff(GetCalenderDate(o + '_ctlReturnDate'),GetCalenderDate(o + '_ctlDepatureDate')) < 0){
			alert('Please check your Return Date! It has to be equal to or higher than the Departure Date.')
			Status =  false;
		}
	}
}

function GetCalenderDate(o){
	var od = document.getElementById(o+'_cmbDay')
	var ot = document.getElementById(o+'_cmbMonthYear')
	var y = ot.options[ot.selectedIndex].value.slice(0,4)
	var m = ot.options[ot.selectedIndex].value.slice(4,6)
	var d = od.options[od.selectedIndex].value 
	return new Date(y,m-1,d,0,0,0)
}

function DefaultSelectValue(obj,value) {
	for(var i=0;i<obj.options.length;i++){
		if(value.toString().toLowerCase()==obj.options[i].value.toString().toLowerCase()){
			obj.options[i].selected=true;
			break; 
		}
	}
}
 
function CopyFirstPassenger(t,o,m){
	var pt = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_PassengerTitel'); 
	if (t.checked){
		var i = 1
		var os = document.getElementById(o+'_ctlPassengerContactInfo_cmbTitelsRcd');		
		var fn = document.getElementById(o+'_ctlPassengerContactInfo_firstname').value
		var ln = document.getElementById(o+'_ctlPassengerContactInfo_lastname').value
		var f = trim(fn)
		var l = trim(ln)
		if (l > 2 || f > 1){
		    if (document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Lastname')!= null) {
			document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Lastname').value = ln
			document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Firstname').value = fn
			pt.selectedIndex = os.selectedIndex
			}
		}
		else{
			document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Lastname').value = ''
			document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Firstname').value = ''
			//document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_PassengerTitel').selectedIndex = 7
			DefaultSelectValue(pt,"MR|M");
			t.checked = false
		}
	}
	else {
			document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Lastname').value = ''
			document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_Firstname').value = ''
			//document.getElementById(o+'_ctlPassengerList_PassengerList__ctl1_PassengerTitel').selectedIndex = 7			
			DefaultSelectValue(pt,"MR|M");
	}
}

function CopyFirstPassengerOld(o,m){
	if (document.getElementById(m + '_cboFirstPassenger').checked){
		var i = 1
		var l = trim(document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_LastName').value)
		var f = trim(document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_FirstName').value)
		if (l > 2 || f > 1){
			document.getElementById(m + '_tboNameOnCard').value = strim(document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_FirstName').value) + ' ' +  strim(document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_LastName').value)
		}
		else{
			document.getElementById(m + '_cboFirstPassenger').checked = false
		}	
	}
	else {
		document.getElementById(m + '_tboNameOnCard').value = ''
	}
}

function SetFirstPassenger(m,s){
	if (document.getElementById(m + '_cboFirstPassenger').checked){
		var ms = s.split('|')
		document.getElementById(m + '_tboNameOnCard').value = ms[0]
		document.getElementById(m + '_tboStreet').value = ms[1]
		document.getElementById(m + '_tboStreet2').value= ms[2]
		document.getElementById(m + '_tboCity').value= ms[3]
		document.getElementById(m + '_tboState').value = ms[4]
		document.getElementById(m + '_tboZipCode').value = ms[5]
		document.getElementById(m + '_cmbCountryRcd').selectedIndex = ms[6]
	}
	else{
		var ms = s.split('|')
		document.getElementById(m + '_tboNameOnCard').value = ''
		document.getElementById(m + '_tboStreet').value = ''
		document.getElementById(m + '_tboStreet2').value= ''
		document.getElementById(m + '_tboCity').value= ''
		document.getElementById(m + '_tboState').value = ''
		document.getElementById(m + '_tboZipCode').value = ''
		document.getElementById(m + '_cmbCountryRcd').selectedIndex = ms[6]
	}
}

function ValidPassengerGrid(o){
	Status =  true
	var e = ''
	var l = trim(document.getElementById(o + '_LastName').value)
	var f = trim(document.getElementById(o + '_FirstName').value)
	var d = document.getElementById(o + '_DateOfBirth').value
	if (l < 2 || f < 1){
		Status =  false;
		e += 'Please supply a valid Passenger Name ;\r'
	}
	// if (trim(d) > 0 && Date.isValid(d,DateValid) == false){
	if (trim(d) > 0 && isDateExist(d) == false){
		Status =  false;
		e += 'Please supply a valid date of birth ' + DateValidText + ' \r'	
	}
	if (e.length > 0) {
		alert(e)
	}
}

function IfAlphaOnly(s){
	var i
	var b = false 
	if (s.length != 0){
		for (i=0;i < s.length;i++){
			var c = s.charCodeAt(i);
			if (c == 45|| c == 39 || c == 46 || c == 32){
				b = true;
			}
			else if ((c > 47 && c < 58)){
				return false;
			}
			else if (((c > 96 && c < 123) || (c > 64 && c < 91))  == false){
				return false;
			}
		}
		b = true
	}
	else{
		b = false;
	}
	return b
}

function ValidateRegister(o){
	Status 	= true;
	var e 	= ''
	var tt 	= document.getElementById(o+'_ctlPassengerContactInfo_cmbTitelsRcd');
	var fn 	= trim(document.getElementById(o+'_ctlPassengerContactInfo_firstname').value);
	var ln 	= trim(document.getElementById(o+'_ctlPassengerContactInfo_lastname').value);
	var pm 	= document.getElementById(o+'_ctlPassengerContactInfo_phone_mobile');
	//var ph 	= document.getElementById(o+'_ctlPassengerContactInfo_phone_home')
	var pb 	= document.getElementById(o+'_ctlPassengerContactInfo_phone_business');
	var pmobile = trim(pm.value);
	var em 	= trim(document.getElementById(o+'_ctlPassengerContactInfo_contact_email').value);
	var ad1 = trim(document.getElementById(o+'_ctlPassengerContactInfo_address_line1').value);
	var cty = trim(document.getElementById(o+'_ctlPassengerContactInfo_city').value);
	var dt 	= trim(document.getElementById(o+'_ctlPassengerContactInfo_province').value);
	var pc 	= trim(document.getElementById(o+'_ctlPassengerContactInfo_zip_code').value);
	var ctr = document.getElementById(o+'_ctlPassengerContactInfo_cmbCountryRcd');
	//--->  Title
	if (trim(tt.options[tt.selectedIndex].value)==0){
		Status =  false;
		e += "<li>Please supply a valid Title</li>";
		document.getElementById(o+'_ctlPassengerContactInfo_cmbTitelsRcd').className = 'error';
	}else{
		document.getElementById(o+'_ctlPassengerContactInfo_cmbTitelsRcd').className = '';
	}
	//--->  First Name
	if (fn==0){
		Status =  false;
		e += "<li>Please supply a valid First Name</li>"
		document.getElementById(o+'_ctlPassengerContactInfo_firstname').className = 'error';
	}else{
		document.getElementById(o+'_ctlPassengerContactInfo_firstname').className = '';
	}
	//--->  Surname
	if (ln==0){
		Status =  false;
		e += "<li>Please supply a valid Surname</li>"
		document.getElementById(o+'_ctlPassengerContactInfo_lastname').className = 'error';
	}else{
		document.getElementById(o+'_ctlPassengerContactInfo_lastname').className = '';
	}
	//--->  Telephone Number
	if (pmobile==0){
		Status =  false;
		e += "<li>Please supply a valid Telephone/Mobile Number</li>";
		pm.className = 'error';
		//ph.className = 'error'
		//pb.className = 'error'
	}
	else{
		pm.className = '';
		//ph.className = ''
		//pb.className = ''
	}
	//--->  Email
	if (em==0){
		Status =  false;
		e += "<li>Please supply a valid Email address</li>";
		document.getElementById(o+'_ctlPassengerContactInfo_contact_email').className = 'error';
	}
	else{
		var email = document.getElementById(o+'_ctlPassengerContactInfo_contact_email').value;
		if (ValidEmail(email)){
			document.getElementById(o+'_ctlPassengerContactInfo_contact_email').className = '';
		} else {
			Status =  false;
			e += "<li>Please supply a valid Email format</li>";
			document.getElementById(o+'_ctlPassengerContactInfo_contact_email').className = 'error';
		}
	}	
	
	//--->  Address 1
	if (ad1==0){
		Status =  false;
		e += "<li>Please supply a valid Address 1</li>"
		document.getElementById(o+'_ctlPassengerContactInfo_address_line1').className = 'error';
	}else{
		document.getElementById(o+'_ctlPassengerContactInfo_address_line1').className = '';
	}
	//--->  Town/City
	if (cty==0){
		Status =  false;
		e += "<li>Please supply a valid Town/City</li>";
		document.getElementById(o+'_ctlPassengerContactInfo_city').className = 'error';
	}else{
		document.getElementById(o+'_ctlPassengerContactInfo_city').className = '';
	}
	//--->  County
	//if (dt==0){
	//	Status =  false;
	//	e += "<li>Please supply a valid County</li>"
	//	document.getElementById(o+'_ctlPassengerContactInfo_district').className = 'error';
	//}else{
	//	document.getElementById(o+'_ctlPassengerContactInfo_district').className = '';
	//}
	//--->  Zip Code
	//if (pc==0){
	//	Status =  false;
	//	e += "<li>Please supply a valid Zip Code</li>"
	//	document.getElementById(o+'_ctlPassengerContactInfo_zip_code').className = 'error';
	//}else{
	//	document.getElementById(o+'_ctlPassengerContactInfo_zip_code').className = '';
	//}
	//--->  Country
	if (trim(ctr.options[ctr.selectedIndex].value)==0){
		Status =  false;
		e += "<li>Please supply a valid Country</li>";
		document.getElementById(o+'_ctlPassengerContactInfo_cmbCountryRcd').className = 'error';
	}else{
		document.getElementById(o+'_ctlPassengerContactInfo_cmbCountryRcd').className = '';
	}

	var il = (document.getElementById('PassengerList').rows.length - 1)/6;
	for (i=1;i<=il;i++){
		var temp_i;
		temp_i = addFullNumerical(i,2);
		var ln = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_Lastname');
		//var fn = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_Firstname');
		var pn = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_number');		
		var dn = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_DateOfBirth');
		var dn_type = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_Label2');
		var p2	= document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_issue_date')
		var p3	= document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_expiry_date')	

		if (ln != null) {
			var l = trim(ln.value);
			if (l < 2){
				Status =  false;
				e += '<li>Please supply a valid Passenger Name at passenger ' + (addFullNumerical(i,3)) + '</li>'
				ln.className = (l < 2) ? 'error' : '';
			}
			else if(IfAlphaOnly(ln.value) == false){
				Status =  false;
				e += '<li>Please supply a valid Passenger Name at passenger ' + (addFullNumerical(i,3)) + '</li>'
				ln.className = (IfAlphaOnly(ln.value)) ? '' : 'error';
			}
			else{
				ln.className = ''
			}
		}

		if(pn != null){
		    var n = trim(pn.value);
			if (n < 1){
				Status =  false;
				e += '<li>Please supply a valid Document Number at passenger ' + (addFullNumerical(i,3))+ '</li>'
				pn.className = 'error';
			}
			else{
				pn.className = ''
			}
		}

        // Issue Date
        if (p2 != null) {
            var	p2v	= p2.value;
            // if ((ptv == true || trim(p2v) > 0) && Date.isValid(p2v,DateValid) == false){
            if ((ptv == true || trim(p2v) > 0) && isDateExist(p2v) == false){
                 Status =  false;
			    e += '<li>' + eMsg[13] + (addFullNumerical(i,3))+ ' ' + DateValidText + '</li>';
			    p2.className = 'error';
		    }
		    else{
			    if (LibDaysDiff(changeToDate(p2v),new Date()) > 0){
				    Status =  false;
				    e += '<li>' + eMsg[15] + (addFullNumerical(i,3))+ '</li>';
				    p2.className = 'error';
			    }
			    else{
				    p2.className = '';
			    }
		    }
	    }
	    
    	// Expiry Date
        if (p3 != null) {
		    var	p3v	= p3.value;
		    // if ((ptv == true || trim(p3v) > 0) && Date.isValid(p3v,DateValid) == false){
		    if ((ptv == true || trim(p3v) > 0) && isDateExist(p3v) == false){
	            Status =  false;
			    e += '<li>' + eMsg[12] + (addFullNumerical(i,3))+ ' ' + DateValidText + '</li>';
			    p3.className = 'error';
		    }
		    else{
			    if (LibDaysDiff(changeToDate(p3v),new Date()) < 0){
				    Status =  false;
				    e += '<li>' + eMsg[16] + (addFullNumerical(i,3))+ '</li>';
				    p3.className = 'error';
			    }
			    else{
				    p3.className = '';
			    }
		    }
	    }
	    
        // Date of Birth
		if (dn != null) {
			var d = dn.value;
			var dt = dn_type.innerHTML
			// if (Date.isValid(d,DateValid) == false){
			if (isDateExist(d)== false){
				Status =  false;
				e += '<li>' + eMsg[5] + (addFullNumerical(i,3))+ ' ' + DateValidText + '</li>';
				dn.className = 'error';
		    }
		    else{
				if (LibDaysDiff(changeToDate(d),new Date()) > 0){
					Status =  false;
					e += '<li>' + eMsg[17] + (addFullNumerical(i,3))+ '</li>';
					dn.className = 'error';
				}
				else{
			        if (dt == "CHD" || dt == "INF" || dt == "ADULT"){
				        //document.getElementById('star' + i).style.visibility = "visible";
				        // if(Date.isValid(d,DateValid) == false){
				        if(isDateExist(d)== false){
					        Status =  false;
					        e += '<li>' + eMsg[5] + (addFullNumerical(i,3))+ ' ' + DateValidText + '</li>'
					        dn.className = 'error'
				        }
				        else{
				            var totalAge = calculateAge(dn.value);
				            var MIN_CHD_AGE = 2;
				            var MAX_CHD_AGE = 12;
				            
				            if(dt == "CHD"){
				                if(!((MIN_CHD_AGE <= totalAge) && (totalAge < MAX_CHD_AGE))){
                                    e += '<li>' + 'Age of child should be between 2-11 years at passenger ' + (addFullNumerical(i,3))+ '</li>';
                                    Status =  false;
			                        dn.className = 'error';                            
				                }else{
					                dn.className = '';
				                }
				            }else if(dt == "INF"){
                                if(!(totalAge < MIN_CHD_AGE)){
                                    e += '<li>' + 'Age of infant should be between 0-23 months at passenger ' + (addFullNumerical(i,3))+ '</li>';
			                        Status =  false;
			                        dn.className = 'error';
		                        }else{
					                dn.className = '';
				                }
				            }else if(dt == "ADULT"){
				                if(!(MAX_CHD_AGE <= totalAge)){
                                    e += '<li>' + 'Age of adult should be 12 up years old at passenger ' + (addFullNumerical(i,3))+ '</li>';
			                        Status =  false;
			                        dn.className = 'error';
		                        }else{
					                dn.className = '';
				                }
				            }
				            
				            /*
                            //Child  2-11 year
                            //Infant 1-23 month
                            var MIN_CHD_AGE = (2*12);
                            var MAX_CHD_AGE = (11*12);
                            //Child  3-17 year
                            //Infant 1-23 month
                            //var MIN_CHD_AGE = (3*12);
                            //var MAX_CHD_AGE = ((17*12)+11);

                            var MIN_INF_AGE = (1);
                            var MAX_INF_AGE = (23);
                            //var MIN_INF_AGE = (1);
                            //var MAX_INF_AGE = (35);
                            
                            var dd = Number(d.substring(0,2));
                            var mm = Number(d.substring(3,5));
                            var yy = Number(d.substring(6,10));
                                mm = mm - 1;
                            var iDate = new Date(yy,mm,dd);
                            var cDate = new Date();
                            var mmAge = dateDiff("m",iDate,cDate,1,1); 				        
				            
				            //var fDate = document.getElementById('ctrBooking_ctrItineraryBase_ctrItineraryGrid_grdItineraryGrid__ctl0_Td46');
							var fDate = document.getElementById('ctrBooking_ctrPassengerInfosBase_ctlBookingInfo_LabDepartureDate');
				            if(dt == "CHD"){
				                if(!((MIN_CHD_AGE<=mmAge)&&(mmAge<=MAX_CHD_AGE))){
                                    e += '<li>' + 'Age of child should be between 2-11 years at passenger ' + (addFullNumerical(i,3))+ '</li>';
                                    Status =  false;
			                        dn.className = 'error';                            
				                }else{
					                dn.className = '';
				                }
				            }else if(dt == "INF"){
                                if(!((MIN_INF_AGE<=mmAge)&&(mmAge<=MAX_INF_AGE))){
                                    e += '<li>' + 'Age of infant should be between 0-23 months at passenger ' + (addFullNumerical(i,3))+ '</li>';
			                        Status =  false;
			                        dn.className = 'error';
		                        }else{
					                dn.className = '';
				                }
				            }else if(dt == "ADULT"){
				                if(!(MAX_CHD_AGE<mmAge)){
                                    e += '<li>' + 'Age of adult should be 12 up years old at passenger ' + (addFullNumerical(i,3))+ '</li>';
			                        Status =  false;
			                        dn.className = 'error';
		                        }else{
					                dn.className = '';
				                }
				            }
				            */
				        }
			        }
			        else{
		                dn.className = '';
	                }
				}
			}
		}
	}

	if (e.length > 0) {
		//Container = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + (il+1) + '_LabError')
		var tempNumber = il + 1;
		Container = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl'+ tempNumber + '_LabError');
		Container.innerHTML = 	'<ul>' + e + '</ul>'
	}
	else{
		//Container = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl2_LabError')
		//Container.innerHTML = 	''
		//Container = document.getElementById('PaymentCommentContainer')
		//var b = document.getElementById(o+'_btmSubmitBooking')
		//b.style.visibility = 'hidden'
		//Container.style.display = 'block'
	}
}

function addFullNumerical(number, count){
	var str_number = number + '';
	var loop = count - str_number.length;
	var j;
	for(j=1;j<=loop;++j){
		str_number = '0' + str_number;
	}
	return str_number;
}

function ValidUpdatePayment(o){	
	Status 	= true
	var e 	= ''	
	var noc = document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboNameOnCard');
	var cdn	= document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber');
	var cvv	= document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboCvvCode');
	var ad1	= document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboStreet');
	var cty	= document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboCity');
	var pc 	= document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboZipCode');
	var st 	= document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboState');
	var ctr = document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_cmbCountryRcd');
	var rcvv = document.getElementById(CcPreselect + '_cbmFormOfPaymentSubtype').options[document.getElementById(CcPreselect + '_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')

	if(document.getElementById('formCC').style.display != 'none'){	
		//--->  Name On Card
		if (trim(noc.value) == 0){
			Status =  false;
			e += "<li>Please supply a valid Name On Card</li>"
			noc.className = 'error';
		}else{
			noc.className = '';
		}
		//--->  Credit Card Number
		if (trim(cdn.value) == 0){
			Status =  false;
			e += "<li>Please supply a valid Credit Card Number</li>"
			cdn.className = 'error';
		}else{
			cdn.className = '';
			var vccn = ValidCreditCardNumber(o, document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber').value);
			if (vccn.length > 0){
				Status =  false;
				e += vccn
				cdn.className = 'error';			
			}else{
				cdn.className = '';
			}
		}
		//--->  CVV
		if (trim(cvv.value) == 0 && rcvv[2]==1){
			Status =  false;
			e += "<li>Please supply a valid CVV</li>"
			cvv.className = 'error';
		}else{
			cvv.className = '';
		}
		//--->  Address 1
		if (trim(ad1.value) == 0){
			Status =  false;
			e += "<li>Please supply a valid Street 1</li>"
			ad1.className = 'error';
		}else{
			ad1.className = '';
		}
		//--->  Town/City
		if (trim(cty.value) == 0){
			Status =  false;
			e += "<li>Please supply a valid Town/City</li>"
			cty.className = 'error';
		}else{
			cty.className = '';
		}
		//--->  Zip Code
		if (trim(pc.value) == 0){
			Status =  false;
			e += "<li>Please supply a valid Zip Code</li>"
			pc.className = 'error';
		}else{
			pc.className = '';
		}
		//--->  County
		//if (trim(st.value) == 0){
		//	Status =  false;
		//	e += "<li>Please supply a valid County</li>"
		//	st.className = 'error';
		//}else{
		//	st.className = '';
		//}
		//--->  Country
		if (trim(ctr.options[ctr.selectedIndex].value)==0){
			Status =  false;
			e += "<li>Please supply a valid Country</li>"
			ctr.className = 'error';
		}else{
			ctr.className = '';
		}
	
		if (e.length > 0) {		
			Container = document.getElementById(o+'_ctlErrorContainer_ErrorContainer');
			Container.innerHTML = 	'<ul>' + e + '</ul>';
		}
		else{
			ContainerBase = document.getElementById('ContainerPayment');
			ContainerBase.style.visibility = 'hidden';
			ContainerPageHeader = document.getElementById('PageHeader');
			ContainerPageHeader.style.visibility = 'hidden';
			CvvForms = document.getElementById('CvvForm');
			CvvForms.style.visibility = 'hidden';
			CvvLabels = document.getElementById('CvvLabel');
			CvvLabels.style.visibility = 'hidden';			
			var IssueNumberLabel = document.getElementById('IssueNumberLabel');
			IssueNumberLabel.style.visibility = 'hidden';
			var IssueNumberForm = document.getElementById('IssueNumberForm');
			IssueNumberForm.style.visibility = 'hidden';
			var IssueDateLabel = document.getElementById('IssueDateLabel');
			IssueDateLabel.style.visibility = 'hidden';
			var IssueDateForm = document.getElementById('IssueDateForm');
			IssueDateForm.style.visibility = 'hidden';
			Container = document.getElementById(o+'_ctlErrorContainer_ErrorContainer');
			Container.innerHTML = '';
			Container = document.getElementById('PaymentCommentContainer');
			Container.style.display = 'block';
			var bStepBackPayment = document.getElementById('StepBackPayment');
			var bCancelPayment = document.getElementById('CancelPayment');
			bStepBackPayment.style.display = 'none';
			bCancelPayment.style.display = 'none';
		}
	}
}

function ValidCreditCardNumber(o, CcNumber){
	var Status 	= true ;
	var e 	= '' ;
	var docNumber ;
	var errorMsg1 = '<li>Invalid Card Number or Type</li>';
	var errorMsg2 = '<li>Invalid or Incomplete Credit Card Number</li>';
	var cardType = CheckCardType(CcNumber.slice(0,6));
	if(document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype') != null){
		iA = document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').options[document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')
		docNumber = document.getElementById(o+'_CtrPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber');
	}else{
		iA = document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').options[document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')
		docNumber = document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber');
	}
	var mi = 15;
	var ma = 19;
	if (iA.length > 0 ){
		if(iA[0] == 'AMEX'){
			if(cardType =='AMEX'){
				if(docNumber.value.length != 15){
					Status =  false;
					e += errorMsg2;
				}				
			}
			else{
				Status =  false;
				e += errorMsg1;
			}
		}
		else 	if(iA[0] == 'ELECTRON'){			
			if(cardType =='VISADRUK' || cardType =='VISAELUK'){
				if(docNumber.value.length < 16 || docNumber.value.length > 19){
					Status =  false;
					e += errorMsg2;
				}
			}
			else{
				Status =  false;
				e += errorMsg1;
			}
		}
		else 	if(iA[0] == 'MAESTRO'){
			if(cardType =='MAESTRO' || cardType =='MAESTROUK' || cardType =='SOLO'){
				if(docNumber.value.length != 16 && docNumber.value.length != 18 && docNumber.value.length != 19){
					Status =  false;
					e += errorMsg2;
				}
			}
			else{
				Status =  false;
				e += errorMsg1;
			}
		}
		else 	if(iA[0] == 'MC'){
			if(cardType =='MC' || cardType =='MCDR'){
				if(docNumber.value.length != 16){
					Status =  false;
					e += errorMsg2;
				}
			}
			else{
				Status =  false;
				e += errorMsg1;
			}
		}
		else if(iA[0] == 'VISA'){
			if(cardType =='VISA' || cardType =='VISADRUK' || cardType =='VISAELUK' || cardType =='VISAPU' || cardType =='VISAPU'){
				if(docNumber.value.length < 16 || docNumber.value.length > 19){
					Status =  false;
					e += errorMsg2;
				}
			}
			else{
				Status =  false;
				e += errorMsg1;
			}
		}
	}
	return e;
}

function ValidPayment(o,b){
	Status 	= true;
	var e 	= '';
	if (document.getElementById('formCC') != null) {
	/*	if(document.getElementById('formCC').style.display != 'none'){
			var noc = trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboNameOnCard').value)
			var cdn	= trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber').value)
			var cvv	= trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboCvvCode').value)
			var ad1	= trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboStreet').value)
			var cty	= trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboCity').value)
			var pc 	= trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboZipCode').value)
			var st 	= trim(document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboState').value)
			var ctr = document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_cmbCountryRcd')
			var rcvv = document.getElementById(CcPreselect + '_cbmFormOfPaymentSubtype').options[document.getElementById(CcPreselect + '_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')

			//--->  Name On Card
			if (noc==0){
				Status =  false;
				e += "<li>Please supply a valid Name On Card</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboNameOnCard').className = 'error';
			}else{
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboNameOnCard').className = '';
			}
			//--->  Credit Card Number
			if (cdn==0){
				Status =  false;
				e += "<li>Please supply a valid Credit Card Number</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber').className = 'error';
			}else{		
				var vccn = ValidCreditCardNumber(o, document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber').value);
				if (vccn.length > 0){
					Status =  false;
					e += vccn
					document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber').className = 'error';			
				}else{
					document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboDocumentNumber').className = '';
				}
			}
			
			//--->  CVV
			if (cvv==0 && rcvv[2]==1){
				Status =  false;
				e += "<li>Please supply a valid CVV</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboCvvCode').className = 'error';
			}else{
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboCvvCode').className = '';
			}
			//--->  Address 1
			if (ad1==0){
				Status =  false;
				e += "<li>Please supply a valid Address 1</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboStreet').className = 'error';
			}else{
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboStreet').className = '';
			}
			//--->  Town/City
			if (cty==0){
				Status =  false;
				e += "<li>Please supply a valid Town/City</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboCity').className = 'error';
			}else{
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboCity').className = '';
			}
			//--->  Zip Code
			if (pc==0){
				Status =  false;
				e += "<li>Please supply a valid Zip Code</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboZipCode').className = 'error';
			}else{
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboZipCode').className = '';
			}
			//--->  County
			//if (st==0){
			//	Status =  false;
			//	e += "<li>Please supply a valid County</li>"
			//	document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboState').className = 'error';
			//}else{
			//	document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_tboState').className = '';
			//}
			//--->  Country
			if (trim(ctr.options[ctr.selectedIndex].value)==0){
				Status =  false;
				e += "<li>Please supply a valid Country</li>"
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_cmbCountryRcd').className = 'error';
			}else{
				document.getElementById(o+'_CtlPaymentsBase_CtlPaymentCreditCard_cmbCountryRcd').className = '';
			}
		} */
	}
	//--->  Terms and Conditions
	if (document.getElementById(o+'_cboConfirm').checked == false){
		Status =  false;
		e += "<li>Please accept Terms and Conditions</li>";
	}

	if (e.length > 0) {
		Container = document.getElementById(o+'_ctlErrorContainer_ErrorContainer');
		Container.innerHTML = 	'<ul>' + e + '</ul>';
	}
	else{
        var ip = document.getElementById('ctrBooking_ctrPassengerInfosBase_lblIp');
        if (ip != null) {
            /*
            if(confirm('Your IP address is '+ ip.innerHTML + ' For security reasons and preventing card fraud your IP address will be logged in our database')){
		        //ContainerBase = document.getElementById('ContainerPayment');
		        //ContainerBase.style.visibility = 'hidden';
		        //ContainerPageHeader = document.getElementById('PageHeader');
		        //ContainerPageHeader.style.visibility = 'hidden';
		        //CvvForms = document.getElementById('CvvForm');
		        //CvvForms.style.visibility = 'hidden';
		        //CvvLabels = document.getElementById('CvvLabel');
		        //CvvLabels.style.visibility = 'hidden';
		        //var IssueNumberLabel = document.getElementById('IssueNumberLabel');
		        //IssueNumberLabel.style.visibility = 'hidden';
		        //var IssueNumberForm = document.getElementById('IssueNumberForm');
		        //IssueNumberForm.style.visibility = 'hidden';
		        //var IssueDateLabel = document.getElementById('IssueDateLabel');
		        //IssueDateLabel.style.visibility = 'hidden';
		        //var IssueDateForm = document.getElementById('IssueDateForm');
		        //IssueDateForm.style.visibility = 'hidden';
		        //Container = document.getElementById(o+'_ctlErrorContainer_ErrorContainer');
		        //Container.innerHTML = '';
		        //Container = document.getElementById('PaymentCommentContainer');
		        //b.style.visibility = 'hidden';
		        //Container.style.display = 'block';
		        //var bStepBackPayment = document.getElementById('StepBackPayment');
		        //var bCancelPayment = document.getElementById('CancelPayment');
		        //bStepBackPayment.style.display = 'none';
		        //bCancelPayment.style.display = 'none';
		    }else{
		        Status =  false;
		    }
		    */
        }
	}
}

function ValidRegistration(o){
	Status =  true
	var e = ''
	var pty	= document.getElementsByName('ctrBooking:ctrPassengerInfosBase:CtlPaymentsBase:CtrPaymentsTab_Value').value
	var pm = document.getElementById(o+'_ctlPassengerContactInfo_phone_mobile')
	var ph = document.getElementById(o+'_ctlPassengerContactInfo_phone_home')
	var pb = document.getElementById(o+'_ctlPassengerContactInfo_phone_business')
	var p = trim(pm.value) + trim(ph.value) + trim(pb.value)
	var m = trim(document.getElementById(o+'_ctlPassengerContactInfo_contact_email').value)
	var c = trim(document.getElementById(o+'_ctlPassengerContactInfo_contact_name').value)	
	var il = (document.getElementById('PassengerList').rows.length - pl) / 2
	for (i=1;i<=il ;i++){
		var ln = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_Lastname');		
		var fn = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_Firstname');		
		var wt = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_PassengerWeight');

		//var dn = document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_DateOfBirth')
		//var d = dn.value
		if ((ln != null) && (fn != null)) {
			var l = trim(ln.value);
			var f = trim(fn.value);
			if (l < 2 || f < 1){
				Status =  false;
				e += '<li>Please supply a valid Passenger Name at line ' + (i)+ '</li>'
				ln.className = (l < 2) ? 'error' : '';
				fn.className = (f < 2) ? 'error' : '';
			}
			else if(IfAlphaOnly(ln.value) == false || IfAlphaOnly(fn.value) == false){
				Status =  false;
				e += '<li>Please supply a valid Passenger Name at line ' + (i)+ '</li>'
				ln.className = (IfAlphaOnly(ln.value)) ? '' : 'error';
				fn.className = (IfAlphaOnly(fn.value)) ? '' : 'error';
			}
			else{
				ln.className = ''
				fn.className = ''
			}
		}
		
		if (wt != null) {
			var w = trim(wt.value);
			if (w < 1) {
				Status =  false;
				e += '<li>Please supply a valid Passenger Weight at line ' + (i)+ '</li>';
				wt.className = 'error';
			}
			else{	
				if (isInteger(strim(wt.value)) < 1){
					Status =  false;
					e += '<li>Please supply a valid Passenger Weight at line ' + (i)+ '</li>';
					wt.className = 'error';
				}
				else{
					wt.className = '';
				}
			}
		}
		//if (trim(d) > 0 && Date.isValid(d,DateValid) == false){
		//	Status =  false;
		//	e += '<li>Please supply a valid date of birth at line ' + (i)+ ' ' + DateValidText + '</li>'
		//	dn.className = 'error'
		//}
		//else{
		//	dn.className = ''
		//}
	}		


	if (pt == true){
		for (i=1;i<=il ;i++){
			var p0	= document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_number')		
			var p1	= document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_issue_place')			
			var p2	= document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_expiry_date')			
			var p3	= document.getElementById(o+'_ctlPassengerList_PassengerList__ctl' + i + '_passport_issue_date')			
			
			if (p0 != null) {
				var p0i = trim(p0.value);
				if (ptv == true && p0i < 1){
					Status =  false;
					e += '<li>Please supply a valid Passport Number at line ' + (i)+ '</li>'
					p0.className = (p0i < 1) ? 'error' : '';
				}
				else{
					p0.className = ''
				}
			}
			
			if (p1 != null) {
				var p1i = trim(p1.value)
				if (ptv == true && p1i < 1){
					Status =  false;
					e += '<li>Please supply a valid Issue Place at line ' + (i)+ '</li>'
					p1.className = (p1i < 1) ? 'error' : '';
				}
				else{
					p1.className = ''
				}
			}
			
			if (p2 != null) {
				var	p2v	= p2.value
				// if ((ptv == true || trim(p2v) > 0) && Date.isValid(p2v,DateValid) == false){
				if ((ptv == true || trim(p2v) > 0) && isDateExist(p2v) == false){
					Status =  false;
					e += '<li>' + eMsg[12] + (i -1)+ ' ' + DateValidText + '</li>'
					p2.className = 'error'
				}
				else{
					p2.className = ''
				}
			}
			
			if (p3 != null) {
				var	p3v	= p3.value
				// if ((ptv == true || trim(p3v) > 0) && Date.isValid(p3v,DateValid) == false){
				if ((ptv == true || trim(p3v) > 0) && isDateExist(p3v) == false){
					Status =  false;
					e += '<li>' + eMsg[13] + (i -1)+ ' ' + DateValidText + '</li>'
					p3.className = 'error'
				}
				else{
					p3.className = ''
				}
			}

		}
	}

	if (c==0){
		Status =  false;
		e += "<li>Please supply a valid Contact Person</li>"
		document.getElementById(o+'_ctlPassengerContactInfo_contact_name').className = 'error';
	}
	else{
		document.getElementById(o+'_ctlPassengerContactInfo_contact_name').className = '';
	}
	
	if (p==0){
		Status =  false;
		e += "<li>Please supply a valid Telephone Number</li>"
		pm.className = 'error'
		ph.className = 'error'
		pb.className = 'error'
	}
	else{
		pm.className = ''
		ph.className = ''
		pb.className = ''
	}

	if (m==0){
		Status =  false;
		e += "<li>Please supply a valid Email address</li>"
		document.getElementById(o+'_ctlPassengerContactInfo_contact_email').className = 'error';
	}
	else{
		var email = document.getElementById(o+'_ctlPassengerContactInfo_contact_email').value;
		if (ValidEmail(email)){
			document.getElementById(o+'_ctlPassengerContactInfo_contact_email').className = '';
		} else {
			Status =  false;
			e += "<li>Please supply a valid Email format</li>";
			document.getElementById(o+'_ctlPassengerContactInfo_contact_email').className = 'error';
		}
	}
	
	/*
	if (CcValidation.length > 0 && pty == 'CC') {
		var CcStatus =  true;
		var st = document.getElementById(CcValidation + '_tboStreet')
		var cy = document.getElementById(CcValidation + '_tboCity')
		var sa = document.getElementById(CcValidation + '_tboState')
		var zi = document.getElementById(CcValidation + '_tboZipCode')
		if (trim(st.value) == 0){
			CcStatus =  false;
			st.className = 'error'
		}
		else{
			st.className = ''
		}
		if (trim(cy.value) == 0){
			CcStatus =  false;
			cy.className = 'error'	
		}
		else{
			cy.className = ''		
		}
		if (trim(sa.value) == 0){
			CcStatus =  false;
			sa.className = 'error'
		}
		else{
			sa.className = ''	
		}
		if (trim(zi.value) == 0){
			CcStatus =  false;
			zi.className = 'error'
		}
		else{
			zi.className = ''	
		}
		if (!CcStatus){
			Status =  false;
			e += "<li>Please supply a valid Address</li>"
		}
	}	*/
	if (document.getElementById(o+'_cboConfirm').checked == false){
		Status =  false;
		e += "<li>Please accept Terms and Conditions</li>"
	}
	if (e.length > 0) {
		Container = document.getElementById(o+'_ctlErrorContainer_ErrorContainer')
		Container.innerHTML = 	'<ul>' + e + '</ul>'
	}
	else{
        Container = document.getElementById(o+'_ctlErrorContainer_ErrorContainer')
        Container.innerHTML = 	''
        Container = document.getElementById('PaymentCommentContainer')
        //var b = document.getElementById(o+'_btmSubmitBooking')
        //b.style.visibility = 'hidden'
        Container.style.display = 'block'
	}
}


function CheckPhones(o){
	var pm = document.getElementById(o+'_ctlPassengerContactInfo_phone_mobile')
	var ph = document.getElementById(o+'_ctlPassengerContactInfo_phone_home')
	var pb = document.getElementById(o+'_ctlPassengerContactInfo_phone_business')
	if (goToRow != null){
		var p = trim(pm.value) + trim(ph.value) + trim(pb.value)
			if (p==0){
			pm.className = 'error'
			ph.className = 'error'
			pb.className = 'error'
		}
		else{
			pm.className = ''
			ph.className = ''
			pb.className = ''
		}
	}
}


function ValidEditPassengers(o){
	Status 	=  true;
	var e 	= '';
	var ln 	= document.getElementById(o+'_PassengerList__ctl1_Lastname');
	var fn 	= document.getElementById(o+'_PassengerList__ctl1_Firstname');
	var pw 	= document.getElementById(o+'_PassengerList__ctl1_PassengerWeight');
    var dn = document.getElementById(o+'_PassengerList__ctl1_DateOfBirth');
    var dn_type = document.getElementById(o+'_PassengerList__ctl1_Label2');
    var p2	= document.getElementById(o+'_PassengerList__ctl1_passport_issue_date');
    var p3	= document.getElementById(o+'_PassengerList__ctl1_passport_expiry_date');
    
	if (trim(fn.value) < 1  || IfAlphaOnly(fn.value) == false){
		Status =  false;
		e += '<li>Please supply a valid Firstname</li>'
		fn.className = 'error';
	}else{
		fn.className = ''
	}
	if (trim(ln.value) < 2 || IfAlphaOnly(ln.value) == false){
		Status =  false;
		e += '<li>Please supply a valid Lastname</li>'
		ln.className = 'error';
	}else{
		ln.className = ''
	}
	if (pw != null){
		if (trim(pw.value)==0){
			Status =  false;
			e += "<li>Please supply a valid Passenger Weight</li>"
			pw.className = 'error';
		}else{
			pw.className = '';
		}
	}	
	if (p2 != null) {
        var	p2v	= p2.value;
        if ((ptv == true || trim(p2v) > 0) && isDate(p2v) == false){
            Status =  false;
            e += '<li>Please supply a valid date Issue Date ' + DateValidText + '</li>';
            p2.className = 'error';
        }
        else{
            if (LibDaysDiff(changeToDate(p2v),new Date()) > 0){
                Status =  false;
                e += '<li>Please check your Issue Date! It must be in the past</li>';
                p2.className = 'error';
            }
            else{
                p2.className = '';
            }
        }
    }
	    
    // Expiry Date
    if (p3 != null) {        
        var	p3v	= p3.value;
        if ((ptv == true || trim(p3v) > 0) && isDate(p3v) == false){
            Status =  false;
            e += '<li>Please supply a valid date Expiry Date ' + DateValidText + '</li>';
            p3.className = 'error';
        }
        else{
            if (LibDaysDiff(changeToDate(p3v),new Date()) < 0){
                Status =  false;
                e += '<li>Please check your Expiry Date! It must be in the future</li>';
                p3.className = 'error';
            }
            else{
                p3.className = '';
            }
        }
    }
    
    // Date of Birth
    if (dn != null) {
        var d = dn.value;
        var dt = dn_type.innerHTML;
        if (isDate(d)== false){
            Status =  false;
            e += '<li>' + eMsg[3] + ' ' + DateValidText + '</li>';
            dn.className = 'error';
        }
        else{
            if (LibDaysDiff(changeToDate(d),new Date()) > 0){
                Status =  false;
                e += '<li>' + eMsg[18] + '</li>';
                dn.className = 'error';
            }
            else{
                if (dt == "CHD" || dt == "INF" || dt == "ADULT"){
                    //document.getElementById('star' + i).style.visibility = "visible";
                    if(isDateExist(d)== false){
                        Status =  false;
                        e += '<li>' + eMsg[3] + ' ' + DateValidText + '</li>';
                        dn.className = 'error';
                    }
                    else{
                        //Child  2-11 year
                        //Infant 1-23 month
                        var MIN_CHD_AGE = (2*12);
                        var MAX_CHD_AGE = (11*12);
                        //Child  3-17 year
                        //Infant 1-23 month
                        //var MIN_CHD_AGE = (3*12);
                        //var MAX_CHD_AGE = ((17*12)+11);

                        var MIN_INF_AGE = (1);
                        var MAX_INF_AGE = (23);
                        //var MIN_INF_AGE = (1);
                        //var MAX_INF_AGE = (35);
                            
                        var dd = Number(d.substring(0,2));
                        var mm = Number(d.substring(3,5));
                        var yy = Number(d.substring(6,10));
                            mm = mm - 1;
                        var iDate = new Date(yy,mm,dd);
                        var cDate = new Date();
                        var mmAge = dateDiff("m",iDate,cDate,1,1); 				        
				            
                        //var fDate = document.getElementById('ctrBooking_ctrItineraryBase_ctrItineraryGrid_grdItineraryGrid__ctl0_Td46');
                        //var fDate = document.getElementById('ctrBooking_ctrPassengerInfosBase_ctlBookingInfo_LabDepartureDate');
                        alert("begin");
                        if(dt == "CHD"){
                            if(!((MIN_CHD_AGE<=mmAge)&&(mmAge<=MAX_CHD_AGE))){
                                e += '<li>' + 'Age of child should be between 2-11 years</li>';
                                Status =  false;
                                dn.className = 'error';                            
                            }else{
                                dn.className = '';
                            }
                        }else if(dt == "INF"){
                            if(!((MIN_INF_AGE<=mmAge)&&(mmAge<=MAX_INF_AGE))){
                                e += '<li>' + 'Age of infant should be between 0-23 months</li>';
                                Status =  false;
                                dn.className = 'error';
                            }else{
                                dn.className = '';
                            }
                        }else if(dt == "ADULT"){
                            if(!(MAX_CHD_AGE<mmAge)){
                                e += '<li>' + 'Age of adult should be 12 up years old</li>';
                                Status =  false;
                                dn.className = 'error';
                            }else{
                                dn.className = '';
                            }
                        }
                        alert("ok");
                    }
                }
                else{
                    dn.className = '';
                }
            }
        }
    }
	
	Container = document.getElementById(o+'_PassengerList__ctl2_LabError');
	if (e.length > 0) {
		Container.innerHTML = '<ul>' + e + '</ul>';
	}else{
		Container.innerHTML = '';
		Status = confirm('A fee will be charged if you proceed\n with the name change?');
	}		
}

function trim(s){
	return s.replace(/^\s*|\s*$/g,"").length;
}	

function strim(s){
	return s.replace(/^\s*|\s*$/g,"");
}	

function OnSubmit(){
	if (Status){
		return true;
	}
	else
	{
		Status = true
		return false;
	}

}

function GetSelectFlight(s,j){
	o = document.getElementById(s)
	if (o != null){
		for (i=1;i<=o.rows.length-1;i++){
			if (o.rows[i].id.length > 0) {
				var obj1 = document.getElementById(o.rows[i].id + '_rb')
				var obj2 = document.getElementById(o.rows[i].id + '_label')
				if (obj1 != null) {
					if (obj1.checked)
					{
						var s =  obj2.getAttribute("name").split('|')  //obj2.name.split('|');
						var d = s[j].split(',')
						//	d[0] is Year (value is yyyy)
						//	d[1] is Month (value is 0-11) ** That's why must be minus 1
						//	d[2] is Day (value is 1-31)
						return new Date(d[0],d[1]-1,d[2],d[3],d[4],0)
					}
				}
			}
		}
	}
}

function LibDaysDiff(d1,d2) {
	var z = Date.UTC(Liby2k(d1.getYear()),d1.getMonth(),d1.getDate(),d1.getHours(),d1.getMinutes(),0) - Date.UTC(Liby2k(d2.getYear()),d2.getMonth(),d2.getDate(),d2.getHours(),d2.getMinutes(),0);
	//	var 1hr = -10740 ; //check 1 HR
		if (z  <=0){ 
		if ((z/1000) >= -10740 )
		{
			return ((z/1000/60/60/24)*-1) ;	
		}
		else
		{
			return z/1000/60/60/24;	
		}
		}else
		{
		return z/1000/60/60/24;s
		}
		//old verion check 4 Hr
		//return z/1000/60/60/24;
}

function Liby2k(number) { return (number < 1000) ? number + 1900 : number; }

if (document.getElementById('ctrHome_ctrFlightSearchBase_ctlDepatureDate_cmbDay')!=null) {
//		ChangeCalender('ctrHome_ctrFlightSearchBase_ctlDepatureDate')
//		ChangeCalender('ctrHome_ctrFlightSearchBase_ctlReturnDate')
		ChangeCalender('ctrHome_ctrFlightSearchBase_ctlDepatureDate','')
		ChangeCalender('ctrHome_ctrFlightSearchBase_ctlReturnDate','')

}

function SetAutoFocus(){
	if (AutoFocus != undefined && AutoFocus != ""){
		if (document.getElementById(AutoFocus) != null){
			document.getElementById(AutoFocus).focus();
		}
	}
}

function isValidEmail(str){
	str = strim(str);
	return 	(str.indexOf(".") > 0) &&						// not started with "."
			(str.indexOf("@") > 0) && 						// must consist of "@" and not started with it
			(str.lastIndexOf(".") > str.indexOf("@")) && 	// must have "." after "@"
			(str.lastIndexOf(".") <  str.length - 1);		// not ended with "."
}

function ValidEmail(s){
	var a = false;
	var res = false;
	if(typeof(RegExp) == 'function'){
		var b = new RegExp('abc');
		if(b.test('abc') == true){
			a = true;
		}
	}
	if(a == true){
		//reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_\\\']+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$');
		reg = new RegExp("^([a-zA-Z0-9\\-\\.\\_\\']+)" + "(\\@)([a-zA-Z0-9\\-\\.]+)" + "(\\.)([a-zA-Z]{2,4})$");
		res = (reg.test(s));
	}
	else{
		res = (s.search('@') >= 1 &&
		s.lastIndexOf('.') > s.search('@') &&
		s.lastIndexOf('.') >= s.length-5)
	}
	return(res);
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function getSubCookie(name,parent) {
  var dc = parent;
  var prefix = name + "=";
  var begin = dc.indexOf("&" + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 1;
  var end = parent.indexOf("&", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function CreatePopup(l,p){
	if (p == 'f'){
		CreateWnd('html/FareCode/' + l + '.html', 300, 400, true);
		dgItemLock = true
	}
}

function IsNumeric(value) {
	value = value
	return (!isNaN(value*1) && !IsSpace(value));
}

function IsSpace(value) {
	return (value==' ');
}

function GetCardSubType(CcNumber){
	var l = new Number(CcNumber.slice(0,6))
	var iA = document.getElementById(CcPreselect + '_cbmFormOfPaymentSubtype').options[document.getElementById(CcPreselect + '_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')
	SelectedCardType = iA[0]
	if 	(
			(l >= 413733 && l <= 413737 ) || 
			(l >= 446200 && l <= 446299 ) || 
			(l >= 453978 && l <= 453979) || 
			(l == 454313 ) ||
			(l >= 454432 && l <= 446299 ) || 
			(l == 454742) ||
			(l >= 456725 && l <= 456745 ) || 
			(l >= 465830 && l <= 465879 ) ||
			(l >= 465901 && l <= 465950 ) ||
			(l >= 475110 && l <= 475159 ) ||
			(l >= 475710 && l <= 475759 ) ||
			(l >= 476220 && l <= 476269 ) ||
			(l >= 476340 && l <= 476389 ) ||
			(l >= 484409 && l <= 484410 ) ||
			(l >= 490960 && l <= 490979 ) ||
			(l >= 492181 && l <= 492182 ) ||
			(l == 498824)
		)
	{
		CardType = "VISADRUK"
	}
	else if
		(
			(l  == 424519) ||
			(l >= 424962 && l <= 424963 ) ||
			(l == 450875) ||
			(l >= 484406 && l <= 484408 ) ||
			(l >= 484411 && l <= 484455 ) ||
			(l >= 491730 && l <= 491759 ) ||
			(l == 491880)
		)
	{
		CardType = "VISAELUK"
	}
	else if
		(
			(l >= 448400 && l <= 448699 ) ||
			(l >= 471500 && l <= 471599 )
		)
	{
		CardType = "VISAPU"
	}
	else if
		(
			(l == 490303) ||
			(l == 493698) ||
			(l == 633311) ||
			(l >= 675900 && l <= 675999)
		)
	{
		CardType = "MAESTROUK"
	}
	else if
		(
			(l >= 510000 && l <= 559999)
		)
	{
		CardType = "MC"
	}
	else if
		(
			(l >= 676700 && l <= 676799)
		)
	{
		CardType = "SOLO"
	}
	else if
		(
			(l >= 6180000 && l <= 180099) ||
			(l >= 6213100 && l <= 213199)
		)
	{
		CardType = "JCB"
	}
	else if
		(
			(l >= 352800 && l <= 358999)
		)
	{
		if (SelectedCardType == "DC"){
			CardType = "DC"}
		else if (SelectedCardType == "AMEX"){
			CardType = "AMEX"}
		else{
			CardType = "JCB"
		}
	}
	else if
		(
			(l >= 300000 && l <= 369999)
		)
	{
		if (SelectedCardType == "AMEX"){
			CardType =  "AMEX"}
		else{
			CardType = "DC"
		}
	}
	else if
		(
			(l >= 340000 && l <= 379999)
		)
	{
		if (SelectedCardType == "AMEX"){
			CardType =  "AMEX"}
		else{
			CardType = "JCB"
		}
	}
	else if
		(
			(l >= 300000 && l <= 399999)
		)
	{
		CardType =  "JCB"
	}
	else if
		(
			(l >= 500000 && l <= 509999) ||
			(l >= 560000 && l <= 589999) ||
			(l >= 600000 && l <= 699999)
		)
	{
		CardType = "MAESTRO"
	}
	else if
		(
			(l >= 400000 && l <= 499999) 
		)
	{
		CardType = "VISA"
	}
	else
	{
		CardType = ""
	}
	
	var FeeAmmount = new Number(0)
	for (i=0;i < FeesRcd.length ;i++){
		if (CardType.toUpperCase() == FeesRcd[i].toUpperCase()){
			FeeAmmount = FeesAmmount[i]
		}
	}
	
	var currency = getDynamicCurrency();
	var currency2 = currency;
	if (currency != "")
	{
		currency = currency + " ";
	}
	if (currency2 != "")
	{
		currency2 = " " + currency2;
	}
	
	if (CardType != "" && FeeAmmount > 0){
		var Total = (CcTotalValue + FeeAmmount)
		document.getElementById('CcMessage').innerHTML = 'Your credit card will be debited card charges of ' +  parseCurrency(FeeAmmount.toFixed(2)+'') + currency2 //+ ' Service ' + parseCurrency(Total.toFixed(2)+'')
        if (document.getElementById('bhCcCarges')!= null)
		{
		    document.getElementById('bhCcCarges').innerHTML = currency + parseCurrency(FeeAmmount.toFixed(2)+'')
		}
		if(document.getElementById('bhSummary') != null){
		    document.getElementById('bhSummary').innerHTML = currency + parseCurrency(Total.toFixed(2)+'');
		}
	}
	else
	{
		//var Total = (CcTotalValue + FeeAmmount)
		//document.getElementById('CcMessage').innerHTML = 'Your credit card will be debited card charges of ' + parseCurrency(Total.toFixed(2)+'')
	
	}
	return CardType
}

function isCreditCard(st){
  if (st.length > 19)
    return (false);

  sum = 0; mul = 1; l = st.length;
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }

  if ((sum % 10) == 0)
    return (true);
  else
    return (false);
}

function isVisa(cc){
  if (((cc.length == 16) || (cc.length == 13)) &&
      (cc.substring(0,1) == 4))
    return isCreditCard(cc);
  return false;
}

function isMasterCard(cc){
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 16) && (firstdig == 5) &&
      ((seconddig >= 1) && (seconddig <= 5)))
    return isCreditCard(cc);
  return false;

}

function isAmericanExpress(cc){
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 15) && (firstdig == 3) &&
      ((seconddig == 4) || (seconddig == 7)))
    return isCreditCard(cc);
  return false;

}

function isDinersClub(cc){
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 14) && (firstdig == 3) &&
      ((seconddig == 0) || (seconddig == 6) || (seconddig == 8)))
    return isCreditCard(cc);
  return false;
}

function isCarteBlanche(cc){
  return isDinersClub(cc);
}

function isDiscover(cc){
  first4digs = cc.substring(0,4);
  if ((cc.length == 16) && (first4digs == "6011"))
    return isCreditCard(cc);
  return false;

} 

function isEnRoute(cc){
  first4digs = cc.substring(0,4);
  if ((cc.length == 15) &&
      ((first4digs == "2014") ||
       (first4digs == "2149")))
    return isCreditCard(cc);
  return false;
}

function isJCB(cc){
  first4digs = cc.substring(0,4);
  if ((cc.length == 16) &&
      ((first4digs == "3088") ||
       (first4digs == "3096") ||
       (first4digs == "3112") ||
       (first4digs == "3158") ||
       (first4digs == "3337") ||
       (first4digs == "3528")))
    return isCreditCard(cc);
  return false;
} 

function isAnyCard(cc){
  if (!isCreditCard(cc))
    return false;
  if (!isMasterCard(cc) && !isVisa(cc) && !isAmericanExpress(cc) && !isDinersClub(cc) &&
      !isDiscover(cc) && !isEnRoute(cc) && !isJCB(cc)) {
    return false;
  }
  return true;
} 

function isCardMatch (cardType, cardNumber){
	cardType = cardType.toUpperCase();
	var doesMatch = true;

	if ((cardType == "VISA") && (!isVisa(cardNumber)))
		doesMatch = false;
	if ((cardType == "MASTERCARD") && (!isMasterCard(cardNumber)))
		doesMatch = false;
	if ( ( (cardType == "AMERICANEXPRESS") || (cardType == "AMEX") )
                && (!isAmericanExpress(cardNumber))) doesMatch = false;
	if ((cardType == "DISCOVER") && (!isDiscover(cardNumber)))
		doesMatch = false;
	if ((cardType == "JCB") && (!isJCB(cardNumber)))
		doesMatch = false;
	if ((cardType == "DINERS") && (!isDinersClub(cardNumber)))
		doesMatch = false;
	if ((cardType == "CARTEBLANCHE") && (!isCarteBlanche(cardNumber)))
		doesMatch = false;
	if ((cardType == "ENROUTE") && (!isEnRoute(cardNumber)))
		doesMatch = false;
	return doesMatch;
} 

Date.$VERSION = 1.01;
Date.LZ = function(x){return(x<0||x>9?"":"0")+x};Date.monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');Date.monthAbbreviations = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');Date.dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');Date.dayAbbreviations = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');Date.preferAmericanFormat = true;if(!Date.prototype.getFullYear){Date.prototype.getFullYear = function(){var yy=this.getYear();return(yy<1900?yy+1900:yy);}}
Date.parseString = function(val, format){if(typeof(format)=="undefined" || format==null || format==""){var generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d','MMM-d','d-MMM');var monthFirst=new Array('M/d/y','M-d-y','M.d.y','M/d','M-d');var dateFirst =new Array('d/M/y','d-M-y','d.M.y','d/M','d-M');var checkList=new Array(generalFormats,Date.preferAmericanFormat?monthFirst:dateFirst,Date.preferAmericanFormat?dateFirst:monthFirst);for(var i=0;i<checkList.length;i++){var l=checkList[i];for(var j=0;j<l.length;j++){var d=Date.parseString(val,l[j]);if(d!=null){return d;}}}return null;}
this.isInteger = function(val){for(var i=0;i < val.length;i++){if("1234567890".indexOf(val.charAt(i))==-1){return false;}}return true;};
this.getInt = function(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(this.isInteger(token)){return token;}}return null;};val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var year=new Date().getFullYear();var month=1;var date=1;var hh=0;var mm=0;var ss=0;var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=this.getInt(val,i_val,x,y);if(year==null){return null;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM" || token=="NNN"){month=0;var names =(token=="MMM"?(Date.monthNames.concat(Date.monthAbbreviations)):Date.monthAbbreviations);for(var i=0;i<names.length;i++){var month_name=names[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){month=(i%12)+1;i_val += month_name.length;break;}}if((month < 1)||(month>12)){return null;}}else if(token=="EE"||token=="E"){var names =(token=="EE"?Date.dayNames:Date.dayAbbreviations);for(var i=0;i<names.length;i++){var day_name=names[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=this.getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return null;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=this.getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return null;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return null;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return null;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return null;}i_val+=hh.length;hh++;}else if(token=="kk"||token=="k"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return null;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=this.getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return null;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=this.getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return null;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return null;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return null;}else{i_val+=token.length;}}}if(i_val != val.length){return null;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return null;}}else{if(date > 28){return null;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return null;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}return new Date(year,month-1,date,hh,mm,ss);}
Date.isValid = function(val,format){return(Date.parseString(val,format) != null);}
Date.prototype.isBefore = function(date2){if(date2==null){return false;}return(this.getTime()<date2.getTime());}
Date.prototype.isAfter = function(date2){if(date2==null){return false;}return(this.getTime()>date2.getTime());}
Date.prototype.equals = function(date2){if(date2==null){return false;}return(this.getTime()==date2.getTime());}
Date.prototype.equalsIgnoreTime = function(date2){if(date2==null){return false;}var d1 = new Date(this.getTime()).clearTime();var d2 = new Date(date2.getTime()).clearTime();return(d1.getTime()==d2.getTime());}
Date.prototype.format = function(format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=this.getYear()+"";var M=this.getMonth()+1;var d=this.getDate();var E=this.getDay();var H=this.getHours();var m=this.getMinutes();var s=this.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(+y+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=Date.LZ(M);value["MMM"]=Date.monthNames[M-1];value["NNN"]=Date.monthAbbreviations[M-1];value["d"]=d;value["dd"]=Date.LZ(d);value["E"]=Date.dayAbbreviations[E];value["EE"]=Date.dayNames[E];value["H"]=H;value["HH"]=Date.LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=Date.LZ(value["h"]);value["K"]=value["h"]-1;value["k"]=value["H"]+1;value["KK"]=Date.LZ(value["K"]);value["kk"]=Date.LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=Date.LZ(m);value["s"]=s;value["ss"]=Date.LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
Date.prototype.getDayName = function(){return Date.dayNames[this.getDay()];}
Date.prototype.getDayAbbreviation = function(){return Date.dayAbbreviations[this.getDay()];}
Date.prototype.getMonthName = function(){return Date.monthNames[this.getMonth()];}
Date.prototype.getMonthAbbreviation = function(){return Date.monthAbbreviations[this.getMonth()];}
Date.prototype.clearTime = function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);
return this;}
Date.prototype.add = function(interval, number){if(typeof(interval)=="undefined" || interval==null || typeof(number)=="undefined" || number==null){
return this;}number = +number;if(interval=='y'){this.setFullYear(this.getFullYear()+number);}else if(interval=='M'){this.setMonth(this.getMonth()+number);}else if(interval=='d'){this.setDate(this.getDate()+number);}else if(interval=='w'){var step =(number>0)?1:-1;while(number!=0){this.add('d',step);while(this.getDay()==0 || this.getDay()==6){this.add('d',step);}number -= step;}}else if(interval=='h'){this.setHours(this.getHours() + number);}else if(interval=='m'){this.setMinutes(this.getMinutes() + number);}else if(interval=='s'){this.setSeconds(this.getSeconds() + number);}
return this;}

function ChangeCalenderMonth(o,r,ix){
	ChangeCalender(o,r,ix)
	//RefreshPopup()
}

function parseCurrency(amount){
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}


//FareShopper

/* comment on 27062007
	function ValidFareShopperDate(){
		Status =  true;
		var o1 = 'ctrHome_ctrFlightAvailabilityBase_ctrFareShopperMonthBase_ctrFareShopperMonthOutbound_ctrTikAeroFareShopperMonth'
		var o2 = 'ctrHome_ctrFlightAvailabilityBase_ctrFareShopperMonthBase_ctrFareShopperMonthInbound_ctrTikAeroFareShopperMonth'
		if (DaysDiff(GetCalenderDate(o2),GetCalenderDate(o1)) < 0){
			alert('Please check your Date from ! It has to be equal to or higher than the To Date')
			Status =  false;
		}
	}
*/

function ValidFareShopperDate(){
  var strReturn = 'ctrHome_ctrFlightAvailabilityBase_ctrFareShopperMonthBase_ctrFareShopperMonthInbound_ctrTikAeroFareShopperMonth_calender'
  var oReturnFight = document.getElementById(strReturn)
  if (oReturnFight != null)
  {
		var o1 = 'ctrHome_ctrFlightAvailabilityBase_ctrFareShopperMonthBase_ctrFareShopperMonthOutbound_ctrTikAeroFareShopperMonth'
		var o2 = 'ctrHome_ctrFlightAvailabilityBase_ctrFareShopperMonthBase_ctrFareShopperMonthInbound_ctrTikAeroFareShopperMonth'
		if (DaysDiff(GetCalenderDate(o2),GetCalenderDate(o1)) < 0){
			alert('Please check your Date from ! It has to be equal to or higher than the To Date')
			//return false
			Status =  false;
	}
  }
}

function ShowHideButton(o){
	if(document.getElementById(o + '_btmSearchf') != null ){												
		if(document.getElementById(o + '_tboPromotionCode').value == "" ){
			document.getElementById(o + '_btmSearchf').style.visibility = "";
		}
		else{
			document.getElementById(o + '_btmSearchf').style.visibility = "hidden";
		}
	}
	if(document.getElementById(o + '_btmSearchlf') != null ){
		if(document.getElementById(o + '_tboPromotionCode').value == "" ){
			document.getElementById(o + '_btmSearchlf').style.visibility = "";
		}
		else{
			document.getElementById(o + '_btmSearchlf').style.visibility = "hidden";
		}
	}
}

function InputLimit(o){
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Contact Detail
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
	//--> First Name
	if(o.substring(o.length-9, o.length) == 'firstname'){
		if(document.getElementById(o).value.length > 30){
			document.getElementById('FirstName_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,30);
		}else{
			document.getElementById('FirstName_ErrorMsg').style.visibility = "hidden";
		}	
	}	
	//--> Surname
	if(o.substring(o.length-8, o.length) == 'lastname'){
		if(document.getElementById(o).value.length > 30){
			document.getElementById('Surname_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,30);
		}else{
			document.getElementById('Surname_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Mobile No
	if(o.substring(o.length-12, o.length) == 'phone_mobile'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('MobileNo_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('MobileNo_ErrorMsg').style.visibility = "hidden";
		}	
	}	
	//--> Home No
	if(o.substring(o.length-10, o.length) == 'phone_home'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('HomeNo_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('HomeNo_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Business No
	if(o.substring(o.length-14, o.length) == 'phone_business'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('BusinessNo_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('BusinessNo_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Email
	if(o.substring(o.length-13, o.length) == 'contact_email'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('Email_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('Email_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Address 1
	if(o.substring(o.length-13, o.length) == 'address_line1'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('Address1_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('Address1_ErrorMsg').style.visibility = "hidden";
		}	
	}	
	//--> Address 2
	if(o.substring(o.length-13, o.length) == 'address_line2'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('Address2_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('Address2_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Town/City
	if(o.substring(o.length-4, o.length) == 'city'){
		if(document.getElementById(o).value.length > 25){
			document.getElementById('TownCity_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,25);
		}else{
			document.getElementById('TownCity_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> County
	if(o.substring(o.length-8, o.length) == 'province'){
		if(document.getElementById(o).value.length > 25){
			document.getElementById('County_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,25);
		}else{
			document.getElementById('County_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Zip Code
	if(o.substring(o.length-8, o.length) == 'zip_code'){
		if(document.getElementById(o).value.length > 20){
			document.getElementById('PostalCode_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,20);
		}else{
			document.getElementById('PostalCode_ErrorMsg').style.visibility = "hidden";
		}	
	}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Form of Payment
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
	//--> Name On Card
	if(o.substring(o.length-13, o.length) == 'tboNameOnCard'){
		if(document.getElementById(o).value.length > 30){
			document.getElementById('NameOnCard_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,30);
		}else{
			document.getElementById('NameOnCard_ErrorMsg').style.visibility = "hidden";
		}
	}
	//--> Issue Number
	if(o.substring(o.length-14, o.length) == 'tboIssueNumber'){
		if(document.getElementById(o).value.length > 10){
			document.getElementById('IssueNumber_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,10);
		}else{
			document.getElementById('IssueNumber_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Credit Card Number	
	if(o.substring(o.length-17, o.length) == 'tboDocumentNumber'){
		var errorTxt = '&nbsp; Invalid Card Number or Type';
		var errorMsg = document.getElementById('DocumentNumber_ErrorMsg');
		if(document.getElementById(o).value.length > 6){
			var cardType = CheckCardType(document.getElementById(o).value);
			var iA
			if(document.getElementById('ctrBooking_ctrBookingSummery_CtrPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype') != null){
				iA = document.getElementById('ctrBooking_ctrBookingSummery_CtrPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').options[document.getElementById('ctrBooking_ctrBookingSummery_CtrPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')
			}else{
				iA = document.getElementById('ctrBooking_ctrPassengerInfosBase_CtlPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').options[document.getElementById('ctrBooking_ctrPassengerInfosBase_CtlPaymentsBase_CtlPaymentCreditCard_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')
			}			
			var mi = 15;
			var ma = 19;
			if (iA.length > 0 ){
				if(iA[0] == 'AMEX'){
					if(cardType =='AMEX'){
						mi = 15;
						ma = 15;
						if(document.getElementById(o).value.length > ma){
							errorMsg.innerHTML = "&nbsp; max " +ma+ " characters";
							errorMsg.style.visibility = "";
							document.getElementById(o).value  = document.getElementById(o).value.substring(0,ma);
						}
						else{
							errorMsg.style.visibility = "hidden";
						}
					}
					else{
						errorMsg.innerHTML = errorTxt;
						errorMsg.style.visibility = "";
					}
				}
				else 	if(iA[0] == 'ELECTRON'){
					if(cardType =='VISADRUK' || cardType =='VISAELUK'){
						mi = 16;
						ma = 19;
						if(document.getElementById(o).value.length > ma){
							errorMsg.innerHTML = "&nbsp; max " +ma+ " characters";
							errorMsg.style.visibility = "";
							document.getElementById(o).value  = document.getElementById(o).value.substring(0,ma);
						}
						else{
							errorMsg.style.visibility = "hidden";
						}
					}
					else{
						errorMsg.innerHTML = errorTxt;
						errorMsg.style.visibility = "";
					}
				}
				else 	if(iA[0] == 'MAESTRO'){
					if(cardType =='MAESTRO' || cardType =='MAESTROUK' || cardType =='SOLO'){
						mi = 16;	
						ma = 19;
						if(document.getElementById(o).value.length > ma){
							errorMsg.innerHTML = "&nbsp; max " +ma+ " characters";
							errorMsg.style.visibility = "";
							document.getElementById(o).value  = document.getElementById(o).value.substring(0,ma);
						}
						else{
							errorMsg.style.visibility = "hidden";
						}
					}
					else{
						errorMsg.innerHTML = errorTxt;
						errorMsg.style.visibility = "";
					}
				}
				else 	if(iA[0] == 'MC'){
					if(cardType =='MC' || cardType =='VISADRUK' || cardType =='VISAELUK' || cardType =='VISAPU' || cardType =='VISAPU'){
						mi = 16;
						ma = 16;
						if(document.getElementById(o).value.length > ma){
							errorMsg.innerHTML = "&nbsp; max " +ma+ " characters";
							errorMsg.style.visibility = "";
							document.getElementById(o).value  = document.getElementById(o).value.substring(0,ma);
						}
						else{
							errorMsg.style.visibility = "hidden";
						}
					}
					else{
						errorMsg.innerHTML = errorTxt;
						errorMsg.style.visibility = "";
					}
				}
				else if(iA[0] == 'VISA'){
					if(cardType =='VISA' || cardType =='VISADRUK' || cardType =='VISAELUK' || cardType =='VISAPU' || cardType =='VISAPU'){
						mi = 16;
						ma = 19;
						if(document.getElementById(o).value.length > ma){
							errorMsg.innerHTML = "&nbsp; max " +ma+ " characters";
							errorMsg.style.visibility = "";
							document.getElementById(o).value  = document.getElementById(o).value.substring(0,ma);
						}
						else{
							errorMsg.style.visibility = "hidden";
						}
					}
					else{
						errorMsg.innerHTML = errorTxt;
						errorMsg.style.visibility = "";
					}
				}
			}
		}
		else{
			errorMsg.style.visibility = "hidden";
		}
	}	
	//--> Address 1
	if(o.substring(o.length-9, o.length) == 'tboStreet'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('Address1_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('Address1_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Address 2
	if(o.substring(o.length-9, o.length) == 'tboStreet2'){
		if(document.getElementById(o).value.length > 60){
			document.getElementById('Address2_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,60);
		}else{
			document.getElementById('Address2_ErrorMsg').style.visibility = "hidden";
		}	
	}	
	//--> Town/City
	if(o.substring(o.length-7, o.length) == 'tboCity'){
		if(document.getElementById(o).value.length > 25){
			document.getElementById('TownCity_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,25);
		}else{
			document.getElementById('TownCity_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> County
	if(o.substring(o.length-8, o.length) == 'tboState'){
		if(document.getElementById(o).value.length > 25){
			document.getElementById('County_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,25);
		}else{
			document.getElementById('County_ErrorMsg').style.visibility = "hidden";
		}	
	}
	//--> Zip Code
	if(o.substring(o.length-10, o.length) == 'tboZipCode'){
		if(document.getElementById(o).value.length > 20){
			document.getElementById('PostalCode_ErrorMsg').style.visibility = "";
			document.getElementById(o).value  = document.getElementById(o).value.substring(0,20);
		}else{
			document.getElementById('PostalCode_ErrorMsg').style.visibility = "hidden";
		}
	}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
}

function ConfirmCancelFlight_Refund(){
	return confirm('Are you sure you want to cancel this flight? Your booking will be cancelled and your credit card refunded.');
}
function ConfirmCancelFlight_NoneRefund(){
	return confirm('Are you sure you want to cancel this flight?');
}
function HideSelectFlightChange(o)
{
    var ctlSubmit = document.getElementById(o + '_btmSubmitFlightSelect');
    if (ctlSubmit != null)
    {
        ctlSubmit.style.visibility='hidden';
    }
}

function ToggleDisplayClientName(){
	var ctrLabelLogonName = document.getElementById("ctrPageHeader_labLogonName");
	if(ctrLabelLogonName != null){
		if(trimString(ctrLabelLogonName.innerHTML) == ""){
			var divWrapperHeader03 = document.getElementById("wrapperHeader03");
			if(divWrapperHeader03 != null){
				divWrapperHeader03.style.display = "none";
			}
		}
	}	
}

function trimString(str){
	var trimmed = str.replace(/^\s+|\s+$/g, '');
	return trimmed;
}

//ToggleDisplayClientName();

function getDynamicCurrency(){
	var objSpanDynamicCurrency = document.getElementById("ctrBooking_ctrPassengerInfosBase_ctlBookingInfo_LabDynamicCurrency");
	var Currency = "";
	if (objSpanDynamicCurrency != null)
	{
		Currency = objSpanDynamicCurrency.innerHTML;
	}
	return Currency;
}

/* Start new function for calculate Age */
function checkleapyear(datea)
{
	if(datea.getYear()%4 == 0)
	{
		if(datea.getYear()% 10 != 0)
		{
			return true;
		}
		else
		{
			if(datea.getYear()% 400 == 0)
				return true;
			else
				return false;
		}
	}
    return false;
}
function DaysInMonth(Y, M) {
    with (new Date(Y, M, 1, 12)) {
        setDate(0);
        return getDate();
    }
}
function datediff(date1, date2) {
    var y1 = date1.getFullYear(), m1 = date1.getMonth(), d1 = date1.getDate(),
	 y2 = date2.getFullYear(), m2 = date2.getMonth(), d2 = date2.getDate();
	    if (d1 < d2) {
        m1--;
        d1 += DaysInMonth(y2, m2);
    }
    if (m1 < m2) {
        y1--;
        m1 += 12;
    }
    return [y1 - y2, m1 - m2, d1 - d2];
}

function calculateAge(birthdate)
{
	var lblDepartureDate = document.getElementById('ctrBooking_ctrPassengerInfosBase_ctlBookingInfo_LabDepartureDate');
	var allDepartureDate = lblDepartureDate.innerHTML.split('/');
	var dat = new Date();
	dat.setFullYear(allDepartureDate[2], convertToFullInt(allDepartureDate[1])-1, convertToFullInt(allDepartureDate[0]));
	var curday = dat.getDate();
	var curmon = dat.getMonth()+1;
	var curyear = dat.getFullYear();
    
    var allbirthday = birthdate.split('/');
	var calday = allbirthday[0];
	var calmon = allbirthday[1];
	var calyear = allbirthday[2];
	
	var curd = new Date(curyear,curmon-1,curday);
	var cald = new Date(calyear,calmon-1,calday);
	
	var diff =  Date.UTC(curyear,curmon,curday,0,0,0) - Date.UTC(calyear,calmon,calday,0,0,0);
	var dife = datediff(curd,cald);
	return dife[0];
}

function convertToFullInt(dvalue)
{
    return parseInt(dvalue);
}
/* End new function for calculate Age */


