﻿var mainPre = "ctl00_";

$(document).ready(function () {
//    try {
//        $("#" + mainPre + "aOrder").poshytip({
//            className: 'tip-order',
//            showOn: 'none',
//            alignTo: 'target',
//            alignX: 'inner',
//            offsetX: 0,
//            //alignX: 'left',
//            //alignY: 'center',
//            //offsetX: 15,
//            content: '<a href="/Signup" class="backtoorder">click to go back to your order</a>'
//        });
//        
//    }
//    catch (err) {

//    }

});
function pageLoad() {
    $(document).ready(function () {
  //  newmenu();

        //alert(height);
        //var height = $("#top").height() + $("#bdy").height() + $("#footer").height() - 3;

        //$(".edgeleft").height(height);
        //$(".edgeright").height(height);

        //$(".edgeright").css("top", -height + $("#footer").height());
        try {
            preloadImages([
		    '/images/mainbg.png'
            , '/images/footlogo.png'
            , '/images/menu3.png'
            , '/images/button/button_gray.png'
            , '/images/button/button_gray_active.png'
            , '/images/button/button_red.png'
            , '/images/button/button_red_active.png'
            , '/images/button/button_red.png'
            , '/images/small-business-mimg.png'
            , '/images/residential-mimg.png'
            , '/images/broadband-migm.png.png'
            , '/images/slides/1.png'
            , '/images/slides/2.png'
            , '/images/slides/3.png'
            , '/images/slides/4.png'
            , '/images/signup_main.png'
            , '/images/signup_main_over.png'
        ]);
        }
        catch (err) {

        }

        $(".menuitem").mouseover(function () {
            if (!$(this).hasClass("curr")) {
                // Cufon.replace('.menuitem.signup b', { fontFamily: 'M+ 1p Medium', textShadow: '2px 2px rgba(248, 149, 144, 0.2)', color: '#f89590', fontSize:'16' });
                if ($(this).hasClass("signup")) {
                    // Cufon.replace('.menuitem.signup b', { fontFamily: 'M+ 1p Medium', textShadow: '2px 2px rgba(0, 0, 0, 0.2)', color: '#FFFFFF', fontSize: '15' });
                }
                $(this).stop().animate({
                    backgroundPositionY: '-100',
                    backgroundPositionX: '0'

                }, {
                    duration: 650
                }, function () {
                    // Animation complete.
                });
            }

        }).mouseout(function () {
            if (!$(this).hasClass("curr")) {
                if ($(this).hasClass("signup")) {
                    //  Cufon.replace('.menuitem.signup b', { fontFamily: 'M+ 1p Medium', textShadow: '2px 2px rgba(225, 48, 38, 0.2)', color: '#FF857E', fontSize: '15' });
                }
                $(this).stop().animate({
                    backgroundPositionY: '0',
                    backgroundPositionX: '0'

                }, 300, function () {
                    // Animation complete.
                });
            }


        });

        $(".btnCloseLogin").removeClass("hdn");
        $(".btnCloseReg").removeClass("hdn");

        $("#aLogin").click(function () {
            $(".play-btn").stop().trigger("click");
            $find("mpeLogin").show();

            $("#" + mainPre + "txtUsername").focus();

        });
        $(".btnCloseLogin").click(function () {
            $(".play-btn").stop().trigger("click");
            $find("mpeLogin").hide();
            $("#" + mainPre + "txtUsername").val("");
            $("#" + mainPre + "txtPassword").val("");

            $("#" + mainPre + "txtUsername").css("background-color", "white");
            $("#" + mainPre + "txtPassword").css("background-color", "white");

            $("#" + mainPre + "loginmessage").html("&nbsp;");
        });

        $(".btnCloseReg").click(function () {
            $find("mpeRegister").hide();
        });

        $("#dLogin").click(function () {
            $("#" + mainPre + "btnLogin").trigger("click");
        });



        $(".chat").click(function () {


            OpenWindowMax("https://a5.websitealive.com/484/operator/guest/gDefault_v2.asp?cframe=login&chattype=normal&groupid=484&websiteid=0&departmentid=0&sessionid_=582&iniframe=&ppc_id=&autostart=&text2chat_info=&loginname=&loginnamelast=&loginemail=&loginphone=&infocapture_ids=&infocapture_values=&dl=&loginquestion=", "LiveChat", 460, 460);
        });


        $(".list li").mouseover(function () {

            var href = $(this).children("a").attr("href");
            if (href) {
                if (href != "")
                    $(this).addClass("showbullet")
            }

        }).mouseout(function () { $(this).removeClass("showbullet") });

        $(".list li").click(function () {
            var href = $(this).children("a").attr("href");
            if (href) {
                if (href != "")
                    document.location = href;
            }

        });
        // click here to go back to your order
        DoChildLoad();
      //  FoceFonts();

        //setTimeout("AnimateBar();", 500);

        // $("#" + mainPre + "aOrder").poshytip('show');
        //  $("#" + mainPre + "aOrder").poshytip('refresh');
    });
}

function AnimateBar() {
    // menbrk
    $("#menbrk").stop().animate({
        backgroundPositionX: '0'

    }, {
        duration: 2000
    }, function () {
        // Animation complete.
    });
}

function SetCurrent(id) {
    $("#" + id).addClass("curr");
    if ($("#" + id).hasClass("first")) {
        $(".leftcorner").css("visibility", "hidden");
        $(".rightcorner").css("visibility", "visible");
    }
    else if ($("#" + id).hasClass("last")) {
        $(".leftcorner").css("visibility", "visible");
        $(".rightcorner").css("visibility", "hidden");
    }
    else {
        $(".leftcorner").css("visibility", "visible");
        $(".rightcorner").css("visibility", "visible");
    }
}

function FoceFonts() {
   // Cufon.replace('.btnGray, .btnRed', { fontFamily: 'M+ 1p Medium', textShadow: '1px 1px rgba(0, 0, 0, 0.2)' });
    Cufon.replace('.menuitem b', { fontFamily: 'M+ 1p Medium', textShadow: '2px 2px rgba(0, 0, 0, 0.2)' });
    Cufon.replace('.curr', { fontFamily: 'M+ 1p Medium', textShadow: '1px 1px rgba(0, 0, 0, 0.2)' });
    //Cufon.replace('.curr', { fontFamily: 'M+ 1p Medium', color: 'black' });
    Cufon.replace('.menuitem.signup b', { fontFamily: 'M+ 1p Medium', textShadow: '2px 2px rgba(225, 48, 38, 0.2)', color: '#FF857E', fontSize: '19' });

    //Cufon.replace('.mainsignup .big', { fontFamily: 'M+ 1p Black', textShadow: '2px 2px rgba(0, 0, 0, 0.2)', fontSize: '28' });
    //Cufon.replace('.mainsignup .small', { fontFamily: 'M+ 1p Black', textShadow: '2px 2px rgba(0, 0, 0, 0.2)', fontSize: '20' });

    Cufon.replace('.loginBox .text', { fontFamily: 'M+ 1p Medium', textShadow: '1px 1px rgba(0, 0, 0, 0.2)', fontSize: '18', color: '#000000' });
    Cufon.replace('#' + mainPre + 'errRegister', { fontFamily: 'Myriad Pro', fontSize: '23' });
}

function preloadImages(imgs) {

    var picArr = [];

    for (i = 0; i < imgs.length; i++) {

        picArr[i] = new Image(100, 100);
        picArr[i].src = imgs[i];


    }

}

function OpenWindowMax(site, Title, W, H) {
    var windowW = window.screen.availWidth - 8;
    var windowH = window.screen.availHeight - 25;
    if (W)
        windowW = W;
    if (H)
        windowH = H;
    var windowX = Math.ceil((window.screen.availWidth - windowW) / 2);
    var windowY = Math.ceil((window.screen.availHeight - windowH) / 2);
    var windowX = 0;
    var windowY = 0;
    newCobrandWindow = window.open(site, Title, "width=" + windowW + ",height=" + windowH + ",top=" + windowX + ",left=" + windowY + ",alwaysRaised,resizable,dependent");
    newCobrandWindow.focus();
}

function ReturnAgent() {
    var nav = navigator.userAgent.toLowerCase();
    if (nav.indexOf("iphone") != -1) {
        return "iPhone";
    }
    else if (nav.indexOf("android") != -1) {
        return "Android";
    }
    else if (nav.indexOf("windows ce") != -1) {
        return "WinCE";
    }
    else if (nav.indexOf("ipad") != -1) {
        return "iPad";
    }
    else {
        return "web";
    }
}


function newmenu() {
    /**
    * for each menu element, on mouseenter, 
    * we enlarge the image, and show both sdt_active span and 
    * sdt_wrap span. If the element has a sub menu (sdt_box),
    * then we slide it - if the element is the last one in the menu
    * we slide it to the left, otherwise to the right
    */
    $('#sdt_menu > li').bind('mouseenter', function () {
        var $elem = $(this);
        $elem.find('img')
						 .stop(true)
						 .animate({
						     'width': '170px',
						     'height': '170px',
						     'left': '0px'
						 }, 400, 'easeOutBack')
						 .andSelf()
						 .find('.sdt_wrap')
					     .stop(true)
						 .animate({ 'top': '140px' }, 500, 'easeOutBack')
						 .andSelf()
						 .find('.sdt_active')
					     .stop(true)
						 .animate({ 'height': '170px' }, 300, function () {
						     var $sub_menu = $elem.find('.sdt_box');
						     if ($sub_menu.length) {
						         var left = '170px';
						         if ($elem.parent().children().length == $elem.index() + 1)
						             left = '-170px';
						         $sub_menu.show().animate({ 'left': left }, 200);
						     }
						 });
    }).bind('mouseleave', function () {
        var $elem = $(this);
        var $sub_menu = $elem.find('.sdt_box');
        if ($sub_menu.length)
            $sub_menu.hide().css('left', '0px');

        $elem.find('.sdt_active')
						 .stop(true)
						 .animate({ 'height': '0px' }, 300)
						 .andSelf().find('img')
						 .stop(true)
						 .animate({
						     'width': '0px',
						     'height': '0px',
						     'left': '85px'
						 }, 400)
						 .andSelf()
						 .find('.sdt_wrap')
						 .stop(true)
						 .animate({ 'top': '25px' }, 500);
    });
}
