jQuery.fn.toggleText = function(a, b) {
	return this.each(function() {
		jQuery(this).text(jQuery(this).text() == a ? b : a);
	});
};


$(function() {

    /*
    $('.LanguageContainer').hover(function() {
    $(this).toggleClass("active");
    });
    */

    $('.RegionCampaign10Box').cycle({
        fx: 'fade',
        speed: 'fast',
        timeout: 3000,
        delay: -2000,
        pause: 1,
        pager: '#RegionCampaign10BoxpNavigation'
    });

    $("h1.divHide").click(function() {
        $(this).parent().children('.hideable').toggle();
        $(this).toggleClass('divShow');
    });

    $("a.divHide").click(function() {
        $(this).parent().children('.hideable').toggle();
        $(this).toggleClass('divShow');
    });

    $('span.flashbox').flash(null, { version: 8 }, function(htmlOptions) {
        var $this = $(this);
        var params = $this.attr('rel').split('|');
        htmlOptions.src = params[0];
        htmlOptions.width = params[1];
        htmlOptions.height = params[2];
        htmlOptions.wmode = 'transparent';
        this.innerHTML = '<div class="alt">' + this.innerHTML + '</div>';
        $this.addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions));
    });

    $("ul.tabs").tabs("div.panes > div.pane", { history: true });

    $(".iframe640x480").fancybox({ 'frameWidth': 640, 'frameHeight': 480, 'overlayShow': false });
    $(".iframe480x360").fancybox({ 'frameWidth': 480, 'frameHeight': 240, 'overlayShow': false });
    $(".iframe750x480").fancybox({ 'frameWidth': 750, 'frameHeight': 480, 'overlayShow': false });
    $(".iframe820x480").fancybox({ 'frameWidth': 820, 'frameHeight': 480, 'overlayShow': false });
    $(".tooltipper").tooltip();

    $('.cmbRoom').change(function() {
        var selIndex;
        var items = [1, 2, 3, 4];
        selIndex = $(".cmbRoom").val();

        $.each(items, function() {

            $("tr.trRoom" + selIndex + " .trPax1").show();

            if (this > selIndex) {
                $("div.Room" + this).hide();
                $("tr.trRoom" + this).hide();

            }
            if (this <= selIndex) {
                $("div.Room" + this).show();
                $("tr.trRoom" + this).show();
            }

        });

    });

    $('.cmbAdults1').change(function() {
        var selIndex = $(".cmbAdults1").val();
        var items = [1, 2, 3, 4];

        if (selIndex != 22) {
            $.each(items, function() {

                if (this > selIndex) {
                    $("tr.trRoom1 .trPax" + this).hide();
                }
                if (this <= selIndex) {
                    $("tr.trRoom1 .trPax" + this).show();
                }

            });
        }

        if (selIndex == 22) {
            $.each(items, function() {
                if (this > 2) {
                    $("tr.trRoom1 .trPax" + this).hide();
                }
                if (this <= 2) {
                    $("tr.trRoom1 .trPax" + this).show();
                }
            });
        }

        if (selIndex == 22 || selIndex == 2) {
            $('.cmbChild1').show();
            $('.ca1').show();
        }
        else {
            $('.cmbChild1').hide();
            $('.ca1').hide();
        }

    });


    $('.cmbAdults2').change(function() {
        var selIndex = $(".cmbAdults2").val();
        var items = [1, 2, 3, 4];
        //alert(selIndex);
        if (selIndex != 22) {
            $.each(items, function() {

                if (this > selIndex) {
                    $("tr.trRoom2 .trPax" + this).hide();
                }
                if (this <= selIndex) {
                    $("tr.trRoom2 .trPax" + this).show();
                }

            });
        }

        if (selIndex == 22) {
            $.each(items, function() {
                if (this > 2) {
                    $("tr.trRoom2 .trPax" + this).hide();
                }
                if (this <= 2) {
                    $("tr.trRoom2 .trPax" + this).show();
                }
            });
        }

        if (selIndex == 22 || selIndex == 2) {
            $('.cmbChild2').show();
            $('.ca2').show();
        }
        else {
            $('.cmbChild2').hide();
            $('.ca2').hide();
        }

    });


    $('.cmbAdults3').change(function() {
        var selIndex = $(".cmbAdults3").val();
        var items = [1, 2, 3, 4];
        //alert(selIndex);
        if (selIndex != 22) {
            $.each(items, function() {

                if (this > selIndex) {
                    $("tr.trRoom3 .trPax" + this).hide();
                }
                if (this <= selIndex) {
                    $("tr.trRoom3 .trPax" + this).show();
                }

            });
        }

        if (selIndex == 22) {
            $.each(items, function() {
                if (this > 2) {
                    $("tr.trRoom3 .trPax" + this).hide();
                }
                if (this <= 2) {
                    $("tr.trRoom3 .trPax" + this).show();
                }
            });
        }

        if (selIndex == 22 || selIndex == 2) {
            $('.cmbChild3').show();
            $('.ca3').show();
        }
        else {
            $('.cmbChild3').hide();
            $('.ca3').hide();
        }

    });


    $('.cmbAdults4').change(function() {
        var selIndex = $(".cmbAdults4").val();
        var items = [1, 2, 3, 4];
        //alert(selIndex);
        if (selIndex != 22) {
            $.each(items, function() {

                if (this > selIndex) {
                    $("tr.trRoom4 .trPax" + this).hide();
                }
                if (this <= selIndex) {
                    $("tr.trRoom4 .trPax" + this).show();
                }

            });
        }

        if (selIndex == 22) {
            $.each(items, function() {
                if (this > 2) {
                    $("tr.trRoom4 .trPax" + this).hide();
                }
                if (this <= 2) {
                    $("tr.trRoom4 .trPax" + this).show();
                }
            });
        }

        if (selIndex == 22 || selIndex == 2) {
            $('.cmbChild4').show();
            $('.ca4').show();
        }
        else {
            $('.cmbChild4').hide();
            $('.ca4').hide();
        }

    });


    $('.cmbChild1').change(function() {
        var selIndex = $(".cmbChild1").val();

        if (selIndex == 0) {
            $("tr.trRoom1 .trChild").hide();
        }
        if (selIndex == 1) {
            $("tr.trRoom1 .trChild").show();
        }
    });

    $('.cmbChild2').change(function() {
        var selIndex = $(".cmbChild2").val();

        if (selIndex == 0) {
            $("tr.trRoom2 .trChild").hide();
        }
        if (selIndex == 1) {
            $("tr.trRoom2 .trChild").show();
        }
    });

    $('.cmbChild3').change(function() {
        var selIndex = $(".cmbChild3").val();

        if (selIndex == 0) {
            $("tr.trRoom3 .trChild").hide();
        }
        if (selIndex == 1) {
            $("tr.trRoom3 .trChild").show();
        }
    });

    $('.cmbChild4').change(function() {
        var selIndex = $(".cmbChild4").val();
        if (selIndex == 0) {
            $("tr.trRoom4 .trChild").hide();
        }
        if (selIndex == 1) {
            $("tr.trRoom4 .trChild").show();
        }
    });

    //    $(".SearchHotel").click(function() {
    //        var cmbSearchVal = $("#ctl00_HotelSearchBox_cmbSearch_text").val();
    //        return false;
    //        if (cmbSearchVal.indexOf("|")==-1) {
    //            return false;
    //        }
    //        else {
    //            return true;
    //        }
    //    });

    $('.FlashBoxContainer').hover(
		 function() {
		     $(this).removeClass('FlashHider');
		 },
		 function() {
		     $(this).addClass('FlashHider');
		 }
	);

	$('.HotelResultEmailBox input').click(function(){
		if($(this).val() == 'Enter your email address') {
			$(this).val('');
		}
	});
	
	$(".AutoComplete").val("Enter city name...");
	$(".AutoComplete").click(function(){
		if ($(".AutoComplete").val() == "Enter city name..."){
			$(".AutoComplete").val("");
		}
	});
	$(".AutoComplete").blur(function(){
		if ($(".AutoComplete").val() == ""){
			$(".AutoComplete").val("Enter city name...");
		}
	});		

		
	if ($(".agentlimit").length) {
		if (jQuery.trim($(".agentlimit").html()) == "") {
			$("div.Menu").hide();
		}
	}
	
});

function ShowMessage(MessageType, MessageId) {    
    $('.MessageBar').show();
    $('.MessageBar .'+MessageType).show();
    $('.MessageBar .'+MessageType).load("Message.aspx?MessageId="+MessageId);
}


//<!-- ATIKTUK GOOGLE ANALYTICS -->//
//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

//try {
//var pageTracker = _gat._getTracker("UA-2376435-32");
//pageTracker._trackPageview();
//} catch(err) {}
//<!-- ATIKTUK GOOGLE ANALYTICS -->//