﻿/// <reference name="MicrosoftAjax.js"/>

function DoPB(P1, P2) {
    __doPostBack(P1, P2);

    return false;
}

function GE(e) {
    if (e == null)
        return;

    var r = new Array();

    for (var i = 0; i < e.childNodes.length; i++) {
        if (e.childNodes[i].nodeType == 1)
            r.push(e.childNodes[i]);
    }

    return r;
}

var NewC = false;//New User Control
var UPN = "ctl00_CP1_UP1";//update Panel
var UPP = "ctl00_UPProgress";//Update Progress

function LoadPart(p) {
    NewC = true;

    __doPostBack(UPN, p);
    return false;
}

function LO(id) {//Load Object For Inside UserControl
    __doPostBack("ctl00_CP1_ctl01_UPI", id);

    return false;
}

function AbortPostBack() {
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    if (prm.get_isInAsyncPostBack())
        prm.abortPostBack();
}

Type.registerNamespace("StrideR");

StrideR.InitCom = function(element) {
    StrideR.InitCom.initializeBase(this, [element]);

    this.prm = null;
}
/////////////////////////////////////////////////
StrideR.InitCom.prototype = {
    initialize: function() {
        StrideR.InitCom.callBaseMethod(this, 'initialize');
        // Add custom initialization here
        this.prm = Sys.WebForms.PageRequestManager.getInstance();

        this.prm.add_endRequest(Function.createDelegate(this, this.EndRequestHandler));
        this.prm.add_initializeRequest(Function.createDelegate(this, this.InitializeRequest));
        this.prm.add_beginRequest(Function.createDelegate(this, this.BeginRequestHandler));

        this.PBE;

        $addHandler(window, 'scroll', Function.createDelegate(this, this.w_onscroll));
        $addHandler(window, 'resize', Function.createDelegate(this, this.w_onresize));

        this.InitNavM();
    },
    InitNavM: function() {
        var i = 0;

        this.IMN(0, 'news/', true);

        this.IMN(1, 'article/', true);

        this.IMN(2, 'university/', true);

        this.IMN(3, 'poem/', true);

        this.IMN(4, 'treasure/', true);

        this.IMN(5, null, true);

        this.IMN(6, 'gallery2/', true);

        this.IMN(7, 'links/', true);

        this.IMN(8, 'faq/', true);

        this.IMN(9, 'contactus/', true);

        //Sub Menus

        this.IMN(10, 'club/', true);

        this.IMN(11, 'clublist/', true);
    },
    IMN: function(id, clk, mo) {
        var el; //el[0] = Get a href tag ,el[1] =get container table for animation effect

        el = this.GetMenu(id); //Menu 100

        if (clk == null)

            el[0].onclick = this.DoNothing;

        else

            $addHandler(el[0], 'click', Function.createCallback(this.LoadPart, clk));

        

        if (mo)

            $addHandler(el[1], 'mouseover', Function.createCallback(PlayColor, el[1]));
    },
    GetMenu: function(id) {
        var RV = new Array();

        RV.push(GE(GE(GE(GE(GE(GE($get('ctl00_NavMn' + id))[0])[0])[0])[0])[0])[0]);

        RV.push(GE(GE(GE(GE($get('ctl00_NavMn' + id))[0])[0])[0])[0]);

        return RV;
    },
    DoNothing: function() {
        return false;
    },
    LoadPart: function(e, p) {
        NewC = true;

        __doPostBack(UPN, p);
        return false;
    },
    InitializeRequest: function(sender, args) {
        if (this.prm.get_isInAsyncPostBack())

            args.set_cancel(true);

        postBackElement = args.get_postBackElement(); //?

        $get(UPP).style.display = 'block';
    },
    BeginRequestHandler: function(sender, args) {
        this.SUPL();

        PBE = args.get_postBackElement().id;
    },
    EndRequestHandler: function(sender, args) {
        if (PBE == "MTDPanel")
            this.SCL();

        $get(UPP).style.display = 'none';

        if (NewC == true) {
            NewC = false;

            __doPostBack(UPN, '☼');
        }
    },
    w_onscroll: function() {
        this.SUPL();
    },
    SUPL: function() {
        var UP = $get(UPP);
        //    if(UP ==null)
        //        UP=$get("ctl00_UPProgress");

        Sys.UI.DomElement.setLocation(UP, parseInt(document.documentElement.clientWidth / 2 - 60), parseInt(document.documentElement.scrollTop + (document.documentElement.clientHeight / 2) - 60));
    },
    w_onresize: function() {
        this.SUPL();
    },
    dispose: function() {
        //Add custom dispose actions here
        StrideR.InitCom.callBaseMethod(this, 'dispose');
    }
}
StrideR.InitCom.registerClass('StrideR.InitCom', Sys.UI.Control);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();


Sys.Application.add_init(function() {
    $create(StrideR.InitCom, null, null, null, $get("Empty"));
});