//JavaScript Document

function trim(str)

{

	return((""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );

}

function isSpchar(value){

	var iChars = "!@#$%^&*()+=-[]\';,./{}|\":<>?";

	for (var i = 0; i < value.length; i++) {

		if (iChars.indexOf(value.charAt(i)) != -1)

		{

			return true;

		}

	}

	return false;

}

function isNumber(str){

//	var filter=/^[\d]+$/;

	var filter=/^[0-9]+$/;

	if(filter.test(trim(str)))

		return true;

	else

		return false;

}

function isNum(value){

	var iChars = "0123456789";

	for (var i = 0; i < value.length; i++) {

		if (iChars.indexOf(value.charAt(i)) != -1)

		{

			return true;

		}

	}

	return false;

}

function isValidEmail(value){

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	if(filter.test(trim(value)))

		return true;

	else

		return false;

}

function toogleElement(EleName,style){

	var objEle = document.getElementById(EleName);

	if(objEle)

		objEle.style.display=style;

}

function showPGWError(msg){
	showPGWStatus(msg,'statusErr');
}

function showPGWStatus(msg,type){
	
	var ele = document.getElementById('msgPg');
	ele.innerHTML = msg;
	ele.className = type;

	toogleElement('msgPg','block');
	try{
	increaseHeight()
	}catch(e){}
}

function showNotification(msg){

	showStatus(msg,'statusMsg');

}

function showError(msg){

	showStatus(msg,'statusErr');

}

function showStatus(msg,type){

	var ele = document.getElementById('msg');

	ele.innerHTML = msg;

	ele.className = type;

	toogleElement('msg','block');

	try{

		increaseHeight()

	}catch(e){}

}

function showPNRError(msg){

	showPNRStatus(msg,'statusErr');

}

function showPNRStatus(msg,type){

	var ele = document.getElementById('pnrmsg');

	ele.innerHTML = msg;

	ele.className = type;

	toogleElement('pnrmsg','block');

}

function showPNRNotification(msg){

	showPNRStatus(msg,'statusMsg');

}

function showTravelError(msg){

	showTravelStatus(msg,'statusErr');

}

function showTravelStatus(msg,type){

	var ele = document.getElementById('travelmsg');

	ele.innerHTML = msg;

	ele.className = type;

	toogleElement('travelmsg','block');

}

function showTravelNotification(msg){

	showTravelStatus(msg,'statusMsg');

}



function hideStatus(){

	toogleElement('msg','none');

}

function changeError(id){

	document.getElementById(id).style.borderStyle="solid";

	document.getElementById(id).style.borderColor="red";

}

function changeProper(id){

	document.getElementById(id).style.borderStyle="";

	document.getElementById(id).style.borderColor="";

}

function showThanks(formdiv){

	toogleElement(formdiv,'none');

	toogleElement('thanks','block');

}

function showform(url){

	location=url;

}

/**

Function to validate the Busticket form on the homepage

 */

function valForm_ticket()

{

	var fromcity = document.getElementById("fromcity").value;

	var tocity = document.getElementById("tocity").value;

	var depdate= document.getElementById("departDate").value;

	var oneWay= document.getElementById("single").checked;

//	alert(fname);

	if(fromcity==""){

		showError("Please select FROM city.");

		document.getElementById("fromcity").focus();

		changeError('fromcity')

		return false;

	}

	else{

		changeProper('fromcity')

	}



	if(tocity==""){

		showError("Please select TO city.");

		document.getElementById("tocity").focus();

		changeError('tocity')

		return false;

	}

	else{

		changeProper('tocity')

	}

	if(trim(fromcity) == trim(tocity) )

	{

		showError("The FROM city and the TO city cannot be the same");

		document.getElementById("fromcity").focus();

		changeError('fromcity')

		changeError('tocity')

		return false;

	}

	else{

		changeProper('fromcity')

		changeProper('tocity')

	}



	if(depdate=="" || depdate=="dd-mm-yyyy"){

		showError("Departure date cannot be blank");

		document.getElementById("departDate").focus();

//		document.getElementById("departDate").value="";

		changeError('departDate')

		return false;

	}

	else{

		changeProper('departDate')

	}

	if((fromcity=='Bangalore' && tocity=='Bangalore Intl Airport') || (fromcity=='BangaloreIntlAirport' && tocity=='Bangalore')){

		showTravel();

		return false;

	}

	toogleElement('msg','none')

	showConfirm('preloaderDiv');

}

/**

Function to validate the car and bus details form

 */

function valForm_carbus(theform)

{

	var name = document.getElementById("name").value;

	var emailid = document.getElementById("emailid").value;

	var mobile= document.getElementById("mobile").value;

	var fromcity = document.getElementById("fromcity").value;

	var tocity = document.getElementById("tocity").value;

	var depdate= document.getElementById("departDate").value;

	var comments= document.getElementById("comments").value;

//	alert(fname);

	if(name==""){

		showError("Please specify passenger's name.");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}else{

		changeProper('name')

	}





	if(emailid==""){

		showError("Please specify a valid email address");

		document.getElementById("emailid").focus();

		changeError('emailid')

		return false;

	}else

		if(!isValidEmail(emailid))

		{

			showError("Please specify a valid email address");

			document.getElementById("emailid").focus();

			changeError('emailid')

			return false;

		}else{

			changeProper('emailid')

		}

	if(mobile=="" || mobile.length > '10'){

		showError("Please enter a valid mobile number. The number should be of 10 digits");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else{

		changeProper('mobile')

	}

	if(!isNumber(mobile))

	{

		showError("Please enter a valid mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else{

		changeProper('mobile')

	}

	if(fromcity==""){

		showError("The FROM city cannot be blank");

		document.getElementById("fromcity").focus();

		changeError('fromcity')

		return false;

	}else{

		changeProper('fromcity')

	}

	if(tocity==""){

		showError("The TO city cannot be blank");

		document.getElementById("tocity").focus();

		changeError('tocity')

		return false;

	}else{

		changeProper('tocity')

	}

	if(depdate=="" || depdate=="dd-mm-yyyy"){

		showError("The departure Date cannot be blank");

		document.getElementById("departDate").focus();

		changeError('departDate')

		return false;

	}

	else{

		changeProper('departDate')

	}

	if(comments==""){

		showError("Please specify some comments");

		document.getElementById("comments").focus();

		changeError('comments')

		return false;

	}else{

		changeProper('comments')

	}

	showThanks(theform)

//	showNotification("Thank you for your request. We will get back to you shortly.");



}

/**

Function to validate the hotels details form

 */

function valForm_hotel(theform)

{

	var name = document.getElementById("name").value;

	var emailadd = document.getElementById("emailadd").value;

	var mobile= document.getElementById("mobile").value;

	var depdate= document.getElementById("departDate").value;

	var retdate= document.getElementById("returnDate").value;

	var city = document.getElementById("tocity").value;

	var comments= document.getElementById("comments").value;



	if(name==""){

		showError("Please specify customer's name");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}else if(isNum(name)){

//		alert("name " + name);

		showError("Numbers are not allowed in the name");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}

	else if(isSpchar(name)){

		showError("Special characters are not allowed in the name");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}

	else{

		changeProper('name')

	}

	if(emailadd==""){

		showError("Please specify a valid email address.");

		document.getElementById("emailadd").focus();

		changeError('emailadd')

		return false;

	}

	else{

		changeProper('emailadd')

	}

	if(!isValidEmail(emailadd))

	{

		showError("Please specify a valid email address.");

		document.getElementById("emailadd").focus();

		changeError('emailadd')

		return false;

	}

	else{

		changeProper('emailadd')

	}

	if(mobile=="" || mobile.length != '10'){

		showError("Please enter a valid mobile number. The number should be of 10 digits.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}

	else{

		changeProper('mobile')

	}

	if(!isNumber(mobile))

	{

		showError("Please enter a valid mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}

	else{

		changeProper('mobile')

	}



	if(depdate=="" || depdate=="dd-mm-yyyy"){

		showError("The Check Inn date cannot be blank");

		document.getElementById("departDate").focus();

//		document.getElementById("departDate").value="";

		changeError('departDate')

		return false;

	}

	else{

		changeProper('departDate')

	}

	if(retdate=="" || retdate=="dd-mm-yyyy"){

		showError("The Check Out date cannot be blank");

		document.getElementById("returnDate").focus();

//		document.getElementById("returnDate").value="";

		changeError('returnDate')

		return false;

	}else if(retdate!=""){

		var fromTemp2 = depdate.replace(/-/,"/");

		var from = fromTemp2.replace(/-/,"/");

		var toTemp2 = retdate.replace(/-/,"/");

		var to = toTemp2.replace(/-/,"/");

		var check = doDateCheck(from, to);

		if(!check){

			showError("Check out date should be greater than or equal to Check Inn date.");

			changeError('returnDate')

			return false;

		}else {

			changeProper('returnDate')

		}

	}



	if(city ==""){

		showError("The City cannot be blank");

		document.getElementById("tocity").focus();

		changeError('tocity')

		return false;

	}

	else{

		changeProper('tocity')

	}

	if(comments==""){

		showError("Please specify some comments");

		document.getElementById("comments").focus();

		changeError('comments')

		return false;

	}

	else{

		changeProper('comments')

	}

	showThanks(theform)

}







function disableTo() {

	if(!document.getElementById("single").checked)

	{

		enableTo();

	}

	else

	{

		document.tab1_form.returnDate.disabled=true;

//		document.tab1_form.returnDateImg.onclick="";

	}

}

function enableTo() {

	document.tab1_form.returnDate.disabled=false;

//	document.tab1_form.returnDateImg.onClick="function abc()";

//	alert("123");

}

function openReturnDateFrame() {

	if(document.form1.returnDate.disabled) {

//		return false;

	} else {

		OpenFrame('returnDate','anchor2x','dd-MM-yyyy');

	}

}

function doDateCheck(from, to) {

	var fromTemp = from;

	var fdd = fromTemp.slice(0,2);

	var fmm = fromTemp.slice(3,5);

	var fyy = fromTemp.slice(6,10);

	var toTemp = to;

	var tdd = toTemp.slice(0,2);

	var tmm = toTemp.slice(3,5);

	var tyy = toTemp.slice(6,10);

	var fromDate = new Date(fyy,fmm,fdd);

	var toDate = new Date(tyy,tmm,tdd);

	if (fromDate > toDate) {

//		alert("Return date should be greater than the Departure date.");

		return false;

	}

	else{

		return true;

	}

}


function valForm_PNRTA(){

	var pnrno = document.getElementById("pnrno").value;


	if(pnrno==""){

		showPNRError("Please specify a PNR number.");

		document.getElementById("pnrno").focus();

		changeError('pnrno')

		return false;

	}else {

		changeProper('pnrno')

	}

	if(pnrno.length < '6'){

		showPNRError("Please specify a valid 6 digit PNR No.");

		document.getElementById("pnrno").focus();

		changeError('pnrno')

		return false;

	}else {

		changeProper('pnrno')

	}



	showPNRNotification("Please wait Getting passenger's Booking Details");

	//if(document.getElementById('helpline').checked == true){

	//location='RetrieveBookingDirect.do?pageId=32&eventId=2&pnrno='+pnrno+'&isretrivebooking=true&showScript=false'

	//}

	//else{

	location='RetrieveBookingDirect.do?pageId=31&eventId=2&pnrnumber='+pnrno+'&isretrivebooking=true&showScript=false'

	//}

}


function valForm_PNR(){

	var pnrno = document.getElementById("pnrno").value;

	var mobile = document.getElementById("mobile").value;

	if(pnrno==""){

		showPNRError("Please specify a PNR number.");

		document.getElementById("pnrno").focus();

		changeError('pnrno')

		return false;

	}else {

		changeProper('pnrno')

	}

	if(pnrno.length < '6'){

		showPNRError("Please specify a valid 6 digit PNR No.");

		document.getElementById("pnrno").focus();

		changeError('pnrno')

		return false;

	}else {

		changeProper('pnrno')

	}

	if(mobile==""){

		showPNRError("Please specify a mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else {

		changeProper('mobile')

	}

	if(!isNum(mobile))

	{

		showPNRError("Please specify a valid mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else {

		changeProper('mobile')

	}

	if(mobile.length<10 || mobile.length>10)

	{

		showPNRError("Please specify a 10 digit mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else {

		changeProper('mobile')

	}

	showPNRNotification("Please wait Getting passenger's Booking Details");

//	if(document.getElementById('helpline').checked == true){

//	location='RetrieveBookingDirect.do?pageId=32&eventId=2&pnrno='+pnrno+'&isretrivebooking=true&showScript=false'

//	}

//	else{

	location='RetrieveBookingDirect.do?pageId=31&eventId=2&pnrnumber='+pnrno+'&mobilenumber='+mobile+'&isretrivebooking=true&showScript=false'

//	}

}



function valForm_HotSeat(){

	var paxno = document.getElementById("paxno").value;

	var seattype = document.getElementById("seattype").value;

	var valid = document.getElementById("valid").value;

	var currdate = document.getElementById("currdate").value;

	var fromstophotseat = document.getElementById("fromstophotseat"+valid).value;

	var tostophotseat = document.getElementById("tostophotseat"+valid).value;

	var fromstopidhotseat = document.getElementById("fromstopidhotseat"+valid).value;

	var tostopidhotseat = document.getElementById("tostopidhotseat"+valid).value;

//	location='RetrieveBookingDirect.do?pageId=31&eventId=2&pnrnumber='+pnrno+'&isretrivebooking=true'

	location='Search.do?pageId=18&eventId=1&isRoundTrip=0&fromcity='+fromstophotseat+'&tocity='+tostophotseat+'&departureDate='+currdate+'&noOfPassenger='+paxno+'&seatType='+seattype+'&departureTime=-1&returnTime=-1&busType=-1&fromStopId='+fromstopidhotseat+'&toStopId='+tostopidhotseat+'&hotseatclicktracing=true'

}

function valForm_Travel(){

	var login = document.getElementById("login").value;

	if(login=="-1" || login==""){

		showTravelError("Please Select Departure Time Range");

		document.getElementById("login").focus();

		changeError('login')

		return false;

	}else {

		changeProper('login')

	}

	document.getElementById("departureTime").value=login;

	document.tab1_form.submit();

//	location='http://localhost:8084/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=0&bus_from=BangaloreIntlAirport&fromcity=BangaloreIntlAirport&tocity=Bangalore&departureDate=19-09-2008&noOfPassenger=1&seatType=Seat&departureTime=2&returnTime=-1&busType=-1&fromStopId=1457&toStopId=343&departureTime=2'

//	showTravelError("Invalid Login ID or Password");

}

/**

Function to validate the passenger details form on the homepage

 */

function val_pd(agentId){

//	alert("Calling");

	var mytitle = document.getElementById("contact_title").value
//	alert("mytitle===>"+mytitle);


	var cfname = document.getElementById("cfname").value;

	var clname = document.getElementById("clname").value;

	var email2 = document.getElementById("email2").value;

//	var paymentMode = document.getElementById("paymentMode").value;



	/*try{var day = document.getElementById("day").value;

	var month = document.getElementById("month").value;

	var year = document.getElementById("year").value;

	}

	catch(e){}
*/
	var mobile = document.getElementById("mobileNo").value;
//	alert("mob===>"+mobile);
	var address = document.getElementById("address").value;

//	var pin = document.getElementById("pin").value;

	var mymsg = document.getElementById("msg");

	var shiftDiv = document.getElementById("contactInfoDiv");

	/*

Check Contact Details

	 */

	if(trim(mytitle).length < 1 || mytitle =="") {

		showError("Please specify passenger's title.");

		scrollIntoView(mymsg);

//		alert(document.getElementById('contact_info'));

		document.getElementById("contact_title").focus();

		changeError('contact_title')

		return false;

	}

	else{

		changeProper('contact_title')

	}





	if(trim(cfname).length < 1 || cfname =="first name"){

		showError("Please specify passenger's first name.");

		mymsg.scrollIntoView();

		document.getElementById("cfname").focus();

		changeError('cfname')

		return false;

	}else if(isNum(cfname)){

//		alert("name " + name);

		showError("Numbers are not allowed in first name.");

		scrollIntoView(mymsg);

//		mymsg.scrollIntoView();

		document.getElementById("cfname").focus();

		changeError('cfname')

		return false;

	}

	else if(isSpchar(cfname)){

		showError("Special characters not allowed in first name.");

		scrollIntoView(mymsg);



		document.getElementById("cfname").focus();

		changeError('cfname')

		return false;

	}

	else{

		changeProper('cfname')

	}



	if(trim(clname).length < 1 || clname =="last name") {

		showError("Please specify passenger's last name.");

		scrollIntoView(mymsg);



		document.getElementById("clname").focus();

		changeError('clname')

		return false;

	}else if(isNum(clname)){

//		alert("name " + name);

		showError("Numbers are not allowed in last name.");

		scrollIntoView(mymsg);



		document.getElementById("clname").focus();

		changeError('clname')

		return false;

	}

	else if(isSpchar(clname)){

		showError("Special characters not allowed in the last name.");

		scrollIntoView(mymsg);



		document.getElementById("clname").focus();

		changeError('clname')

		return false;

	}

	else{

		changeProper('clname')

	}

	if(mobile=="" || mobile.length != '10'){

		showError("Please enter a valid mobile number. The number should be of 10 digits.");

		scrollIntoView(mymsg);

		document.getElementById("mobileNo").focus();

		changeError('mobileNo')

		return false;

	}else{

		changeProper('mobileNo')

	}



	if(!isNumber(mobile))

	{

		showError("Please enter a valid mobile number.");

		scrollIntoView(mymsg);

		document.getElementById("mobileNo").focus();

		changeError('mobileNo')

		return false;

	}else{

		changeProper('mobileNo')

	}


if(agentId==1000){
	if(email2==""){

		showError("Please specify passenger's email address. A copy of e-ticket will be sent on this email.");

		scrollIntoView(mymsg);



		document.getElementById("email2").focus();

		changeError('email2')

		return false;

	}else {

		changeProper('email2')

	}

	if(!isValidEmail(email2))

	{

		showError("Please specify a valid email address. A copy of e-ticket will be sent on this email.");

		scrollIntoView(mymsg);



		document.getElementById("email2").focus();

		changeError('email2')

		return false;

	}else {

		changeProper('email2')

	}
}

	/** day condition added by rajesh to check null for request booking***/

	/*if(document.getElementById("day")!=null){

		if(trim(day).length < 1 || day =="") {

			showError("Please specify passenger's day of birth.");

			scrollIntoView(mymsg);



			document.getElementById("day").value="";

			document.getElementById("day").focus();

			changeError('day')

			return false;

		}

		else{

			changeProper('day')

		}

	}

	*//** month condition added by rajesh to check null for request booking***//*

	if(document.getElementById("month")!=null){

		if(trim(month).length < 1 || month =="") {

			showError("Please specify passenger's month of birth.");

			scrollIntoView(mymsg);



			document.getElementById("month").value="";

			document.getElementById("month").focus();

			changeError('month')

			return false;

		}

		else{

			changeProper('month')

		}

	}

	*//** year condition added by rajesh to check null for request booking***//*

	if(document.getElementById("year")!=null){

		if(trim(year).length < 1 || year =="") {

			showError("Please specify passenger's year of birth.");

			scrollIntoView(mymsg);



			document.getElementById("year").value="";

			document.getElementById("year").focus();

			changeError('year')

			return false;

		}

		else{

			changeProper('year')

		}

	}*/

	if(trim(address).length < 1 || address =="") {
		document.getElementById("address").value="Not Available";
	}



	if(document.getElementById("paymentMode")!==null){

		var paymentMode = document.getElementById("paymentMode").value;

		if(paymentMode == 0) {

			showPGWError("Please select a valid payment method.");

			//scrollIntoView(mymsg);

			//document.anchors[0].scrollIntoView();

			document.getElementById("paymentMode").focus();

			changeError('paymentMode')

			return false;
		}else{
			changeProper('paymentMode')
		}

	}





	toogleElement('msg','none')

	if(document.getElementById("processme").style.display == 'none')

	{

		document.getElementById("processme").style.display = 'block';

	}

	else

	{

		document.getElementById("processme").style.display = 'none';

	}

	if(!ValidatePassengerInfoTitle()){

		return false;

	}
	document.getElementById("payNow").disabled=true;
	commonGenderTest();
	return false;
}



/*

Funciton to check promo code

 */

function Promo(proname,val,isRoundTrip,ticketType,ticketTypeForReturn){

	var provalue=proname.checked;

	if(isRoundTrip=="1")

	{



		if(provalue)

		{

			document.getElementById("applyDiscount").style.display="";

			if(ticketType.toLowerCase()=="book")

			{

				for(var i=0;i<val;i++)

				{

					document.getElementById("p1_pmc"+i).style.visibility="visible";

				}

				document.getElementById("pm_t").style.visibility="visible";

			}

			if(ticketTypeForReturn.toLowerCase()=="book")

			{

				for(var i=0;i<val;i++)

				{

					document.getElementById("p1_rpmc"+i).style.visibility="visible";

				}

				document.getElementById("rpm_t").style.visibility="visible";

			}

//			for(var i=0;i<val;i++){

//			document.getElementById("p1_pmc"+i).style.visibility="visible";

//			document.getElementById("p1_rpmc"+i).style.visibility="visible";

//			document.getElementById("p1_pmc1").style.visibility="visible";

//			document.getElementById("p2_pmc").style.visibility="visible";

//			document.getElementById("p1_rpmc1").style.visibility="visible";

//			}

//			document.getElementById("p1_pmc2").style.visibility="visible";

//			document.getElementById("p1_rpmc2").style.visibility="visible";

//			document.getElementById("p2_rpmc").style.visibility="visible";

//			document.getElementById("pm_t").style.visibility="visible";

//			document.getElementById("rpm_t").style.visibility="visible";

		}

		else{

			document.getElementById("applyDiscount").style.display="none";

//			document.getElementById("p1_pmc").disabled=true;

			/*document.getElementById("p1_pmc").style.visibility="hidden";

document.getElementById("p2_pmc").style.visibility="hidden";

document.getElementById("p1_rpmc").style.visibility="hidden";

document.getElementById("p2_rpmc").style.visibility="hidden"; */

			if(ticketType.toLowerCase()=="book")

			{

				for(var i=0;i<val;i++)

				{

					document.getElementById("p1_pmc"+i).style.visibility="visible";

				}

				document.getElementById("pm_t").style.visibility="visible";

			}

//			for(var i=0;i<val;i++){

//			document.getElementById("p1_pmc"+i).style.visibility="hidden";

//			document.getElementById("p1_rpmc"+i).style.visibility="hidden";

//			document.getElementById("p1_pmc1").style.visibility="hidden";

//			document.getElementById("p2_pmc").style.visibility="visible";

//			document.getElementById("p1_rpmc1").style.visibility="hidden";

//			document.getElementById("p1_pmc2").style.visibility="hidden";

//			document.getElementById("p1_rpmc2").style.visibility="hidden";

//			}

//			document.getElementById("pm_t").style.visibility="hidden";

//			document.getElementById("rpm_t").style.visibility="hidden";

		}

	}else{

		if(provalue){

			document.getElementById("applyDiscount").style.display="";

			for(var i=0;i<val;i++)

			{

				document.getElementById("p1_pmc"+i).style.visibility="visible";

				document.getElementById("p1_rpmc"+i).style.visibility="hidden";

			}

			document.getElementById("pm_t").style.visibility="visible";

			document.getElementById("rpm_t").style.visibility="hidden";

		}else{document.getElementById("applyDiscount").style.display="none";

		for(var i=0;i<val;i++)

		{

			document.getElementById("p1_pmc"+i).style.visibility="hidden";

		}

		document.getElementById("pm_t").style.visibility="hidden";

		}

	}

	if(document.getElementById("pmc").checked){

		document.getElementById("promo_record").style.display = '';

	}else{

		document.getElementById("promo_record").style.display = 'none';

		for(var i=0;i<val;i++)

		{

			document.getElementById("p1_pmc"+i).style.visibility="hidden";

			document.getElementById("p1_rpmc"+i).style.visibility="hidden";

		}

		document.getElementById("pm_t").style.visibility="hidden";

		document.getElementById("rpm_t").style.visibility="hidden";

	}



}

/*

Funciton to validate Request booking form

 */

function val_req_pd(){

	var mytitle = document.getElementById("contact_title").value

	var cfname = document.getElementById("cfname").value;

	var clname = document.getElementById("clname").value;

	var email1 = document.getElementById("email2").value;

	var address = document.getElementById("address").value;

	var mobile = document.getElementById("mobile").value;

	if(trim(mytitle).length < 1 || mytitle =="") {

		showError("Please specify passenger's title ");

		scrollIntoView(mymsg);

		document.getElementById("contact_title").focus();

		changeError('contact_title')

		return false;

	}

	else{

		changeProper('contact_title')

	}

	if(trim(cfname).length < 1 || cfname =="first name") {

		showError("Please specify passenger's first name ");

		document.getElementById("cfname").value="";

		document.getElementById("cfname").focus();

		changeError('cfname')

		return false;

	}

	else{

		changeProper('cfname')

	}

	if(trim(clname).length < 1 || clname =="last name") {

		showError("Please specify passenger's last name");

		document.getElementById("clname").value="";

		document.getElementById("clname").focus();

		changeError('clname')

		return false;

	}

	else{

		changeProper('clname')

	}

	if(trim(email1).length < 1){

		showError("Please specify a valid email address.");

		document.getElementById("email1").focus();

		changeError('email1')

		return false;

	}else if(!isValidEmail(email1))

	{

		showError("Please specify a valid email address.");

		document.getElementById("email1").focus();

		changeError('email1')

		return false;

	}else{

		changeProper('email1')

	}

	if(trim(address).length < 1) {

		showError("Please enter passenger's address.");

		document.getElementById("address").focus();

		changeError('address')

		return false;

	}

	else{

		changeProper('address')

	}

	if(mobile=="" || mobile.length > '10'){

		showError("Please enter a valid mobile number. The number should be of 10 digits.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else{

		changeProper('mobile')

	}



	if(!isNumber(mobile))

	{

		showError("Please enter a valid mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else{

		changeProper('mobile')

	}



	toogleElement('msg','none')

	if(document.getElementById("processme").style.display == 'none')

	{

		document.getElementById("processme").style.display = 'block';

	}

	else

	{

		document.getElementById("processme").style.display = 'none';

	}

//	hideStatus()

	ValidatePassengerInfoTitle();

}

/*

Function for feedback form

 */

function valForm_feedback(theform){

	var myfeedback = document.getElementById("fb").value;

	if(myfeedback==""){

		showError("Please provide your valuable comments.");

		document.getElementById("fb").focus();

		changeError('fb')

		return false;

	}else {

		changeProper('fb')

	}

	toogleElement('msg','none')

	showThanks(theform)

}

/*

Function for contact form

 */

function valForm_contact(theform)

{

	var name = document.getElementById("name").value;

	var emailid = document.getElementById("emailid").value;

	var subject = document.getElementById("subject").value;

	var mobile= document.getElementById("mobile").value;

	var comments= document.getElementById("comments").value;

//	alert(fname);

	if(name==""){

		showError("Please specify your name");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}else if(isNum(name)){

//		alert("name " + name);

		showError("Numbers are not allowed in the name.");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}

	else if(isSpchar(name)){

		showError("Special characters not allowed in the name.");

		document.getElementById("name").focus();

		changeError('name')

		return false;

	}

	else{

		changeProper('name')

	}

	if(emailid==""){

		showError("Please specify your valid email address.");

		document.getElementById("emailid").focus();

		changeError('emailid');

		return false;

	}else{

		changeProper('emailid')

	}

	if(!isValidEmail(emailid))

	{

		showError("Please specify your valid email address.");

		document.getElementById("emailid").focus();

		changeError('emailid')

		return false;

	}else{

		changeProper('emailid')

	}

	if(subject==""){

		showError("Please specify the subject.");

		document.getElementById("subject").focus();

		changeError('subject')

		return false;

	}else{

		changeProper('subject')

	}

	if(mobile==""){

		showError("Please specify your mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else{

		changeProper('mobile')

	}

	if(!isNumber(mobile))

	{

		showError("Please enter numbers only for mobile number.");

		document.getElementById("mobile").focus();

		changeError('mobile')

		return false;

	}else{

		changeProper('mobile')

	}

	if(comments==""){

		showError("Please specify the feedback / comments you wish to send us.");

		document.getElementById("comments").focus();

		changeError('comments')

		return false;

	}else{

		changeProper('comments')

	}

	toogleElement('msg','none')

	showThanks(theform)



}

function openTerms( pageToLoad, winName, width, height, center)

{

	xposition=0; yposition=0;

	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){

		xposition = (screen.width - width) / 2;

		yposition = (screen.height - height) / 2;

	}

//	0 => no

//	1 => yes

	var args = "";

	args += "width=" + width + "," + "height=" + height + ","

	+ "location=0,"

	+ "menubar=0,"

	+ "resizable=0,"

	+ "scrollbars=1,"

	+ "statusbar=true,dependent,alwaysraised,"

	+ "status=false,"

	+ "titlebar=no,"

	+ "toolbar=0,"

	+ "hotkeys=0,"

	+ "screenx=" + xposition + "," //NN Only

	+ "screeny=" + yposition + "," //NN Only

	+ "left=" + xposition + "," //IE Only

	+ "top=" + yposition; //IE Only

//	fullscreen=yes, add for full screen

	var dmcaWin = window.open(pageToLoad,winName,args );

	dmcaWin.focus();

//	window.showModalDialog(pageToLoad,"","dialogWidth:650px;dialogHeight:500px");

}

function bookdirect(){

	var reDiraction = document.form420.paymentMode.value;

	if(reDiraction=='0'){

		return;

	}else if(reDiraction=='2'){

		document.form420.pageId.value="102";

		document.form420.eventId.value="7";

		document.form420.action="OtherBooking.do";

	}else{

		document.form420.pageId.value="24";

		document.form420.eventId.value="14";

		document.form420.action="doBooking.do";

		document.form420.paymentmode.value=reDiraction;

	}

	document.form420.submit();

}

//Three method for shirdi offer direct call to result page with spefice group

function methodcall(){

	var whichRoute = document.getElementById("route").value

//	alert('nop : ' + document.getElementById("numOfPax").value);

//	alert('isReturn : ' + document.getElementById("journyType").value);

	var nop = document.getElementById("numOfPax").value;

	var isRoundTrip = document.getElementById("isRoundTrip").value;

	if(whichRoute=='1'){

//		alert('Yes in ONE');

		forKonduskartravelsfromMumbai(nop,isRoundTrip);

	}else if(whichRoute=='2'){

//		alert('Yes in TWO');

		forPrasannaTravelsfromPune(nop,isRoundTrip);

	}else{

//		alert('Yes in THREE');

		forAlphaTravelsfromHyderabad(nop,isRoundTrip);

	}

}









function forKonduskartravelsfromMumbai(nop,isRoundTrip){

//	showConfirm('preloaderDiv');

	if(isRoundTrip==0){

		document.Mahabaleshwar.action= "/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=0&fromcity=Mumbai&tocity=Shirdi&departureDate=17-07-2008&noOfPassenger="+nop+"&seatType=Seat&departureTime=-1&returnTime=-1&busType=-1&fromStopId=1&toStopId=35&specificGroupId=19";//"/ebusxpress/Booking.do";

	}else{

		document.Mahabaleshwar.action= "/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=1&fromcity=Mumbai&tocity=Shirdi&departureDate=17-07-2008&returnDate=18-07-2008&noOfPassenger="+nop+"&seatType=Seat&departureTime=-1&returnTime=-1&busType=-1&fromStopId=1&toStopId=35&specificGroupId=19"

	}

	document.Mahabaleshwar.submit();

}

function forPrasannaTravelsfromPune(nop,isRoundTrip){

//	showConfirm('preloaderDiv');

	if(isRoundTrip==0){

		document.Mahabaleshwar.action= "/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=0&fromcity=Pune&tocity=Shirdi&departureDate=17-07-2008&noOfPassenger="+nop+"&seatType=Seat&departureTime=-1&returnTime=-1&busType=-1&fromStopId=6&toStopId=35&specificGroupId=-1";//"/ebusxpress/Booking.do";

	}else{

		document.Mahabaleshwar.action= "/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=1&fromcity=Pune&tocity=Shirdi&departureDate=17-07-2008&returnDate=18-07-2008&noOfPassenger="+nop+"&seatType=Seat&departureTime=-1&returnTime=-1&busType=-1&fromStopId=6&toStopId=35&specificGroupId=-1";

	}

	document.Mahabaleshwar.submit();

}

function forAlphaTravelsfromHyderabad(nop,isRoundTrip){

//	showConfirm('preloaderDiv');

	if(isRoundTrip==0){

		document.Mahabaleshwar.action= "/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=0&fromcity=Hyderabad&tocity=Shirdi&departureDate=17-07-2008&noOfPassenger="+nop+"&seatType=Seat&departureTime=-1&returnTime=-1&busType=-1&fromStopId=345&toStopId=35&specificGroupId=-1";//"/ebusxpress/Booking.do";

	}else{

		document.Mahabaleshwar.action= "/ticketvala/Search.do?pageId=18&eventId=1&isRoundTrip=1&fromcity=Hyderabad&tocity=Shirdi&departureDate=17-07-2008&returnDate=18-07-2008&noOfPassenger="+nop+"&seatType=Seat&departureTime=-1&returnTime=-1&busType=-1&fromStopId=345&toStopId=35&specificGroupId=-1";

	}

	document.Mahabaleshwar.submit();

}

/*

Function checks whether vrl booking is possible or not using Ajax

 */

function commonGenderTest(){

	var xmlHttp;
	try{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function(){

		if(xmlHttp.readyState==4){
			var response = (xmlHttp.responseText).toString();

			if(parseInt(response.indexOf("noerr"))<0 ){

				showError(response);
				document.anchors[0].scrollIntoView();
				document.getElementById("payNow").disabled=false;
				return false;

			}else{

				document.contact_form.submit();
				return true;
			}
		}
	}

	var tripId=document.contact_form.tripId.value;
	var noOfPassenger=document.contact_form.noOfPassenger.value;
	var phone=document.contact_form.mobileNo.value;
	var seatNumbersOnward=document.contact_form.seatNumbersOnward.value;
	var pickUpIdz=document.contact_form.pickUpId.value;
	var seatType=document.contact_form.seatTypes.value;
	var url="jsp/TempBooking.jsp?tripId="+tripId+"&noOfPassenger="+noOfPassenger+"&phone="+phone+"&seatNumbersOnward="+seatNumbersOnward+"&pickUpId="+pickUpIdz+"&seatType="+seatType+"&date="+new Date();

	var nop =parseInt(noOfPassenger);

	for(var i=0;i<nop;i++){

		url=url+"&titleAdult"+i+"="+document.getElementById("p1_title"+i).value;
		url=url+"&firstNameAdult"+i+"="+document.getElementById("p1_fname"+i).value;
		url=url+"&lastNameAdult"+i+"="+document.getElementById("p1_lname"+i).value;

	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	return false;

}


function fillPaxInfo(){
	var noOfPassenger=document.contact_form.noOfPassenger.value;
	var cfName=document.getElementById("cfname").value;
	var clName=document.getElementById("clname").value;
	var ctitle=document.getElementById("contact_title").selectedIndex;
	//alert('ctitle='+ctitle);
	
	for(var i=0;i<noOfPassenger;i++){
		document.getElementById('p1_fname'+i).value=cfName;
		document.getElementById('p1_lname'+i).value=clName;
		document.getElementById('p1_title'+i).selectedIndex=ctitle;
		
	}
}

