var P = {
    siteUrl: "",
    templatePath: "",
    topMenuPath: "",
    sideMenuPath: "",
    $: function (id) {
        if (typeof (id) == "string") {
            return document.getElementById(id);
        }
        else {
            return id;
        }
    },
    preLoadImages: function () {
        var d = document;

        if (d.images) {
            if (!d.MM_p) {
                d.MM_p = new Array();
            }

            var i, j = d.MM_p.length, a = P.preLoadImages.arguments;
            for (i = 0; i < a.length; i++) {
                if (a[i].indexOf("#") != 0) {
                    d.MM_p[j] = new Image;
                    d.MM_p[j++].src = a[i];
                }
            }
        }
    },
    get: function (url, pnl) {
        if (typeof (url) == "object") {
            url = url.getAttribute("href");
        }

        //Remove ajax if present in url.
        var re = /[?&]ajax=1/g;
        url = url.replace(re, "");
        url += (url.indexOf("?") > -1 ? "&" : "?") + "ajax=1";

        PAjax.$(url, function (xmlHttp) {
            //Set the panel html.
            P.setHtml(pnl, xmlHttp);

            //Process scripts...
            PAjax.processScripts(xmlHttp);
        });

        return false;
    },
    post: function (frm, pnl) {
        //Remove ajax if present in url.
        var form = P.getForm(frm);
        form += (form != "" ? "&" : "") + "ajax=1";

        PAjax.$p(frm.action, form, function (xmlHttp) {
            //Set the panel html.
            P.setHtml(pnl, xmlHttp);

            //Process scripts...
            PAjax.processScripts(xmlHttp);
        });

        return false;
    },
    setHtml: function (pnl, content) {
        var html = typeof (content) == "object" ? content.responseText : content;

        if (html.toLowerCase().indexOf("<body") > -1) {
            var html2 = html.substring(html.indexOf("<body") + 5);
            html2 = html2.substring(html2.indexOf(">") + 1);
            html2 = html2.substring(0, html2.indexOf("</body>"));
            P.$(pnl).innerHTML = html2;
        }
        else {
            P.$(pnl).innerHTML = html;
        }
    },
    getForm: function (frm) {
        //Parse the form.
        var form = "";
        var i;

        for (i = 0; i < frm.length; i++) {
            if (frm[i].type == "radio") {
                if (frm[i].checked) {
                    form += frm[i].name + "=" + escape(frm[i].value) + "&";
                }
            }
            else if (frm[i].type == "checkbox") {
                if (frm[i].checked) {
                    form += frm[i].name + "=" + escape(frm[i].value) + "&";
                }
            }
            else if (frm[i].type == "select-one") {
                if (frm[i].options.length > 0) {
                    form += frm[i].name + "=" + escape(frm[i].value) + "&";
                }
            }
            else if (frm[i].type == "select-multiple") {
                var j;
                for (j = 0; j < frm[i].options.length; j++) {
                    if (frm[i].options[j].selected) {
                        form += frm[i].name + "=" + escape(frm[i].options[j].value) + "&";
                    }
                }
            }
            else {
                form += frm[i].name + "=" + escape(frm[i].value) + "&";
            }
        }

        if (form != "") {
            form = form.substring(0, form.length - 1);
        }

        return form;
    },
    scrollToTop: function () {
        if (PBrowser.isFF | PBrowser.isSafari | PBrowser.isChrome | PBrowser.isOpera) {
            document.anchors["top"].scrollIntoView();
        }
        else {
            P.$("top").scrollIntoView();
        }
    }
};

//--------------------------
//--- START OF AJAX CODE ---
//--------------------------

var PAjax = {
    referer: "",
    currentPage: "default.aspx",
    getXmlHttpObject: function () {
        var xmlHttp = false;
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlHttp = false;
            }
        }
        if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
            try {
                xmlHttp = new XMLHttpRequest();
            } catch (e) {
                xmlHttp = false;
            }
        }
        if (!xmlHttp && window.createRequest) {
            try {
                xmlHttp = window.createRequest();
            } catch (e) {
                xmlHttp = false;
            }
        }
        return xmlHttp;
    },
    xmlHttpObjectGet: function (url) {
        var xmlHttp = PAjax.getXmlHttpObject();
        xmlHttp.open("GET", url, true);

        xmlHttp.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        xmlHttp.setRequestHeader("Pragma", "no-cache");
        xmlHttp.setRequestHeader("Cache-Control", "no-cache");

        if (PAjax.referer != "") {
            xmlHttp.setRequestHeader("Referer", PAjax.referer);
        }

        return xmlHttp;
    },
    $: function (url, callback) {
        var xmlHttp = PAjax.xmlHttpObjectGet(url);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                callback(xmlHttp);

                //Cleanup
                try {
                    xmlHttp.onreadystatechange = null;
                    xmlHttp.abort = null;
                }
                catch (e) { }

                xmlHttp = null;
            }
        };
        xmlHttp.send(null);
    },
    $p: function (url, form, callback) {
        var xmlHttp = PAjax.getXmlHttpObject();
        xmlHttp.open("POST", url, true);

        if (document.cookie) {
            xmlHttp.setRequestHeader("Cookie", document.cookie);
        }

        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
        xmlHttp.setRequestHeader("Content-Length", form.length);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                callback(xmlHttp);

                //Cleanup
                try {
                    xmlHttp.onreadystatechange = null;
                    xmlHttp.abort = null;
                }
                catch (e) { }

                xmlHttp = null;
            }
        };
        xmlHttp.send(form);
    },
    get: function (url, pnl) {
        //Check if this is a string of anchor.
        if (typeof (url) == "object") {
            url = url.getAttribute("href");
        }

        //Show Progress
        PAjax.progress(pnl);

        //Remove ajax if present in url.
        var re = /[?&]ajax=1/g;
        url = url.replace(re, "");
        url += (url.indexOf("?") > -1 ? "&" : "?") + "ajax=1";

        //Get the new page.
        PAjax.$(url, function (xmlHttp) {
            var panel = P.$(pnl);

            if (panel != null) {
                //Set the panel html.
                P.setHtml(panel, xmlHttp);

                //Process scripts...
                PAjax.processScripts(xmlHttp);
            }
        });

        return false;
    },
    post: function (frm, pnl) {
        //Parse the form.
        var form = P.getForm(frm);

        //Remove ajax if present in url.
        form += (form != "" ? "&" : "") + "ajax=1";

        //Show Progress
        PAjax.progress(pnl);

        //Get the new page.
        PAjax.$p(frm.action, form, function (xmlHttp) {
            var panel = P.$(pnl);

            if (panel != null) {
                //Set the panel html.
                P.setHtml(panel, xmlHttp);

                //Process scripts...
                PAjax.processScripts(xmlHttp);
            }
        });

        return false;
    },
    frameGet: function (url, pnl) {
        window.setTimeout("PAjax.get('" + url + "', '" + pnl + "');", 20);
    },
    progress: function (pnl) {
        var html = "<img src=\"" + P.siteUrl + "/images/ajax-loader.gif\" width=\"16\" height=\"16\" border=\"0\" />";

        if (PAjax.progress.arguments.length > 1) {
            html += "<br /><br />" + PAjax.progress.arguments[1];
        }

        P.setHtml(pnl, "<center><div style=\"padding:20px 0px 20px 0px;\">" + html + "</div></center>");
    },
    progress2: function (pnl) {
        P.setHtml(pnl, "<center><div style=\"padding:20px 0px 20px 0px;\"><img src=\"" + P.siteUrl + "/images/ajax-loader.gif\" width=\"16\" height=\"16\" border=\"0\" /></div></center>");
    },
    setCookie: function (name, value, expires, path) {
        top.P.$("setcookie").src = P.siteUrl + "/setcookie.aspx?cookie=" + name + "&value=" + value + "&expires=" + expires + "&path=" + path;
    },
    processScripts: function (xmlHttp) {
        //Process scripts...
        var html = xmlHttp.responseText;
        var scr = /<script[^>]+?>(.*?)<\/script>/gim;
        var scripts = html.replace(/[\n\r]/g, '').match(scr);

        if (scripts != null) {
            var i;
            for (i = 0; i < scripts.length; i++) {
                if (scripts[i].toLowerCase().indexOf(" src=") == -1) {
                    var scrStart = /<script.+?>/gi;
                    var scrEnd = /<\/script>/gi;
                    var script = scripts[i].replace(scrStart, "").replace(scrEnd, "");
                    eval(script);
                }
            }
        }
    }
};

//------------------------
//--- END OF AJAX CODE ---
//------------------------

//--------------------------
//--- START OF MENU CODE ---
//--------------------------

var PMenu = {
    tmr: new Array(null, null, null),
    show: function(id, evt)
    {
        window.clearTimeout(PMenu.tmr[id]);
        
        var menu = document.getElementById("mnu" + id).style;
        
        if(evt != null)
        {
            var e = new PEvent.e(evt);    
            menu.left = e.eventElementPosition[0] + "px";
            menu.top = (e.eventElementPosition[1] + e.eventElementDimensions[1]) + "px";
        }
        else
        {
            var menuHeader = document.getElementById("mnuHeader" + id).style;
            menuHeader.backgroundColor = "#186B7D";
            menuHeader.color = "#FFFFFF";
        }
        
        menu.visibility = "visible";
    },
    startHide: function(id)
    {
        PMenu.tmr[id] = window.setTimeout("PMenu.hide(" + id + ");", 30);
    },
    hide: function(id)
    {
        document.getElementById("mnu" + id).style.visibility = "hidden";
        var menuHeader = document.getElementById("mnuHeader" + id).style;
        menuHeader.backgroundColor = "#FFFFFF";
        menuHeader.color = "#186B7D";
    }
};

//------------------------
//--- END OF MENU CODE ---
//------------------------

//------------------------------
//--- START OF FACEBOOK CODE ---
//------------------------------

var Facebook = {
    accessToken: null,
    userId: null,
    extendedperms: false,
    registered: false,
    login: function (permissions, targetUrl) {
        FB.login(function (response) {
            if (response.session) {
                if (response.perms) {
                    // user is logged in and granted some permissions.
                    // perms is a comma separated list of granted permissions
                    Facebook.accessToken = response.session.access_token;
                    Facebook.userId = response.session.uid;
                    Facebook.extendedperms = true;
                } else {
                    // user is logged in, but did not grant any permissions
                    Facebook.accessToken = response.session.access_token;
                    Facebook.userId = response.session.uid;
                    Facebook.extendedperms = false;
                }

                window.location.href = targetUrl + "?userid=" + Facebook.userId + "&access_token=" + Facebook.accessToken;
            } else {
                // user is not logged in
                Facebook.accessToken = null;
                Facebook.userId = null;
                Facebook.extendedperms = false;
            }
        }, { perms: permissions });

        return false;
    },
    logout: function (targetUrl) {
        FB.logout(function (response) {
            // user is now logged out
            Facebook.accessToken = null;
            Facebook.userId = null;
            Facebook.extendedperms = false;

            //Get the target url
            if (targetUrl != null && targetUrl != "") {
                PAjax.get("logout.aspx?targetUrl=" + targetUrl, "content");
            }
            else {
                PAjax.get("logout.aspx", "content");
            }
        });

        return false;
    },
    getLoginStatus: function () {
        FB.getLoginStatus(function (response) {
            if (response.session) {
                // logged in and connected user, someone you know
                Facebook.accessToken = response.session.access_token;
                Facebook.userId = response.session.uid;
                return true;
            } else {
                // no user session available, someone you dont know
                Facebook.accessToken = null;
                Facebook.userId = null;
                Facebook.extendedperms = false;
                return false;
            }
        });
    },
    register: function () {
        if (Facebook.registered) {
            return;
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/account/register.aspx?userId=" + Facebook.userId + "&access_token=" + Facebook.accessToken, false);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                //Process cookies...
                P.processCookies(xmlHttp);

                //Process scripts...
                eval(xmlHttp.responseText);
            }
        };
        xmlHttp.send(null);
    }
};

//----------------------------
//--- END OF FACEBOOK CODE ---
//----------------------------

//---------------------------------
//--- START OF POPUP PANEL CODE ---
//---------------------------------

var PPanel = {
    tmr: new Array(),
    get: function (pnl) {
        var i;

        for (i = 0; i < PPanel.tmr.length; i++) {
            if (PPanel.tmr[i][0] == pnl) {
                return PPanel.tmr[i];
            }
        }

        PPanel.tmr.push([pnl, null]);
        return PPanel.tmr[PPanel.tmr.length - 1];
    },
    show: function (pnl) {
        window.clearTimeout(PPanel.get(pnl)[1]);
        P.$(pnl).style.visibility = "visible";
    },
    startHide: function (pnl) {
        PPanel.get(pnl)[1] = window.setTimeout("PPanel.hide('" + pnl + "');", 300, "JavaScript");
    },
    hide: function (pnl) {
        P.$(pnl).style.visibility = "hidden";
    }
};

//-------------------------------
//--- END OF POPUP PANEL CODE ---
//-------------------------------

//-------------------------------
//--- START OF GEOGRAPHY CODE ---
//-------------------------------

var PGeo = {
    getContinentRegions: function (sel, targetSel, countrySel, provinceSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(countrySel, true);
        PSel.disable(countrySel);

        PSel.clear(provinceSel, true);
        PSel.disable(provinceSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_continentregions.aspx?continentid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var regions = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a Region --");

                for (i = 0; i < regions.length; i++) {
                    PSel.add(targetSel, regions[i][0], regions[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getRegionCountries: function (sel, targetSel, provinceSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(provinceSel, true);
        PSel.disable(provinceSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_regioncountries.aspx?regionid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var countries = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a Country --");

                for (i = 0; i < countries.length; i++) {
                    PSel.add(targetSel, countries[i][0], countries[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getCountryProvinces: function (sel, targetSel, areaSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(areaSel, true);
        PSel.disable(areaSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_countryprovinces.aspx?countrycode=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var provinces = eval(xmlHttp.responseText);

                if (provinces.length == 0) {
                    PGeo.getCountryCities(sel, citySel, suburbSel);
                }
                else {
                    PSel.enable(targetSel);
                    PSel.add(targetSel, "", "-- Select a Province / State --");

                    for (i = 0; i < provinces.length; i++) {
                        PSel.add(targetSel, provinces[i][0], provinces[i][1]);
                    }
                }
            }
        };
        xmlHttp.send(null);
    },
    getProvinceAreas: function (sel, countryCode, targetSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_provinceareas.aspx?countrycode=" + countryCode + "&provinceid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var provinceAreas = eval(xmlHttp.responseText);

                if (provinceAreas.length == 0) {
                    PGeo.getProvinceCities(sel, countryCode, citySel, suburbSel);
                }
                else {
                    PSel.enable(targetSel);
                    PSel.add(targetSel, "", "-- Select an Area --");

                    for (i = 0; i < provinceAreas.length; i++) {
                        PSel.add(targetSel, provinceAreas[i][0], provinceAreas[i][1]);
                    }
                }
            }
        };
        xmlHttp.send(null);
    },
    getCountryCities: function (sel, targetSel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_countrycities.aspx?countrycode=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var countryCities = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a City --");

                for (i = 0; i < countryCities.length; i++) {
                    PSel.add(targetSel, countryCities[i][0], countryCities[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getProvinceCities: function (sel, countryCode, targetSel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_provincecities.aspx?countrycode=" + countryCode + "&provinceid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var provinceCities = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a City --");

                var i;
                for (i = 0; i < provinceCities.length; i++) {
                    PSel.add(targetSel, provinceCities[i][0], provinceCities[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getAreaCities: function (sel, countryCode, provinceId, targetSel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_areacities.aspx?countrycode=" + countryCode + "&provinceid=" + provinceId + "&areaid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var areaCities = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a City --");

                var i;
                for (i = 0; i < areaCities.length; i++) {
                    PSel.add(targetSel, areaCities[i][0], areaCities[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getCitySuburbs: function (sel, targetSel, additionalPostalCode) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (additionalPostalCode != null) {
            additionalPostalCode.style.display = "none";
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_citysuburbs.aspx?cityid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var suburbs = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a Suburb --");

                for (i = 0; i < suburbs.length; i++) {
                    if (i == 0) {
                        if (suburbs[i][0].split("|")[2] == "0") {
                            additionalPostalCode.style.display = PBrowser.isFF ? "inline-block" : "block";
                        }
                    }

                    PSel.addWithTitle(targetSel, suburbs[i][0], suburbs[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    searchText: null,
    searchResult: null,
    searchNoMatchText: "",
    xmlHttp: null,
    l: null,
    lrp: null,
    search: function (textInput, countrySel, provinceSel, areaSel, resultInput) {
        if (PGeo.xmlHttp != null) {
            PGeo.xmlHttp.abort();
        }

        var popup = P.$("locationsearchpopup");
        var popupResults = P.$("locationsearchresults");
        var popupPages = P.$("locationresultpages");
        var popupPageSel = P.$("locationsearchpage");
        var searchImg = P.$("locationsearching");

        PGeo.searchText = textInput;
        PGeo.searchResult = resultInput;

        searchImg.style.display = "none";
        popupResults.innerHTML = "";
        popupPages.style.display = "none";
        popup.style.visibility = "hidden";
        PSel.clear(popupPageSel, true);

        if (textInput.value.length < 3) {
            return;
        }

        searchImg.style.display = "block";

        PGeo.xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_geographysearchresults.aspx?txt=" + textInput.value + "&countrycode=" + countrySel.value + "&provinceid=" + (provinceSel.disabled ? "0" : (provinceSel.value == "" ? "0" : provinceSel.value)) + "&areaid=" + (areaSel.disabled ? "0" : (areaSel.value == "" ? "0" : areaSel.value)) + "&start=0&end=499");
        PGeo.xmlHttp.onreadystatechange = function () {
            if (PGeo.xmlHttp.readyState == 4) {
                PGeo.l = new Array();
                PGeo.lrp = new Array();
                eval(PGeo.xmlHttp.responseText);

                var html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";

                if (PGeo.l.length == 0) {
                    html += "<tr><td style=\"padding:2px 2px 2px 2px;\"><b>" + PGeo.searchNoMatchText + "</b></td></tr>";
                }
                else {
                    var i;
                    for (i = 0; i < PGeo.l.length; i++) {
                        html += "<tr id=\"loc_srchres_row" + i + "\" style=\"cursor:pointer;\" valign=\"baseline\">";
                        html += "<td style=\"padding:2px 2px 2px 2px;\" onmouseover=\"PGeo.set(" + i + ", true);\" onmouseout=\"PGeo.set(" + i + ", false);\" onclick=\"PGeo.sel(" + i + ");\"><b>" + PGeo.l[i][1] + "</b></td>";
                        html += "<td style=\"padding:2px 20px 2px 10px;\" onmouseover=\"PGeo.set(" + i + ", true);\" onmouseout=\"PGeo.set(" + i + ", false);\" onclick=\"PGeo.sel(" + i + ");\">" + PGeo.l[i][2] + "</td>";
                        html += "</tr>";

                        if (i >= 499) {
                            break;
                        }
                    }
                }

                html += "</table>";

                popupResults.innerHTML = html;

                if (PGeo.lrp.length > 0) {
                    popupPages.style.display = "block";

                    for (i = 0; i < PGeo.lrp.length; i++) {
                        PSel.add(popupPageSel, PGeo.lrp[i][0] + "|" + PGeo.lrp[i][1], PGeo.lrp[i][2] + " -> " + PGeo.lrp[i][3], false)
                    }
                }

                searchImg.style.display = "none";
                PGeo.show(textInput);
            }
        };
        PGeo.xmlHttp.send(null);
    },
    filter: function (i, textInput, countrySel, provinceSel, areaSel) {
        var searchImg = P.$("locationsearching");
        searchImg.style.display = "block";

        var popupResults = P.$("locationsearchresults");
        var tableWidth = PEvent.getElementDimensions(popupResults)[0];

        popupResults.innerHTML = "<center><img src=\"" + P.siteUrl + "/images/ajax-loader.gif\" width=\"16\" height=\"16\" border=\"0\" /></center>";
        PGeo.show(textInput);

        var startEnd = i.split("|");

        PGeo.xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_geographysearchresults.aspx?txt=" + textInput.value + "&countrycode=" + countrySel.value + "&provinceid=" + (provinceSel.disabled ? "0" : (provinceSel.value == "" ? "0" : provinceSel.value)) + "&areaid=" + (areaSel.disabled ? "0" : (areaSel.value == "" ? "0" : areaSel.value)) + "&start=" + startEnd[0] + "&end=" + startEnd[1]);
        PGeo.xmlHttp.onreadystatechange = function () {
            if (PGeo.xmlHttp.readyState == 4) {
                PGeo.l = new Array();
                PGeo.lrp = new Array();
                eval(PGeo.xmlHttp.responseText);

                var html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"" + tableWidth + "\">";

                var i;
                for (i = 0; i < PGeo.l.length; i++) {
                    html += "<tr id=\"loc_srchres_row" + i + "\" style=\"cursor:pointer;\" valign=\"baseline\">";
                    html += "<td style=\"padding:2px 2px 2px 2px;\" onmouseover=\"PGeo.set(" + i + ", true);\" onmouseout=\"PGeo.set(" + i + ", false);\" onclick=\"PGeo.sel(" + i + ");\"><b>" + PGeo.l[i][1] + "</b></td>";
                    html += "<td style=\"padding:2px 20px 2px 10px;\" onmouseover=\"PGeo.set(" + i + ", true);\" onmouseout=\"PGeo.set(" + i + ", false);\" onclick=\"PGeo.sel(" + i + ");\">" + PGeo.l[i][2] + "</td>";
                    html += "</tr>";

                    if (i >= 499) {
                        break;
                    }
                }

                html += "</table>";

                popupResults.innerHTML = html;
                searchImg.style.display = "none";
                PGeo.show(textInput);
            }
        };
        PGeo.xmlHttp.send(null);
    },
    show: function (textInput) {
        var popup = P.$("locationsearchpopup");
        popup.style.top = (PEvent.getElementPosition(textInput)[1] + PEvent.getElementDimensions(textInput)[1]) + "px";
        popup.style.left = PEvent.getElementPosition(textInput)[0] + "px";
        popup.style.visibility = "visible";
    },
    hide: function () {
        var popup = P.$("locationsearchpopup");
        var popupResults = P.$("locationsearchresults");
        popupResults.innerHTML = "";
        popup.style.visibility = "hidden";
    },
    set: function (id, onOff) {
        P.$("loc_srchres_row" + id).style.backgroundColor = (onOff ? "#CCCCCC" : "#FFFFFF");
    },
    sel: function (i) {
        PGeo.searchResult.value = PGeo.l[i][0];
        PGeo.searchText.value = PGeo.l[i][1];
        PGeo.hide();
    },
    add: function (continentSel, regionSel, countrySel, provinceSel, citySel, targetSel) {
        if (continentSel.value == "") {
            return;
        }
        else {
            var value = continentSel.value + "|" + regionSel.value + "|" + countrySel.value + "|" + provinceSel.value + "|" + citySel.value;
            var txt = PBrowser.isFF ? continentSel.options[continentSel.options.selectedIndex].text : continentSel.options[continentSel.options.selectedIndex].innerText;

            if (regionSel.value != "") {
                txt += " > " + (PBrowser.isFF ? regionSel.options[regionSel.options.selectedIndex].text : regionSel.options[regionSel.options.selectedIndex].innerText);
            }

            if (countrySel.value != "") {
                txt += " > " + (PBrowser.isFF ? countrySel.options[countrySel.options.selectedIndex].text : countrySel.options[countrySel.options.selectedIndex].innerText);
            }

            if (provinceSel.value != "") {
                txt += " > " + (PBrowser.isFF ? provinceSel.options[provinceSel.options.selectedIndex].text : provinceSel.options[provinceSel.options.selectedIndex].innerText);
            }

            if (citySel.value != "") {
                txt += " > " + (PBrowser.isFF ? citySel.options[provinceSel.options.selectedIndex].text : citySel.options[provinceSel.options.selectedIndex].innerText);
            }

            PSel.addWithTitle(targetSel, value, txt, true);
        }
    },
    tmrLoc: null,
    showLocations: function (evt, position) {
        window.clearTimeout(PGeo.tmrLoc);

        var locations = P.$("locations");
        var currentcountry = P.$("currentcountry");

        if (locations.style.visibility == "hidden") {
            if (position) {
                var e = new PEvent.e(evt);
                locations.style.top = (e.eventElementPosition[1] + e.eventElementDimensions[1] + (PBrowser.isFF ? 6 : 7)) + "px";
                locations.style.left = (e.eventElementPosition[0] - PEvent.getElementDimensions(currentcountry)[0] - 10) + "px";
            }

            locations.style.visibility = "visible";
        }
    },
    startHideLocations: function () {
        PGeo.tmrLoc = window.setTimeout("PGeo.hideLocations();", 300, "JavaScript");
    },
    hideLocations: function () {
        P.$("locations").style.visibility = "hidden";
    }
};

//-----------------------------
//--- END OF GEOGRAPHY CODE ---
//-----------------------------

//--------------------------------
//--- START OF GOOGLE MAP CODE ---
//--------------------------------

var Map = {
    map: null,
    center: null,
    zoomLevel: null,
    init: function (mapId, width, height, gLatLng, zoomLevel, addControl) {
        if (GBrowserIsCompatible()) {
            Map.map = new GMap2(document.getElementById(mapId), { size: new GSize(width, height) });
            Map.map.setCenter(gLatLng, zoomLevel);
            Map.center = gLatLng;
            Map.zoomLevel = zoomLevel;
            Map.map.addControl(new GSmallMapControl());
        }
    },
    createMarker: function (id, gLatLng, html) {
        var marker = new GMarker(gLatLng);
        marker.bindInfoWindowHtml(html, null);
        GEvent.addListener(marker, "infowindowclose", function () { Map.map.setCenter(Map.center, Map.zoomLevel); });
        Map.map.addOverlay(marker);
    }
};

//------------------------------
//--- END OF GOOGLE MAP CODE ---
//------------------------------

//----------------------------
//--- START OF SELECT CODE ---
//----------------------------

var PSel = {
    disable: function (sel) {
        if (sel != null) {
            sel.disabled = true;
        }
    },
    enable: function (sel) {
        if (sel != null) {
            sel.disabled = false;
        }
    },
    add: function (sel, val, txt, unique) {
        var opt;

        if (!unique) {
            if (PBrowser.isFF) {
                opt = new Option(txt, val);
                sel.appendChild(opt);
            }
            else if (PBrowser.isSafari | PBrowser.isOpera) {
                sel.options[sel.options.length] = new Option(txt, val);
                opt = sel.options[sel.options.length - 1];
            }
            else {
                opt = document.createElement("OPTION");
                sel.options.add(opt);

                opt.innerText = txt;
                opt.value = val;
            }
        }
        else {
            var found;
            var i;
            for (i = 0; i < sel.options.length; i++) {
                if (sel.options[i].value == val) {
                    found = true;
                    break;
                }
            }

            if (!found) {
                if (PBrowser.isFF) {
                    opt = new Option(txt, val);
                    sel.appendChild(opt);
                }
                else if (PBrowser.isSafari | PBrowser.isOpera) {
                    sel.options[sel.options.length] = new Option(txt, val);
                    opt = sel.options[sel.options.length - 1];
                }
                else {
                    opt = document.createElement("OPTION");
                    sel.options.add(opt);

                    opt.innerText = txt;
                    opt.value = val;
                }
            }
        }

        return opt;
    },
    addWithTitle: function (sel, val, txt, unique) {
        if (!unique) {
            if (PBrowser.isFF) {
                var opt = new Option(txt, val);
                opt.title = txt;
                sel.appendChild(opt);
            }
            else if (PBrowser.isSafari | PBrowser.isOpera) {
                sel.options[sel.options.length] = new Option(txt, val);
                sel.options[sel.options.length - 1].title = txt;
            }
            else {
                var opt = document.createElement("OPTION");
                sel.options.add(opt);

                opt.innerText = txt;
                opt.value = val;
                opt.title = txt;
            }
        }
        else {
            var found;
            var i;
            for (i = 0; i < sel.options.length; i++) {
                if (sel.options[i].value == val) {
                    found = true;
                    break;
                }
            }

            if (!found) {
                if (PBrowser.isFF) {
                    var opt = new Option(txt, val);
                    opt.title = txt;
                    sel.appendChild(opt);
                }
                else if (PBrowser.isSafari | PBrowser.isOpera) {
                    sel.options[sel.options.length] = new Option(txt, val);
                    sel.options[sel.options.length - 1].title = txt;
                }
                else {
                    var opt = document.createElement("OPTION");
                    sel.options.add(opt);

                    opt.innerText = txt;
                    opt.value = val;
                    opt.title = txt;
                }
            }
        }
    },
    addAtIndex: function (sel, val, txt, index) {
        var opt;

        if (PBrowser.isFF) {
            opt = new Option(txt, val);
            sel.insertBefore(opt, sel.options[index]);
        }
        else if (PBrowser.isSafari | PBrowser.isOpera) {
            //Move all the options after this option up 1 level.
            for (i = sel.options.length; i > index; i--) {
                sel.options[i] = new Option(sel.options[i - 1].text, sel.options[i - 1].value);
                sel.options[i].style.color = sel.options[i - 1].style.color;
            }

            sel.options[index] = new Option(txt, val);
            opt = sel.options[index];
        }
        else {
            opt = document.createElement("OPTION");
            sel.options.insertBefore(opt, sel.options[index]);

            opt.text = txt;
            opt.value = val;
        }

        return opt;
    },
    clear: function (sel, clearAll) {
        if (sel != null) {
            var i;
            if (clearAll) {
                if (PBrowser.isSafari | PBrowser.isOpera) {
                    sel.options.length = 0;
                }
                else {
                    for (i = sel.options.length; i >= 0; i--) {
                        sel.remove(i);
                    }
                }
            }
            else {
                if (PBrowser.isSafari | PBrowser.isOpera) {
                    sel.options.length = 1;
                }
                else {
                    for (i = sel.options.length; i > 0; i--) {
                        sel.remove(i);
                    }
                }
            }
        }
    },
    clearDisable: function (elms, clearAll) {
        if (elms instanceof Array) {
            var i;

            for (i = 0; i < elms.length; i++) {
                if (elms[i] != null) {
                    PSel.clear(elms[i], clearAll);
                    PSel.disable(elms[i]);
                }
            }
        }
        else {
            if (elms != null) {
                PSel.clear(elms, clearAll);
                PSel.disable(elms);
            }
        }
    },
    sort: function (sel) {
        arrTexts = new Array();
        arrValues = new Array();
        arrOldTexts = new Array();

        for (i = 0; i < sel.length; i++) {
            arrTexts[i] = sel.options[i].text;
            arrValues[i] = sel.options[i].value;

            arrOldTexts[i] = sel.options[i].text;
        }

        arrTexts.sort();

        for (i = 0; i < sel.length; i++) {
            sel.options[i].text = arrTexts[i];
            for (j = 0; j < sel.length; j++) {
                if (arrTexts[i] == arrOldTexts[j]) {
                    sel.options[i].value = arrValues[j];
                    j = sel.length;
                }
            }
        }
    },
    selectAll: function (sel) {
        for (i = 0; i < sel.length; i++) {
            sel.options[i].selected = true;
        }
    },
    unSelectAll: function (sel) {
        for (i = 0; i < sel.length; i++) {
            sel.options[i].selected = false;
        }
    },
    removeSelected: function (sel) {
        var i;
        for (i = sel.options.length - 1; i >= 0; i--) {
            if (sel.options[i].selected) {
                sel.remove(i);
            }
        }
    },
    removeValue: function (sel, val) {
        var i;
        for (i = sel.options.length - 1; i >= 0; i--) {
            if (sel.options[i].value == val) {
                sel.remove(i);
            }
        }
    }
};

//--------------------------
//--- END OF SELECT CODE ---
//--------------------------

//-----------------------------
//--- START OF BROWSER CODE ---
//-----------------------------

var PBrowser = {
    isIE: navigator.appName == "Microsoft Internet Explorer",
    isFF: (navigator.userAgent.indexOf("Firefox") != -1),
    isMac: (navigator.appVersion.indexOf("Mac") != -1),
    isSafari: (navigator.appVersion.indexOf("Safari") != -1 && navigator.userAgent.indexOf("Chrome") == -1),
    isOpera: (navigator.userAgent.indexOf("Opera") != -1 ? true : false),
    isChrome: (navigator.userAgent.indexOf("Chrome") != -1 ? true : false)
};

//---------------------------
//--- END OF BROWSER CODE ---
//---------------------------

//---------------------------
//--- START OF EVENT CODE ---
//---------------------------

var PEvent = {
    e: function (evt) {
        this.event = PEvent.getEvent(evt);
        this.eventElement = PEvent.getEventElement(evt);
        this.eventElementPosition = PEvent.getEventElementPosition(evt);
        this.eventElementDimensions = PEvent.getEventElementDimensions(evt);
        this.windowDimensions = PEvent.getWindowDimensions();
    },
    getEvent: function (evt) {
        if (window.event) {
            return window.event;
        }
        else {
            return evt;
        }
    },
    getEventElement: function (evt) {
        var e = PEvent.getEvent(evt);

        var elm;
        if (e.srcElement) {
            elm = e.srcElement;
        }
        else {
            elm = e.target;
        }

        return elm;
    },
    getEventElementPosition: function (evt) {
        var obj = PEvent.getEventElement(evt);

        var curleft = 0;
        var curtop = 0;

        if (obj.offsetParent) {
            curleft = obj.offsetLeft;
            curtop = obj.offsetTop;

            while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
            }
        }

        return [curleft, curtop];
    },
    getEventElementDimensions: function (evt) {
        var obj = PEvent.getEventElement(evt);

        var innerWidth = 0;
        var innerHeight = 0;

        if (obj.offsetWidth) {
            innerWidth = obj.offsetWidth;
            innerHeight = obj.offsetHeight;
        }
        else {
            innerWidth = obj.clientWidth;
            innerHeight = obj.clientHeight;
        }

        return [innerWidth, innerHeight];
    },
    getElementPosition: function (obj) {
        var curleft = 0;
        var curtop = 0;

        if (obj.offsetParent) {
            curleft = obj.offsetLeft;
            curtop = obj.offsetTop;

            while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
            }
        }

        return [curleft, curtop];
    },
    getElementDimensions: function (obj) {
        var innerWidth = 0;
        var innerHeight = 0;

        if (obj.offsetWidth) {
            innerWidth = obj.offsetWidth;
            innerHeight = obj.offsetHeight;
        }
        else {
            innerWidth = obj.clientWidth;
            innerHeight = obj.clientHeight;
        }

        return [innerWidth, innerHeight];
    },
    getWindowDimensions: function () {
        if (window.innerWidth) {
            return [window.innerWidth, window.innerHeight];
        }
        else if (document.documentElement.clientHeight != 0) {
            return [document.documentElement.clientWidth, document.documentElement.clientHeight];
        }
        else if (document.body.clientWidth != 0) {
            return [document.body.clientWidth, document.body.clientHeight];
        }
        else {
            return [0, 0];
        }
    },
    getIFrameWindowDimensions: function (iframe) {
        if (iframe.contentWindow.document.body.clientWidth) {
            return [iframe.contentWindow.document.body.clientWidth, iframe.contentWindow.document.body.clientHeight];
        }

        if (iframe.contentDocument.width) {
            return [iframe.contentDocument.width, iframe.contentDocument.height];
        }

        return [0, 0];
    },
    getScrollXY: function () {
        var scrOfX = 0, scrOfY = 0;

        if (typeof (window.pageYOffset) == "number") {
            //Netscape compliant
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
        }
        else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            //DOM compliant
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
        }
        else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
            //IE6 standards compliant mode
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
        }

        return [scrOfX, scrOfY];
    }
};

//-------------------------
//--- END OF EVENT CODE ---
//-------------------------

//------------------------------
//--- START OF CURRENCY CODE ---
//------------------------------

var PCurrency = {
    cur: new Array(),
    current: function () {
        return P.$("defaultCurrency").value;
    },
    update: function () {
        try {
            var defaultCurrency = PCurrency.current();

            if (document.getElementsByTagName) {
                var prices = document.getElementsByTagName("span");
                var i;

                for (i = 0; i < prices.length; i++) {
                    if (prices[i].className.match("price")) {
                        if (prices[i].className.match("summaryprice")) {
                            var id = prices[i].id;
                            var priceId = prices[i].id.replace("currency_", "");
                            var originalCur = prices[i].innerHTML.substring(0, prices[i].innerHTML.indexOf(")")).replace("(", "");

                            P.$(id).innerHTML = PCurrency.getSymbol(defaultCurrency);

                            if (P.$(priceId).value != "") {
                                P.$(priceId).value = PCurrency.convert2(originalCur, defaultCurrency, P.$(priceId).value);
                            }
                        }
                        else {
                            var originalPrice = prices[i].title.split(" ");
                            var exchangeAmount = PCurrency.convert(originalPrice[0], defaultCurrency, originalPrice[1]);

                            if (Math.abs(exchangeAmount) == 0) {
                                prices[i].innerHTML = "";
                            }
                            else {
                                prices[i].innerHTML = "<i>(" + defaultCurrency + ")&nbsp;" + exchangeAmount + "</i>";
                            }
                        }
                    }
                }
            }
        }
        catch (e) { }
        return false;
    },
    getSymbol: function (currency) {
        //Get new currency symbol.
        var symbol = "";
        var i;
        for (i = 0; i < PCurrency.cur.length; i++) {
            if (PCurrency.cur[i].indexOf(currency + "|") > -1) {
                symbol = "(" + currency + ")&nbsp;" + PCurrency.cur[i].split("|")[2];
                break;
            }
        }

        return symbol;
    },
    updateSymbols: function () {
        var preferredCurrency = P.$("preferredcurrency").value;

        //Get new currency symbol.
        var currencySymbol = "";
        var i;
        for (i = 0; i < PCurrency.cur.length; i++) {
            if (PCurrency.cur[i].indexOf(preferredCurrency + "|") > -1) {
                currencySymbol = "(" + preferredCurrency + ")" + PCurrency.cur[i].split("|")[2];
                break;
            }
        }

        if (document.getElementsByTagName) {
            var currencySymbols = document.getElementsByTagName("span");
            var i;

            for (i = 0; i < currencySymbols.length; i++) {
                if (currencySymbols[i].className.match("currencysymbol")) {
                    currencySymbols[i].innerHTML = currencySymbol;
                }
            }
        }

        return false;
    },
    convert: function (fromCurrency, toCurrency, amount) {
        if (fromCurrency == toCurrency) {
            return 0;
        }
        else {
            var fromCurrencyRate, toCurrencyRate, tmpAmount, currencyRate, currencySymbol;
            var i;

            for (i = 0; i < PCurrency.cur.length; i++) {
                if (PCurrency.cur[i].indexOf(fromCurrency + "|") > -1) {
                    fromCurrencyRate = PCurrency.cur[i].split("|")[1];
                }

                if (PCurrency.cur[i].indexOf(toCurrency + "|") > -1) {
                    toCurrencyRate = PCurrency.cur[i].split("|")[1];
                    currencySymbol = PCurrency.cur[i].split("|")[2];
                }
            }

            var price = "00" + Math.round(100 * (Math.abs(amount) / Math.abs(fromCurrencyRate) * Math.abs(toCurrencyRate)), 2).toString();
            price = price.substring(0, price.length - 2) + "." + price.substring(price.length - 2);

            while (price.indexOf("0") == 0 && price.indexOf("0.") != 0) {
                price = price.substring(1);
            }

            if (price == ".0") {
                price = "0.00";
            }

            return currencySymbol + price;
        }
    },
    convert2: function (fromCurrency, toCurrency, amount) {
        if (fromCurrency == toCurrency) {
            return 0;
        }
        else {
            var fromCurrencyRate, toCurrencyRate, tmpAmount, currencyRate;
            var i;

            for (i = 0; i < PCurrency.cur.length; i++) {
                if (PCurrency.cur[i].indexOf(fromCurrency + "|") > -1) {
                    fromCurrencyRate = PCurrency.cur[i].split("|")[1];
                }

                if (PCurrency.cur[i].indexOf(toCurrency + "|") > -1) {
                    toCurrencyRate = PCurrency.cur[i].split("|")[1];
                }
            }

            var price = Math.round(100 * (Math.abs(amount) / Math.abs(fromCurrencyRate) * Math.abs(toCurrencyRate)), 2).toString();
            price = price.substring(0, price.length - 2) + "." + price.substring(price.length - 2);

            if (price == ".0") {
                price = "0.00";
            }

            return price;
        }
    }
};

//----------------------------
//--- END OF CURRENCY CODE ---
//----------------------------

//---------------------------
//--- START OF IMAGE CODE ---
//---------------------------

var PImage = {
    tmr: null,
    enlarge: function (src, target) {
        var img = new Image();
        img.src = src;

        if (PBrowser.isFF | PBrowser.isSafari | PBrowser.isOpera) {
            img.onload = function () {
                if (img.width > 400 | img.height > 300) {
                    var x = img.width / 400;
                    var y = img.height / 300;

                    if (x > y) {
                        target.width = img.width / x;
                        target.height = img.height / x;
                    }
                    else {
                        target.width = img.width / y;
                        target.height = img.height / y;
                    }
                }
                else {
                    target.width = img.width;
                    target.height = img.height;
                }

                target.src = img.src;
            };
        }
        else {
            img.onreadystatechange = function () {
                if (img.readyState == "complete") {
                    if (img.width > 400 | img.height > 300) {
                        var x = img.width / 400;
                        var y = img.height / 300;

                        if (x > y) {
                            target.width = img.width / x;
                            target.height = img.height / x;
                        }
                        else {
                            target.width = img.width / y;
                            target.height = img.height / y;
                        }
                    }
                    else {
                        target.width = img.width;
                        target.height = img.height;
                    }

                    target.src = img.src;
                }
            };

            if (img.readyState == "complete") {
                if (img.width > 400 | img.height > 300) {
                    var x = img.width / 400;
                    var y = img.height / 300;

                    if (x > y) {
                        target.width = img.width / x;
                        target.height = img.height / x;
                    }
                    else {
                        target.width = img.width / y;
                        target.height = img.height / y;
                    }
                }
                else {
                    target.width = img.width;
                    target.height = img.height;
                }

                target.src = img.src;
            }
        }
    },
    getPopup: function (src, evt) {
        window.clearTimeout(PImage.tmr);

        var e = new PEvent.e(evt);
        var popup = P.$("popup");
        var popupText = P.$("popupText");
        popup.style.visibility = "hidden";
        popup.style.top = e.eventElementPosition[1] + "px";
        popup.style.left = (e.eventElementPosition[0] + (e.eventElementDimensions[0] / 2) - 35) + "px";
        popup.style.width = "70px";
        popup.style.height = "30px";
        popupText.innerHTML = "Loading...";
        popup.style.visibility = "visible";

        //Get the image.
        var img = new Image();
        img.onload = function () {
            popupText.innerHTML = "<img src=\"" + src + "\" />";

            var imgNew = popupText.getElementsByTagName("IMG");
            popup.style.width = (imgNew[0].width + 30) + "px";

            if (e.eventElementPosition[0] <= PEvent.getWindowDimensions()[0]) {
                popup.style.left = (e.eventElementPosition[0] + e.eventElementDimensions[0] - imgNew[0].width - 35) + "px";
            }

            popup.style.height = (imgNew[0].height + 30) + "px";
        };
        img.src = src;
    },
    getPopup2: function (src, evt) {
        window.clearTimeout(PImage.tmr);

        var e = new PEvent.e(evt);
        var popup = P.$("popup");
        var popupText = P.$("popupText");
        popup.style.visibility = "hidden";
        popup.style.top = e.eventElementPosition[1] + "px";
        popup.style.left = (e.eventElementPosition[0] + (e.eventElementDimensions[0] / 2) - 35) + "px";
        popup.style.width = "70px";
        popup.style.height = "30px";
        popupText.innerHTML = "Loading...";
        popup.style.visibility = "visible";

        //Get the image.
        var img = new Image();
        img.onload = function () {
            popupText.innerHTML = "<img src=\"" + src + "\" />";

            var imgNew = popupText.getElementsByTagName("IMG");
            popup.style.width = (imgNew[0].width + 30) + "px";

            if (e.eventElementPosition[0] <= PEvent.getWindowDimensions()[0]) {
                popup.style.left = e.eventElementPosition[0] + "px";
            }
            else {
                popup.style.left = (e.eventElementPosition[0] + e.eventElementDimensions[0] - imgNew[0].width - 35) + "px";
            }

            popup.style.height = (imgNew[0].height + 30) + "px";
        };
        img.src = src;
    },
    show: function (img) {
        P.$("imgLarge").src = img.src.replace("thumbnails", "large");
        P.$("imgTitle").innerHTML = img.title;
        P.$("imgDescription").innerHTML = img.getAttribute("alt");
    },
    calculateSize: function (dim, w, h, r) {
        if (w.value != "" && w.value != "0" && h.value != "" && h.value != "0" && r.value != "" && r.value != "0") {
            if (dim == "w") {
                w.value = Math.floor(parseFloat(h.value) * parseFloat(r.value));
            }
            else if (dim == "h") {
                h.value = Math.floor(parseFloat(w.value) * (1 / parseFloat(r.value)));
            }
        }
    }
};

//-------------------------
//--- END OF IMAGE CODE ---
//-------------------------

//---------------------------
//--- START OF POPUP CODE ---
//---------------------------

var PPopup = {
    tmr: null,
    get: function (url, evt) {
        window.clearTimeout(PPopup.tmr);
        var e = new PEvent.e(evt);

        //Set up the popup and determine the positioning of the popup.
        var popup = P.$("popup");
        var elmPos = e.eventElementPosition;
        var popupText = P.$("popupText");
        popup.style.visibility = "hidden";
        popup.style.top = (elmPos[1] + (elmPos[1] > 410 ? -40 : 20)) + "px";
        popup.style.left = (elmPos[0] + (elmPos[0] > (e.windowDimensions[0] / 2) ? -50 : 25)) + "px";
        popup.style.width = "70px";
        popup.style.height = "30px";
        popupText.innerHTML = "Loading...";
        popup.style.visibility = "visible";

        //Get the new page.
        var xmlHttp = PAjax.xmlHttpObjectGet(url + (url.indexOf("?") > -1 ? "&" : "?") + "ajax=1");
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                popup.style.left = ((e.windowDimensions[0] / 2) - 310) + "px";
                popup.style.width = "615px";

                if (xmlHttp.responseText.toLowerCase().indexOf("<body") > -1) {
                    var html = xmlHttp.responseText.substring(xmlHttp.responseText.indexOf("<body") + 5);
                    html = html.substring(html.indexOf(">") + 1);
                    html = html.substring(0, html.indexOf("</body>"));
                    popupText.innerHTML = html;
                }
                else {
                    popupText.innerHTML = xmlHttp.responseText;
                }

                var tblDim;
                var i;
                for (i = 0; i < popup.childNodes.length; i++) {
                    if (popup.childNodes[i].tagName == "TABLE") {
                        tblDim = PEvent.getElementDimensions(popup.childNodes[i]);
                        break;
                    }
                }

                if (tblDim[1] > 395) {
                    popup.style.top = (elmPos[1] + (elmPos[1] > 410 ? -420 : 20)) + "px";
                    popup.style.height = "400px";
                }
                else {
                    popup.style.top = (elmPos[1] + (elmPos[1] > 410 ? -(tblDim[1] + 15) : 20)) + "px";
                    popup.style.height = (tblDim[1] + 15) + "px";
                }

                var script = xmlHttp.responseText.substring(xmlHttp.responseText.toLowerCase().indexOf("</body>") + 7);
                if (script.toLowerCase().indexOf("<script ") > -1) {
                    script = script.substring(script.indexOf(">") + 1);
                    script = script.substring(0, script.toLowerCase().indexOf("</script>"));
                    eval(script);
                }
            }
        };
        xmlHttp.send(null);
    },
    resize: function () {
        var popup = P.$("popup");

        if (popup.style.visibility == "visible") {
            var tblDim;
            var i;

            for (i = 0; i < popup.childNodes.length; i++) {
                if (popup.childNodes[i].tagName == "TABLE") {
                    tblDim = PEvent.getElementDimensions(popup.childNodes[i]);
                    break;
                }
            }

            if (tblDim[1] > 395) {
                popup.style.height = "400px";
            }
            else {
                popup.style.height = (tblDim[1] + 15) + "px";
            }
        }
    },
    show: function () {
        window.clearTimeout(PPopup.tmr);
        P.$("popup").style.visibility = "visible";
    },
    startHide: function () {
        PPopup.tmr = window.setTimeout("PPopup.hide();", 1000, "JavaScript");
    },
    hide: function () {
        P.$("popup").style.visibility = "hidden";
    }
};

//-------------------------
//--- END OF POPUP CODE ---
//-------------------------

//------------------------------
//--- START OF CALENDAR CODE ---
//------------------------------

var PCal = {
    calDate: null,
    y: null,
    m: null,
    d: null,
    id1: null,
    id2: null,
    fmt: null,
    hiddenElms: null,
    show: function (id1, id2, fmt, evt) {
        if (PCal.show.arguments.length > 5) {
            var i;
            PCal.hiddenElms = new Array();
            for (i = 5; i < PCal.show.arguments.length; i++) {
                PCal.hiddenElms[i - 5] = PCal.show.arguments[i];
                P.$(PCal.hiddenElms[i - 5]).style.visibility = "hidden";
            }
        }
        else {
            PCal.hiddenElms = null;
        }

        PCal.id1 = id1;
        PCal.id2 = id2;
        PCal.fmt = fmt;

        if (P.$(id1).value != "") {
            try {
                var dtParts;
                dtParts = P.$(id1).value.split("/");

                if (PCal.fmt == "yyyy/mm/dd") {
                    PCal.calDate = new Date(dtParts[0], dtParts[1] - 1, dtParts[2]);
                }
                else {
                    if (PCal.fmt == "yy/mm/dd") {
                        PCal.calDate = new Date(2000 + Math.abs(dtParts[0]), dtParts[1] - 1, dtParts[2]);
                    }
                    else {
                        if (PCal.fmt == "dd/mm/yy") {
                            PCal.calDate = new Date(2000 + Math.abs(dtParts[2]), dtParts[1] - 1, dtParts[0]);
                        }
                        else {
                            if (PCal.fmt == "dd/mm/yyyy") {
                                PCal.calDate = new Date(dtParts[2], dtParts[1] - 1, dtParts[0]);
                            }
                            else {
                                PCal.calDate = new Date();
                            }
                        }
                    }
                }
            }
            catch (e) {
                PCal.calDate = new Date();
            }
        }
        else {
            PCal.calDate = new Date();
        }

        PCal.y = PCal.calDate.getFullYear();
        PCal.m = PCal.calDate.getMonth();
        PCal.d = PCal.calDate.getDate();

        PCal.create();

        //Get the coordinates
        var pageXY = PEvent.getEventElementPosition(evt);
        var elmDim = PEvent.getEventElementDimensions(evt);

        var cal = P.$("cal").style;
        cal.left = pageXY[0] + "px";
        cal.top = (pageXY[1] + elmDim[1]) + "px";
        cal.visibility = "visible";

        P.$(id1).blur();
    },
    create: function () {
        var firstDay, firstWeekDay, monthLength;
        var y = PCal.y;
        var m = PCal.m;
        var i, j;
        var html;

        //Create the month 'selected' array;
        var monthSel = new Array();
        for (i = 0; i < 12; i++) {
            if (i == PCal.m) {
                monthSel[i] = " selected='selected'";
            }
            else {
                monthSel[i] = "";
            }
        }

        html = "<table class='calendar' cellspacing='0' cellpadding='0' border='0' width='140' style='background-color:#86B59D;border:1px solid #D3D3D3;font-size:11px;'>";
        html += "<tr><td width='84'><select id='cal_month' class='select' style='width:80px;font-size:11px;' onchange='PCal.month();'>";
        html += "<option value='0'" + monthSel[0] + ">January</option>";
        html += "<option value='1'" + monthSel[1] + ">February</option>";
        html += "<option value='2'" + monthSel[2] + ">March</option>";
        html += "<option value='3'" + monthSel[3] + ">April</option>";
        html += "<option value='4'" + monthSel[4] + ">May</option>";
        html += "<option value='5'" + monthSel[5] + ">June</option>";
        html += "<option value='6'" + monthSel[6] + ">July</option>";
        html += "<option value='7'" + monthSel[7] + ">August</option>";
        html += "<option value='8'" + monthSel[8] + ">September</option>";
        html += "<option value='9'" + monthSel[9] + ">October</option>";
        html += " <option value='10'" + monthSel[10] + ">November</option>";
        html += "<option value='11'" + monthSel[11] + ">December</option>";
        html += "</select>";
        html += "</td><td width='54'>";
        html += "<select id='cal_year' class='select' style='width:50px;font-size:11px;' onchange='PCal.year();'>";

        var now = new Date();
        for (i = now.getFullYear() + 2; i >= now.getFullYear() - 90; i--) {
            if (i == PCal.y) {
                html += "<option value='" + i + "' selected='selected'>" + i + "</option>";
            }
            else {
                html += "<option value='" + i + "'>" + i + "</option>";
            }
        }

        html += "</td></tr><tr><td id='calendar' colspan='2' style='padding-left:3px;'>";
        html += "<table class='calendar' cellspacing='0' cellpadding='0' border='0' width='132' style='background-color:#FFFFFF;font-size:10px;'>";
        html += "<tr align='center'>";
        html += "<td><b>M</b></td>";
        html += "<td><b>T</b></td>";
        html += "<td><b>W</b></td>";
        html += "<td><b>T</b></td>";
        html += "<td><b>F</b></td>";
        html += "<td><b>S</b></td>";
        html += "<td><b>S</b></td>";
        html += "</tr><tr>";

        firstDay = new Date(y, m, 1);
        firstWeekDay = firstDay.getDay();
        monthLength = PCal.getMonthLength(y, m);

        if (firstWeekDay == 0) {
            for (j = 0; j < 6; j++) {
                html += "<td width=20>&nbsp;</td>"
            }
        }
        else {
            for (j = 0; j < firstWeekDay - 1; j++) {
                html += "<td width=20>&nbsp;</td>"
            }
        }

        for (j = 1; j < monthLength + 1; j++) {
            if ((j + firstWeekDay - 2) % 7 == 0) {
                html += "</tr><tr>";
            }

            if (y == PCal.y && m == PCal.m && j == PCal.d) {
                html += "<td id=date_" + y + "_" + m + "_" + j + " width=20 style='border:1px solid FFCC00' align='center' onclick=PCal.day('" + y + "_" + m + "_" + j + "')>" + j + "</td>"
            }
            else {
                html += "<td id=date_" + y + "_" + m + "_" + j + " width=20 style='border:1px solid white' align='center' onclick=PCal.day('" + y + "_" + m + "_" + j + "')>" + j + "</td>"
            }
        }

        html += "</tr>";
        html += "</table>";
        html += "</td></tr>";
        html += "<tr><td colspan='2' align='right' style='padding-right:2px;'><input type='button' class='button' value='Cancel' onclick='PCal.hide();' /></td></tr>";
        html += "</table>";

        P.setHtml("cal", html);

        if (PCal.getMonthLength(PCal.y, PCal.m) < PCal.d) {
            PCal.d = PCal.getMonthLength(PCal.y, PCal.m);
        }

        P.$("date_" + PCal.y + "_" + PCal.m + "_" + PCal.d).style.border = "1px solid green";
    },
    year: function () {
        PCal.y = P.$("cal_year").value;
        PCal.create();
    },
    month: function () {
        PCal.m = P.$("cal_month").value;
        PCal.create();
    },
    day: function (dt) {
        PCal.y = dt.substr(0, 4);
        PCal.m = dt.substr(5, 2).replace("_", "");
        PCal.d = dt.substr(dt.lastIndexOf("_") + 1);

        PCal.submit();
    },
    getMonthLength: function (y, m) {
        if (m == 0 | m == 2 | m == 4 | m == 6 | m == 7 | m == 9 | m == 11) {
            return (31);
        }
        else {
            if (m == 3 | m == 5 | m == 8 | m == 10) {
                return (30);
            }
            else {
                if (m == 1) {
                    if (y % 4 == 0) {
                        return (29);
                    }
                    else {
                        return (28);
                    }
                }
            }
        }
    },
    submit: function () {
        var dt, year, month, day;

        if (PCal.y.toString().length < 3) {
            year = 2000 + Math.abs(PCal.y);
        }
        else {
            year = PCal.y.toString();
        }

        month = Math.abs(PCal.m) + 1;
        if (month.toString().length == 1) {
            month = "0" + month;
        }

        if (PCal.d.toString().length == 1) {
            day = "0" + PCal.d;
        }
        else {
            day = PCal.d;
        }

        dt = PCal.fmt;
        dt = dt.replace("dd", day);
        dt = dt.replace("mm", month);

        if (PCal.fmt.indexOf("yyyy") != -1) {
            dt = dt.replace("yyyy", year);
        }
        else {
            dt = dt.replace("yy", year.substring(2));
        }

        P.$(PCal.id1).value = dt;

        if (P.$(PCal.id1).fireEvent) // IE 5.5(WIN)
        {
            P.$(PCal.id1).fireEvent("onchange");
        }
        else // Mozilla, Safari...
        {
            var evt = document.createEvent("HTMLEvents");
            evt.initEvent("change", true, true);
            P.$(PCal.id1).dispatchEvent(evt);
        }

        P.$(PCal.id1).style.borderColor = "";

        if (PCal.id2 != null) {
            P.$(PCal.id2).value = dt;
            P.$(PCal.id2).style.borderColor = "";
        }

        P.$("cal").style.visibility = "hidden";
        PCal.showHiddenElms();

        P.$(PCal.id1).focus();
    },
    hide: function () {
        P.$("cal").style.visibility = "hidden";
        PCal.showHiddenElms();
    },
    showHiddenElms: function () {
        if (PCal.hiddenElms != null) {
            var i;
            for (i = 0; i < PCal.hiddenElms.length; i++) {
                P.$(PCal.hiddenElms[i]).style.visibility = "visible";
            }

            PCal.hiddenElms = null;
        }
    }
};

//----------------------------
//--- END OF CALENDAR CODE ---
//----------------------------

//--------------------------
//--- START OF USER CODE ---
//--------------------------

var PUser = {
    expandCollapse: function (img, url, pnl) {
        var panel = P.$(pnl);

        if (panel.style.display == "none") {
            img.src = P.siteUrl + "/images/collapse.jpg";
            panel.style.display = "inline-block";
            PAjax.get(url, pnl);
        }
        else {
            img.src = P.siteUrl + "/images/expand.jpg";
            panel.style.display = "none";
        }
    },
    getContinentRegions: function (sel, targetSel, countrySel, provinceSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(countrySel, true);
        PSel.disable(countrySel);

        PSel.clear(provinceSel, true);
        PSel.disable(provinceSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellercontinentregions.aspx?continentid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var regions = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a Region --");

                for (i = 0; i < regions.length; i++) {
                    PSel.add(targetSel, regions[i][0], regions[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getRegionCountries: function (sel, targetSel, provinceSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(provinceSel, true);
        PSel.disable(provinceSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellerregioncountries.aspx?regionid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var countries = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a Country --");

                for (i = 0; i < countries.length; i++) {
                    PSel.add(targetSel, countries[i][0], countries[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getCountryProvinces: function (sel, targetSel, areaSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(areaSel, true);
        PSel.disable(areaSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellercountryprovinces.aspx?countrycode=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var provinces = eval(xmlHttp.responseText);

                if (provinces.length == 0) {
                    PUser.getCountryCities(sel, citySel, suburbSel);
                }
                else {
                    PSel.enable(targetSel);
                    PSel.add(targetSel, "", "-- Select a Province / State --");

                    for (i = 0; i < provinces.length; i++) {
                        PSel.add(targetSel, provinces[i][0], provinces[i][1]);
                    }
                }
            }
        };
        xmlHttp.send(null);
    },
    getProvinceAreas: function (sel, countryCode, targetSel, citySel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        PSel.clear(citySel, true);
        PSel.disable(citySel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellerprovinceareas.aspx?countrycode=" + countryCode + "&provinceid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var provinceAreas = eval(xmlHttp.responseText);

                if (provinceAreas.length == 0) {
                    PUser.getProvinceCities(sel, countryCode, citySel, suburbSel);
                }
                else {
                    PSel.enable(targetSel);
                    PSel.add(targetSel, "", "-- Select an Area --");

                    for (i = 0; i < provinceAreas.length; i++) {
                        PSel.add(targetSel, provinceAreas[i][0], provinceAreas[i][1]);
                    }
                }
            }
        };
        xmlHttp.send(null);
    },
    getCountryCities: function (sel, targetSel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellercountrycities.aspx?countrycode=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var countryCities = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a City --");

                for (i = 0; i < countryCities.length; i++) {
                    PSel.add(targetSel, countryCities[i][0], countryCities[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getProvinceCities: function (sel, countryCode, targetSel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellerprovincecities.aspx?countrycode=" + countryCode + "&provinceid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var provinceCities = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a City --");

                var i;
                for (i = 0; i < provinceCities.length; i++) {
                    PSel.add(targetSel, provinceCities[i][0], provinceCities[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getAreaCities: function (sel, countryCode, provinceId, targetSel, suburbSel) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (suburbSel != null) {
            PSel.clear(suburbSel, true);
            PSel.disable(suburbSel);
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellerareacities.aspx?countrycode=" + countryCode + "&provinceid=" + provinceId + "&areaid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var areaCities = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a City --");

                var i;
                for (i = 0; i < areaCities.length; i++) {
                    PSel.add(targetSel, areaCities[i][0], areaCities[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    },
    getCitySuburbs: function (sel, targetSel, additionalPostalCode) {
        PSel.clear(targetSel, true);
        PSel.disable(targetSel);

        if (additionalPostalCode != null) {
            additionalPostalCode.style.display = "none";
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_sellercitysuburbs.aspx?cityid=" + sel.value);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var suburbs = eval(xmlHttp.responseText);

                PSel.enable(targetSel);
                PSel.add(targetSel, "", "-- Select a Suburb --");

                for (i = 0; i < suburbs.length; i++) {
                    if (i == 0) {
                        if (suburbs[i][0].split("|")[2] == "0") {
                            additionalPostalCode.style.display = PBrowser.isFF ? "inline-block" : "block";
                        }
                    }

                    PSel.addWithTitle(targetSel, suburbs[i][0], suburbs[i][1]);
                }
            }
        };
        xmlHttp.send(null);
    }
};

//------------------------
//--- END OF USER CODE ---
//------------------------

//-------------------------------------
//--- START OF ROTATING BANNER CODE ---
//-------------------------------------

var PRotatingBanner = {
    tmrHomeSlider: null,
    activeSlideNum: 1,
    slideCount: 0,
    slidesLoaded: 0,
    imageLoaded: function() {
        PRotatingBanner.slidesLoaded++;

        if (PRotatingBanner.slidesLoaded == PRotatingBanner.slideCount) {
            PRotatingBanner.slide();
        }
    },
    slide: function() {
        //try {
        var activeSlide = document.getElementById("homeslide" + PRotatingBanner.activeSlideNum);
        var activeSlideOpacity = parseInt(activeSlide.getAttribute("alt"));
        var prevSlide = document.getElementById("homeslide" + (PRotatingBanner.activeSlideNum == 1 ? PRotatingBanner.slideCount : PRotatingBanner.activeSlideNum - 1));
        var prevSlideOpacity = parseInt(prevSlide.getAttribute("alt"));

        if (activeSlideOpacity < 100) {
            activeSlideOpacity += 2;
            activeSlide.setAttribute("alt", activeSlideOpacity);

            if (PBrowser.isSafari | PBrowser.isFF | PBrowser.isChrome | PBrowser.isOpera) {
                activeSlide.style.opacity = activeSlideOpacity / 100;
            }
            else {
                activeSlide.style.filter = "alpha(opacity=" + activeSlideOpacity + ")";
            }

            prevSlideOpacity -= 2;
            prevSlide.setAttribute("alt", prevSlideOpacity);

            if (PBrowser.isSafari | PBrowser.isFF | PBrowser.isChrome | PBrowser.isOpera) {
                prevSlide.style.opacity = prevSlideOpacity / 100;
            }
            else {
                prevSlide.style.filter = "alpha(opacity=" + prevSlideOpacity + ")";
            }

            PRotatingBanner.tmrHomeSlider = window.setTimeout("PRotatingBanner.slide();", 10);
        }
        else {
            activeSlide.style.zIndex = 100;
            prevSlide.style.zIndex = 1;

            PRotatingBanner.activeSlideNum++;

            if (PRotatingBanner.activeSlideNum > PRotatingBanner.slideCount) {
                PRotatingBanner.activeSlideNum = 1;
            }

            PRotatingBanner.tmrHomeSlider = window.setTimeout("PRotatingBanner.slide();", 4000);
        }
        //}
        //catch (e) { }
    }
};

//-----------------------------------
//--- END OF ROTATING BANNER CODE ---
//-----------------------------------

var PWebsite = {
    getCategoriesByParent: function (catId, targetSel) {
        PSel.clearDisable(targetSel, false);

        if (PWebsite.getCategoriesByParent.arguments.length > 2) {
            var i;
            for (i = 2; i < PWebsite.getCategoriesByParent.arguments.length; i++) {
                PSel.clearDisable(PWebsite.getCategoriesByParent.arguments[i], false);
            }
        }

        var xmlHttp = PAjax.xmlHttpObjectGet(P.siteUrl + "/ajax/get_categoriesbyparent.aspx?parentid=" + catId);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                var cats = eval(xmlHttp.responseText);

                if (cats.length != 0) {
                    PSel.enable(targetSel);
                    for (i = 0; i < cats.length; i++) {
                        PSel.add(targetSel, cats[i][0], cats[i][1]);
                    }
                }
            }
        };
        xmlHttp.send(null);
    }
};
