function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function chart_window(url) {
	//remove a attribute if you don't want it to show up
	window.open(url,'console','width=530,height=360');
}

function readMore(rateid) {
	//alert(rateid);
	document.getElementById(rateid+"A").style.display="none";
	document.getElementById(rateid+"B").style.display="";
	document.getElementById(rateid+"C").style.display="none";
}

function readBack(rateid) {
	//alert(rateid);
	document.getElementById(rateid+"A").style.display="";
	document.getElementById(rateid+"B").style.display="none";
	document.getElementById(rateid+"C").style.display="";
}

function openIReS() {
	window.open('IReSExplorerPop.html','console','width=400,height=200,top=150,left=150');
}

function newWindow(url) {
	window.open(url);
}

function openReviewTxt() {
	window.open('page.html','console','width=300,height=100,top=150,left=150');		
}

function goback() {
	history.go(-1);
}

function showThumbNail( link, public_link,loc,date,ratesheetid,resname) {			
		x = screen.width - 250; 
		y = screen.height - 250; 
		wth = x-10; 
		ht = y-10; 
		lft = 100; 
		tp = 50; 
		var wind = window.open("resort_gallery_pop.php?link="+link+"&public_link="+public_link+"&loc="+loc+"&date="+date+"&ratesheetid="+ratesheetid+"&resname="+resname+"","help","toolbar=no,status=no,resizable=no,menubar=no,width=500,height=490,left="+lft+",top="+tp);
}

function TravellerPopup(resid) {			
		x = screen.width - 250; 
		y = screen.height - 250; 
		wth = x-10; 
		ht = y-10; 
		lft = 100; 
		tp = 50; 
		var wind = window.open("Traveller_gallery_pop.php?resid="+resid+"","help","toolbar=no,status=no,resizable=no,menubar=no,width=500,height=520,left="+lft+",top="+tp);
}

function showRooms(roomNo,fld) {
	switch(fld.value)
		 {
		  case '1':
		  document.getElementById('tdname_1').style.display='none';
		  document.getElementById('room1').style.display='block';
		  document.getElementById('room2').style.display='none';
		  document.getElementById('room3').style.display='none';
		  document.getElementById('room4').style.display='none';
		  //document.getElementById('room').style.display='none';
		  document.getElementById('rooma').style.display='block';
		  //document.getElementById('blankTD').style.display='block';
		
		  break;
		
		  case '2':
		  document.getElementById('tdname_1').style.display='block';
		  document.getElementById('room1').style.display='block';
		  document.getElementById('room2').style.display='block';
		  document.getElementById('room3').style.display='none';
		  document.getElementById('room4').style.display='none';
		   //document.getElementById('room').style.display='none';
		  document.getElementById('rooma').style.display='block';
		  //document.getElementById('blankTD').style.display='none';
		  break;
		
		  case '3':
		  document.getElementById('tdname_1').style.display='block';
		  document.getElementById('room1').style.display='block';
		  document.getElementById('room2').style.display='block';
		  document.getElementById('room3').style.display='block';
		  document.getElementById('room4').style.display='none';
		  // document.getElementById('room').style.display='none';
		  document.getElementById('rooma').style.display='block';
		  //document.getElementById('blankTD').style.display='none';
		  break;
		
		  case '4':
		  document.getElementById('tdname_1').style.display='block';
		  document.getElementById('room1').style.display='block';
		  document.getElementById('room2').style.display='block';
		  document.getElementById('room3').style.display='block';
		  document.getElementById('room4').style.display='block';
		  // document.getElementById('room').style.display='none';
		  document.getElementById('rooma').style.display='block';
		 // document.getElementById('blankTD').style.display='none';
		  break;
		 }
}

function pop_window(url) {
	window.open(url,'console','width=580,height=400,top=150,left=150');
}

function popwin(url,w,h) { 
	width=w+20; height=h+20;
    options = "width=" + width + ",height=" + height+"toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0"
	var newWin = window.open(url, "pop", options) 
}
 
function DateFormat(dateFor) {	
	var ind = dateFor.split("/");
	//var ind2 = dateFor.lastIndexOf("/");		
	//var ln = dateFor.length;	
	var dd = ind[0];	
	var mm = ind[1];;
	var yyyy = ind[2];;

	dateFor = mm+"/"+dd+"/"+yyyy;
	return dateFor;
}

function OnSubmit(){
	//alert(document.frmCheckAvailability.checkboxval.length);
	var objcheckbox = document.getElementsByName( "checkboxval" );
	
	var len ="";
	var true_flag = 0;
	var strGroupId = document.frmCheckAvailability.strGroupId.value;
	var itemCode = document.frmCheckAvailability.itemCode.value;
	var currency = document.frmCheckAvailability.currency.value;
	var strRooms = document.frmCheckAvailability.strRooms.value;
	var checkIn = DateFormat(document.frmCheckAvailability.checkIn.value);
	var checkOut = DateFormat(document.frmCheckAvailability.checkOut.value);
	var destinationid = document.getElementById( "destinationid").value;
	var resortid      = document.getElementById( "resortid" ).value;

	// for debugging
	//alert ( "destination id : "+ destinationid );
	//alert ( "resort id : " + resortid );
	//return false;
	
	// case : room1 table is being displayed 
	if ( document.getElementById('room1').style.display == 'block' )
	{
		//alert ( "room1 display style :" + document.getElementById('room1').style.display );

		var strAdultsRoom1 = document.frmCheckAvailability.strAdultsRoom1.value;
		var strChildrenRoom1 = document.frmCheckAvailability.strChildrenRoom1.value;
        }

	// case : room2 table is being displayed 
	if ( document.getElementById('room2').style.display == 'block' )
	{
		//alert ( "room2 display style :" + document.getElementById('room2').style.display );
		var strAdultsRoom2 = document.frmCheckAvailability.strAdultsRoom2.value;
		var strChildrenRoom2 = document.frmCheckAvailability.strChildrenRoom2.value;
	}
	
	// case : room3 table is being displayed 
	if ( document.getElementById('room3').style.display == 'block' )
	{
		//alert ( "room3 display style :" + document.getElementById('room3').style.display );
		var strAdultsRoom3 = document.frmCheckAvailability.strAdultsRoom3.value;
		var strChildrenRoom3 = document.frmCheckAvailability.strChildrenRoom3.value;
	}

        // case : room4 table is being displayed 
	if ( document.getElementById('room4').style.display == 'block' )
	{
		//alert ( "room4 display style :" + document.getElementById('room4').style.display );
		var strAdultsRoom4 = document.frmCheckAvailability.strAdultsRoom4.value;
		var strChildrenRoom4 = document.frmCheckAvailability.strChildrenRoom4.value;
	}

	var date_format = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/i;
	
	// case : check in date shud not be empty and shud contain valid date 
	if ( ( checkIn == "" ) || (  checkIn.search(date_format) == -1 ) )
	{
		alert ( "Please select a valid Check in date" );
		return false;
	}
	
	// split the given input dates
	var check_in_arr = checkIn.split( "/" );
	var lead_zero = /^0/;
        var check_in_date = parseInt( check_in_arr[1].replace( lead_zero, "" ) );
	var check_in_mnth = parseInt( check_in_arr[0].replace( lead_zero, "" ) );
	/*alert ( "check in date aftr parsing ==> " + check_in_date );
	alert ( "check in mnth after parsing ==> " + check_in_mnth );
	alert ( "Check in yr : "+ parseInt ( check_in_arr[2] ) );*/

	var curr_date = new Date();
	var cur_date = parseInt( curr_date.getDate());
	var cur_mnth = parseInt( curr_date.getMonth()) + 1;
	var cur_yr = parseInt(curr_date.getFullYear()); 

	/*alert ( "curr date :" + cur_date );
	alert ( "Curr mnth :" + cur_mnth );
	alert ( "curr yr : "+ cur_yr );*/

	// case : arrival date shud always be greater than current date
	if ( parseInt( check_in_arr[2] ) < cur_yr ) 
	{
		alert ( "Check in date shoud be greater than today's date" );
		return false;
	}

	// case : year is same and month is lesser than current 
	if ( ( parseInt( check_in_arr[2] ) == cur_yr )  && ( parseInt( check_in_mnth ) < cur_mnth ) ) 
        {
		alert ( "Check in date shoud be greater than today's date" );
		return false;
	}

	// case : year and month are same but date is lesser
	if ( ( parseInt( check_in_arr[2] ) == cur_yr ) &&
	     ( parseInt( check_in_mnth ) == cur_mnth ) &&
	     ( parseInt( check_in_date ) <= cur_date )
	    )
	{
		alert( "Check in date shoud be greater than today's date" );
		return false;


	}

	
	// case : check out date shud not be empty and shud contain valid date 
	if ( ( checkOut == "" ) || ( checkOut.search(date_format) == -1 ) )
	{
		alert ( "Please select a valid Check out date" );
		return false;
	}
        
	var check_out_arr = checkOut.split( "/" );
	var check_out_date = parseInt( check_out_arr[1].replace( lead_zero, "" ) );
	var check_out_mnth = parseInt ( check_out_arr[0].replace( lead_zero, "" ) );
	
	
	// case : departure date is lesser than arrival date 
	if ( parseInt( check_out_arr[2] ) < parseInt( check_in_arr[2] ) )
	{
		alert ( "Check out shoud be greater than Check in date" );
		return false;
	}

	// case : departure date shud always be greater than arrival date 
	if ( ( parseInt( check_out_arr[2] ) == parseInt( check_in_arr[2] ) ) && ( check_out_mnth < check_in_mnth ) ) 
	{
		alert( "Check out date shoud be greater than Check in date" );
		return false;
	}

	// case : if months are same and departure date is lesser than arrival date
	if( ( parseInt( check_out_arr[2] ) == parseInt( check_in_arr[2] ) ) && 
	    ( check_out_mnth  == check_in_mnth )&& 
	    ( check_out_date  <= check_in_date ) 
	   )
	{
		alert ( "Check out date shoud be greater than Check in date" );
		return false;
	}
	
	// case : the user shud select atleast one checkbox if the checkboxes are avilable 
	if ( objcheckbox.length > 0 )
	{
		for ( i = 0; i < objcheckbox.length; i++ )
		{
			if ( objcheckbox[i].checked == true ) 
			{
				true_flag = 1;
				break;
			}
		}
		
		// case : no check 
		if ( true_flag == 0 ) 
		{
			alert( "Please select a vendor" );
			return false;
		}

	}

 	
	/*(if(objcheckbox.length)
	{		
		
	}else{
		//if(objcheckbox.checked){			
			//window.open(url+"?"+query_str, "", 'toolbar=yes, directories=no, location=yes, width = 1000, height = 500 status=yes, menubar=yes, resizable=yes, scrollbars=yes');
		//}
		//return false;
	}*/
	var id = "";
	len = objcheckbox.length;	
	
	for(var i=0;i<len;i++)
	{
		if(objcheckbox[i].checked )
		{
			var checkboxval = objcheckbox[i].value.split("#");
			//alert(checkboxval[1]);
			//alert(checkboxval[2]);
			vendorId = checkboxval[0];
			strGroupId = checkboxval[1];
			itemCode = checkboxval[2];
			if(strGroupId == 'FGH' && itemCode != "")
			{
				var url = "http://www.travelpartnerweb.com/index.jsp";
				var query_str = "strGroupId="+strGroupId+"&itemCode="+itemCode+"&checkIn="+checkIn+"&checkOut="+checkOut+"&currency="+currency+"&strRooms="+strRooms+"&strAdultsRoom1="+strAdultsRoom1+"&strChildrenRoom1="+strChildrenRoom1+ ( ( strAdultsRoom2 >= 1 ) ? "&strAdultsRoom2="+strAdultsRoom2 : "" )+ ( ( strChildrenRoom2 >= 0 ) ? "&strChildrenRoom2="+strChildrenRoom2 : "" )+ ( (strAdultsRoom3 >= 1 ) ? "&strAdultsRoom3="+strAdultsRoom3 : "" )+ ( ( strChildrenRoom3 >= 0 )? "&strChildrenRoom3="+strChildrenRoom3 : "" ) + ( ( strAdultsRoom4 >= 1 ) ? "&strAdultsRoom4="+strAdultsRoom4 :"" ) + ( (strChildrenRoom4 >= 0 ) ? "&strChildrenRoom4="+strChildrenRoom4:"");	
				window.open( url +"?"+ query_str, "", 'toolbar=yes, directories=no, location=yes, width = 1000, height = 500 status=yes, menubar=yes, resizable=yes, scrollbars=yes');

			}
			else{
				alert("Invalid Vendor Group Code OR Item Code ");
				continue;
			}
			// insert the clicks for the selected vendor 
                        document.getElementById( "clicksdiv" ).style.display = "";
			//alert ( "div style for display : " + document.getElementById( "clicksdiv" ).style.display );
			document.getElementById( "clicksframe" ).setAttribute( "src", "checkavailability_clicks.php?pkgid="+resortid+"&packagetypeid=99&destid="+destinationid+"&vendorid="+vendorId );
			//alert ( "iframe src value : " + document.getElementById( "clicksframe" ).src );
			
		}
	}



 //window.open ( "http://www.travelpartnerweb.com/index.jsp?strGroupId=FGH&itemCode=00000125&checkIn=02/10/2007&checkOut=02/13/2007&currency=INR&strRooms=1&strAdultsRoom1=1&strChildrenRoom1=0&strAdultsRoom2=1&strChildrenRoom2=0&strAdultsRoom3=1&strChildrenRoom3=0&strAdultsRoom4=1&strChildrenRoom4=0", "", 'toolbar=yes, directories=no, location=yes, width = 1000, height = 500 status=yes, menubar=yes, resizable=yes, scrollbars=yes');
}

//Added by Annie on 15-Jun-07 :: Customize a Package Form 

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;
}

function show(id,no) {
	/*el = document.getElementById(id);
	
	if(no == 1 ) {


	    el.style.position="absolute";
	    //el.style.position="relative";
		//el.style.z-index="1";
	    el.style.top="530px";
		el.style.left="25px";
		el.style.width= "360px";
		//position:relative; top: 0px;left:0px;width:360px;
	}

	if(no == 2 ) {
		el.style.position="absolute";
	    el.style.top="460px";
		el.style.left="25px";
		el.style.width= "360px";


	}

	if (el.style.display == 'none')
	{
		el.style.display = '';

		el = document.getElementById('more' + id);
		//el.innerHTML = 'less...';
	} else {
		el.style.display = 'none';
		el = document.getElementById('more' + id);
		//el.innerHTML = 'more...';
	}
	*/

	el = document.getElementById(id);
	if (el.style.display == 'none')
	{
		el.style.display = '';
		el = document.getElementById('more' + id);
		//el.innerHTML = 'less...';
	} else {
		el.style.display = 'none';
		el = document.getElementById('more' + id);
		//el.innerHTML = 'more...';
	}
}


function fnValidateCustPackageDetails(form_name) {
	user='document.'+form_name+'.username.value';
	email='document.'+form_name+'.email.value';
	contact='document.'+form_name+'.contactno.value';
	noofpeople='document.'+form_name+'.noofpeople.value';
	cityofresidence = document.userinfo.cityofresidence.options[document.userinfo.cityofresidence.selectedIndex].value;
      
        var checkIn = DateFormat(document.userinfo.datefrom.value);
	var checkOut = DateFormat(document.userinfo.dateto.value);
	
	var date_format = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/i;

	f_user='document.'+form_name+'.username.focus()';
	f_email='document.'+form_name+'.email.focus()';
	f_contact='document.'+form_name+'.contactno.focus()';
	f_noofpeople='document.'+form_name+'.noofpeople.focus()';
   
	if(eval(user)=="") {
			alert("Please Enter User Name");
			eval(f_user);
			return false;
	} 

	if(eval(email)=="") 
	{
		alert("Please Enter your Email Id");
		//eval(f_contact);
		return false;
	}

	if(eval(email)!=="") 
	{

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eval(email)))
			{
			
			
			} else {
					alert("Invalid E-mail Address! Please re-enter.");
					eval(f_email);
					return false;
				  }
	}

	if(eval(contact)=="")
	{
		alert("Please Enter your Phone Number");
		//eval(f_contact);
		return false;
	}

	if(eval(contact)!=="")
		   {

		    phoneno=eval(contact);
		    var phoneno_validation= IsNumeric(phoneno);
		    //alert(phoneno_validation);
		    if(phoneno_validation==false) 
				 {
					 alert("Please Enter valid Phone Number");
					 eval(f_contact);
					 return false;  
				 }
          }

	
       if(eval(noofpeople)!="")
	   {
           	nopeople=eval(noofpeople);
		var people_validation= IsNumeric(nopeople);
		if(people_validation==false)
		{
		 alert("Please Enter valid Number of people");
		 eval(f_noofpeople);
		 return false;
		}
        } 
	if(cityofresidence==-1) {
		alert("Please select a city of residence")
		return false;
	}
	// case : check in date shud not be empty and shud contain valid date 
	if ( ( checkIn == "" ) || (  checkIn.search(date_format) == -1 ) )
	{
		alert ( "Please select a valid From Date" );
		return false;
	}
	
	// split the given input dates
	var check_in_arr = checkIn.split( "/" );
	var lead_zero = /^0/;
        var check_in_date = parseInt( check_in_arr[1].replace( lead_zero, "" ) );
	var check_in_mnth = parseInt( check_in_arr[0].replace( lead_zero, "" ) );
	
	var curr_date = new Date();
	var cur_date = parseInt( curr_date.getDate());
	var cur_mnth = parseInt( curr_date.getMonth()) + 1;
	var cur_yr = parseInt(curr_date.getFullYear()); 

	// case : arrival date shud always be greater than current date
	if ( parseInt( check_in_arr[2] ) < cur_yr ) 
	{
		alert ( "From Date shoud be greater than or equal to today's date" );
		return false;
	}

	// case : year is same and month is lesser than current 
	if ( ( parseInt( check_in_arr[2] ) == cur_yr )  && ( parseInt( check_in_mnth ) < cur_mnth ) ) 
        {
		alert ( "From Date shoud be greater than or equal to today's date" );
		return false;
	}

	// case : year and month are same but date is lesser
	if ( ( parseInt( check_in_arr[2] ) == cur_yr ) &&
	     ( parseInt( check_in_mnth ) == cur_mnth ) &&
	     ( parseInt( check_in_date ) < cur_date )
	    )
	{
		alert( "From Date shoud be greater than or equal to today's date" );
		return false;


	}

	
	// case : check out date shud not be empty and shud contain valid date 
	if ( ( checkOut == "" ) || ( checkOut.search(date_format) == -1 ) )
	{
		alert ( "Please select a valid To Date" );
		return false;
	}
        
	var check_out_arr = checkOut.split( "/" );
	var check_out_date = parseInt( check_out_arr[1].replace( lead_zero, "" ) );
	var check_out_mnth = parseInt ( check_out_arr[0].replace( lead_zero, "" ) );
	
	
	// case : departure date is lesser than arrival date 
	if ( parseInt( check_out_arr[2] ) < parseInt( check_in_arr[2] ) )
	{
		alert ( "To Date shoud be greater than From date" );
		return false;
	}

	// case : departure date shud always be greater than arrival date 
	if ( ( parseInt( check_out_arr[2] ) == parseInt( check_in_arr[2] ) ) && ( check_out_mnth < check_in_mnth ) ) 
	{
		alert( "To Date shoud be greater than From date" );
		return false;
	}

	// case : if months are same and departure date is lesser than arrival date
	if( ( parseInt( check_out_arr[2] ) == parseInt( check_in_arr[2] ) ) && 
	    ( check_out_mnth  == check_in_mnth )&& 
	    ( check_out_date  <= check_in_date ) 
	   )
	{
		alert ( "To Date shoud be greater than From date" );
		return false;
	}
	

}
//End :: Customize a Package Form

//Added by Annie on 26-Sep-07 :: Hotel Booking
function OnHBSubmit(){
	var url = "http://www.cleartrip.com/hotels/info/";
	var hbhotelid = document.hotelbooking.xref_data.value;
	var resortid = document.hotelbooking.resortid.value;
	var destinationid = document.hotelbooking.destinationid.value;
	window.open( url + hbhotelid, "", 'toolbar=yes, directories=no, location=yes, width = 1000, height = 500 status=yes, menubar=yes, resizable=yes, scrollbars=yes');
	// insert the clicks for the selected vendor 
	document.getElementById( "clicksdiv1" ).style.display = "";
	//alert ( "div style for display : " + document.getElementById( "clicksdiv1" ).style.display );
	document.getElementById( "clicksframe1" ).setAttribute( "src", "checkavailability_clicks.php?pkgid="+resortid+"&packagetypeid=97&destid="+destinationid+"&vendorid=5" );
	//alert ( "iframe src value : " + document.getElementById( "clicksframe1" ).src );
}
//End :: Hotel Booking 


function usefulLinkNewWindow(url){ 
	
	if( url.search("http://") == -1 && url.search("HTTP://") == -1 )  
		url = "http://"+url;
	

	/*else if( url.search("www") == -1 && url.search("WWW") == -1 ) 
		url = "www."+url;*/

	window.open (url); 
}
