﻿function popUp() {
    var URL = arguments[0];
    var sWidth = arguments[1];
    var sHeight = arguments[2];
    
    var iScrollbars = (arguments[3]) ? arguments[3] : 1 ;
    var iResizable = (arguments[4]) ? arguments[4] : 1 ;
     
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=" + iScrollbars + ",location=0,statusbar=0,menubar=0,resizable= " + iResizable + ",width=" + sWidth + ",height=" + sHeight + ",left = 100,top = 100');");
}

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

//jquery for each page

$(window).ready(function() {
    $('#header_banner img').hide();
})



$(document).ready(function() {
    $("#helpcontents").jqm({ overlay: 10 });

    $("#givervideo").jqm({ overlay: 10 });

    $("a.helplink").click(function() {
        var linkOffset = $("a.helplink").offset();

        $("#helpcontents").css("top", linkOffset.top);
        $("#helpcontents").css("left", linkOffset.left);

        $("#helpcontents").jqmShow();
    })
    

    $(".leftnav_title + .submenu").hide();
    $(".leftnav_title_link").click(function() {
        $(".leftnav_arrow").attr("src", "/assets/images/common/nav_arrow.gif");

        if ($(this).parent(".leftnav_title").next(".submenu:visible").length > 0) {
            $(this).children(".leftnav_arrow").attr("src", "/assets/images/common/nav_arrow.gif");
        }
        else {
            $(this).children(".leftnav_arrow").attr("src", "/assets/images/common/nav_arrow_down.gif");
        }
        $(this).parent(".leftnav_title").next(".submenu").slideToggle('fast').siblings('.submenu:visible:not(.login_links)').slideUp('fast');
    });

    $('ul.jd_menu').jdMenu();
    // Add menu hiding on document click
    $(document).bind('click', function() {
        $('ul.jdmenu ul:visible').jdMenuHide();
    });

    $('#hidden_images a').appendTo("#header_banner");

    $('#header_banner').cycle({
    fx: 'fade',
    autostop: 1,
    random: 1
    });

    $('.banner_right').jCarouselLite({
        vertical: true,
        visible: 5,
        auto: 6000,
        speed: 1000
    });

    $('input.bizsearch').focus(function() {
        $(this).val("");
    })

    $('input.googlequery').focus(function() {
        $(this).val("");
    })

    $(".googlebutton").click(function() {
        var query = $(".googlequery").val();
        window.open("http://www.google.com/cse?cx=001845117290378558779:jhln8igjzm0&q=" + query, "_blank");
    })

});


function showDialog() {
    
    $("#givervideo").jqmShow();
}
