// JavaScript Document
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: true, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='"+pathdateimg+"/images/plus.gif' class='statusicon' />", "<img src='"+pathdateimg+"/images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
   });

$("document").ready(function() {

	$(".sendquery" ).click(function(){
        //id = $(this).attr('id');
        //pieces = id.split("-");
		pkgName= '';//$("form[name='form-"+pieces[1]+"'] input[name='package_name_title'][type='hidden']").val();
		pkgid= '';//$("form[name='form-"+pieces[1]+"'] input[name='package_id'][type='hidden']").val();
		$.ajax({
             type:"POST",
             url:HOSTURL+"hotels/30percentcashbackhotels/sendmailform",
             data:"package_name_title="+escape(pkgName)+"&country="+countryName+"&city="+cityName+"&pkgid="+pkgid+"&action=sendQuery",
             success:function(results){
				 			  //alert(results);
							  jQuery.facebox( results );
							  $("img#emailformbtnfield").css("cursor", "pointer").bind("click",function(e){
									$.ajax({
											type:"POST",
											url:HOSTURL+"hotels/30percentcashbackhotels/validatemailform",
											data:"action=sendQueryVal&sendqueryname="+$("input[type='text'][name='sendqueryname']").val()+"&sendqueryemail="+$("input[type='text'][name='sendqueryemail']").val()+"&sendquerytel="+$("input[type='text'][name='sendquerytel']").val()+"&sendquerymob="+$("input[type='text'][name='sendquerymob']").val()+"&sendqueryremarks="+$("textarea[name='sendqueryremarks']").val()+"&packagename="+$("input[type='hidden'][name='query_pckname']").val(),
											success:function(msg){
												$("div.msg").html("*"+msg);
											}

									});
									return false;
							  });
							  
             },
             error:function ( XMLHttpRequest, textStatus, errorThrown) {
                 alert("An error occured.Detail can not obtained");
                 return null;
             }
        });
				return false;

    });

	if(hotelNames.length>0)
	{
		getImages(countryName, cityName, hotelNames);
	}

	//getCountryDropDown(countryName);
	//getCityDropDown(countryName, cityName);
    //initPagination();
        
 	$("a[rel*=facebox]").facebox();
 	 $('#facebox').livequery(function() {
   			$(this).bgiframe();
	});

	$("div#Pagination a").click(function(){
		showOverlay();					
	});
	   
	$("div.submenu ul li a").click(function(){
		showOverlay();					
	});
		
	$("#faq" ).click(function(){    	
    	NewWindow("http://static.ezeego1.co.in/ezeego_html/ezeego1/B2C/english/html/hotels/hotels_faqs.html","FAQs",'yes', '610', '600');     
        return false;
    });
	$("#terms" ).click(function(){    	
    	NewWindow("http://static.ezeego1.co.in/ezeego_html/ezeego1/B2C/english/html/terms_conditions/terms_lotushotels.html","Terms_and_Conditions",'yes', '630', '630');     
        return false;
    });
    

 });

 function img_popup(obj, cityName, countryName, hotelName){        	 	
	jQuery.facebox('<div style="width:770px;"><div class="floatright" style="margin:5px 5px 0 0;"><a href="javascript:;" class="colorgrey bold text11" style="text-decoration:none" onClick="$(document).trigger(\'close.facebox\');">Close</a>&nbsp;<img src="'+pathdateimg+'/images/close.gif" alt="Close" width="16" height="16" align="absmiddle" onClick="$(document).trigger(\'close.facebox\');" style="cursor:pointer;"></div><div class="clear" align="center"><img src="'+pathdateimg+'/images/loading.gif" align="middle" /><br />Loading...<br /></div><div class="clear" style="line-height:10px;">&nbsp;</div></div>');

	$("#facebox div.content").load(HOSTURL+"hotels/30percentcashbackhotels/ajaxController.php", {f: 'getImages', city: cityName, country: countryName, hotelName: hotelName,zone:zoneName}, function(){ 				
		  $('#facebox a.img').click(function() { 
		  	$("#facebox img.image_show_big").attr("src", $(this).find("img").attr("src")); 
		  	return false;
		  });				
    }); 
    return false;
  }
 function inclusions_popup(obj,cityName, countryName, hotelName){
	jQuery.facebox('<div style="width:588px;"><div class="floatright" style="margin:5px 5px 0 0;"><a href="javascript:;" class="colorgrey bold text11" style="text-decoration:none" onClick="$(document).trigger(\'close.facebox\');">Close</a>&nbsp;<img src="'+pathdateimg+'/images/close.gif" alt="Close" width="16" height="16" align="absmiddle" onClick="$(document).trigger(\'close.facebox\');" style="cursor:pointer;"></div><div class="clear" align="center"><img src="'+pathdateimg+'/images/loading.gif" align="middle" /><br />Loading...<br /></div><div class="clear" style="line-height:10px;">&nbsp;</div></div>');

	$("#facebox div.content").load(HOSTURL+"hotels/30percentcashbackhotels/ajaxController.php", {f: 'getInclusions', city: cityName, country: countryName, hotelName: hotelName,zone:zoneName}, function(){ 				
    }); 
    return false;
  }  

 
 
function ajaxController(query, methodName )
{	 
	$.ajax({
             type:"POST",
             url:HOSTURL+"hotels/30percentcashbackhotels/ajaxController.php",
             data: query,
             success:function(results){  
             		if(methodName) 	
                    	eval (methodName+"(results)");
             },
             error:function ( XMLHttpRequest, textStatus, errorThrown) {
                // alert("An error occured.Detail can not obtained");
                 return null;
             }
       	});     
}

function getImages(countryName, cityName, hotelNames)	
{
	for (k in hotelNames)
	{
		$("div#pic-left-pack-"+k).load(HOSTURL+"hotels/30percentcashbackhotels/ajaxController.php", {f: 'getFrontImage', city: cityName, country: countryName, hotelName: hotelNames[k],zone:zoneName});
	}
}

function getCityDropDown(countryName, cityName)
{
	$("span#city_loader_img").show();
	var queryStr ='f=getCities&country='+countryName+'&city='+cityName;
	ajaxController(queryStr,'displayCityContent');
}

function getCountryDropDown(countryName)
{
	$("span#country_loader_img").show();
	var queryStr ='f=getCountries&country='+countryName;
	ajaxController(queryStr,'displayCountrtyContent');
}

function displayCityContent(data)
{
	$("select#city_drop").replaceWith(data);
	$("span#city_loader_img").hide();
}

function displayCountrtyContent(data)
{
	$("select#country_drop").replaceWith(data);
	$("span#country_loader_img").hide();
}

function getHotels()
{
	showOverlay();
	var curLocation	= location.href;
	var lastChar 	= curLocation.substring(curLocation.length-1);
	var prefix		= '../../../../';
	if(lastChar != '/')
	{
		prefix = '../../../';
	}		
	location.href = prefix+$("#country_drop").val().toLowerCase()+"/"+$("#city_drop").val().toLowerCase()+"/page/1";
	
}

function NewWindow(mypage,myname,scroll,w,h){    
    var width = w ? w : '725';
    var height = h ? h : '600';
  	window.open(mypage,myname,'scrollbars=yes,width='+width+',height='+height);
}

function showOverlay()
{
	/*$("select").css("background-color", "#ebebe4");
	$("div#modal").css("width",screen.width+"px").css("height", screen.height+"px");
	$("div#modal").bgiframe();
	$("div#modal").show();
	$('div#loader').show();
	$('div#loader').html("Loading...<br><img src='webroot/images/loader.gif' />");*/
}

