//jQuery(function($){
var prevId = "";
$(document).ready(function(){
    $('#xxx1').click(function(){
        srcImage = $('#li111').attr("title");
        changeImage(srcImage);
       
    });

    $('#xxx2').click(function(){
        srcImage = $('#li112').attr("title");
        changeImage(srcImage);
       
       
    });
       
    $('#xxx3').click(function(){
        srcImage = $('#li113').attr("title");
        changeImage(srcImage);
      
        
    });
    
    $('#previmg').click(function(){
        if ( curImg > 0 ) {
            curImg--;
        } else {
            curImg = 2;
        }
        changeImage(t[curImg]);
    });

    $('#nextimg').click(function(){
        if ( curImg < 2 ) {
            curImg++;
        } else {
            curImg = 0;
        }
        changeImage(t[curImg]);
    });
        
    var qpMoreTimer = null;
    $("#LangBox").hover(function () { 
        clearTimeout(qpMoreTimer); 
        qpMoreTimer = setTimeout(function () { 
            $("#LngList").show();
            $("#linkMore").addClass("hover");}, 10);}, function () { 
            clearTimeout(qpMoreTimer); qpMoreTimer = setTimeout(function () { 
            $("#LngList").hide();
            $("#linkMore").removeClass("hover"); }, 200);});
    
    $("#strRooms").change(function() {
        var id = $(this).val();
        for ( var i=1; i<=5; i++ ) {
            $("#room"+i).hide();
        }

        for ( var i=1; i<=id; i++ ) {
            $("#room"+i).show();
        }
    });
    

     
    
});


    function showMAP() {
			    $('#flashmap').show('slow');
    			
			    $('#mapbutton1').replaceWith('<a href="#" id="mapbutton2" onclick="closeMap()"><img src="images/buttons/tab-location-map-close.gif" width="112" height="32" /></a>');
		    }
    		
		    function closeMap() {
			    $('#flashmap').hide('slow');

			    $('#mapbutton2').replaceWith('<a href="#" id="mapbutton1" onclick="showMAP()"><img src="images/buttons/tab-location-map.gif" width="112" height="32" /></a>');
		    }

    		
		    function showHotel() {
			    $('#memberlogin').slideUp(800);
			    $("#hotsearchform").slideDown(800);

			    $('#button2').replaceWith('<a href="#" id="button2" onclick="showHotel()"><img src="images/buttons/tab-hotel-search-active.gif" width="94" height="34" /></a>');
			    $('#button3').replaceWith('<a href="#" id="button3" onclick="showLogin()"><img src="images/buttons/tab-memberlogin.gif" width="96" height="32" /></a>');
		    }

		    function showLogin() {
			    $('#hotsearchform').slideUp(800);
			    $("#memberlogin").slideDown(800);
    			
			    $('#button3').replaceWith('<a href="#" id="button3" onclick="showLogin()"><img src="images/buttons/tab-memberlogin-active.gif" width="96" height="34" /></a>');
			    $('#button2').replaceWith('<a href="#" id="button2" onclick="showHotel()"><img src="images/buttons/tab-hotel-search.gif" width="94" height="32" /></a>');

		    }

		    $(document).ready(function(){
		    $('li.languagelink ul').hide();
		    $('li.languagelink').hover(
			    function() { $('ul', this).css('display', 'block'); },
			    function() { $('ul', this).css('display', 'none'); });
	    });
var PrevId1="";
    function showCheckAvail(id,pid) {
  
        $('#popupwindow'+PrevId1+' #popupcheck'+prevId).fadeOut('slow');
	    $('#popupwindow'+pid+''+id+' #popupcheck'+id+''+pid).fadeIn('slow');
	    prevId = id+''+pid;
	    PrevId1=pid+''+id;
	    
	    Changeddl(id+1, PrevId1,pid);
    }

    function closeCheckAvail(id, pid) {
	    $('#popupwindow'+ pid +''+ id +' #popupcheck'+id+''+pid).fadeOut("slow");

    }
    
    
    function Changeddl(indexid,pid,ppid){
    
    
     $('#popupwindow'+pid+' #strRooms1'+indexid+''+ppid).change(function() {
     
        var id = $(this).val();
         
        for ( var i=0; i<=5; i++ ) {
            $('#popupwindow'+pid+' #room'+i+indexid+''+ppid).hide();
        }
        for ( var i=0; i<=id; i++ ) {
            $('#popupwindow'+pid+' #room'+i+indexid+''+ppid).show();
        }
    });
    };
    
    function SubmitBooking(IndexID, pid,PopId){
   
        var itemCode= ($('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' .hotelid').val());
   
        var chkinDate=($('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' #txtArriDate'+pid+IndexID).val());

        var chkoutDate=($('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' #txtDepDate'+pid+(IndexID+1)).val());
        var NubmerOfroom=($('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' #strRooms1'+(IndexID+1+''+pid)).val());
      
        
        
        var TCurrentDate = new Date();
        var Cmonth = TCurrentDate.getMonth()+1;
        var Cday = TCurrentDate.getDate();
        var Cyear = TCurrentDate.getFullYear();
        
        var MatchCurrentDate=(Cmonth+'/'+Cday+'/'+Cyear);
            if(chkinDate=="" || chkinDate=="dd/mm/yyyy")
            {
            alert("Please select check-in Date.");
            return false;
            };
            if(chkoutDate=="" || chkoutDate=="dd/mm/yyyy")
            {
            alert("Please select check-Out Date.");
            return false;
            };
       
        var ddCID,mmCID,yyyyCID;
		var ddCOD,mmCOD,yyyyCOD;
		var tempCID,tempCOD;
        inid = chkinDate.split('/');
		outid = chkoutDate.split('/');
		ddCID=inid[0];
		mmCID=inid[1];
		yyyyCID=inid[2];
		tempCID="";
		tempCID=mmCID + "/" + ddCID + "/" + yyyyCID;

		ddCOD=outid[0];
		mmCOD=outid[1];
		yyyyCOD=outid[2];
		tempCOD="";
		tempCOD=mmCOD + "/" + ddCOD + "/" + yyyyCOD;
            
            if(Date.parse(tempCOD) <= Date.parse(tempCID))
            {
	            alert("Check-out date should be greater than check-in date");
	            return false;
            }
           
               if(Date.parse(MatchCurrentDate) > Date.parse(tempCID))
            {
	            alert("Check-In date should be greater than Current date");
	            return false;
            }
            
            
            if(Date.parse(tempCOD) - Date.parse(tempCID) < 1*86400000)
            {
	            alert("The minimum stay period should not be less than 1 days");
	            return false;
            }
            
            if(Date.parse(tempCOD) - Date.parse(tempCID)>30*86400000)
            {
	            alert("The maximum stay period should not be greater than 30 days");
	            return false;
            }
             AR1=$('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' #strAdultsRoom1'+(IndexID+1+''+pid)).val();
             CR1=$('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' #strChildrenRoom1'+(IndexID+1+''+pid)).val();
             
              var nextURL= "https://gc.synxis.com/rez.aspx?Hotel="+itemCode+"&Chain=12382&arrive="+tempCID+"&depart="+tempCOD+"&rooms="+NubmerOfroom+"";        
             //var CurrType = $('#popupwindow'+PopId+' #popupcheck'+IndexID+''+pid+' #CmbBxCurrency'+IndexID).val();
             //var nextURL= "http://fortunehotels.travelpartnerweb.com/index.jsp?strGroupId=FGH&itemCode="+itemCode+"&checkIn="+tempCID+"&checkOut="+tempCOD+"&currency="+CurrType+"&strRooms="+NubmerOfroom+"&strAdultsRoom1="+AR1+"&strChildrenRoom1="+CR1+"&strAdultsRoom2="+AR2+"&strChildrenRoom2="+CR2+"&strAdultsRoom3="+AR3+"&strChildrenRoom3="+CR3+"&strAdultsRoom4="+AR4+"&strChildrenRoom4="+CR4+"";
             //alert(nextURL);
             window.location=nextURL;

    };
    
   
   


