﻿
function JS_getScreenWidth() {
    var sWidth;
    sWidth = self.screen.width;
    return (sWidth);
}

function JS_getScreenHeight() {
    var sHeight;
    sHeight = self.screen.height;
    return (sHeight);
}

function JS_getResolution() {
    var sRes;
    var rwidth = JS_getInnerWidth();

    if (rwidth <= 640) {
        sRes = "a";
    } 	// 640 x 480 Resolution
    else if (rwidth <= 800) {
        sRes = "b";
    } 	// 800 x 600 Resolution
    else if (rwidth <= 1024) {
        sRes = "c";
    } 	// 1024 x 800 Resolution
    else if (rwidth <= 1280) {
        sRes = "d";
    } 	// 1280 x 1024 Resolution
    else if (rwidth <= 1600) {
        sRes = "e";
    } 	// 1600 x 1200 Resolution
    else {
        sRes = "z";
    }
    return (sRes);
}

function JS_getFrameStatus() {
    if (JS_fFind(top, "SHP2_Prod_section") != null) {
        //alert("SHP2_Prod_section available");
        return "Y";
    }
    else {
        //alert("SHP2_Prod_section not available");
        return "N";
    }

}

function JS_fFind(startfrm, fName) {
    var loc_name = "";
    try {
        loc_name = startfrm.name;
    }
    catch (e) {
        var error = "ASP_Redirect";
    }

    if (loc_name == fName) {
        return startfrm;
    }
    else {
        var i, j = startfrm.frames.length;
        for (i = 0; i < j; i++) {
            var fNext = JS_fFind(startfrm.frames[i], fName);
            if (fNext != null) {
                return fNext;
            }
        }
        return null;
    }
}

function JS_focusonhash(hashcode) {
    var vBrowser = navigator.appName;
    if (vBrowser == "Netscape") {
        var strurlin = window.location.href;
        var strurlout = strurlin;
        var hashptr = strurlin.indexOf('#');
        if (hashptr > 0)
        { strurlout = strurlin.substring(0, hashptr); }
        var strfocus = strurlout + "#" + hashcode;
        window.location.hash = "#" + hashcode;
        //document.GetElementByName(hashcode).focus();
    }
    else if (vBrowser == "Microsoft Internet Explorer") {
        var strurlin = window.location.href;
        var strurlout = strurlin;
        var hashptr = strurlin.indexOf('#');
        if (hashptr > 0) {
            strurlout = strurlin.substring(0, hashptr);
        }
        //document.GetElementByName(hashcode).focus();
        window.location.hash = "#" + hashcode;
    }
    else if (vBrowser == "Opera") {
        var strurlin = window.location.href;
        var strurlout = strurlin;
        var hashptr = strurlin.indexOf('#');
        if (hashptr > 0) {
            strurlout = strurlin.substring(0, hashptr);
        }
        //document.GetElementByName(hashcode).focus();
        window.location.hash = "#" + hashcode;
    }
}

function SearchPage(dir) {
    var allfields = trim(String(document.getElementById('ALLFIELDS').value));
    var searchTerm = encodeURIComponent(allfields).replace(new RegExp("%20", "g"), "+");
    location.href = '/' + dir + '/shpsearch.aspx?search=allfields&allfields=' + searchTerm;
}
function LTrim(value) {
    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");
}

function RTrim(value) {
    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");
}
function trim(value) {
    return LTrim(RTrim(value));
}

function ValidateSearch() {
    var f0;
    var f1;
    var f2;
    var formbParam;
    var formheight;
    var formwidth;
    var iformheight;
    var iformwidth;
    var pn;
    var nframes;
    var pageheight;
    var pagewidth;
    var submitvalue;
    var temp;
    submitvalue = document.getElementById("ALLFIELDS").value;

    formbParam = document.getElementById("b").value;

    if (formbParam.constructor != String || formbParam.length < 4) {
        formbParam = "ie6x";
    }

    formwidth = document.getElementById("w").value;

    iformwidth = eval(formwidth);
    if (iformwidth == 0) {
        formwidth = "1024";
    }

    formheight = document.getElementById("h").value;
    iformheight = eval(formheight);
    if (iformheight == 0) {
        formheight = "768";
    }

    temp = window.parent.pagebParam;
    var pagebParam;
    if (temp == undefined) {
        pagebParam = formbParam;
        window.parent.pagebParam = pagebParam;
        //alert("ValidateSearch #4B - pagebParam = " + pagebParam);
        pagewidth = formwidth;
        window.parent.pagewidth = pagewidth;
        //alert("ValidateSearch #4C - pagewidth = " + pagewidth);
        pageheight = formheight;
        window.parent.pageheight = formheight;
        //alert("ValidateSearch #4D - pageheight = " + pageheight);
    }
    pagebParam = window.parent.pagebParam;
    if (pagebParam.constructor != String || pagebParam.length < 4) {
        pagebParam = "ie6x";
    }
    pagewidth = window.parent.pagewidth;
    if (pagewidth == undefined) {
        pagewidth = formwidth;
    }
    ipagewidth = eval(pagewidth);
    if (ipagewidth == 0) { pagewidth = "1024"; }

    pageheight = window.parent.pageheight;
    if (pageheight == undefined) {
        pageheight = formheight;
    }
    //alert("ValidateSearch #7 - pageheight = " + pageheight);
    ipageheight = eval(pageheight);
    if (ipageheight == 0) { pageheight = "768"; }

    if (submitvalue.indexOf("'") >= 0) {
        pn = parent.name;
        //alert ("parent.name: " + pn);
        nframes = parent.frames.length;
        f0 = "undefined";
        f1 = "undefined";
        f2 = "undefined";
        //alert ("Parent: " + pn + " nframes: " + nframes);

        if (nframes >= 1) {
            f0 = parent.frames[0].name;
        }
        //alert ("frame data: " + nframes + " f0:" + f0);
        if (nframes >= 2) {
            f1 = parent.frames[1].name;
        }
        //alert ("frame data: " + nframes + " f0:" + f0 + " f1:" + f1);
        if (nframes >= 3) {
            //alert ("About to read f2");
            //f2	    = parent.frames[2].name;
            //alert ("Before Rename: parent: " + pn + " nframes = " + nframes + " f0:" + f0 + " f1:" + f1 + " f2:" + f2);
            //alert ("before F2 Frame name Set");
            //window.parent.frames[2].name = "SHP2_Prod_section";
            //alert ("After F2 Frame name Set");
            //f2		    = parent.frames[2].name;
            f2 = "SHP2_Prod_section";
            //alert ("After Rename: parent: " + pn + " nframes= " + nframes + " f0:" + f0 + " f1:" + f1 + " f2:" + f2);
        }
        if (nframes > 0) {
            //alert ("parent: " + pn + " nframes: " + nframes + " f0:" + f0 + " f1:" + f1 + " f2:" + f2);
        }
        document.getElementById("ALLFIELDS").value = "invalid single quote";

    }
    else {
        if (submitvalue != "") {
            window.parent.lastsearch = submitvalue;
            if (pagebParam.constructor != String) {
                pagebParam = "ie6x";
            }
            document.getElementById("b").value = pagebParam;
            document.getElementById("w").value = pagewidth;
            document.getElementById("h").value = pageheight;
            document.leftsearch.submit();
        }
    }
    return false;
}

function checkState() {
    if (document.readyState == "complete") {
        document.body.style.cursor = "default";
    }
    else {
        document.body.style.cursor = "wait";
        setTimeout("checkState()", 500);
    }
}

function JS_Redirect(newurl, newqueryext, newhash, newtarget, topgm, strsavehistory, menu, tp) {

    // alert(newurl);
    //alert ("newqueryext    = " + newqueryext);
    //alert ("newhash        = " + newhash);
    //alert ("newtarget      = " + newtarget);
    //alert ("topgm          = " + topgm);
    //alert ("strsavehistory = " + strsavehistory);
    //alert ("menu           = " + menu);
    //alert ("tp             = " + tp);
    var FromIframe = pubFromIframe;
    //alert ("FromIframe = " + FromIframe);
    var url = newurl;
    var strtarget = newtarget;
    var passquery = newqueryext;
    var nl = "\n\r";
    var re = /&amp;/g;
    //alert ("JS_Redirect before replace: newurl = " + newurl + nl + " newtarget = " + newtarget + nl + "query = " + passquery);
    passquery = passquery.replace(re, "&");
    //alert ("JS_Redirect after replace : newurl = " + newurl + nl + " newtarget = " + newtarget + nl + "query = " + passquery);
    //alert("strsavehistory = " + strsavehistory);
    if (strtarget == "shp2_prod_section") {
        strtarget = "SHP2_Prod_section";
    }
    if (FromIframe == "False") {
        try {
            //alert ("FromIframe is false");
            window.parent.name = "_top";
            var pn = parent.name;
            //alert ("JS_Redirect-parent.name: " + pn);
            var nframes = parent.frames.length;
            var f0 = "undefined";
            var f1 = "undefined";
            var f2 = "undefined";
            //alert ("JS_Redirect-Parent: " + pn + " nframes: " + nframes);
            if (nframes >= 1) {
                f0 = parent.frames[0].name;
            }
            //alert ("JS_Redirect: " + nframes + " f0:" + f0);
            if (nframes >= 2) {
                f1 = parent.frames[1].name;
            }
            //alert ("JS_Redirect: " + nframes + " f0:" + f0 + " f1:" + f1);
            if (nframes >= 3) {
                window.parent.frames[2].name = "SHP2_Prod_section";
                f2 = "SHP2_Prod_section";
                //alert ("After Rename: parent: " + pn + nl + " nframes= " + nframes + nl + " f0:" + f0 + nl + " f1:" + f1 + nl + " f2:" + f2);
            }
        }
        catch (e3) {
        }

    }
    else {
        //alert ("FromIframe NOT false");
    }
    var strcookie = "";
    var strdir = pubDir;
    //alert ("JS_Redirect strdir = " + strdir);
    //var strdir                    = "<%=dir%>";
    var strtopg = topgm;
    var lastbparam = pubbParam;
    var lastWidth = pubWidth;
    //var lastWidth		            = "<%=width%>";
    var lastHeight = pubHeight;
    var lastRHSwidth = pubRHSwidth;
    var lastRHSheight = pubRHSheight;
    //var lastHeight	            = "<%=height%>";
    var strfrompage = pubProgramNumber;
    //var strfrompage	            = "<%=program_number%>";
    var leftpix = pubLeftPix;
    //var leftpix		            = eval("<%=left_size%>");
    var toppix = pubTopPix;
    //var toppix		            = eval("<%=banner_height%>");
    var strmenupage = menu;
    var aspframemode = pubFrameMode;
    //var aspframemode	            = "<%=FrameMode%>";
    var strFramesPresent = JS_getFrameStatus();
    var vBrowser = navigator.appName;
    var vVersion = navigator.appVersion;
    var sWidth;
    var sHeight;
    var iWidth;
    var iHeight;
    var throughput;
    var pagebParam;
    var temp;
    var itemp;
    if (FromIframe == "False") {
        sWidth = JS_getScreenWidth();
        //alert ("sWidth = " + sWidth);
        sHeight = JS_getScreenHeight();
        //alert ("sHeight = " + sHeight);
        iWidth = JS_getInnerWidth();
        //alert ("iWidth = " + iWidth);
        iHeight = JS_getInnerHeight();
        //alert ("iHeight = " + iHeight);
        throughput = tp;
        //alert ("throughput = " + throughput);
        var strwidth = iWidth;
        var strheight = iHeight;
        var strBrowser = JS_getBrowser();
        var strResolution = JS_getResolution();

        if (strfrompage != "0" && strfrompage != "19") {
            window.parent.pagebparam = strBrowser + strResolution;
            window.parent.pagewidth = iWidth;
            window.parent.pageheight = iHeight;
            window.parent.rhswidth = iWidth - leftpix;
            window.parent.rhsheight = iHeight - toppix;
        }

        if (strfrompage == "0") {
            temp = window.parent.pagewidth;
            //alert("#1 window.parent.pagewidth =" + temp);
            if (temp == "undefined") {
                temp = lastWidth;
            }
            itemp = eval(temp);
            //alert("#2 itemp =" + itemp);
            if (itemp > leftpix) {
                iWidth = itemp;
                //alert("#3 iWidth =" + iWidth);
            }

            else {
                iWidth = eval(lastWidth);
                //alert("#4 iWidth =" + iWidth);
            }
            //alert("#5 iWidth =" + iWidth);	
            temp = window.parent.pageheight;
            if (temp == "undefined") {
                temp = lastHeight;
            }
            itemp = eval(temp);
            if (itemp > toppix) {
                iHeight = itemp;
            }
            else {
                iHeight = eval(lastHeight);
            }
        }
    }
    else {
        throughput = tp;
        if (strfrompage == "0") {
            //we cannot send the h & w values from the iframe
            pagebParam = lastbparam;
            iWidth = eval(lastWidth);
            //alert("iWidth = " + iWidth);
            iHeight = eval(lastHeight);
            //alert("iHeight = " + iHeight);	                   
        }
    }
    ///changes vibgyor/////
    //var redir						= "/shpwebsite/" + strdir + "/sc/asp_redirector.aspx";
    var redir = "/" + strdir + "/sc/asp_redirector.aspx";
    var crlf = String.fromCharCode(13, 10);
    var strwidth = iWidth;
    var strheight = iHeight;
    var strBrowser = JS_getBrowser();
    var strResolution = JS_getResolution();

    if (nframes == 0 & pubFrameMode == "True") {
        //alert ("There are no frames present - must load top file");
        //we have a request to load a rhs frame, but there are no frames
        //if the file is default_right load default.aspx
        url = newurl.replace("default_right", "default");
        //alert ("url #1 = " + url);
        //if the file contains a _R.aspx, make it .aspx and load it as a top file
        url = url.replace("_R.aspx", ".aspx");
        url = url.replace("_r.aspx", ".aspx");
        //alert ("url #2 =" + url);
        var NewLocationT = url + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=N&tp=" + throughput + "&frompg=" + pubProgramNumber + "&menupage=" + pubMenuPage + "&topg=" + pubProgramNumber;
        //alert(NewLocationT)
        window.parent.location.replace(NewLocationT);
        return false;
    }
    //alert("strdir1: " + strdir);	
    //alert ("newurl1 = " + newurl);		
    if (strFramesPresent == "Y" && aspframemode == "True") {
        if (passquery.length >= 3) {
            passquery = passquery + "&target=" + strtarget;
        }
        else {
            passquery = "target=" + strtarget;
        }
    }

    var passhash = newhash;

    if (passhash.length <= 2) {
        passhash = "";
    }
    //alert("strtopg = " + strtopg + nl + "strFramesPresent = " + strFramesPresent + nl + "aspframemode = " + aspframemode + nl + "passquery = " + passquery);
    if (strtopg == "0" && strFramesPresent == "Y" && aspframemode == "True") {
        if (passhash.length <= 2) {
            if (passquery.length <= 2) {
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg;
                    //alert ("FromIframe 1 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg;
                    // alert ("FromIframe 2 NewLocationT = " + NewLocationT);
                }

                else {

                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + strcookie;
                    //alert ("Normal 1 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + strcookie;
                    // alert ("Normal 2 NewLocationT = " + NewLocationT);
                }
            }
            else {
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery;
                    //alert ("FromIframe 3 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery;
                    //alert ("FromIframe 4 NewLocationT = " + NewLocationT);
                }
                else {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + strcookie;
                    //alert ("Normal 3 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + strcookie;
                    //alert ("Normal 4 NewLocationT = " + NewLocationT);
                }
            }
        }
        else {
            if (FromIframe == "True") {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash;
                //alert ("FromIframe 5 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash;
                //alert ("FromIframe 6 NewLocationT = " + NewLocationT);
            }
            else {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash + strcookie;
                //alert ("Normal 5 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash + strcookie;
                // alert ("Normal 6 NewLocationT = " + NewLocationT);
            }
        }
    }
    else {
        //alert ("failed strtopg test");
        //alert ("passhash.length =" + passhash.length); 
        if (passhash.length <= 2) {
            //alert ("passhash.length< 2");
            //alert ("passquery.length =" + passquery.length); 
            if (passquery.length <= 2) {
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage;
                    //alert ("FromIframe 7 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage;
                    // alert ("FromIframe 8 NewLocationT = " + NewLocationT);
                }
                else {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + strcookie;
                    //alert ("Normal 7 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + strcookie;
                    //alert ("Normal 8 NewLocationT = " + NewLocationT);
                }
            }
            else {
                //alert ("passquery.length > 2 = " + passquery.length + nl + "FromIframe = " + FromIframe);   
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery;
                    //alert ("FromIframe 9 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?" + passquery + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage;
                    //alert ("FromIframe 10 NewLocationT = " + NewLocationT)
                }
                else {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery + strcookie;
                    //alert ("Normal 9 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?" + passquery + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + strcookie;
                    //alert ("Normal 10 NewLocationT = " + NewLocationT);
                }
            }
        }
        else {
            if (FromIframe == "True") {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery + "#" + passhash;
                //alert ("FromIframe 11 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?" + passquery + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "#" + passhash;
                //alert ("FromIframe 12 NewLocationT = " + NewLocationT);
            }
            else {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery + "#" + passhash + strcookie;
                //alert ("Normal 11 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?" + passquery + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "#" + passhash + strcookie;
                //alert ("Normal 12 NewLocationT = " + NewLocationT);
            }
        }
    }

    if (newtarget == "_top") {
        if (strsavehistory == "Y") {
            if (strfrompage == strtopg) {
                //alert ("#1 NewLocationT = " + NewLocationT + " newtarget = " + newtarget + " frompg = topage savehistory = Y, going to do a replace");
                //window.parent.location.replace([NewLocationT]);
                //alert (NewLocationT)
                window.top.location.href = NewLocationT;
            }
            else {
                //alert ("#2 NewLocationT = " + NewLocationT + " newtarget = " + newtarget + " frompg <> topage savehistory = Y, going to do a href");
                //window.top.location.href=NewLocationT;
                //alert (NewLocationT)
                window.parent.location.href = NewLocationT;
                //window.location.replace([NewLocationT]);
            }
        }
        else {
            //alert ("#3 NewLocationT = " + NewLocationT + " newtarget = " + newtarget + " savehistory = N, going to do a replace");
            //window.top.location.replace([NewLocationT]);
            //alert (NewLocationT)
            window.location.replace([NewLocationT]);
        }
    }
    else {
        if (strsavehistory == "Y") {
            if (strfrompage == "0") {
                if (FromIframe == "True") {
                    //alert ("#4 NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage = 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    //alert ("#5 NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage = 0, FromIframe = false, going to do a href");
                    window.parent.frames.SHP2_Prod_section.location.href = NewLocationR;
                    //window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                }
            }
            else {
                if (FromIframe == "True") {
                    //alert ("#6A NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage <> 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    try {
                        //alert ("#6B NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage <> 0, FromIframe = false, going to do a href(try)");
                        window.parent.frames.SHP2_Prod_section.location.href = NewLocationR;
                        //window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                    }
                    catch (eIEWF) {
                        //alert ("#6C NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage <> 0, FromIframe = false, going to do a href(catch)");
                        //window.top.location.href=NewLocationT;
                        window.parent.frames.SHP2_Prod_section.location.href = NewLocationR;
                    }
                }
            }
        }
        else {
            if (strfrompage == "0") {
                if (FromIframe == "True") {
                    //alert ("#7A NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage = 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    //alert ("#7B NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage = 0, FromIframe = false, going to do a replace");
                    //window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                    window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                }
            }
            else {
                if (FromIframe == "True") {
                    //alert ("#8A NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage <> 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    //alert ("#8B NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage <> 0, FromIframe = false, going to do a replace");
                    //window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                    window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                }
            }
        }
    }
    return false;
}

function JS_Redirect_Frame(newurl, newqueryext, newhash, newtarget, topgm, strsavehistory, menu, tp) {

    // alert(newurl);
    //alert ("newqueryext    = " + newqueryext);
    //alert ("newhash        = " + newhash);
    //alert ("newtarget      = " + newtarget);
    //alert ("topgm          = " + topgm);
    //alert ("strsavehistory = " + strsavehistory);
    //alert ("menu           = " + menu);
    //alert ("tp             = " + tp);
    var FromIframe = pubFromIframe;
    //alert ("FromIframe = " + FromIframe);
    var url = newurl;
    var strtarget = newtarget;
    var passquery = newqueryext;
    var nl = "\n\r";
    var re = /&amp;/g;
    //alert ("JS_Redirect before replace: newurl = " + newurl + nl + " newtarget = " + newtarget + nl + "query = " + passquery);
    passquery = passquery.replace(re, "&");
    //alert ("JS_Redirect after replace : newurl = " + newurl + nl + " newtarget = " + newtarget + nl + "query = " + passquery);
    //alert("strsavehistory = " + strsavehistory);
    if (strtarget == "shp2_prod_section") {
        strtarget = "SHP2_Prod_section";
    }
    if (FromIframe == "False") {
        try {
            //alert ("FromIframe is false");
            window.parent.name = "_top";
            var pn = parent.name;
            //alert ("JS_Redirect-parent.name: " + pn);
            var nframes = parent.frames.length;
            var f0 = "undefined";
            var f1 = "undefined";
            var f2 = "undefined";
            //alert ("JS_Redirect-Parent: " + pn + " nframes: " + nframes);
            if (nframes >= 1) {
                f0 = parent.frames[0].name;
            }
            //alert ("JS_Redirect: " + nframes + " f0:" + f0);
            if (nframes >= 2) {
                f1 = parent.frames[1].name;
            }
            //alert ("JS_Redirect: " + nframes + " f0:" + f0 + " f1:" + f1);
            if (nframes >= 3) {
                window.parent.frames[2].name = "SHP2_Prod_section";
                f2 = "SHP2_Prod_section";
                //alert ("After Rename: parent: " + pn + nl + " nframes= " + nframes + nl + " f0:" + f0 + nl + " f1:" + f1 + nl + " f2:" + f2);
            }
        }
        catch (e1) {
        }
    }
    else {
        //alert ("FromIframe NOT false");
    }
    var strcookie = "";
    var strdir = pubDir;
    //alert ("JS_Redirect strdir = " + strdir);
    //var strdir                    = "<%=dir%>";
    var strtopg = topgm;
    var lastbparam = pubbParam;
    var lastWidth = pubWidth;
    //var lastWidth		            = "<%=width%>";
    var lastHeight = pubHeight;
    var lastRHSwidth = pubRHSwidth;
    var lastRHSheight = pubRHSheight;
    //var lastHeight	            = "<%=height%>";
    var strfrompage = pubProgramNumber;
    //var strfrompage	            = "<%=program_number%>";
    var leftpix = pubLeftPix;
    //var leftpix		            = eval("<%=left_size%>");
    var toppix = pubTopPix;
    //var toppix		            = eval("<%=banner_height%>");
    var strmenupage = menu;
    var aspframemode = pubFrameMode;
    //var aspframemode	            = "<%=FrameMode%>";
    var strFramesPresent = JS_getFrameStatus();
    var vBrowser = navigator.appName;
    var vVersion = navigator.appVersion;
    var sWidth;
    var sHeight;
    var iWidth;
    var iHeight;
    var throughput;
    var pagebParam;
    var temp;
    var itemp;
    if (FromIframe == "False") {
        sWidth = JS_getScreenWidth();
        //alert ("sWidth = " + sWidth);
        sHeight = JS_getScreenHeight();
        //alert ("sHeight = " + sHeight);
        iWidth = JS_getInnerWidth();
        //alert ("iWidth = " + iWidth);
        iHeight = JS_getInnerHeight();
        //alert ("iHeight = " + iHeight);
        throughput = tp;
        //alert ("throughput = " + throughput);
        var strwidth = iWidth;
        var strheight = iHeight;
        var strBrowser = JS_getBrowser();
        var strResolution = JS_getResolution();

        if (strfrompage != "0" && strfrompage != "19") {
            window.parent.pagebparam = strBrowser + strResolution;
            window.parent.pagewidth = iWidth;
            window.parent.pageheight = iHeight;
            window.parent.rhswidth = iWidth - leftpix;
            window.parent.rhsheight = iHeight - toppix;
        }

        if (strfrompage == "0") {
            temp = window.parent.pagewidth;
            //alert("#1 window.parent.pagewidth =" + temp);
            if (temp == "undefined") {
                temp = lastWidth;
            }
            itemp = eval(temp);
            //alert("#2 itemp =" + itemp);
            if (itemp > leftpix) {
                iWidth = itemp;
                //alert("#3 iWidth =" + iWidth);
            }

            else {
                iWidth = eval(lastWidth);
                //alert("#4 iWidth =" + iWidth);
            }
            //alert("#5 iWidth =" + iWidth);	
            temp = window.parent.pageheight;
            if (temp == "undefined") {
                temp = lastHeight;
            }
            itemp = eval(temp);
            if (itemp > toppix) {
                iHeight = itemp;
            }
            else {
                iHeight = eval(lastHeight);
            }
        }
    }
    else {
        throughput = tp;
        if (strfrompage == "0") {
            //we cannot send the h & w values from the iframe
            pagebParam = lastbparam;
            iWidth = eval(lastWidth);
            //alert("iWidth = " + iWidth);
            iHeight = eval(lastHeight);
            //alert("iHeight = " + iHeight);	                   
        }
    }
    ///changes vibgyor/////
    //var redir						= "/shpwebsite/" + strdir + "/sc/asp_redirector.aspx";
    var redir = "/" + strdir + "/sc/asp_redirector.aspx";
    var crlf = String.fromCharCode(13, 10);
    var strwidth = iWidth;
    var strheight = iHeight;
    var strBrowser = JS_getBrowser();
    var strResolution = JS_getResolution();

    if (nframes == 0 & pubFrameMode == "True") {
        //alert ("There are no frames present - must load top file");
        //we have a request to load a rhs frame, but there are no frames
        //if the file is default_right load default.aspx
        url = newurl.replace("default_right", "default");
        //alert ("url #1 = " + url);
        //if the file contains a _R.aspx, make it .aspx and load it as a top file
        url = url.replace("_R.aspx", ".aspx");
        url = url.replace("_r.aspx", ".aspx");
        //alert ("url #2 =" + url);
        var NewLocationT = url + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=N&tp=" + throughput + "&frompg=" + pubProgramNumber + "&menupage=" + pubMenuPage + "&topg=" + pubProgramNumber;
        //alert(NewLocationT)
        window.parent.location.replace(NewLocationT);
        return false;
    }
    //alert("strdir1: " + strdir);	
    //alert ("newurl1 = " + newurl);		
    if (strFramesPresent == "Y" && aspframemode == "True") {
        if (passquery.length >= 3) {
            passquery = passquery + "&target=" + strtarget;
        }
        else {
            passquery = "target=" + strtarget;
        }
    }

    var passhash = newhash;

    if (passhash.length <= 2) {
        passhash = "";
    }
    //alert("strtopg = " + strtopg + nl + "strFramesPresent = " + strFramesPresent + nl + "aspframemode = " + aspframemode + nl + "passquery = " + passquery);
    if (strtopg == "0" && strFramesPresent == "Y" && aspframemode == "True") {
        if (passhash.length <= 2) {
            if (passquery.length <= 2) {
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg;
                    //alert ("FromIframe 1 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg;
                    // alert ("FromIframe 2 NewLocationT = " + NewLocationT);
                }

                else {

                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + strcookie;
                    //alert ("Normal 1 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + strcookie;
                    // alert ("Normal 2 NewLocationT = " + NewLocationT);
                }
            }
            else {
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery;
                    //alert ("FromIframe 3 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery;
                    //alert ("FromIframe 4 NewLocationT = " + NewLocationT);
                }
                else {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + strcookie;
                    //alert ("Normal 3 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + strcookie;
                    //alert ("Normal 4 NewLocationT = " + NewLocationT);
                }
            }
        }
        else {
            if (FromIframe == "True") {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash;
                //alert ("FromIframe 5 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash;
                //alert ("FromIframe 6 NewLocationT = " + NewLocationT);
            }
            else {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash + strcookie;
                //alert ("Normal 5 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&" + passquery + "#" + passhash + strcookie;
                // alert ("Normal 6 NewLocationT = " + NewLocationT);
            }
        }
    }
    else {
        //alert ("failed strtopg test");
        //alert ("passhash.length =" + passhash.length); 
        if (passhash.length <= 2) {
            //alert ("passhash.length< 2");
            //alert ("passquery.length =" + passquery.length); 
            if (passquery.length <= 2) {
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage;
                    //alert ("FromIframe 7 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage;
                    // alert ("FromIframe 8 NewLocationT = " + NewLocationT);
                }
                else {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + strcookie;
                    //alert ("Normal 7 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + strcookie;
                    //alert ("Normal 8 NewLocationT = " + NewLocationT);
                }
            }
            else {
                //alert ("passquery.length > 2 = " + passquery.length + nl + "FromIframe = " + FromIframe);   
                if (FromIframe == "True") {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery;
                    //alert ("FromIframe 9 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?" + passquery + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage;
                    //alert ("FromIframe 10 NewLocationT = " + NewLocationT)
                }
                else {
                    var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery + strcookie;
                    //alert ("Normal 9 NewLocationR = " + NewLocationR);
                    var NewLocationT = newurl + "?" + passquery + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + strcookie;
                    //alert ("Normal 10 NewLocationT = " + NewLocationT);
                }
            }
        }
        else {
            if (FromIframe == "True") {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery + "#" + passhash;
                //alert ("FromIframe 11 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?" + passquery + "&b=" + lastbparam + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "#" + passhash;
                //alert ("FromIframe 12 NewLocationT = " + NewLocationT);
            }
            else {
                var NewLocationR = redir + "?rdirurl=" + url + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "&" + passquery + "#" + passhash + strcookie;
                //alert ("Normal 11 NewLocationR = " + NewLocationR);
                var NewLocationT = newurl + "?" + passquery + "&b=" + strBrowser + strResolution + "&w=" + strwidth + "&h=" + strheight + "&f=" + strFramesPresent + "&tp=" + throughput + "&frompg=" + strfrompage + "&topg=" + strtopg + "&menupage=" + strmenupage + "#" + passhash + strcookie;
                //alert ("Normal 12 NewLocationT = " + NewLocationT);
            }
        }
    }

    if (newtarget == "_top") {
        if (strsavehistory == "Y") {
            if (strfrompage == strtopg) {
                //alert ("#1 NewLocationT = " + NewLocationT + " newtarget = " + newtarget + " frompg = topage savehistory = Y, going to do a replace");
                //window.parent.location.replace([NewLocationT]);
                //alert (NewLocationT)
                //change
                //window.top.location.href=NewLocationT;
                window.parent.location.href = NewLocationT;
            }
            else {
                //alert ("#2 NewLocationT = " + NewLocationT + " newtarget = " + newtarget + " frompg <> topage savehistory = Y, going to do a href");
                //window.top.location.href=NewLocationT;
                //alert (NewLocationT)
                window.parent.location.href = NewLocationT;
                //window.location.replace([NewLocationT]);
            }
        }
        else {
            //alert ("#3 NewLocationT = " + NewLocationT + " newtarget = " + newtarget + " savehistory = N, going to do a replace");
            //window.top.location.replace([NewLocationT]);
            //alert (NewLocationT)
            //window.location.replace([NewLocationT]);
            window.parent.location.href = NewLocationT;
        }
    }
    else {
        if (strsavehistory == "Y") {
            if (strfrompage == "0") {
                if (FromIframe == "True") {
                    //alert ("#4 NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage = 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    //alert ("#5 NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage = 0, FromIframe = false, going to do a href");
                    // window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                    window.parent.location.href = NewLocationR;
                    //window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                }
            }
            else {
                if (FromIframe == "True") {
                    //alert ("#6A NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage <> 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    try {
                        //alert ("#6B NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage <> 0, FromIframe = false, going to do a href(try)");
                        //window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                        window.parent.location.href = NewLocationR;
                        //window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                    }
                    catch (eIEWF) {
                        //alert ("#6C NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = Y, frompage <> 0, FromIframe = false, going to do a href(catch)");
                        //window.top.location.href=NewLocationT;
                        // window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                        window.parent.location.href = NewLocationR;
                    }
                }
            }
        }
        else {
            if (strfrompage == "0") {
                if (FromIframe == "True") {
                    //alert ("#7A NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage = 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    //alert ("#7B NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage = 0, FromIframe = false, going to do a replace");
                    //window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                    //window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                    window.parent.location.href = NewLocationR;
                }
            }
            else {
                if (FromIframe == "True") {
                    //alert ("#8A NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage <> 0, FromIframe = true, going to do a window.open");
                    window.open(NewLocationR, strtarget);
                }
                else {
                    //alert ("#8B NewLocationR = " + NewLocationR + " newtarget = " + newtarget + " savehistory = N, frompage <> 0, FromIframe = false, going to do a replace");
                    //window.parent.frames.SHP2_Prod_section.location.href=NewLocationR;
                    //  window.parent.frames.SHP2_Prod_section.location.replace(NewLocationR);
                    window.parent.location.href = NewLocationR;
                }
            }
        }
    }
    return false;
}




function reloadpage() {
    if (self.location == top.location) {
        var strInnerWidth = JS_getInnerWidth();
        var strInnerHeight = JS_getInnerHeight();
        var strFramesPresent = "N";
        var strBrowser = JS_getBrowser();
        var strResolution = JS_getResolution();
        var strurl = pubUrl;
        //var strurl			= "<%=PageURL%>";
        var strquery = pubQuery;
        //var strquery			= "<%=PageQuery%>";
        var strmenupage = pubMenuPage;
        //var strmenupage		= "<%=menu_page%>";
        if (strquery.length > 0) {
            var pageurl = strurl + "?b=" + strBrowser + strResolution + "&w=" + strInnerWidth + "&h=" + strInnerHeight + "&f=" + strFramesPresent + "&menupage=" + strmenupage + "&" + strquery;
        }
        else {
            var pageurl = strurl + "?b=" + strBrowser + strResolution + "&w=" + strInnerWidth + "&h=" + strInnerHeight + "&f=" + strFramesPresent + "&menupage=" + strmenupage;
        }
        window.top.location.replace(pageurl);
    }
}

function JS_getInnerWidth() {
    var iWidth;
    var leftpix = eval(pubLeftPix);
    //var leftpix					= eval("<%=left_size%>");
    var strfrompage = pubProgramNumber;
    //var strfrompage				= "<%=program_number%>";
    var lastWidth = eval(pubWidth);
    //var lastWidth					= eval("<%=width%>");
    var vBrowser = navigator.appName;
    var vVersion = navigator.appVersion;
    var strFramesPresent = JS_getFrameStatus();
    if (vBrowser == "Netscape") {
        if (strFramesPresent == "Y") {
            iWidth = document.documentElement.clientWidth;

            if (strfrompage == 0 && iWidth <= leftpix) {
                iWidth = lastWidth; 	//the measured width is 200 in the left frame
            }
            else if (strfrompage == 0 && iWidth > leftpix) {
                iWidth = iWidth + 0; //the measured wifth is correct in the top frame
            }
            else {
                iWidth = iWidth + leftpix; //report the full window width
            }
        }
        else {
            iWidth = window.innerWidth;
            if (iWidth <= 0) { iWidth = screen.availWidth; }
        }
    }
    else if (vBrowser == "Microsoft Internet Explorer") {
        if (strFramesPresent == "Y") {
            try {
                iWidth = document.body.clientWidth;
                if (strfrompage == 0 && iWidth <= eval(leftpix)) {
                    iWidth = lastWidth; 	//the measured width is 200 in the left frame
                }
                else if (strfrompage == 0 && iWidth > eval(leftpix)) {
                    iWidth = iWidth + 0; //the measured wifth is correct in the top frame
                }
                else {
                    iWidth = iWidth + eval(leftpix); //report the full window width
                }
            }
            catch (eIEWF) {
                iWidth = self.screen.availWidth;
            }

        }
        else {
            try {
                iWidth = document.body.clientWidth;
                if (iWidth == 0) iWidth = screen.availWidth;
            }
            catch (eIEWNF) {
                iWidth = screen.availWidth;
            }
        }
    }
    else if (vBrowser == "Opera") {
        if (strFramesPresent == "Y") {
            iWidth = document.body.clientWidth;
            if (strfrompage == 0 && iWidth <= eval(leftpix)) {
                iWidth = lastWidth; 	//the measured width is 200 in the left frame
            }
            else if (strfrompage == 0 && iWidth > eval(leftpix)) {
                iWidth = iWidth + 0; //the measured width is correct in the top frame
            }
            else {
                iWidth = iWidth + eval(leftpix); //report the full window width
            }
        }
        else {
            iWidth = document.body.clientWidth;
        }
    }

    else {
        iWidth = screen.availWidth;
    }
    if (iWidth <= 0) iWidth = 1024;
    //alert ("JS_getInnerWidth iWidth = " + iWidth);
    return (iWidth);
}

function JS_getInnerHeight() {
    var iHeight;
    var toppix = eval(pubTopPix);
    //var toppix					= eval("<%=banner_height%>");
    var vBrowser = navigator.appName;
    var vVersion = navigator.appVersion;
    var strFramesPresent = JS_getFrameStatus();

    if (vBrowser == "Netscape") {
        if (strFramesPresent == "Y") {
            iHeight = window.innerHeight;
            iHeight = iHeight + eval(toppix);
        }
        else {
            iHeight = window.innerHeight;

        }
    }
    else if (vBrowser == "Microsoft Internet Explorer") {
        if (strFramesPresent == "Y") {
            try {
                iHeight = document.body.clientHeight;
                iHeight = iHeight + eval(toppix);


            }
            catch (eIEHF) {
                iHeight = screen.availHeight;
            }
        }
        else {
            try {

                iHeight = document.body.clientHeight;
                if (iHeight <= 0)
                    iHeight = screen.availHeight;
                else
                    iHeight = iHeight + eval(toppix);
            }
            catch (eIEHNF) {
                iHeight = screen.availHeight;
            }
        }
    }
    else if (vBrowser == "Opera") {
        if (strFramesPresent == "Y") {
            iHeight = document.body.clientHeight;
            iHeight = iHeight + eval(toppix);
        }
        else
            try {

            iHeight = document.body.clientHeight;
            if (iHeight <= 0)
                iHeight = screen.availHeight;
            else
                iHeight = iHeight + eval(toppix);
        }
        catch (eIEHNF) {
            iHeight = screen.availHeight;
        }
    }
    else {
        iHeight = screen.availHeight;
    }
    if (iHeight <= 0) iHeight = 768;
    //alert ("JS_getInnerHeight iHeight = " + iHeight);
    return (iHeight);
}
function JS_getBrowser() {
    var strHTTPUserAgent = navigator.userAgent.toUpperCase();
    var vBrowser = navigator.appName;
    var vVersion = navigator.appVersion;
    var sBrowser;
    if (strHTTPUserAgent.indexOf("MSIE") >= 0 && strHTTPUserAgent.indexOf("8.") >= 0)
    { sBrowser = "ie8"; }
    else if (strHTTPUserAgent.indexOf("MSIE") >= 0 && strHTTPUserAgent.indexOf("7.") >= 0)
    { sBrowser = "ie7"; }
    else if (strHTTPUserAgent.indexOf("MSIE") >= 0 && strHTTPUserAgent.indexOf("6.") >= 0)
    { sBrowser = "ie6"; }
    else if (strHTTPUserAgent.indexOf("MSIE") >= 0 && strHTTPUserAgent.indexOf("5.") >= 0)
    { sBrowser = "ie5"; }
    else if (strHTTPUserAgent.indexOf("MSIE") >= 0 && strHTTPUserAgent.indexOf("4.") >= 0)
    { sBrowser = "ie4"; }
    else if (strHTTPUserAgent.indexOf("MSIE") >= 0 && strHTTPUserAgent.indexOf("3.") >= 0)
    { sBrowser = "ie3"; }
    else if (strHTTPUserAgent.indexOf("FIREFOX") >= 0 && strHTTPUserAgent.indexOf("/0") >= 0)
    { sBrowser = "ff0"; }
    else if (strHTTPUserAgent.indexOf("FIREFOX") >= 0 && strHTTPUserAgent.indexOf("/1") >= 0)
    { sBrowser = "ff1"; }
    else if (strHTTPUserAgent.indexOf("FIREFOX") >= 0 && strHTTPUserAgent.indexOf("/3") >= 0)
    { sBrowser = "ff3"; }
    else if (strHTTPUserAgent.indexOf("FIREFOX") >= 0 && strHTTPUserAgent.indexOf("/2") >= 0)
    { sBrowser = "ff2"; }
    else if (strHTTPUserAgent.indexOf("GECKO") >= 0 && strHTTPUserAgent.indexOf("I/5") >= 0)
    { sBrowser = "sf5"; }
    else if (strHTTPUserAgent.indexOf("GECKO") >= 0 && strHTTPUserAgent.indexOf("I/4") >= 0)
    { sBrowser = "sf4"; }
    else if (strHTTPUserAgent.indexOf("OPERA") >= 0 && strHTTPUserAgent.indexOf("8") >= 0)
    { sBrowser = "ie6"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/9") >= 0)
    { sBrowser = "sf9"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/8") >= 0)
    { sBrowser = "sf8"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/7") >= 0)
    { sBrowser = "sf7"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/6") >= 0)
    { sBrowser = "sf6"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/5") >= 0)
    { sBrowser = "sf5"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/4") >= 0)
    { sBrowser = "sf4"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/3") >= 0)
    { sBrowser = "sf3"; }
    else if (strHTTPUserAgent.indexOf("SAFARI") >= 0 && strHTTPUserAgent.indexOf("I/2") >= 0)
    { sBrowser = "sf2"; }
    else if (strHTTPUserAgent.indexOf("NETSCAPE") >= 0 && strHTTPUserAgent.indexOf("/8") >= 0)
    { sBrowser = "ns8"; }
    else if (strHTTPUserAgent.indexOf("NETSCAPE") >= 0 && strHTTPUserAgent.indexOf("/7") >= 0)
    { sBrowser = "ns7"; }
    else if (strHTTPUserAgent.indexOf("NETSCAPE") >= 0 && strHTTPUserAgent.indexOf("/6") >= 0)
    { sBrowser = "ns6"; }
    else if (strHTTPUserAgent.indexOf("NETSCAPE") >= 0 && strHTTPUserAgent.indexOf("/5") >= 0)
    { sBrowser = "ns5"; }
    else if (strHTTPUserAgent.indexOf("NETSCAPE") >= 0 && strHTTPUserAgent.indexOf("/4") >= 0)
    { sBrowser = "ns4"; }
    else if (strHTTPUserAgent.indexOf("NETSCAPE") >= 0 && strHTTPUserAgent.indexOf("/3") >= 0)
    { sBrowser = "ns3"; }
    else if (strHTTPUserAgent.indexOf("OPERA") >= 0 && strHTTPUserAgent.indexOf("/10") >= 0)
    { sBrowser = "opA"; }
    else if (strHTTPUserAgent.indexOf("OPERA") >= 0 && strHTTPUserAgent.indexOf("/9") >= 0)
    { sBrowser = "op9"; }
    else if (strHTTPUserAgent.indexOf("OPERA") >= 0 && strHTTPUserAgent.indexOf("/8") >= 0)
    { sBrowser = "op8"; }
    else if (strHTTPUserAgent.indexOf("MOZILLA/5") >= 0)
    { sBrowser = "ns8"; }
    else if (strHTTPUserAgent.indexOf("MOZILLA/4") >= 0)
    { sBrowser = "mz1"; }
    else if (strHTTPUserAgent.indexOf("MOZILLA/3") >= 0)
    { sBrowser = "mz2"; }
    else if (strHTTPUserAgent.indexOf("MOZILLA/2") >= 0)
    { sBrowser = "mz3"; }
    else if (strHTTPUserAgent.indexOf("MOZILLA/1") >= 0)
    { sBrowser = "mz4"; }
    else if (strHTTPUserAgent.indexOf("MOZILLA") >= 0)
    { sBrowser = "mz5"; }
    else
    { sBrowser = "other"; }
    return (sBrowser);
}

function JS_SaveWidthHeight() {
    var leftpix = eval(pubLeftPix);
    //alert ("JS_SaveWidthheight #1 leftpix = " + leftpix);
    var toppix = eval(pubTopPix);
    //alert ("JS_SaveWidthheight #2 toppix = " + toppix);
    var iWidth = JS_getInnerWidth();
    //alert ("JS_SaveWidthheight #3 iWidth = " +  iWidth);
    var iHeight = JS_getInnerHeight();
    //alert ("JS_SaveWidthheight #4 iHeight = " +  iHeight);
    var strBrowser = JS_getBrowser();
    //alert ("JS_SaveWidthheight #5 strBrowser = " + strBrowser);
    var strResolution = JS_getResolution();
    //alert ("JS_SaveWidthheight #6 strResolution = " + strResolution);
    window.parent.pagebparam = strBrowser + strResolution;
    window.parent.pagewidth = iWidth;
    //alert ("JS_SaveWidthheight #7 window.parent.pagewidth set to " +  iWidth);
    window.parent.pageheight = iHeight;
    //alert ("JS_SaveWidthheight #8 window.parent.pageheight set to " + iHeight);
    var rhswidth = iWidth - leftpix;
    window.parent.rhswidth = rhswidth;
    //alert ("JS_SaveWidthheight #9 window.parent.rhswidth set to " +  rhswidth);
    var rhsheight = iHeight - toppix;
    window.parent.rhsheight = rhsheight;
    //alert ("JS_SaveWidthheight #10 window.parent.rhsheight set to " +  rhsheight);
    return false;
}

function cookies_enabled() {
    //First set test cookie
    var name = "test";
    var value = "1";
    var days = 1;
    var createstatus = createCookie(name, value, days);
    //Check if test cookie exists
    var chki = readCookie(name);
    if (chki == "1") {
        //Cookies works fine
        //alert ("cookies are enabled - everything should work fine");
        var deletestatus = eraseCookie(name);
        return true;
    }
    else {
        //alert ("cookies are NOT enabled - This site requires ASP session variables and cookies");
        //Test cookie lost!
        return false;
    }
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else {
        var expires = "";
    }

    var ck = name + "=" + value + expires + "; path=/";
    if (days != -1) {
        //alert('Cookie\n' + ck + '\ncreated');
    }
    else {
        //alert('Cookie\n' + ck + '\nmarked for erase');
    }

    document.cookie = ck;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) {
            //alert("read: " + c.substring(nameEQ.length,c.length));
            return c.substring(nameEQ.length, c.length);
        }
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

function pop_up_blocker() {
    win = window.open('', '', 'width=5,height=5');

    try {
        //win.document;
        win.close();
        return false;
    }
    catch (e) {
        return true;
    }
}

function OpenPopUP(WinURL, WinTarget, WinxOffset, WinyOffset, WinWidth, WinHeight) {
    var popupargs = "top=" + WinyOffset + ",left=" + WinxOffset + ",width=" + WinWidth + ",height=" + WinHeight + ",scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no,status=no,directories=no,copyhistory=no";
    //alert("OpenPopUP WinURL = " + WinURL + "\n\r" + "WinTarget = " + WinTarget  + "\n\r"    + "popupargs = " + popupargs);
    var popup = window.open(WinURL, WinTarget, popupargs);

}

function RLF_setFrames(strmenupage, dir) {
    if (self.location != top.location) {
        var strcookie = "";
        var strcategory = pubDispCategory;
        //var strcategory		= "<%=DispCategory%>";												
        var strResolution = JS_getResolution();
        var strScreenWidth = JS_getScreenWidth();
        var strScreenHeight = JS_getScreenHeight();
        var strInnerWidth = JS_getInnerWidth();
        var strInnerHeight = JS_getInnerHeight();
        var strFramesPresent = JS_getFrameStatus();
        var strBrowser = JS_getBrowser();
        //				var strResolution		= JS_getResolution();
        var newnavtarget = dir.toUpperCase() + "_Nav_section";
        var newtoptarget = dir.toUpperCase() + "_RHS_Banner";
        if (strInnerWidth == "undefined") { alert("#47 warning: strInnerWidth is undefined"); }
        if (strInnerHeight == "undefined") { alert("#48 warning: strInnerHeight is undefined"); }
        var default_left = "/" + dir + "/default_left.aspx" + "?b=" + strBrowser + strResolution + "&w=" + strInnerWidth + "&h=" + strInnerHeight + "&f=" + strFramesPresent + "&menupage=" + strmenupage + "&rll=yes&category=" + strcategory + strcookie;
        var default_banner = "/" + dir + "/default_banner.aspx" + "?b=" + strBrowser + strResolution + "&w=" + strInnerWidth + "&h=" + strInnerHeight + "&f=" + strFramesPresent + "&menupage=" + strmenupage + "&rlt=yes" + strcookie;
        window.parent.frames[0].location.replace(default_banner);
        window.parent.frames[1].location.replace(default_left);
    }
}

function RLL_setFrames(strmenupage, dir, strframes, strcategory) {
    if (self.location != top.location) {
        var strcookie = "";
        //var cookie_status		= cookies_enabled();
        //if (cookie_status		== true)
        //	{
        //		var strcookie	= "";
        //	}
        //else
        //	{
        //		var strcookie	= "&cookies=NO";
        //	}
        var strInnerWidth = JS_getInnerWidth();
        var strInnerHeight = JS_getInnerHeight();
        var strFramesPresent = strframes;
        var strBrowser = JS_getBrowser();
        var strResolution = JS_getResolution();
        var newnavtarget = dir.toUpperCase() + "_Nav_section";
        var newtoptarget = dir.toUpperCase() + "_RHS_Banner";
        var default_left = "/" + dir + "/default_left.aspx" + "?b=" + strBrowser + strResolution + "&w=" + strInnerWidth + "&h=" + strInnerHeight + "&f=" + strFramesPresent + "&menupage=" + strmenupage + "&rll=yes&category=" + strcategory + strcookie;
        window.parent.frames[1].location.replace(default_left);
    }
}

function RLT_setFrames(strmenupage, dir, strframes) {
    if (self.location != top.location) {
        var strcookie = "";
        //var cookie_status		= cookies_enabled();
        //if (cookie_status		== true)
        //	{
        //		var strcookie	= "";
        //	}
        //else
        //	{
        //		var strcookie	= "&cookies=NO";
        //	}
        var strInnerWidth = JS_getInnerWidth();
        var strInnerHeight = JS_getInnerHeight();
        var strFramesPresent = strframes;
        var strBrowser = JS_getBrowser();
        var strResolution = JS_getResolution();
        var newnavtarget = dir.toUpperCase() + "_Nav_section";
        var newtoptarget = dir.toUpperCase() + "_RHS_Banner";
        var default_banner = "/" + dir + "/default_banner.aspx" + "?b=" + strBrowser + strResolution + "&w=" + strInnerWidth + "&h=" + strInnerHeight + "&f=" + strFramesPresent + "&menupage=" + strmenupage + "&rlt=yes" + strcookie;
        window.parent.frames[0].location.replace(default_banner);
    }
}
