﻿function hideallstyle()
	{
	R1C1.style.display='none';
    R1C2.style.display='none';
    R1C3.style.display='none';
    R1C4.style.display='none';
    R2C1.style.display='none';
    R2C2.style.display='none';
    R2C3.style.display='none';
    R2C4.style.display='none';
    R3C1.style.display='none';
    R3C2.style.display='none';
    R3C3.style.display='none';
    R3C4.style.display='none';
    R4C1.style.display='none';
    R4C2.style.display='none';
    R4C3.style.display='none';
    R4C4.style.display='none';
    R1.style.display='none';
    R2.style.display='none';
    R3.style.display='none';
    R4.style.display='none';   
    ChHead.style.display='none'; 
	}

function HideChildG(GrpID)
	{
	if (GrpID==1)
		{
		R1C1.style.display='none';
	    R1C2.style.display='none';
	    R1C3.style.display='none';
	    R1C4.style.display='none';
		}
	else if (GrpID==2)
		{
		R2C1.style.display='none';
	    R2C2.style.display='none';
	    R2C3.style.display='none';
	    R2C4.style.display='none';
		}
	else if (GrpID==3)
		{
		R3C1.style.display='none';
	    R3C2.style.display='none';
	    R3C3.style.display='none';
	    R3C4.style.display='none';
		}
	else if (GrpID==4)
		{
		R4C1.style.display='none';
	    R4C2.style.display='none';
	    R4C3.style.display='none';
	    R4C4.style.display='none';
		}						
	}	

function ViewChildG(Gna)
	{
	var ChildId =0;
	HideChildG(Gna);
	if ((booking.R1C.value!=0) || (booking.R2C.value!=0) || (booking.R3C.value!=0) || (booking.R4C.value!=0) )
		{
		ChHead.style.display='';
		}
	else
		{
		ChHead.style.display='none';
		}
	if (Gna==1)
		{
		ChildId =booking.R1C.value;
		if (ChildId==1)
			{
			R1C1.style.display='';
			}
		else if (ChildId==2)
			{
			R1C1.style.display='';
			R1C2.style.display='';
			}
		else if (ChildId==3)
			{
			R1C1.style.display='';
			R1C2.style.display='';
			R1C3.style.display='';
			}
		else if (ChildId==4)
			{
			R1C1.style.display='';
			R1C2.style.display='';
			R1C3.style.display='';
			R1C4.style.display='';
			}	
		else if (ChildId==0)
			{
			R1C1.style.display='none';
			R1C2.style.display='none';
			R1C3.style.display='none';
			R1C4.style.display='none';
			}									
		}
	else if (Gna==2)
		{
		ChildId =booking.R2C.value;
		if (ChildId==1)
			{
			R2C1.style.display='';
			}
		else if (ChildId==2)
			{
			R2C1.style.display='';
			R2C2.style.display='';
			}
		else if (ChildId==3)
			{
			R2C1.style.display='';
			R2C2.style.display='';
			R2C3.style.display='';
			}
		else if (ChildId==4)
			{
			R2C1.style.display='';
			R2C2.style.display='';
			R2C3.style.display='';
			R2C4.style.display='';
			}	
		else if (ChildId==0)
			{
			R2C1.style.display='none';
			R2C2.style.display='none';
			R2C3.style.display='none';
			R2C4.style.display='none';
			}									
		}
	else if (Gna==3)
		{
		ChildId =booking.R3C.value;
		if (ChildId==1)
			{
			R3C1.style.display='';
			}
		else if (ChildId==2)
			{
			R3C1.style.display='';
			R3C2.style.display='';
			}
		else if (ChildId==3)
			{
			R3C1.style.display='';
			R3C2.style.display='';
			R3C3.style.display='';
			}
		else if (ChildId==4)
			{
			R3C1.style.display='';
			R3C2.style.display='';
			R3C3.style.display='';
			R3C4.style.display='';
			}	
		else if (ChildId==0)
			{
			R3C1.style.display='none';
			R3C2.style.display='none';
			R3C3.style.display='none';
			R3C4.style.display='none';
			}									
		}
	else if (Gna==4)
		{
		ChildId =booking.R4C.value;
		if (ChildId==1)
			{
			R4C1.style.display='';
			}
		else if (ChildId==2)
			{
			R4C1.style.display='';
			R4C2.style.display='';
			}
		else if (ChildId==3)
			{
			R4C1.style.display='';
			R4C2.style.display='';
			R4C3.style.display='';
			}
		else if (ChildId==4)
			{
			R4C1.style.display='';
			R4C2.style.display='';
			R4C3.style.display='';
			R4C4.style.display='';
			}	
		else if (ChildId==0)
			{
			R4C1.style.display='none';
			R4C2.style.display='none';
			R4C3.style.display='none';
			R4C4.style.display='none';
			}									
		}				
	}

	
function viewRoom()
	{
	//hideallstyle();
	if (tourValidate()==false){return false;}
	var tmpRoo=booking.NoRoom.value;
	if (tmpRoo==1)
		{
		R1.style.display='';
		R2.style.display='none';
		R3.style.display='none';
		R4.style.display='none';
		}
	else if (tmpRoo==2)
		{
		R1.style.display='';
		R2.style.display='';
		R3.style.display='none';
		R4.style.display='none';
		}
	else if (tmpRoo==3)
		{
		R1.style.display='';
		R2.style.display='';
		R3.style.display='';
		R4.style.display='none';	
		}			
	else if (tmpRoo==4)
		{
		R1.style.display='';
		R2.style.display='';
		R3.style.display='';
		R4.style.display='';				
		}
		ViewChildG(1);
		ViewChildG(2);
		ViewChildG(3);
		ViewChildG(4);
	}	
	
	function AEDChange()
	{
	if (booking.cmbBudget.value!="2")
		{
		AEDTab.style.display="none";
		}
	else
		{
		AEDTab.style.display="";
		booking.AEDF.focus();
		}
	}

function tourValidate()
	{
	if ((booking.txtService.value =='TUR') && (booking.NoRoom.value>2))
		{
		alert("No of rooms shouldn't be grater than 2");
		booking.NoRoom.focus()
		return false;
		}
	}

function ValidateMe()
	{
	//if ((booking.txtService.value !='HTL') && (booking.txtService.value !='APT')) {alert("This service is under construction.\n\n Please try it later. \n\n Thank You");return false;}

	if (tourValidate()==false){return false;}

	if (booking.NoRoom.value==1)
		{
		if (ValidateRoom1()==false){return false;}
		}
	else if (booking.NoRoom.value==2)
		{
		if (ValidateRoom1()==false){return false;}
		if (ValidateRoom2()==false){return false;}		
		}	
	else if (booking.NoRoom.value==3)
		{
		if (ValidateRoom1()==false){return false;}
		if (ValidateRoom2()==false){return false;}
		if (ValidateRoom3()==false){return false;}
		}	
	else if (booking.NoRoom.value==4)
		{
		if (ValidateRoom1()==false){return false;}
		if (ValidateRoom2()==false){return false;}
		if (ValidateRoom3()==false){return false;}
		if (ValidateRoom4()==false){return false;}
		}
	
	if (booking.cmdCityCode.value=="0"){alert ("Select City");booking.cmdCityCode.focus();return false;}
	//if (booking.cmbSpType.value=="0"){alert ("Select Service provider type");booking.cmbSpType.focus();return false;}
	//if (booking.cmbCategory.value=="0"){alert ("Select category");booking.cmbCategory.focus();return false;}
	if (booking.cmbBudget.value=="0")
		{
		alert ("Select Budget");
		booking.cmbBudget.focus();
		return false;
		}
	else if (booking.cmbBudget.value=="2")
		{
		if (IsNumeric(booking.AEDF.value)==false){alert("Invalid data for this field");booking.AEDF.focus();booking.AEDF.select();return false;}
		if (IsNumeric(booking.AEDT.value)==false){alert("Invalid data for this field");booking.AEDT.focus();booking.AEDT.select();return false;}
		if (booking.AEDF.value==""){alert ("Enter minimum price");booking.AEDF.focus();return false;}
		if (booking.AEDT.value=="" != booking.AEDT.value==""){alert ("Enter maximum price");booking.AEDT.focus();return false;}
		var aa=booking.AEDF.value;
		var bb=booking.AEDT.value;
		aa=aa*1
		bb=bb*1
		if (aa<0){alert ("Minimum price should be greater than Zero");booking.AEDF.focus();booking.AEDF.select();return false;}
		if (aa>bb){alert ("Maximum price should not be less than " + booking.AEDF.value);booking.AEDT.focus();booking.AEDT.select();return false;}
		}
	else
		{
		booking.AEDF.value="0";
		booking.AEDT.value="0";
		}
			
	booking.cmdsearch.value="Please wait..";
	booking.submit();
	}

	
function ValidateRoom1()
	{
	if (booking.R1C.value==1)
		{
		if (booking.R1C1.value==-1){alert ("Select child's age");booking.R1C1.focus();return false;}
		}
	else if (booking.R1C.value==2)
		{
		if (booking.R1C1.value==-1){alert ("Select child's age");booking.R1C1.focus();return false;}
		if (booking.R1C2.value==-1){alert ("Select child's age");booking.R1C2.focus();return false;}
		}
	else if (booking.R1C.value==3)
		{
		if (booking.R1C1.value==-1){alert ("Select child's age");booking.R1C1.focus();return false;}
		if (booking.R1C2.value==-1){alert ("Select child's age");booking.R1C2.focus();return false;}
		if (booking.R1C3.value==-1){alert ("Select child's age");booking.R1C3.focus();return false;}
		}
	else if (booking.R1C.value==4)
		{
		if (booking.R1C1.value==-1){alert ("Select child's age");booking.R1C1.focus();return false;}
		if (booking.R1C2.value==-1){alert ("Select child's age");booking.R1C2.focus();return false;}
		if (booking.R1C3.value==-1){alert ("Select child's age");booking.R1C3.focus();return false;}
		if (booking.R1C4.value==-1){alert ("Select child's age");booking.R1C4.focus();return false;}
		}						
	}
function ValidateRoom2()
	{
	if (booking.R2C.value==1)
		{
		if (booking.R2C1.value==-1){alert ("Select child's age");booking.R2C1.focus();return false;}
		}
	else if (booking.R2C.value==2)
		{
		if (booking.R2C1.value==-1){alert ("Select child's age");booking.R2C1.focus();return false;}
		if (booking.R2C2.value==-1){alert ("Select child's age");booking.R2C2.focus();return false;}
		}
	else if (booking.R2C.value==3)
		{
		if (booking.R2C1.value==-1){alert ("Select child's age");booking.R2C1.focus();return false;}
		if (booking.R2C2.value==-1){alert ("Select child's age");booking.R2C2.focus();return false;}
		if (booking.R2C3.value==-1){alert ("Select child's age");booking.R2C3.focus();return false;}
		}
	else if (booking.R2C.value==4)
		{
		if (booking.R2C1.value==-1){alert ("Select child's age");booking.R2C1.focus();return false;}
		if (booking.R2C2.value==-1){alert ("Select child's age");booking.R2C2.focus();return false;}
		if (booking.R2C3.value==-1){alert ("Select child's age");booking.R2C3.focus();return false;}
		if (booking.R2C4.value==-1){alert ("Select child's age");booking.R2C4.focus();return false;}
		}						
	}
function ValidateRoom3()
	{
	if (booking.R3C.value==1)
		{
		if (booking.R3C1.value==-1){alert ("Select child's age");booking.R3C1.focus();return false;}
		}
	else if (booking.R3C.value==2)
		{
		if (booking.R3C1.value==-1){alert ("Select child's age");booking.R3C1.focus();return false;}
		if (booking.R3C2.value==-1){alert ("Select child's age");booking.R3C2.focus();return false;}
		}
	else if (booking.R3C.value==3)
		{
		if (booking.R3C1.value==-1){alert ("Select child's age");booking.R3C1.focus();return false;}
		if (booking.R3C2.value==-1){alert ("Select child's age");booking.R3C2.focus();return false;}
		if (booking.R3C3.value==-1){alert ("Select child's age");booking.R3C3.focus();return false;}
		}
	else if (booking.R3C.value==4)
		{
		if (booking.R3C1.value==-1){alert ("Select child's age");booking.R3C1.focus();return false;}
		if (booking.R3C2.value==-1){alert ("Select child's age");booking.R3C2.focus();return false;}
		if (booking.R3C3.value==-1){alert ("Select child's age");booking.R3C3.focus();return false;}
		if (booking.R3C4.value==-1){alert ("Select child's age");booking.R3C4.focus();return false;}
		}						
	}
	
	
function ValidateRoom4()
	{
	if (booking.R4C.value==1)
		{
		if (booking.R4C1.value==-1){alert ("Select child's age");booking.R4C1.focus();return false;}
		}
	else if (booking.R4C.value==2)
		{
		if (booking.R4C1.value==-1){alert ("Select child's age");booking.R4C1.focus();return false;}
		if (booking.R4C2.value==-1){alert ("Select child's age");booking.R4C2.focus();return false;}
		}
	else if (booking.R4C.value==3)
		{
		if (booking.R4C1.value==-1){alert ("Select child's age");booking.R4C1.focus();return false;}
		if (booking.R4C2.value==-1){alert ("Select child's age");booking.R4C2.focus();return false;}
		if (booking.R4C3.value==-1){alert ("Select child's age");booking.R4C3.focus();return false;}
		}
	else if (booking.R4C.value==4)
		{
		if (booking.R4C1.value==-1){alert ("Select child's age");booking.R4C1.focus();return false;}
		if (booking.R4C2.value==-1){alert ("Select child's age");booking.R4C2.focus();return false;}
		if (booking.R4C3.value==-1){alert ("Select child's age");booking.R4C3.focus();return false;}
		if (booking.R4C4.value==-1){alert ("Select child's age");booking.R4C4.focus();return false;}
		}						
	}

function FillSubData (objTo,Code)
	{
	var str;
	var str1;
	var ary;
	var ary1;
	objTo.selectedIndex = -1;
	var iListBoxLength = objTo.options.length;
	for (var i = 0; i < iListBoxLength; i++){objTo.options.remove(0);}
	var objHTTP;
	try {objHTTP = new XMLHttpRequest();objHTTP.overrideMimeType("text/xml");}catch(e){
	try {objHTTP = new ActiveXObject("Msxml2.xmlHTTP");}catch(e){
	try {objHTTP = new ActiveXObject("Microsoft.xmlHTTP");objHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");}catch(e){}}}
	objHTTP.open("GET", "source.asp?Passval="  + Code,false);
	objHTTP.send(Code);
	str1=objHTTP.responseText;
	ary1=str1.split(";");
	var tCat=booking.cmbCat.value;
	for (var i = 0; i < ary1.length; i++)
		{
		var objOption = document.createElement("option");
		str2=ary1[i];
		ary2=str2.split("@");
		if (i==0)
			{
			objOption.setAttribute('value', '0');
			var opColTxt = document.createTextNode('ALL');
			objOption.appendChild(opColTxt);
			}
		else
			{
			objOption.setAttribute('value', ary2[0]);
			var opColTxt = document.createTextNode(ary2[1]);
			objOption.appendChild(opColTxt);

			}
		objTo.appendChild(objOption);
		}
	}

	
 var win = null;
 function fnopen(id) 
 { 
 win=window.open("calendarexample.asp?mode=0","Calender","width=305,height=305,scrollbars=no,title=no,status=no,toolbar=no,menubar=no,resizable=no,screenX=200,screenY=200")
 }



function GoFillSubData (Imgname,SerTyp,objTo,Code,cmbClea)
	{

	//if ((SerTyp !='HTL') && (SerTyp !='APT'))
	//	{
	//	alert("This service is under construction.\n\n Please try it later. \n\n Thank You");
	//	}
//	else
//		{
		booking.ImgHot.src="images/OptHot1.jpg";
		booking.ImgApt.src="images/OptApt1.jpg";
		booking.ImgCar.src="images/OptCar1.jpg";
		booking.ImgTou.src="images/OptTou1.jpg";
		booking.ImgTra.src="images/OptTra1.jpg";
		Imgname.src="images/Opt" + Right(Imgname.name,3) + "s1.jpg";
		booking.txtService.value=SerTyp;
		if (cmbClea=='1'){booking.cmbCat.value='';}
		FillSubData(objTo,Code);
//		}	
	}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


