$(document).ready(function() {
    window.EventId = $('meta[name=show_id]').attr('content');
});

Ext.ux.IFrameComponent = Ext.extend(Ext.BoxComponent, {
    onRender: function(ct, position) {
        this.el = ct.createChild({ tag: 'iframe', id: 'iframe-' + this.id, frameBorder: 0, src: this.url });
    }
});

function doWin(marg, regopen) {
    var isInt = /^\d+$/.test(marg);
    if (!isInt) {
        doHelp(marg);
        return true;
    }
    Ext.ux.IFrameComponent = Ext.extend(Ext.BoxComponent, {
        onRender: function(ct, position) {
            this.el = ct.createChild({ tag: 'iframe', id: 'iframe-' + this.id, frameBorder: 0, src: this.url });
        }
    });
    if (marg == "101") {
        if (regopen == "0") {
            murl = "<iframe src='" + proxyUrl + "/Adapt/EditProfile.aspx' width='100%' height=475 frameborder='0' />"
            win = new Ext.Window({
                title: 'Edit My Profile',
                x: 100,
                y: 75,
                shadow: true,
                layout: 'fit',
                width: 700,
                height: 475,
                modal: true,
                html: murl
            });
            win.show();
            win.center();
        } else {
            murl = portalUrl + "/commoncontrols/redirectExperient.aspx?EventId=" + EventId + "&page=profile"
            window.open(murl);
        }
    }
    if (marg == "2") {
        murl = proxyUrl + "/apps/Visa/VisaWelcome.aspx?eventID=" + EventId
        var iframe = new Ext.ux.IFrameComponent({ url: murl });
        win = new Ext.Window({
            id: 'bogus',
            title: 'Visa Letter',
            layout: 'fit',
            width: 640,
            height: 580,
            iconCls: 'bogus',
            shim: false,
            animCollapse: false,
            constrainHeader: true,
            items: iframe
        });
        win.show();
        win.center();
    }
    if (marg == "3") {
        var xhReq = getXHR();
        murl = proxyUrl + "/commoncontrols/getBrochureLink.aspx?EventId=" + EventId + "&rnd=" + getRandom();
        xhReq.open("GET", murl, false);
        xhReq.send(null);
        retData = xhReq.responseText;
        if (retData != "") {
            window.open(retData, "bwin", "top=20,left=20,status=0,location=0,menubar=0,modal=yes");
        }
    }
    if (marg == "4") {
        murl1 = portalUrl + "/test/calendartest.aspx?eventID=" + EventId
        window.open(murl1, null, "status=0,toolbar=0,scrollbars=1");
    }
    if (marg == '1') {
        var xhReq = getXHR();
        murl = proxyUrl + "/commoncontrols/getEsmLink.aspx?EventId=" + EventId + "&rnd=" + getRandom();
        xhReq.open("GET", murl, false);
        xhReq.send(null);
        retData = xhReq.responseText;
        if (retData != "") {
            window.open(retData);
            theport.doLayout();
        }
    }
    if (marg == '7') {
        murl = "<iframe src='" + portalUrl + "/Exhibitor/BuyerInvite.aspx?EventId=" + EventId + "' width='100%' height='100%' frameborder='0' />"
        buyerInviteWin = new Ext.Window({
            title: 'Buyer Invite',
            x: 100,
            y: 75,
            shadow: true,
            layout: 'fit',
            width: 870,
            height: 400,
            modal: true,
            html: murl
        });
        buyerInviteWin.show();
        buyerInviteWin.center();
    }
    if (marg == '99') {
        targ = portalUrl + "/Exhibitor/ViewStatment.aspx?EventID=" + EventId + "&rnd=" + getRandom();
        murl = "<iframe src='" + portalUrl + "/hw/PageProcessor.aspx?Page=" + escape(targ) + "'  width='100%'  height='100%'   frameborder='0' />"
        //alert(murl);
        win = new Ext.Window({
            title: 'Viewing Statement',
            shim: true,
            width: 870,
            height: 500,
            html: murl
        });
        win.show();
    }
    if (marg == '98') {
        var murl = portalUrl + "/commoncontrols/BoothProfileParent.aspx?EventId=" + EventId + "&goto=nz_ELMyProfile";
        window.open(murl);
        /*
        var murl1 ="<iframe src='" + murl + "' height='100%' width='100%' frameborder='0' />";              
        win=new Ext.Window({
        title:'Edit Booth Profile',
        layout:'form',
        width:900,
        height:580,
        modal:true,
        html:murl1
        });
        win.show();  
        win.center();      
        */
    }
    if (marg == 'yy') {
        var murl = portalUrl + "/commoncontrols/getEACLink.aspx?EventId=" + EventId + "&rnd=" + getRandom();
        var murl1 = "<iframe src='" + murl + "' height='100%' width='100%' frameborder='0' />";
        win = new Ext.Window({
            title: 'Select EAC',
            layout: 'form',
            width: 900,
            height: 580,
            modal: true,
            html: murl1
        });
        win.show();
        win.center();
    }
    if (marg == "5") {
        var xhReq = getXHR();
        murl = proxyUrl + "/commoncontrols/getFlashFloorPlan.aspx?EventId=" + EventId + "&rnd=" + getRandom();
        xhReq.open("GET", murl, false);
        xhReq.send(null);
        retData = xhReq.responseText;
        if (retData != "") {
            window.open(retData, "bwin", "top=20,left=20,status=0,location=0,menubar=0");
        }
    }
    if (marg == "6") {
        var xhReq = getXHR();
        murl = proxyUrl + "/commoncontrols/getPDFFloorPlan.aspx?EventId=" + EventId + "&rnd=" + getRandom();
        xhReq.open("GET", murl, false);
        xhReq.send(null);
        retData = xhReq.responseText;
        if (retData != "") {
            window.open(retData, "bwin", "top=20,left=20,status=0,location=0,menubar=0");
        }
    }
}

function doHelp(murl) {
    window.open(murl);
}

function doSessionDoc(msession, mflag) {

    var murl = "sessiondocs.html?sid=" + msession + "&flag=" + mflag + "&rnd=" + getRandom();
    //alert(murl)
    var win1 = new Ext.Window({
        title: 'Session Documents',
        x: 200,
        y: 75,
        shadow: true,
        layout: 'fit',
        width: 600,
        height: 300,
        modal: true,
        //html:murl
        items: new Ext.ux.ManagedIframePanel({ defaultSrc: murl })
    });
    win1.show();
    win1.center();
}

function showSessionDoc(murl) {
    window.open("../" + murl);
}

function doSessionDetail(sessionid) {


    var murl = "../commoncontrols/SessionDetails.aspx?sessionid=" + sessionid + "&rnd=" + getRandom();
    //alert(murl)

    sesswin = new Ext.Window({
        id: 'sessbogus',
        title: 'Session Details',
        layout: 'fit',
        width: 600,
        height: 480,
        iconCls: 'bogus',
        shim: false,
        animCollapse: false,
        constrainHeader: true,

        items: new Ext.ux.ManagedIframePanel({ defaultSrc: murl })


    });
    sesswin.show();
    sesswin.center();

}

function doMoreLinks(param) {
    var xhReq = new getXHR();
    var murl1 = proxyUrl + "/commoncontrols/getMoreLinks.aspx?EventId=" + EventId + "&Cat=" + param + "&rnd=" + getRandom();
    xhReq.open("GET", murl1, false);
    xhReq.send(null);
    contentHTML = "<div style='padding:10px'>";
    contentHTML += xhReq.responseText;
    contentHTML += "</div>";
    xwin = new Ext.Window({
        title: 'More Links',
        x: 200,
        y: 75,
        shadow: true,
        layout: 'fit',
        width: 600,
        height: 200,
        modal: true,
        html: contentHTML,
        bodyStyle: {
            background: 'white'
        }
    });
    xwin.show();
    xwin.center();
}

function getRandom() {
    var xdte = new Date();
    return xdte.getTime();
}

function getXHR() {
    if (window.XMLHttpRequest) {
        var xhReq = new XMLHttpRequest();
    } else {
        var xhReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xhReq;
}

function doPass() {
    win = new Ext.Window({
        id: 'forgot_password',
        title: 'Password Retrieval',
        layout: 'fit',
        width: 260,
        height: 210,
        iconCls: 'bogus',
        shim: false,
        animCollapse: false,
        constrainHeader: true,
        items: new Ext.ux.IFrameComponent({
            url: portalUrl + '/PasswordRecovery.aspx'
        })
    });
    win.show();
    win.center();
}

function downloadics() {
    url = portalUrl + "/commoncontrols/getScheduleOutlook.aspx?EventId=" + EventId;
    window.open(url, null, "height=10,width=10,left=0,top=0,");

}

function doSchedule(murl) {
    window.open(murl);
}

function doMap(murl) {
    window.open(murl);
}

function closeWindow() {
    win.hide();
}

function doBlog(blogurl) {
    window.open(blogurl);
}

function doEAC(boothid) {
    Ext.ux.IFrameComponent = Ext.extend(Ext.BoxComponent, {
        onRender: function(ct, position) {
            this.el = ct.createChild({ tag: 'iframe', id: 'iframe-' + this.id, frameBorder: 0, src: this.url });
        }
    });
    var murl = proxyUrl + "/Exhibitor/EACManagement.aspx?EventID=" + EventId + "&BoothID=" + boothid + "&rnd=" + getRandom();
    //alert(murl)
    var iframe = new Ext.ux.IFrameComponent({
        url: murl
    });

    eacwin = new Ext.Window({
        id: 'bogus',
        title: 'Manage EACs',
        layout: 'fit',
        width: 640,
        height: 580,
        iconCls: 'bogus',
        shim: false,
        animCollapse: false,
        constrainHeader: true,
        items: iframe

    });
    eacwin.show();
    eacwin.center();

}
function doExperient(marg, boothid) {
    Ext.ux.IFrameComponent = Ext.extend(Ext.BoxComponent, {
        onRender: function(ct, position) {
            this.el = ct.createChild({ tag: 'iframe', id: 'iframe-' + this.id, frameBorder: 0, src: this.url });
        }
    });
    var murl = proxyUrl + "/commoncontrols/redirectExperient.aspx?eventID=" + marg + "&BoothNumber=" + boothid + "&page=ExhibitingCompanyInfo";
    //alert(murl)
    var iframe = new Ext.ux.IFrameComponent({
        url: murl
    });

    var win = new Ext.Window({
        id: 'Experient',
        title: 'Manage Booth Personnel',
        layout: 'fit',
        width: 640,
        height: 580,
        iconCls: 'bogus',
        shim: false,
        animCollapse: false,
        constrainHeader: true,
        items: iframe

    });
    win.show();
    win.center();

}
