// JavaScript Document
 
	/* populates userlogin details if user selected populate my login account option while register. */
	/* @Author Manjunath J  */
	
	var chkRememberLoginFlag="";
	var userLoginId="";
	var userLoginPwd="";
	var userLoginName="";
	var chkUserLoginSession="";
	
	var cookie = document.cookie.split(';');
	//alert(cookie);
	var individual_cookie=new Array();
	for(var i=0;i<cookie.length;i++){
		individual_cookie=cookie[i].split(',');
		for(var j=0;j<individual_cookie.length;j++){
			loginDtls=individual_cookie[j].split('=');
			//alert(loginDtls);
			for(var k=0;k<loginDtls.length;k++){
				if(loginDtls[k].toString()=="chkRememberLoginFlag" || loginDtls[k].toString()==" chkRememberLoginFlag"){
					chkRememberLoginFlag=loginDtls[k+1];
					//alert("chkRememberLoginFlag = "+chkRememberLoginFlag);
				}
				if(loginDtls[k].toString()=="chkUserLoginSession" || loginDtls[k].toString()==" chkUserLoginSession"){
					chkUserLoginSession=loginDtls[k+1];
					//alert("chkUserLoginSession = "+chkUserLoginSession +  "   "+chkUserLogingth);
				}					
				if(loginDtls[k].toString()=="userLoginId" || loginDtls[k].toString()==" userLoginId"){
					userLoginId=loginDtls[k+1];
					//alert("userLoginId = "+userLoginId);
				}
				if(loginDtls[k].toString()=="userLoginPwd" || loginDtls[k].toString()==" userLoginPwd"){
					userLoginPwd=loginDtls[k+1];
					//alert("userLoginPwd = "+userLoginPwd);
				}
				if(loginDtls[k].toString()=="userLoginName" || loginDtls[k].toString()==" userLoginName"){
					userLoginName=loginDtls[k+1];
					//alert("userLoginName = "+userLoginName);
				}		
			}// end of for loop var k
		}// end of for loop var j
	}// end of for loop var i
	

function showHidechildText(){
		//alert((document.getElementsByName("children")).length);
		var childCountFlag=0;
		for(var i=0; i<(document.getElementsByName("children")).length; i++){
			if(document.getElementsByName("children")[i].value != 0){
				childCountFlag++;
			}
		}
		if(childCountFlag == 0){
			document.getElementById("titleSpan").style.display="none"
		}
		else{
			document.getElementById("titleSpan").style.display="block"
		}
	}
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

	


function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isThisDate(dtStr,fname){
	var todaydate = new Date();	
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert(dateFormat)
		document.getElementById(fname).value="dd/mm/yyyy";
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		 if(isNaN(month)){
			 alert(dateFormat);
			 document.getElementById(fname).focus();
		 }else{
		alert("Please enter a valid month.")
		 document.getElementById(fname).focus();
		 }
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		
		 document.getElementById(fname).focus();
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert(valid4Digit+" "+todaydate.getYear()+".")
		 document.getElementById(fname).focus();
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		
		 document.getElementById(fname).focus();
		return false
	}
return true
}

function ValidateForm(id,fname){
	    
		if (isDate(id,fname)==false){
			document.getElementById(fname).focus();
			document.getElementById(fname).value="dd/mm/yyyy";
					return false
	}
    return true
 }
			
			

			function validate()
			{
				var cityCombo=document.getElementById("cityName");
				
			     document.getElementById('tableDiv').style.display = "none";
				 if ( validateCity() && validateDates() && validateRoomStrength())
				 {					
					document.getElementById("totalDiv").style.display = "none";
					adultsInRoom();
					childInRoom();
					hotelParameterPassing();
					document.forms[0].action =hotelRequestUrl;
					document.forms[0].submit();
					
				 }
			}

			function fillCriterion()
			{
					
					var otherCityName = document.getElementById("tempCityName").value
					document.getElementById("progressDisplayCityName").innerHTML = otherCityName;

					var checkInDate= document.getElementById("arrDateOway").value;
					var checkOutDate = document.getElementById("HdeptDateOway").value;					
					var checkInDateString = getDateString(checkInDate);
					var checkOutDateString = getDateString(checkOutDate);
					document.getElementById("progressDisplayDatesSpan").innerHTML = "Check-in Date:<br/><strong>"+checkInDateString+"</strong><br/>Check-out Date:<br/>   <strong>"+checkOutDateString+"</strong></span>"
			}


			function getDateString(dateString)
			{
					var	months = new Array();
							months[0] = "Jan";
							months[1] = "Feb";
							months[2] = "Mar";
							months[3] = "Apr";
							months[4] = "May";
							months[5] = "Jun";
							months[6] = "Jul";
							months[7] = "Aug";  
							months[8] = "Sep";
							months[9] = "Oct";
							months[10] = "Nov";
							months[11] = "Dec";				
					var parts = dateString.split("/");
					if (parts[1] == "09")
					{
							parts[1] = "9";
					}
					if (parts[1] == "08")
					{
							parts[1] = "8";
					}
					var dateStringToReturn = parts[0] + "-" + months[ parseInt(parts[1])-1] + "-"+   parts[2];
					return dateStringToReturn;		
			}
			
			/* Kishore Change the current date validation */
			function validateDates()
			{	
				
				var fromDateString = document.getElementById("arrDateOway").value;
				var toDateString = document.getElementById("HdeptDateOway").value;
				var chekinHt = "arrDateOway";
				var checkoutHt = "HdeptDateOway";
				isThisDate(fromDateString,"arrDateOway")
				if(fromDateString == "dd/mm/yyyy"){
				 fromDateString="";
				}
				if(toDateString == "dd/mm/yyyy"){
					toDateString="";
				}
				
											
				if (fromDateString.length==0 && toDateString.length==0)
				{				
					alert(enterDates);
					document.getElementById(chekinHt).focus();
						
					return;
				}
				if (fromDateString.length==0)
				{
					alert(enterCheckIn);
					document.getElementById(chekinHt).focus();
					return;
				}
				if (toDateString.length==0)
				{
					alert(enterCheckOut);
					document.getElementById(checkoutHt).focus();
					return;
				}
				
				if(!isThisDate(fromDateString,"arrDateOway")){
					
					return false;
				}
				if(!isThisDate(toDateString,"HdeptDateOway")){
					return false;
				}	
				
				
				var fromDate = buildDate(fromDateString);
				var toDate = buildDate(toDateString);
				var todayDate = new Date();
				var todayTime = todayDate.getTime();
				//alert("The from date is:" + fromDate + " and the to date is:" + toDate);
				var fromTime = fromDate.getTime();
				var toTime = toDate.getTime();
				var now=new Date().getTime();
				/*if(todayTime>fromTime){
					alert(checkInDate);
					return false;
				}*/
				
				if (fromTime > toTime)
				{
					alert(checkIn_CheckOut);
					return false;
				}
				else if (fromTime==toTime)
				{
					alert(same_check_in_out);
					return false;
				}
				
				else
				{
					return true;
				}
			}
			
			
			/* Kishore LTrim, RTrim, trim, validateCity and change validate */
			function LTrim(String)
			{
					var i = 0;
					var j = String.length - 1;
			
					if (String == null)
						return (false);
			
					for (i = 0; i < String.length; i++)	
					{
					if (String.substr(i, 1) != ' ' && String.substr(i, 1) != '\t')
							break;
					}
			
					if (i <= j)
						return (String.substr(i, (j+1)-i));
					else
						return ('');
			}//@End LTrim(String)
				 
			
			
			function RTrim(String)
			{
					var i = 0;
					var j = String.length - 1;
			
					if (String == null)
						return (false);
			
					for(j = String.length - 1; j >= 0; j--)
					{
						if (String.substr(j, 1) != ' ' && String.substr(j, 1) != '\t')
							break;
					}
			
					if (i <= j)
						return (String.substr(i, (j+1)-i));
					else
						return ('');
			}//@End RTrim(String)
			function trim(val)
			{
				return LTrim(RTrim(val));
				
			}//@End trim(val)


			function validateCity()
			{
				//alert("inside validate City ");
				var cities = document.getElementsByName("cityCode");
				var otherCityCode = "otherCityCode";
				var cityCombo=document.getElementById("cityName");	
				
				for (var count=0;count<cities.length; count++)
				{
					var id = cities[count].id;
					if (id != otherCityCode)
					{
						if (cities[count].checked == true)
						{	
													
							return true;
						}
					}
				}
				if ( cityCombo.selectedIndex>0 )
				{	
					if(document.getElementById("cityName").value =="0"){
						alert(enterCity);
						cityCombo.focus();
						return false;
					}
					
					return true;
				}
				
					

				alert(enterCity);
				cityCombo.focus();
				return false;
			}


			function validateCityOld()
			{

			
				var cities = document.getElementsByName("cityCode")
				var selectedIndex = -1;
				for (var count=0;count<cities.length-1; count++)
				{
					if (cities[count].checked==true)
					{
						selectedIndex = count;
						break;
					}
				}
				var endIndex = (cities.length==0 || cities.length==null) ? 0 : (cities.length-1);					
				if (cities.length!=0 && cities.length!=null)
				{
					if (selectedIndex==-1)
					{
							if((cities[cities.length-1].checked==true&&document.getElementById("cityName").selectedIndex==0)||cities[cities.length-1].checked==false)
							{
								alert(enterCity);
								document.getElementById("otherCity").value="";
								document.getElementById("otherCity").focus();
								return false;
							}
							else if(cities[cities.length-1].checked==true&&document.getElementById("cityName").selectedIndex>0)
							{
							   var cityCombo=document.getElementById("cityName");							   
							   document.getElementById("tempCityName").value = cityCombo.options[cityCombo.selectedIndex].innerHTML;
							}
						    else
							{
								var fromdate = document.getElementById("arrDateOway").value;
								var todate = document.getElementById("HdeptDateOway").value;
								
								
								if(fromdate == "dd/mm/yyyy" && todate == "dd/mm/yyyy"){
									alert(enterDates);
									return;
								}
								else if(fromdate == "dd/mm/yyyy"){
									
									alert(enterCheckIn);
									return;
								}
								else if(todate == "dd/mm/yyyy"){
									alert(enterCheckOut);
									return;
								}
								//alert("Here otherCityNameValue.length:" + otherCityNameValue.length + " and cities[cities.length-1].checked:: "+ cities[cities.length-1].checked)
							}
					}
					else
					{
						var id = 'cityName' + cities[selectedIndex].value;
						//document.getElementById("otherCity").value = document.getElementById(id).innerHTML

					}
					}
					else
					{	
						if (selectedIndex==-1&& document.getElementById("cityName").selectedIndex==0)
						{
							alert(enterCity);
							return false;

						}
					}
					
				return true;
			}
			
			function buildDate(dateString)    // date string is in format dd/mm//yyyy
			{
				var dd = parseInt(dateString.split("/")[0],10);
				var mm = parseInt(dateString.split("/")[1],10);
				var yyyy = parseInt(dateString.split("/")[2],10);
				var date = new Date (yyyy, (mm-1) , dd, 0, 0, 0, 0)
				return date;
			}
			
			
			function close(divID)
			{
				document.getElementById(divID).style.display = 'none'
			}

			function addListener()
			{
					document.getElementById("otherCity").onkeydown = getCityNames;
			}
			function submitAdditional(){
				var sendStringPax = "";
				var sendChildAges = "";
				var numberOfRooms = document.getElementById("rooms").value;				
				for(var countRooms = 0; countRooms < numberOfRooms; countRooms++){
					sendStringPax = sendStringPax+"~"+document.getElementsByName('adults')[countRooms].value+"~"+document.getElementsByName('children')[countRooms].value+"/";
					
					for(var childCount = 1; childCount <= document.getElementsByName('children')[countRooms].value; childCount++){
						sendChildAges = sendChildAges+document.getElementById("Room"+countRooms+"_"+childCount).value + "~";
					}
					sendChildAges = sendChildAges+"/";
					
				}
				var selectedIndex = document.getElementById("cityName").selectedIndex;
				if(cityNames.length<=0 && document.getElementById("otherCityCode").checked==true){
					document.forms[1].action = "Hotels?Open=Yes&selectedIndex="+selectedIndex;
					document.forms[1].submit();
				}
				else{
					document.forms[1].action = "Hotels?Open=Yes&fwd=true&roomString="+sendStringPax+"&sendChildAges="+sendChildAges+"&selectedIndex="+selectedIndex;
					document.forms[1].submit();
				}

			}
			function disableOtherCity(){
				
				document.getElementById("cityName").selectedIndex = 0 ;			
			}
			function setFocusOtherCity(){
				
				document.getElementById("tempCityName").value = "";
				document.getElementById("otherCityCode").checked = true;
				document.getElementById("otherCity").readOnly = false;
				document.getElementById("otherCityCode").value = "";
				document.getElementById("otherCity").focus();
			}
			
			function enableOtherCity(){
				
				document.getElementById("cityName").selectedIndex = 0;
			}

	var maxRoomStrength = 6;


function searchoptnfn()
{
//alert("searchoptnfn");
document.getElementById("searchoptn").style.display="";
}


function showHotelsSearch()
{
	document.getElementById("flightsTable").style.display = "none";
	document.getElementById("hotelsTable").style.display = "block";
}
var roomDtls=new Array(5);

for(var t=0;t<5;t++)
{
	var roomRec=new Array(2);
	roomRec[0]=1;
	roomRec[1]=0;
	roomDtls[t]=roomRec;
}
function updateArray(val,val1,ele)
{
   roomDtls[val][val1]=ele.value;
}
var childAges=new Array(5);
for(var t=0;t<5;t++)
{
	var ageRec=new Array(5);
	for(var a=0;a<5;a++)
		ageRec[a]=1;//changed from 0 to 1 to make children age to start from 1
	childAges[t]=ageRec;
}
function updateAgeArray(val,val1,ele)
{
   childAges[val][val1]=ele.value;

}
function createRooms()
{
    var table = document.getElementById("guestsTable");
	deleteTableWithHeader(table);
	var childrenAgesTable = document.getElementById("childrenAgesTable");
	deleteTable(childrenAgesTable);
	var titleSpan = document.getElementById("titleSpan");
	var rooms = document.getElementById("rooms").value;
	for (var count=0;count<rooms;count++)
	{
		var row = table.insertRow(count + 1);
		row.valign = "top"
	/*	var cell1 = row.insertCell(0);*/
		var cell1 = row.insertCell(0);
		var cell2 = row.insertCell(1);
		cell1.className = "whiteText"
		cell2.className = "whiteText"
	
		cell1.innerHTML =  "<select name='adults' onchange='validateRoomStrength(),updateArray("+count+",0,this)' style='width:40px;font-size:9px;'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option></select>";
		cell2.innerHTML = "<select name='children' style='width:40px;font-size:9px;' onchange='validateRoomStrength(),showChildrenAges(),showHidechildText(),updateArray("+count+",1,this)'><option value='0' selected>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select>";
		cell2.align = "left"
		cell1.align = "left";
		if(count>0){
			document.forms[1].adults[count].value=roomDtls[count][0];
			document.forms[1].children[count].value=roomDtls[count][1];
		}else{
			document.forms[1].adults.value=roomDtls[count][0];
			document.forms[1].children.value=roomDtls[count][1];
		}
	}
    createArrows();
	showChildrenAges();
  }


function createArrows()
{
     	var rooms = document.getElementById("rooms").value;
		var arrowsTableObj = document.getElementById("arrowsTable");
		deleteTable(arrowsTableObj );
		for (var count=0;count<rooms;count++)
		{
			var row = arrowsTableObj .insertRow(count);
			row.valign = "top"
			var cell = row.insertCell(0);
			cell.className = "whiteText"
			if(count==0){
			cell.innerHTML = "&nbsp;<img src='http://www.travelpartnernetwork.net/widget/images/arrow2.gif' height='0'><img src='http://www.travelpartnernetwork.net/widget/images/arrow3.gif' width='25' height='3'/>Room" +  (count + 1)+":";
			}
			else{
			cell.innerHTML = "<img src='http://www.travelpartnernetwork.net/widget/images/arrow2.gif' height='16'><img src='http://www.travelpartnernetwork.net/widget/images/arrow3.gif' width='18' height='3'/>Room" +  (count + 1)+":";
			}
		}
}

function deleteTableWithHeader(table)
{
	for (var count=table.rows.length-1;count>0;count--)
	{
		table.deleteRow(count);
	}
}

function deleteTable(table)
{
	for (var count=table.rows.length-1;count>=0;count--)
	{
		table.deleteRow(count);
	}
}

function showChildrenAges()
{
var childrenAgeTable = document.getElementById("childrenAgesTable");
	deleteTable(childrenAgeTable);
	var childSelects = document.getElementsByName("children");
	var v = 0;
	for (var count=0;count<childSelects.length;count++){
		if (childSelects[count].value>0)
		{
			v +=1 
		}
	}
	if (v>0)
	{
		document.getElementById("titleSpan").style.display = "block";
	}
	else
	{
		document.getElementById("titleSpan").style.display = "none";
	}

	var childrenAgeTable = document.getElementById("childrenAgesTable");
	deleteTable(childrenAgeTable);
	var childSelects = document.getElementsByName("children");
	var v = 0;
	for (var count=0;count<childSelects.length;count++)
	{	
		var childAge = childSelects[count].value;
		if (childAge>0)
		{
			var row = childrenAgeTable.insertRow( v++);
			var cell = row.insertCell(0);
			var cell2 = row.insertCell(1);
			cell.className = "whiteText"
			cell2.className = "whiteText"
			cell.innerHTML = "Room" + (count+1) + ":";
			var str = "";
			var childStr = "";
			str += "<table><tr>";
			var dupCnt=0;
			for(var childCount=1;childCount<=childAge;childCount++)
			{
				childStr += "Child " + childCount +  ":&nbsp;&nbsp;&nbsp;" 
				str += "<td class='whiteText'>Child " + childCount +  ":<BR>";
				var selectName = "Room" + (count + 1);
				str += "<SELECT class='childSelect' name='" + selectName+"' id='Room"+count+"_"+childCount+"' onchange='updateAgeArray("+count+","+dupCnt+",this)'>";
				for (var ageCount=1;ageCount<=12;ageCount++)//changed from 0 to 1 to make children age to start from 1
				{
					str += "<option value=" + ageCount + ">" + ageCount + "</option>";
				}
				str += "</select>";
				str += "</TD>";
				dupCnt++;				
			}
			//alert("str:" + str);
			str += "</tr></table>";
			cell2.innerHTML = str;
			var dupCnt=0;
			for(var childCount=1;childCount<=childAge;childCount++)
			{
				document.getElementById("Room"+count+"_"+childCount).value=childAges[count][dupCnt]
				dupCnt++;
			}
//			cell2.innerHTML = childStr + "<BR>" +str;
		}
	  }	
  	createArrows();
}


function validateRoomStrength()
{
//	alert(document.forms[0].childSelect);
	var numberOfRooms = document.getElementById("rooms").value;
	var adults = document.getElementsByName("adults");
	var children = document.getElementsByName("children");
	for (var count=0;count<numberOfRooms;count++)
	{
		var adultsInRoom = parseInt(adults[count].value);
		var childrenInRoom = parseInt(children[count].value);
		//alert("childrenInRoom::" + childrenInRoom);
		var roomStrength = adultsInRoom + childrenInRoom;
		if ( roomStrength > maxRoomStrength)
		{
			alert("Please check that the total number of persons (including children) per room is:" + maxRoomStrength);
			children[count].focus();
			var childrenAgeTable = document.getElementById("childrenAgesTable");
			deleteTable(childrenAgeTable);
			return false;
		}
		children[count].length=maxRoomStrength-adultsInRoom;
		for(var j=0;j<=maxRoomStrength-adultsInRoom;j++){
			children[count].options[j]=new Option(j,j,true,false);
		}
		children[count].value=childrenInRoom;
		// Based on children slected the number of adults will be displayed
		adults[count].length=maxRoomStrength-childrenInRoom;
		for(var j=0;j<maxRoomStrength-childrenInRoom;j++){
			adults[count].options[j]=new Option(j+1,j+1,true,false);
		}
		adults[count].value=adultsInRoom;
	}
//	showChildrenAges();
	return true;
}

function validateHtlChain()
{
	var htlChn1=document.forms[1].HotelChain1[0].value;
	var htlChn2=document.forms[1].HotelChain1[1].value;
	var htlChn3=document.forms[1].HotelChain1[2].value;		
   	if(htlChn1!="Select" || htlChn2!="Select" || htlChn3!="Select"){
		if(htlChn1!="Select" && htlChn2!="Select" && htlChn1==htlChn2){
			alert(hotelChainSelect)
			document.forms[1].HotelChain1[0].focus();
			return false;
		}
		if(htlChn1!="Select" && htlChn3!="Select" && htlChn1==htlChn3){
			alert(hotelChainSelect)
			document.forms[1].HotelChain1[0].focus();
			return false;
		}
		if(htlChn3!="Select" && htlChn2!="Select" && htlChn3==htlChn2){
			alert(hotelChainSelect)
			document.forms[1].HotelChain1[1].focus();
			return false;
		}
	}

  return true;
}	


	
		function buildDate234(dateString)    // date string is in format dd/mm//yyyy
			{
				var dd = parseInt(dateString.split("/")[0]);
				var mm = parseInt(dateString.split("/")[1]);
				var yyyy = parseInt(dateString.split("/")[2]);
				var date = new Date();
				date.setDate(dd);
				date.setMonth(mm-1);
				date.setFullYear(yyyy)
				date.setHours(0);
				date.setMinutes(0);
				date.setSeconds(0);
				date.setMilliseconds(0);
				return date;
			}
			
			
			function close(divID)
			{
				document.getElementById(divID).style.display = 'none'
			}

			function addListener()
			{
				//	document.getElementById("otherCity").onblur = getCityNames;
			}
			
			function doNothing()
			{
			}
			
			
			function showOtherCity(checked)
			{
				document.getElementById("otherCityCode").value="";	
			}

function enterAlphaNumericWithSpace(e)
{
//alert("in alpha numeris")
var key=0;
	
	if (!e) var e = window.event;
	// e gives access to the event in all browsers
	if(!e.which) key = e.keyCode; // This is used store the keycode(IE Only) 
	else key = e.which; // This is used store the keycode(Netscape Only)
	
     if((key>=48)&&(key<=57)||(key>=65)&&(key<=90)||(key>=97)&&(key<=122)||key==8||key==9||key==32||key==13||key==10||key==189)
     {

        key=key;
        return true;

     }
     else
     {
     alert("Please enter Alpha Numerics only.");
       key=0;
       return false;

     }
     
}// @End enterAlphaNumeric(e)

function whatIsThisCity(evt)
	{
		 evt = (evt) ? evt : ((window.event) ? window.event : "")
		//var evt = window.event;
		if (evt) {
			var elem = (evt.target) ? evt.target : evt.srcElement
			var x = evt.clientX - 160;
			var y = evt.clientY - 220;
			var divObj = document.getElementById("WhatIsX");
			divObj.style.display = "block";
			divObj.style.position = "absolute";
			divObj.style.left = x;
			divObj.style.top = y;
			divObj.innerHTML = "<table width='301' height='26' bgcolor='#3396FF' cellspacing=0 cellpadding=0 style='border:1px solid #3396FF'><tr><td><table width='300' height='25' cellspacing='0' cellpading='0' bgcolor='#FFFFFF'><tr bgcolor='#3396FF'><td align='left'><font color='white'><B>What is the Other City field?</B></font></td><td align='right'><a href='javascript:divclose1(\"WhatIsX\")' style='font-size:12'><b><font color='white' title='Close' ><b>close[X]</b></font></b></a></td></tr><tr><td align='left' colspan='2'><font size='1' family='verdana'>On entering up to two characters of a city name in the Other City text field, the system will auto-complete the city name that contain those characters. The options will appear for selection in a drop-down overlay. </font><br><br></td></tr></table></td></tr></table>"
		}
		createArrows();
		//window.location.href = "include/flights_web_taxes.jsp?taxvalue='+taxvalue+'"
	}

	function divclose1(name){
        var divObj;
        divObj= document.getElementById(name);
        divObj.style.display = "none";
		createArrows();
    }
	javascript:window.history.forward(-1);

djConfig = {parseWidgets: false};

var timechange=true;
var modifychange=false;

var modifychange=false;
function bodyOnLoad(){

    // addCityOption_list();
	refereshPage();
	onewayfn();
//loadImages();
	
}
function changeTab(tabName){
	if(tabName=="flt"){
	document.getElementById("hotels_tab").style.display="none"
		document.getElementById("flights_tab").style.display="block"
		document.getElementById("FlightTabData").style.display="block";
		document.getElementById("HotelTabData").style.display="none";
		
		}
	else if(tabName=="htl"){
		//document.getElementById("selHtlImg").src="images/search-for-hotels.jpg";
		document.getElementById("hotels_tab").style.display="block"
		document.getElementById("flights_tab").style.display="none"
		document.getElementById("FlightTabData").style.display="none";
		document.getElementById("HotelTabData").style.display="block";
		if(document.getElementById("otherCityCode").value==""){
		}
		
	}
	createArrows();
}


function dojoload(){
		var file="js/flights/dojo/dojo_to.js"
		fileref1=document.createElement('script')
fileref1.setAttribute("type","text/javascript");
fileref1.setAttribute("src", file);
document.getElementsByTagName("head").item(0).appendChild(fileref1);
		}



function deleteAllCookies(){
	try{setCookie("htlName",null,-1);}catch(e){}
	try{setCookie("location",null,-1);}catch(e){}
	try{setCookie("order",null,-1);}catch(e){}
		for(var i=1;i<=3;i++){
			try{setCookie("chain"+i,null,-1);}catch(e){}
		}
	try{setCookie("pageNum",null,-1);}catch(e){}
	try{setCookie("amenity",null,-1);}catch(e){}
	try{setCookie("property",null,-1);}catch(e){}
}

function setCookie(c_name,value,expiredays)
{
	try{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
	}catch(e){}
}


<!-- MMT JS -->

var hotelRequestUrl="http://www.travelpartnernetwork.net/Affiliate/affiliateGateway.do?action=HTLSRCH&&webId=15";
var flightRequestUrl="http://www.travelpartnernetwork.net/Affiliate/affiliateGateway.do?action=FLTSRCH&&webId=15"; 

function validateFlightSection(){

var flag = true;

var selOrigin = document.getElementById("selorigin").value;
var selDestination = document.getElementById("seldestination").value;

if(selOrigin == "0" || selOrigin == ""){
	alert("please select Leaving From City ");
	flag = false;
  //document.getElementById("selorigin").focus;
	// return flag;
}else if(selDestination == "0"){
	alert("please select going To City ");
	flag = false;
	//return flag;
}

if(document.flightsSearchForm.radtripType[0].checked && flag){
	var retnDateRTrip = document.getElementById("txtretnDateRtrip").value;
	var deptDateRTrip = document.getElementById("txtdeptDateRtrip").value; 	

 		if(deptDateRTrip == "DD/MM/YYYY" || deptDateRTrip== ""){
			alert("please specify a departurre Date");
			//document.getElementById("deptDateRTrip").focus;
			flag = false;			
 		}else if(retnDateRTrip == "DD/MM/YYYY" || retnDateRTrip== ""){
			alert("please specify a Return Date");
			flag = false;			
 		}
 		
 		
}else if(document.flightsSearchForm.radtripType[1].checked && flag){	

	var deptDateOnWay = document.getElementById("txtdeptDateOway").value;
	if(deptDateOnWay == "DD/MM/YYYY" || deptDateOnWay== ""){
			alert("please specify a Return Date");
			flag = false;			
 		}
		
		
}


//alert("the Value of Flag = "+flag);

if(flag){
 		flightButtonCall();
 	}
 	
}

function validateHotelSearch(){
var flag = true;


var cityName = document.getElementById("cityName").value;
if(cityName == "0" || cityName == ""){
	alert("please select the destination ");
	flag=true;
}

var checkinDate = document.getElementById("arrDateOway").value;
var checkoutDate = document.getElementById("HdeptDateOway").value;

if(flag){
if(checkinDate == "dd/mm/yyyy" || checkinDate== ""){
			alert("please enter a valide Date");
			//document.getElementById("checkinDate").focus;
			flag = false;			
 		}else if(checkoutDate == "dd/mm/yyyy" || checkoutDate== ""){
			alert("please enter a valide Date");
			flag = false;			
 		}
}

if(flag){
	
	hotelParameterPassing();
}

}

function refereshPage(){
	//alert("inside refereshPage");
	window.reset;
}




<!-- Code Ended -->



<!-- SCRIPT CREATED BY VINOD FOR FLT SEARCH OPTION -->

	
	function callFromAdditionalSearchOption(){
	
		 if(document.getElementById("additionalSearch").style.display == "block"){
			 document.getElementById("additionalSearch").style.display = "none";		 	
		 }else {
		 	document.getElementById("additionalSearch").style.display = "block";
		 }
	}
	

function validateOptions(){
	//alert("  ................>  "+document.getElementById("selorigin"));
}




	
	function adultsInRoom(){
				
				var roomArr = document.getElementById("rooms").value;
				//alert("length of room Arr :  "+roomArr);
				hotelRequestUrl+="&numberOfRooms="+roomArr;
				for(var i=0; i<roomArr;i++){
					var adults = document.getElementsByName("adults");
					//alert("no of adults in single room : "+adults[i].value);					
					hotelRequestUrl+="&adults="+adults[i].value;
				}
				//alert("adults"+hotelRequestUrl);
				
			}
	
	function childInRoom(){
		var roomArr = document.getElementById("rooms").value;
		//alert("length of room Arr :  "+roomArr);
		
		for(var i=0; i<roomArr;i++){
					var children = document.getElementsByName("children");
					//alert("no of adults in single room : "+children[i].value);
					var k = i+1;
					hotelRequestUrl+="&children="+children[i].value;
					if(children[i] != "0"){
					var arrOfChildAge = document.getElementsByName("Room"+k);
					//alert("age of children"+arrOfChildAge.length);					
					for(var j=0; j<arrOfChildAge.length; j++){
						var childAge = arrOfChildAge[j].value;
						//alert("child age is : "+childAge);
						hotelRequestUrl+="&Room"+k+"="+childAge;
					}
					//alert("URL ------ >>>>   : "+hotelRequestUrl);
					}
					
				}
		//alert("children    :  "+hotelRequestUrl);
	}
	
	function hotelParameterPassing(){
			//alert("inside hotelParameterPassing");
			var ctynam="";
			var checkindt;
			var checkoutdt;
			
			if(document.getElementById("residentOfIndia").checked){
				hotelRequestUrl+="&residentOfIndia=Y";
			}else{
				hotelRequestUrl+="&residentOfIndia=Y";
			}
			
			
			if(document.getElementById("cityName")!=null){
				ctynam=document.getElementById("cityName");
			}
			
			if(document.getElementById("HdeptDateOway").value!=null){
				checkoutdt =document.getElementById("HdeptDateOway").value;
			}
			//alert("checkin Date : "+document.getElementById("arrDateOway").value);
			if(document.getElementById("arrDateOway").value!=null){
				checkindt =document.getElementById("arrDateOway").value;
				
				
			}
			var ctycode;
			var ctyname;
			
			if(document.getElementById("cityName").value!=null){
				ctycode =document.getElementById("cityName").value;
			}

//if(document.getElementById("arrDateOway").value!=null){
// ctyname =document.getElementById("arrDateOway").value;
// }
			var countryNam;


			var noofchd="";
			var noofadult="";



			if(document.getElementById("selnoOfChildren").value!=null){
				noofchd =document.getElementById("selnoOfChildren").value;
			}

			
			var noofroom="";
			
			
			var cityNameStr = document.getElementById("tempCityName").value;
			
			//alert("no of rooms"+noofroom);
			 hotelRequestUrl+="&checkinDate="+checkindt+"&checkoutDate="+checkoutdt+"&cityCode="+ctycode+"&cityName="+cityNameStr;
					

		}






var ori=new Array();
function makeTxt(id,txt)
{
  var obj=document.getElementById(id);
  if (!ori[id]) ori[id]=obj.innerHTML;
  obj.innerHTML=txt;
}
function reTxt(id)
{
  var obj=document.getElementById(id);
  if (ori[id]) obj.innerHTML=ori[id];
}

javascript:window.history.forward(-1);
<!-- End MMT JS -->