﻿//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();
//        }
//    });
//    
//   $(".newsticker-jcarousellite").jCarouselLite({
//	    vertical: true,
//	    hoverPause:true,
//	    visible: 2,
//	    auto:500,
//	    speed:2000
//    });
//     
    
//});


    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'); });
	    });




    
    function showCheckAvail(id) {
        $('#popupcheck'+prevId).fadeOut('slow');
        
	    $('#popupcheck'+id).fadeIn('slow');
	    prevId = id;
	    Changeddl(id+1);
    }

    function closeCheckAvail(id) {
	    $('#popupcheck'+id).fadeOut('slow');

    }
    
    
    function Changeddl(indexid){
   
     $("#strRooms1"+indexid).change(function() {
        var id = $(this).val();
         
        for ( var i=0; i<=5; i++ ) {
            $("#room"+i+indexid).hide();
        }
        

        for ( var i=0; i<=id; i++ ) {
            $("#room"+i+indexid).show();
        }
        
    });
    };
    
    function SubmitBooking(IndexID){
   
        var itemCode= ($('#popupcheck'+IndexID+' .hotelid').val());
        var chkinDate=($('#popupcheck'+IndexID+' #txtArriDate'+IndexID).val());
        var chkoutDate=($('#popupcheck'+IndexID+' #txtDepDate'+(IndexID+1)).val());
        var NubmerOfroom=($('#popupcheck'+IndexID+' #strRooms1'+(IndexID+1)).val());
        
            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(tempCOD<=tempCID)
            {
	            alert("Check-out date should be greater than check-in 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;
            }
            var AR1,AR2,AR3,AR4,CR1,CR2,CR3,CR4;           
             if(NubmerOfroom=="01")
             {
             AR1=$('#popupcheck'+IndexID+' #strAdultsRoom1'+(IndexID+1)).val();
             CR1=$('#popupcheck'+IndexID+' #strChildrenRoom1'+(IndexID+1)).val();
             AR2="0";
             AR3="0";
             AR4="0";
             CR1="0";
             CR2="0";
             CR3="0";
             CR4="0";
             }
             if(NubmerOfroom=="02")
             {
             AR1=$('#popupcheck'+IndexID+' #strAdultsRoom1'+(IndexID+1)).val();
             CR1=$('#popupcheck'+IndexID+' #strChildrenRoom1'+(IndexID+1)).val();
             AR2=$('#popupcheck'+IndexID+' #strAdultsRoom2'+(IndexID+1)).val();
             AR3="0"
             AR4="0";
             CR2=$('#popupcheck'+IndexID+' #strChildrenRoom2'+(IndexID+1)).val();
             CR3="0";
             CR4="0";
             }
             if(NubmerOfroom=="03")
             {
             AR1=$('#popupcheck'+IndexID+' #strAdultsRoom1'+(IndexID+1)).val();
             CR1=$('#popupcheck'+IndexID+' #strChildrenRoom1'+(IndexID+1)).val();
             AR2=$('#popupcheck'+IndexID+' #strAdultsRoom2'+(IndexID+1)).val();
             AR3=$('#popupcheck'+IndexID+' #strAdultsRoom3'+(IndexID+1)).val();
             AR4="0";
             CR2=$('#popupcheck'+IndexID+' #strChildrenRoom2'+(IndexID+1)).val();
             CR3=$('#popupcheck'+IndexID+' #strChildrenRoom3'+(IndexID+1)).val();
             CR4="0";
             }
             if(NubmerOfroom=="04")
             {
             AR1=$('#popupcheck'+IndexID+' #strAdultsRoom1'+(IndexID+1)).val();
             CR1=$('#popupcheck'+IndexID+' #strChildrenRoom1'+(IndexID+1)).val();
             AR2=$('#popupcheck'+IndexID+' #strAdultsRoom2'+(IndexID+1)).val();
             AR3=$('#popupcheck'+IndexID+' #strAdultsRoom3'+(IndexID+1)).val();
             AR4=$('#popupcheck'+IndexID+' #strAdultsRoom4'+(IndexID+1)).val();
             CR2=$('#popupcheck'+IndexID+' #strChildrenRoom2'+(IndexID+1)).val();
             CR3=$('#popupcheck'+IndexID+' #strChildrenRoom3'+(IndexID+1)).val();
             CR4=$('#popupcheck'+IndexID+' #strChildrenRoom4'+(IndexID+1)).val();
             }
             var CurrType=$('#popupcheck'+IndexID+' #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;

    };
    
   
   


