function fncurrency(){
		document.frmcur.submit();
	}

	function removeOption(type){
		  var lst = document.forms["frm"][type];
		  lst.options.length = 0;
		}
	function selOption(type,mkval){
			document.forms["frm"][type].value=mkval;
		}
	function addOption(index,text,value,type) {
			//alert(index + text + value + type);
			var lst = document.forms["frm"][type];
			lst.options[index] = new Option(text, value);
			//document.getElementById("shiptocust").value=text;
		}
	function processEQ(){
			//document.frm.cmbCity.disabled = true;
			document.getElementById("fillcomb").src ='ComboResult_Country.asp?countcode='+document.frm.cmbCountry[document.frm.cmbCountry.selectedIndex].value
			//alert(document.getElementById("fillcomb").src)
		}
	function processEQ1(){
		document.frm.cmbLocation.disabled = true;
		document.getElementById("fillcomb1").src ='ComboResult_City.asp?citycode='+document.frm.cmbCity[document.frm.cmbCity.selectedIndex].value
		//alert(document.getElementById("fillcomb1").src)
	}
	function setvalue(){
		document.getElementById("cmbCity").value;
		//alert(document.getElementById("cmbCity").value)
		document.frm.cmbCity.focus();
	}
	function fnchkadt(){
		var dt1=document.frm.adate;
		if (isDate(dt1.value)==false){
			dt1.focus()
			return false
		}	
	}
	function fnchkddt(){
		var dt2=document.frm.ddate;
		if (isDate(dt2.value)==false){
			dt2.focus()
			return false
		}	
	}
	function fnhsr(loc){
		var dt1=document.frm.adate;
		var dt2=document.frm.ddate;
		if (isDate(dt1.value)==false){
			dt1.focus()
			return false
		} else if (isDate(dt2.value)==false){
			dt2.focus()
			return false
		} else {
			document.location.href=loc;
		}
	}
	function ChkValues(){
		dtAriv = document.frm.ddate.value;
		var dtCh= "/";
		var pos1=dtAriv.indexOf(dtCh)
		var pos2=dtAriv.indexOf(dtCh,pos1+1)
		var ArivMonth=dtAriv.substring(pos1+1,pos2)
		var ArivDay=dtAriv.substring(0,pos1)
		var ArivYear=dtAriv.substring(pos2+1)
		
		dtDept = document.frm.adate.value;
		var dtCh= "/";
		var pos1=dtDept.indexOf(dtCh)
		var pos2=dtDept.indexOf(dtCh,pos1+1)
		var DeptMonth=dtDept.substring(pos1+1,pos2)
		var DeptDay=dtDept.substring(0,pos1)
		var DeptYear=dtDept.substring(pos2+1)
		
		var Dep =new Date(DeptYear,DeptMonth,DeptDay)
		var Arv =new Date(ArivYear,ArivMonth,ArivDay)

		
		if(Math.ceil(Arv.getTime())<=Math.ceil(Dep.getTime())){
			alert(" Arrival date is greater or equal to departure date. Please check and try again.");
			document.frm.ddate.focus();
			return false;
		}
		if (document.frm.cmbCountry[document.frm.cmbCountry.selectedIndex].value == "0") {
			alert("Please select country");
			document.frm.cmbCountry.focus();
			return false;
		}
		if (document.frm.cmbCity[document.frm.cmbCity.selectedIndex].value == "0") {
			alert("Please select city");
			document.frm.cmbCity.focus();
			return false;
		}
		
		if (isDate(document.frm.adate.value)==false){
			document.frm.adate.focus()
			return false
		}
		if (isDate(document.frm.ddate.value)==false){
			document.frm.ddate.focus()
			return false
		}
		
		
		document.frm.cmbCurrency.value=document.frmcur.cmbCurrency.value;
 	    document.frm.submit();

		return true;
	}
	
		var dtCh= "/";
		var minYear=1900;
		var maxYear=2100;
		function isInteger(s){
			var i;
				for (i = 0; i < s.length; i++){
				var c = s.charAt(i);
				if (((c < "0") || (c > "9"))) return false;
				}
				return true;
		}

		function stripCharsInBag(s, bag){
			var i;
				var 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){
			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 isDate(dtStr){
			var daysInMonth = DaysArray(12)
			var pos1=dtStr.indexOf(dtCh)
			var pos2=dtStr.indexOf(dtCh,pos1+1)
			var strMonth=dtStr.substring(pos1+1,pos2)
			var strDay=dtStr.substring(0,pos1)
			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("The date format should be : dd/mm/yyyy")
				return false
			}
			if (strMonth.length<1 || month<1 || month>12){
				alert("Please enter a valid month")
				return false
			}
			if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
				alert("Please enter a valid day")
				return false
			}
			if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
				return false
			}
			if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
				alert("Please enter a valid date")
				return false
			}
			return true
		}
	

	function OpenCalender(mode,num) {
		if (isDate(document.frm.adate.value)==false){
			document.frm.adate.focus()
			return false
		}
		if (isDate(document.frm.ddate.value)==false){
			document.frm.ddate.focus()
			return false
		}
		var dt2;
		params = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=160,height=150';
		 if(window.top.screenX == -4){
			a = window.screenX+330;
			b = window.screenY+370;
			hor = window.screenX;
			ver = window.screenY;
		 }else {
		   	a = event.screenX-280;
	 		b = event.screenY+20;
	 		hor = event.screenX;
			ver = event.screenY;
		  }
	    if (navigator.userAgent.toLowerCase().charAt(8)==4){
			params+=',left='+a+',top='+b
		} else {
			params+=',screenX='+a+',screenY='+b
		}
		  if (navigator.userAgent.toLowerCase().charAt(8)==5){
			params+=',left='+a+',top='+b
		  }
		if (num == "1"){
			dt2 = "";
		} else {
			dt2 = document.getElementById("ddate").value;
		}
		window.open('common/calendar.asp?dt1=' + document.getElementById("adate").value + '&dt2=' + dt2 +'&itm1=adate&itm2=ddate&hor=' +  hor + '&ver=' + ver +'','Wind3',params);
	}

	function GetWeekday(yr,mn,dy,yr2,mn2,dy2){
		var calDate = new Date(yr,mn-1,dy);
		var calDatedd = new Date(yr2,mn2-1,dy2);
		//alert(yr+mn+dy);
		calDate = calDate.getDay();
		calDatedd = calDatedd.getDay();
		document.getElementById("weeekday1").value = fnmon(calDate);
		document.getElementById("weeekday2").value = fnmon(calDatedd);
	}

	function fnmon(strdy){
		if(strdy=="0") return "Sun";
		if(strdy=="1") return "Mon";
		if(strdy=="2") return "Tue";
		if(strdy=="3") return "Wed";
		if(strdy=="4") return "Thu";
		if(strdy=="5") return "Fri";
		if(strdy=="6") return "Sat";
	}


	function fnCreateCol(cn,itr,txt,cmbname,cnum,st,en,sl){
		var rownum=itr;
		if(document.getElementById("roomno").value== 1){
			var rownum=itr-1;
		}
   		var tbl = document.getElementById('TBLroom');
   		var iteration = itr;
		var row = tbl.rows[rownum];
    	var cellRight = row.insertCell(cn);
    	var alr=cellRight.vAlign="top";
	    var p1 = document.createElement('p');
		if(cmbname==''){
			if(rownum==0){
	    		p1.className = "txt1";
			} else {
	    		p1.className = "txt6";
	    	}
    		var textNode = document.createTextNode(txt);
			cellRight.appendChild(p1).appendChild(textNode);
		} else {
	    	p1.className = "txt4";
    		var textNode = document.createTextNode(txt);
	    	if(cnum!=0){
				var el = document.createElement('select');
				el.name = cmbname;
				el.id = cmbname;
				el.size = "1";
				el.style.width="60px";
				el.onchange = function(){ fnchild(cnum);}
			} else {
				var el = document.createElement('select');
				el.name = cmbname;
				el.id = cmbname;
				el.size = "1";
				el.style.width="60px";
				//el.setAttribute('width','60px');
	    	}
	    	var k=0;
	    	for(i=st;i<=en;i++){
				el.options[k] = new Option(i, i);
				k=k+1;
			}
			el.options.value=sl;
			cellRight.appendChild(p1).appendChild(textNode)+cellRight.appendChild(el);
		}
	}

	function fnCreateChild(cn,itr,txt,cmbname,cnum,st,en,sl,cl){
		var rownum=itr;
		if(document.getElementById("roomno").value== 1){
			var rownum=itr-1;
		}
   		var tbl = document.getElementById('TBLroom');
   		var iteration = itr;
		var row = tbl.rows[rownum];
		if (cl==1){
    		var cellRight = row.insertCell(cn);
    	} else {
    		var cellRight = row.cells[cn];
    	}
    	var alr=cellRight.vAlign="top";
	    var p1 = document.createElement('p');
		if(cmbname==''){
			p1.id = 'p'+rownum;
			p1.name = 'p'+rownum;
			if(rownum==0){
	    		p1.className = "txt1";
			} else {
	    		p1.className = "txt7";
	    	}
    		var textNode = document.createTextNode(txt);
			cellRight.appendChild(p1).appendChild(textNode);
		} else {
	    	p1.className = "txt4";
    		var textNode = document.createTextNode(txt);
			var el = document.createElement('select');
			el.name = cmbname;
			el.id = cmbname;
			el.size = "1";
			el.style.width="60px";
	    	var k=0;
	    	for(i=st;i<=en;i++){
				el.options[k] = new Option(i, i);
				k=k+1;
			}
			el.options.value=sl;
			cellRight.appendChild(p1).appendChild(textNode)+cellRight.appendChild(el);
		}
	}
	function fnRoomSel(){
		if(document.getElementById("cmbTRooms").value==1){
			if(document.getElementById("roomno").value==1){
				var cmba =document.getElementById('p0');
				if(cmba != null){
					cmba.style.display='none';
				}
	    		var tbl = document.getElementById('TBLroom');
	    		var lastRow = tbl.rows.length;
	    		// if there's no header row in the table, then iteration = lastRow + 1
	    		var iteration = lastRow;
				var row = tbl.rows[lastRow-1];
				//Create Adults Combo
				fnCreateCol(1,iteration,'Adults','cmbadult'+iteration,0,1,4,2);
				fnCreateCol(2,iteration,'Children (0-3)','cmbchild'+iteration,iteration,0,3,0);
				document.getElementById("roomno").value=1;
			} else {
				document.getElementById("roomno").value=1;
	    		var tbl = document.getElementById('TBLroom');
	    		var lastRow = tbl.rows.length;
	    		var iteration = lastRow;
	    		if( iteration>1){
	    			for(j=iteration-1;j>=1;j--){
						var row = tbl.rows[j];
						var row = tbl.deleteRow(j);
	    			}
					var row = tbl.rows[0];
					//Create Adults Combo
					fnCreateCol(1,1,'Adults','cmbadult1',0,1,4,2);
					fnCreateCol(2,1,'Children (0-3)','cmbchild1',1,0,3,0);
				}
			}
		} else if(document.getElementById("cmbTRooms").value>1){
			var cmba =document.getElementById('p0');
			if(cmba != null){
				cmba.style.display='none';
			}
			if (document.getElementById("roomno").value==1){
				var cmba =document.getElementById('cmbadult1');
				if(cmba != null){
	    			var tbl = document.getElementById('TBLroom');
	    			var lastRow = tbl.rows.length;
	    			var iteration = lastRow;
					var row = tbl.rows[lastRow-1];
					var cellRight = row.deleteCell(2);
					var cellRight = row.deleteCell(1);
					document.getElementById("roomno").value=document.getElementById("cmbTRooms").value;
					for(x=1;x<=document.getElementById("roomno").value;x++){
						var row = tbl.insertRow(x);
						fnCreateCol(0,x,'Room '+x,'',0,0,0,0)
						fnCreateCol(1,x,'Adults','cmbadult'+x,0,1,4,2)
						fnCreateCol(2,x,'Children (0-3)','cmbchild'+x,x,0,3,0)
					}
				}
			} else if (document.getElementById("roomno").value>document.getElementById("cmbTRooms").value){
    			var tbl = document.getElementById('TBLroom');
    			var lastRow = tbl.rows.length;
    			var iteration = lastRow;
				var row = tbl.rows[lastRow-1];
	    		if( iteration>1){
	    			for(j=iteration-1;j>document.getElementById("cmbTRooms").value;j--){
						var row = tbl.rows[j];
						var row = tbl.deleteRow(j);
	    			}
					var row = tbl.rows[document.getElementById("cmbTRooms").value];
					document.getElementById("roomno").value=document.getElementById("cmbTRooms").value;
				}
			} else if (document.getElementById("roomno").value<document.getElementById("cmbTRooms").value){
    			var tbl = document.getElementById('TBLroom');
    			var lastRow = tbl.rows.length;
    			var iteration = lastRow;
				var row = tbl.rows[lastRow-1];
				document.getElementById("roomno").value=document.getElementById("cmbTRooms").value;
				for(x=lastRow;x<=document.getElementById("roomno").value;x++){
					var row = tbl.insertRow(x);
					fnCreateCol(0,x,'Room '+x,'',0,0,0,0)
					fnCreateCol(1,x,'Adults','cmbadult'+x,0,1,4,2)
					fnCreateCol(2,x,'Children (0-3)','cmbchild'+x,x,0,3,0)
				}
			}
		}
	}

	function fnchild(cnum){
		if(cnum>0){
			var tbl = document.getElementById('TBLroom');
   			var lastRow = tbl.rows.length;
   			cnu=cnum;
			if(document.getElementById("roomno").value== 1){
   				cnu=cnum-1;
   			}
			if(document.getElementById('cmbchild'+cnum).value==0){
				var cmba =document.getElementById('p'+cnu);
				if(cmba != null){
					cmba.style.display='none';
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(1)');
				if(cmba != null){
					cmba.style.display='none';
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(2)');
				if(cmba != null){
					cmba.style.display='none';
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(3)');
				if(cmba != null){
					cmba.style.display='none';
				}
			} else if(document.getElementById('cmbchild'+cnum).value==1){
				//var row = tbl.insertRow(cnum);
				var cmba =document.getElementById('p'+cnu);
				if(cmba != null){
					cmba.style.display='';
				} else {
					fnCreateChild(0,cnum,'Age of children','',0,0,0,0,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(1)');
				if(cmba != null){
					cmba.style.display='';
				} else {
				fnCreateChild(1,cnum,'','cmbchildren'+cnum+'('+1+')',0,1,17,1,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(2)');
				if(cmba != null){
					cmba.style.display='none';
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(3)');
				if(cmba != null){
					cmba.style.display='none';
				}
			} else if(document.getElementById('cmbchild'+cnum).value==2){
				var cmba =document.getElementById('p'+cnu);
				if(cmba != null){
					cmba.style.display='';
				} else {
					fnCreateChild(0,cnum,'Age of children','',0,0,0,0,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(1)');
				if(cmba != null){
					cmba.style.display='';
				} else {
				fnCreateChild(1,cnum,'','cmbchildren'+cnum+'('+1+')',0,1,17,1,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(2)');
				if(cmba != null){
					cmba.style.display='';
				} else {
				fnCreateChild(2,cnum,'','cmbchildren'+cnum+'('+2+')',0,1,17,1,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(3)');
				if(cmba != null){
					cmba.style.display='none';
				}
			} else if(document.getElementById('cmbchild'+cnum).value==3){
				//var row = tbl.insertRow(cnum);
				var cmba =document.getElementById('p'+cnu);
				if(cmba != null){
					cmba.style.display='';
				} else {
					fnCreateChild(0,cnum,'Age of children','',0,0,0,0,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(1)');
				if(cmba != null){
					cmba.style.display='';
				} else {
				fnCreateChild(1,cnum,'','cmbchildren'+cnum+'('+1+')',0,1,17,1,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(3)');
				if(cmba != null){
					cmba.style.display='';
				} else {
				fnCreateChild(1,cnum,'','cmbchildren'+cnum+'('+3+')',0,1,17,1,0);
				}
				var cmba =document.getElementById('cmbchildren'+cnum+'(2)');
				if(cmba != null){
					cmba.style.display='';
				} else {
				fnCreateChild(2,cnum,'','cmbchildren'+cnum+'('+2+')',0,1,17,1,0);
				}
			}
		}
	}

	function getImgSize(id,x,y){
		var pic = document.getElementById(id);
		var ih = pic.height;
		var iw = pic.width;
		iw1=x
		ih1=Math.round((x/iw)*ih)
		if(ih1>y) {
			ih1=y
			iw1=Math.round((y/ih)*iw)
		}
		pic.height=ih1;
		pic.width=iw1;
	}

	function fn_bh(cn,ct,ht,fl){
		var dt1=document.frm.adate;
		var dt2=document.frm.ddate;
		if (isDate(dt1.value)==false){
			dt1.focus()
			return false
		} else if (isDate(dt2.value)==false){
			dt2.focus()
			return false
		} else {
			document.location.href='HotelSubmitDetails.asp?cmbCountry='+cn+'&cmbCity='+ct+'&hc='+ht+'&flg='+fl+'&adate='+document.frm.adate.value+'&ddate='+document.frm.ddate.value+'&cmbTRooms=1&cmbAdult1=2&cmbChild1=0&cmbPick=1&cmbCurrency='+document.frmcur.cmbCurrency.value;
		}
		
	}
	function fn_besthotel(cn,ct,ht,fl){
	var dt1=document.frm.adate;
		var dt2=document.frm.ddate;
		if (isDate(dt1.value)==false){
			dt1.focus()
			return false
		} else if (isDate(dt2.value)==false){
			dt2.focus()
			return false
		} else {
			document.location.href='HotelSubmitDetails.asp?cmbCountry='+cn+'&cmbCity='+ct+'&hc='+ht+'&flg='+fl+'&adate='+document.frm.adate.value+'&ddate='+document.frm.ddate.value+'&cmbTRooms=1&cmbAdult1=2&cmbChild1=0&cmbPick=1&cmbCurrency='+document.frmcur.cmbCurrency.value;
		}

		
	}