/**
* @author nsf
*/
(function($) {
    $(function() {
	if ($.browser.msie && $.browser.version == "6.0") {
		$(document).pngFix(); 
        }

        //global vars
        var locale = "en_gb", $pageWrap = $("div.PageWrap"), $page = $("div.Page");
        if (window.location.href.indexOf("ar_ae") > -1) locale = "ar_ae";

        var isIE = $.browser.msie;
        var isIE6 = isIE && ($.browser.version == 6.0);

        var swfEnabled = false;
        swfEnabled = typeof swfobject == "object" && swfobject.hasFlashPlayerVersion("8.0");

        //add 'FirstChild' for ie6 
        var firstChild = function() {
            $("li:first-child").addClass("FirstChild");
        }
        if ($.browser.msie && $.browser.version == "6.0") {
            firstChild();
        }

        // add 'LastChild' (applied to all browsers)
        $("li:last-child").addClass("LastChild");

        // image caption replacements
        var setFont = function(fSize, fWeight, sFamily, oAttrib) {
            var fStyle = { fontFamily: sFamily, fontWeight: fWeight, fontSize: fSize };
            return typeof oAttrib == 'object' ? $.extend(fStyle, oAttrib) : fStyle;
        }

        Cufon.replace("ul#menu li a", setFont(16, 300, 'Aeroportal', { hover: true }))
        ("div.preordercontent", setFont(22, 300, 'Aeroportal', { hover: true }))
        ("li.facebookli", setFont(18, 300, 'Aeroportal', { hover: true }))
        ("li.sendbqli", setFont(18, 300, 'Aeroportal', { hover: true }))
        ("a.fb_wall", setFont(18, 300, 'Aeroportal', { hover: true }))
        ("div.footer", setFont(12, 300, 'Aeroportal', { hover: true }))
        ;

        $(".showPleasewait").click(function() {
            return showSpinner($(this));
        });

        function showSpinner($t) {
            var $theForm = $(document.forms['aspnetForm']);
            if ($theForm.attr("onsubmit") != null && !WebForm_OnSubmit())
                return false;

            $t.css("visibility", "hidden");

            var $PleaseWait = $("<div class='pleasewait'><div id='holder'></div>Please wait...</div>");
            $PleaseWait.css("top", $t.position().top + 20);
            $PleaseWait.css("left", $t.position().left + 30);

            $t.parent().append($PleaseWait);

            spinner("holder", 4, 7, 10, 3, "#fff");

            return true;
        }
        
        $(function() {
            $(".photo-list a").hover(function() {
                $(this).children("span").fadeOut();
            }, function() {
                $(this).children("span").fadeIn();
            })
        });

    });

    function setCookie(c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
    }

    function getCookie(c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) c_end = document.cookie.length;
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return "";
    }
})(jQuery);