function getScreenResolution() {
    document.getElementById("ScreenResolution").value = screen.width;
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

// If this is run in a RADWindow then overwrite the self.close method.
var popupWindow;
try {
    popupWindow = GetRadWindow();
    if (popupWindow) { }
}
catch (e) {
    popupWindow = null;
}
if (popupWindow != null) {
    self.close = function() {
        closeEditWindow();
    }
}

function reloadParentWindowAndClose() {
    var wnd = GetRadWindow();
    var a = popupWindow.GetWindowManager().GetWindows();
    // apparently 2 with one RadWindow open.
    if (a.length == 2) {
        wnd.BrowserWindow.location.reload();
    }
    else {
        // Seems to be that the order is <Browser Window> -> <First RadWindow> -> <Second RadWindow>
        // So we subtract 2 from the length, i.e. 3 - 2 = 1 = the second array item
        wnd.Argument.Reload();
    }
    wnd.Close();
}

function restoreContentEditWindow(contentId, reloadParent) {
    var wnd = GetRadWindow();
    if (reloadParent) {
        wnd.Argument.Reload();
        wnd.Close();
    }
    else {
        wnd.Reload();
    }
}

function closeEditWindow() {
    var wnd = GetRadWindow();
    wnd.Close();
}

function openEditWindow(name, url) {
    var nTop;
    var nLeft;
    var nWidth = 955; //(window.document.body.clientWidth) * .75;
    var nHeight;

    if (window.screen.height < 768) {
        nHeight = 608; //(window.document.body.clientHeight) * .75;
    }
    else {
        nHeight = 624;
    }
    if (window.screen.height <= 768) {
        nTop = document.body.scrollTop;
        //nLeft = window.document.body.clientWidth - 955;
        nLeft = (window.document.body.clientWidth / 2) - (nWidth / 2);
    }
    else {
        nTop = document.body.scrollTop + (window.document.body.clientHeight / 10);
        nLeft = window.document.body.clientWidth / 8;
    }

    var url2 = '';
    if (url.indexOf('?') > 0) {
        url2 = url + '&res=' + window.screen.width
    }
    else {
        url2 = url + '?res=' + window.screen.width
    }
    var oManager = null;
    var wnd;
    try {
        oManager = GetRadWindowManager();
        wnd = oManager.Open(url2, name);
        document.getElementById("AdminMenu_MenuPanel").disabled = true;
        document.documentElement.style.overflow = "hidden";
        document.body.style.overflow = "hidden";
    } catch (e) { }

    try {
        //if (wnd == 'undefined'){
        var oWnd = GetRadWindow();
        oManager = oWnd.GetWindowManager();
        if (window.screen.width <= 1024) {
            nLeft = oWnd.BrowserWindow.document.body.clientWidth - 955;
        }
        else {
            nTop = oWnd.BrowserWindow.document.body.scrollTop + (oWnd.BrowserWindow.document.body.clientHeight / 10);
            nLeft = oWnd.BrowserWindow.document.body.clientWidth / 8;
        }
        url2 = "/CMSAdmin/" + url2;
        wnd = oManager.Open(url2, name);
        wnd.Argument = oWnd;
        //}
    } catch (e) { }

    wnd.SetSize(nWidth, nHeight);
    wnd.MoveTo(nLeft, nTop);
    window.scroll(0, 0);

}

function openSendToFriendWindow(name, url, nWidth, nHeight, params) {
    var paramURL = location.href;

    paramURL = paramURL.replace(/&/g, "|"); /** hack.. .NET trims out &amp; symbol **/
    params = params != '' ? params + '&' : '';
    openWindow(name, url + '?' + params + 'EmailLinks=' + paramURL, nWidth, nHeight);
}

function RadWindow_ClientClose(wnd) {
    var oManager = GetRadWindowManager();
    // apparently 1 because the window is still closing
    if (oManager.GetWindows().length == 1) {
        if (document.getElementById("AdminMenu_MenuPanel") != null) {
            document.getElementById("AdminMenu_MenuPanel").disabled = false;
        }
        document.documentElement.style.overflow = "";
        document.body.style.overflow = "";
    }
    else {
        document.documentElement.style.overflow = "hidden";
        document.body.style.overflow = "hidden";
    }
}

function divDisplay(divID) {
    if (document.getElementById(divID).style.display == 'block') {
        document.getElementById(divID).style.display = "none";
    }
    else {
        document.getElementById(divID).style.display = "block";
    }
}

function divDisplaySwitch(divID, YesNoID) {
    if (document.getElementById(YesNoID).value == 'Yes' || document.getElementById(YesNoID).value == 'yes') {
        document.getElementById(divID).style.display = "block";
    }
    else {
        document.getElementById(divID).style.display = "none";
    }
}

function switchPage(currentDiv, requestedDiv) {
    divDisplay(currentDiv);
    divDisplay(requestedDiv);
}

function clearSearch(me, defaultValue) {
    if (me.value == defaultValue) {
        me.value = '';
    }
}

function restoreSearch(me, defaultValue) {
    if (me.value == '') {
        me.value = defaultValue;
    }
}

function searchSubmit(me, action, additionalParams) {
    if (me.value != '') {
        window.location.href = action + '?q=' + escape(me.value) + additionalParams;
    }
}

function keypressSearchSubmit(me, e, action, additionalParams) {
    try {
        if (e.keyCode == 13) {
            searchSubmit(me, action, additionalParams);
            return false;
        }
    } catch (e) { }
}

function openNormalWindow(name, url, options) {
    window.open(url, name, options)
}
function refreshImage(imageID) {
    var wnd = GetRadWindow();
    var today = new Date();
    var time = today.getSeconds();
    //var img = wnd.Argument.GetContentFrame().contentWindow.document.getElementById(imageID);
    var img = wnd.BrowserWindow.document.getElementById(imageID);
    img.src = img.src + '?' + time.valueOf();
    wnd.Close();

}




function openWindow(name, url, nWidth, nHeight) {

    document.documentElement.style.overflow = "hidden";
    document.body.style.overflow = "hidden";

    var nLeft = (window.document.body.clientWidth / 2) - (nWidth / 2);
    var nTop = (window.document.body.clientHeight - nHeight) / 2;  //window.document.body.scrollTop;
    if (nTop < 0) {
        nTop = 0;
    }
    nTop += window.document.body.scrollTop;

    var url2 = '';

    if (url.indexOf('?') > 0) {
        url2 = url + '&res=' + window.screen.width
    }
    else {
        url2 = url + '?res=' + window.screen.width
    }

    var oManager = null;
    var wnd = null;

    try {
        //alert ( "url: "+url2);
        oManager = GetRadWindowManager();
        wnd = oManager.Open(url2, name);
    }
    catch (e) { }

    try {
        //alert ( "url: "+url2);
        // var oWnd = GetRadWindow();
        oManager = GetRadWindow().GetWindowManager();
        wnd = oManager.Open(url2, name);
    }
    catch (e) { }

    wnd.SetSize(nWidth, nHeight);

    wnd.MoveTo(nLeft, nTop);


    if (!wnd) return;
}

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Philip Myers :: http://virtualipod.tripod.com/bookmark.html */
function bookmark(url, title) {
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
        window.external.AddFavorite(url, title);
    } else if (navigator.appName == "Netscape") {
        window.sidebar.addPanel(title, url, "");
    } else {
        alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
    }
}

function replyTo(id, commentId, textVal) {
    document.getElementById(id).value = commentId;
    document.getElementById("formHeader").innerHTML = textVal;
    document.getElementById("formHeader").className = textVal.toLowerCase().replace(/ /g, '_');
}



/*** Gourmet Specific ******/
function divDisplay(divID) {
    if (document.getElementById(divID).style.display == 'block') {
        document.getElementById(divID).style.display = "none";
    }
    else {
        document.getElementById(divID).style.display = "block";
    }
}

function divDisplaySwitch(divID, YesNoID) {
    if (document.getElementById(YesNoID).value == 'Yes' || document.getElementById(YesNoID).value == 'yes') {
        document.getElementById(divID).style.display = "block";
    }
    else {
        document.getElementById(divID).style.display = "none";
    }
}

function switchPage(currentDiv, requestedDiv) {
    divDisplay(currentDiv);
    divDisplay(requestedDiv);
}

function keypressSearchSubmit(me, e, action, additionalParams) {
    try {
        if (e.keyCode == 13) {
            searchSubmit(me, action, additionalParams);
            return false;
        }
    }
    catch (e) { }
}

function restoreSearch(me, defaultValue) {
    if (me.value == '') {
        me.value = defaultValue;
    }
}

function clearSearch(me, defaultValue) {
    //if (me.value == defaultValue) 
    if (me.value == "Please enter text") {
        me.value = '';
    }
    if (me.value == "search") {
        me.value = '';
    }
    if (me.value == " Enter Keywords") {
        me.value = '';
    }
    if (me.value == "Your Name") {
        me.value = '';
    }
    if (me.value == "Your email address") {
        me.value = '';
    }
}

function searchSubmit(me, action, additionalParams) {
    if (empty(stripSpaces(me.value))) me.value = "Please enter text";
    if (me.value == "search") me.value = "Please enter text";

    if (me.value == "Please enter text") me.value = "Please enter text";

    else {
        window.location.href = action + '?q=' + escape(me.value) + additionalParams;
    }
}

function stripSpaces(x) {
    while (x.substring(0, 1) == ' ') x = x.substring(1);
    return x;
}

function empty(x) { if (x.length > 0) return false; else return true; }




//length conversion function
var inches = new Array
(1, 0.0833, 0.0278, 0.00001578, 2.540, 0.0254, 0.00002539);
var feet = new Array
(12, 1, 0.3333, 0.0001894, 30.48, 0.3048, 0.00003048);
var yards = new Array
(36, 3, 1, 0.0005682, 91.44, 0.9144, 0.0009144);
var miles = new Array
(63360, 5280, 1760, 1, 160934, 1609.3, 1.609);
var centimeters = new Array
(0.3937, 0.0328, 0.0109, 0.000006214, 1, 0.01, 0.001);
var meters = new Array
(39.37, 3.281, 1.0936, 0.0006214, 100, 1, 0.001);
var kilometers = new Array
(39370, 3281, 1094, 0.6214, 100000, 1000, 1);

var factors = new Array(inches, feet, yards, miles,
  centimeters, meters, kilometers);

function Convert(me) {
    iFrom = me.fromUnits.selectedIndex;
    iTo = me.toUnits.selectedIndex;

    factor = factors[iFrom][iTo];

    if (isNaN(me.fromLength.value))
        document.getElementById("lengthResult").innerHTML = "Error";
    else
        document.getElementById("lengthResult").innerHTML = "Equals: " + factor * me.fromLength.value + " " + me.toUnits.options[me.toUnits.selectedIndex].text;
}


// weight conversion function
var grams = new Array
(1, 0.001, 1000, 0.035273, 0.002204);
var kilograms = new Array
(1000, 1, 1000000, 35.2739, 2.20462);
var milligrams = new Array
(0.001, 0.0000001, 1, 0.0000353, 0.0000022);
var ounces = new Array
(28.3495, 0.028349, 28349.523, 1, 0.062499);
var pounds = new Array
(453.592, 0.453592, 453592.37, 16, 1);

var weightFactors = new Array(grams, kilograms, milligrams, ounces,
  pounds);

function WeightConvert(me) {
    iFrom = me.fromWeight.selectedIndex;
    iTo = me.toWeight.selectedIndex;

    weightFactor = weightFactors[iFrom][iTo];

    if (isNaN(me.fromWeightTxt.value))
        document.getElementById("weightResult").innerHTML = "Error";
    else
        document.getElementById("weightResult").innerHTML = "Equals: " + weightFactor * me.fromWeightTxt.value + " " + me.toWeight.options[me.toWeight.selectedIndex].text;
}

//Area conversion function
var squreKilometer = new Array
(1, 1000000, 100, 10763910, 0.3861022);
var squareMeter = new Array
(0.000001, 1, 0.0001, 10.76391, 0.000000039);
var hectare = new Array
(0.01, 10000, 1, 107639.1, 0.003861);
var squareFoot = new Array
(0.00000009, 0.0929, 0.000009, 1, 0.000000036);
var squareMile = new Array
(2.589988, 2589988, 258.9988, 27878400, 1);

var areaFactors = new Array(squreKilometer, squareMeter, hectare, squareFoot, squareMile);

function AreaConvert(me) {
    iFrom = me.fromArea.selectedIndex;
    iTo = me.toArea.selectedIndex;

    areaFactor = areaFactors[iFrom][iTo];

    if (isNaN(me.fromAreaTxt.value))
    //    document.getElementById("toLength").innerHTML = "Error";
        document.getElementById("areaResult").innerHTML = "Error";
    else
        document.getElementById("areaResult").innerHTML = "Equals: " + areaFactor * me.fromAreaTxt.value + " " + me.toArea.options[me.toArea.selectedIndex].text;
}

//temperature conversion function 

function TemperatureConvert(me) {
    var FromVal, ToVal, FromName, ToName, v1;

    v1 = me.what.value;
    v1 = stripBad(v1);
    v1 = parseFloat(v1);
    if (isNaN(v1)) v1 = 0;
    me.what.value = v1;

    FromVal = me.from[me.from.selectedIndex].value;
    ToVal = me.to[me.to.selectedIndex].value;
    FromName = me.from.options[me.from.selectedIndex].text;
    ToName = me.to.options[me.to.selectedIndex].text;

    var ConvertedTemp = get_fact(v1, FromVal, ToVal);
    if (ConvertedTemp == "Below Absolute Zero") {
        document.getElementById("answer").innerHTML = "Your input cannot be below absolute zero.";
    } else {
        document.getElementById("answer").innerHTML = "Equals: " + ConvertedTemp + " " + ToName;
    }
}

function get_fact(ff, from_val, to_val) {
    // first convert to kelvin
    if (from_val == 0) {
        ff = ff + 273.15;
    } else if (from_val == 1) {
        ff = ((ff - 32) / 1.8) + 273.15;
    } else if (from_val == 2) {
        ff = ff / 1.8;
    } else if (from_val == 3) {
        ff = (ff * 1.25) + 273.15;
    }

    if (ff < 0) {
        // Below absolute zero
        return "Below Absolute Zero";
    }

    // now convert kelvin to unit
    if (to_val == 0) {
        ff = ff - 273.15;
    } else if (to_val == 1) {
        ff = (1.8 * (ff - 273.15)) + 32;
    } else if (to_val == 2) {
        ff = ff * 1.8;
    } else if (to_val == 3) {
        ff = (ff - 273.15) / 1.25;
    }

    // round it off
    if (Number.prototype.toFixed) {
        ff = ff.toFixed(7);
        ff = parseFloat(ff);
    }
    else {
        var leftSide = Math.floor(ff);
        var rightSide = ff - leftSide;
        ff = leftSide + Math.round(rightSide * 10000000) / 10000000;
    }

    return ff;
}

//Volume conversion function
var teaSpoon = new Array
(1, 0.333333, 0.020833, 5, 0.005, 0.008799, 0.175976, 0.00109985);
var tableSpoon = new Array
(3, 1, 0.0625, 15, 0.015, 0.0263964, 0.527927, 0.003300);
var cup = new Array
(48, 16, 1, 240, 0.24, 0.422342, 8.446832, 0.052793);
var mililitre = new Array
(0.2, 0.066667, 0.004167, 1, 0.001, 0.001760, 0.035195, 0.000220);
var litre = new Array
(200, 66.666667, 4.166667, 1000, 1, 1.759757, 35.195133, 0.219970);
var pint = new Array
(113.652077, 37.884026, 2.367752, 568.260384, 0.568260, 1, 20, 0.125);
var liquidOunce = new Array
(5.682604, 1.894201, 0.118388, 28.413019, 0.028413, 0.05, 1, 0.00625);
var gallon = new Array
(909.216614, 303.072205, 18.942013, 4546.083072, 4.546083, 8, 160, 1);

var volumeFactors = new Array(teaSpoon, tableSpoon, cup, mililitre, litre, pint, liquidOunce, gallon);

function VolumeConvert(me) {
    iFrom = me.fromVolume.selectedIndex;
    iTo = me.toVolume.selectedIndex;

    volumeFactor = volumeFactors[iFrom][iTo];

    if (isNaN(me.fromVolumeTxt.value))
        document.getElementById("volumeResult").innerHTML = "Error";
    else
        document.getElementById("volumeResult").innerHTML = "Equals: " + volumeFactor * me.fromVolumeTxt.value + " " + me.toVolume.options[me.toVolume.selectedIndex].text;
}


function stripBad(string) {
    for (var i = 0, output = '', valid = "eE-0123456789."; i < string.length; i++)
        if (valid.indexOf(string.charAt(i)) != -1)
        output += string.charAt(i)
    return output;
}

function microsoftKeyPressTemperature() {
    if (window.event.keyCode == 13)
        TemperatureConvert();
}
function microsoftKeyPressLength() {
    if (window.event.keyCode == 13)
        Convert();
}
function microsoftKeyPressWeight() {
    if (window.event.keyCode == 13)
        WeightConvert();
}
function microsoftKeyPressArea() {
    if (window.event.keyCode == 13)
        AreaConvert();
}
function microsoftKeyPressVolume() {
    if (window.event.keyCode == 13)
        VolumeConvert();
}

// topNav rollover start.
function navHover() {
    var imgs = document.getElementById("topNav").getElementsByTagName("img");
    for (i = 0; i < imgs.length; i++) {
        if (getName(imgs[i].src, ".gif").indexOf("On") == -1) {
            imgs[i].onmouseover = function() {
                var objImg = getName(this.src, ".gif") + "Hov.gif";
                this.src = objImg;
            }
            imgs[i].onmouseout = function() {
                var objImg = getName(this.src, "Hov.gif") + ".gif";
                this.src = objImg;
            }
        }
    }
}

function getName(s, splitString) {
    var arrayS = s.split(splitString);
    return arrayS[0];
}
// topNav rollover end.


// second nav highlight start.
function recipeNavAct() {
    var lis = document.getElementById("recipeLocalNav").getElementsByTagName("li");
    var arrayNavMenu = ["Recipe-Find.htm", "Recipe-Index.htm", "Recipe_Fare_Exchange.htm", "Recipe-Classic-Dishes.htm", "Recipe_Perfect_Match.htm", "Recipe-In-Season.htm", "Recipe_Gourmet_Fast.htm", "Recipe-GourmetFastVideo.htm", "recipe_conversion_tool.htm", "Recipe-Glossary.htm", "Content.aspx?id=26"];
    var PositionInArray = getPositionInArray(arrayNavMenu, getPageName());

    switch (PositionInArray) {
        case 0: lis[0].style.fontWeight = "bold"; break;
        case 1:
        case 9: lis[1].style.fontWeight = "bold"; break;
        case 2: lis[2].style.fontWeight = "bold"; break;
        case 3: lis[3].style.fontWeight = "bold"; break;
        case 4: lis[4].style.fontWeight = "bold"; break;
        case 5: lis[5].style.fontWeight = "bold"; break;
        case 6: lis[6].style.fontWeight = "bold"; break;
        case 7: lis[7].style.fontWeight = "bold"; break;
        case 8: lis[8].style.fontWeight = "bold"; break;
        case 9: lis[9].style.fontWeight = "bold"; break;

    }
}

function wineNDrnksNavAct(innerPageSec) {
    //var lis = document.getElementById("localNav").getElementsByTagName("li");
    var lis = document.getElementById("myGmtLocalNav").getElementsByTagName("li");
    var arrayNavMenu = ["", "wine_event_calendar.htm", "best_buys.htm", "wine_traveller.htm", "food_wine_match.htm", "wine_awards.htm", "wine_list_of_the_year_awards_2008.htm", "wine_polls.htm", "submit_your_say.htm"];
    if (innerPageSec) {
        var PositionInArray = parseInt(innerPageSec);
    }
    else {
        var PositionInArray = getPositionInArray(arrayNavMenu, getPageName());
    }

    switch (PositionInArray) {
        case 1: lis[0].style.fontWeight = "bold"; break;
        case 2: lis[1].style.fontWeight = "bold"; break;
        case 3: lis[2].style.fontWeight = "bold"; break;
        case 4: lis[3].style.fontWeight = "bold"; break;
        case 5: lis[4].style.fontWeight = "bold"; break;
        case 6: lis[5].style.fontWeight = "bold"; break;
        case 7: lis[6].style.fontWeight = "bold"; break;
        case 8: lis[7].style.fontWeight = "bold"; break;
    }
}

function ROTY09NavAct() {
    if (window.location.href.toLowerCase().indexOf(hlROTYHome.href.toLowerCase()) != -1)
        hlROTYHome.className = "active";
    else if (window.location.href.toLowerCase().indexOf(hlROTYVote.href.toLowerCase()) != -1)
        hlROTYVote.className = "active";
    else if (window.location.href.toLowerCase().indexOf(hlROTYPrizes.href.toLowerCase()) != -1)
        hlROTYPrizes.className = "active";
}

function RnRNavAct(innerPageSec) {
    var lis = document.getElementById("myGmtLocalNav").getElementsByTagName("li");
    var arrayNavMenu = ["", "Readers_Choice_Awards_Voting.htm", "australian_gourmet_traveller_2008_restaurant_guide_awards.htm", "restaurant_news1.htm", "feature_reviews.htm", "australian_gourmet_traveller_2009_restaurant_guide_awards.htm", "submit_your_say.htm"];
    //alert(getPageName());

    //var PositionInArray = getPositionInArray(arrayNavMenu, getPageName());
    if (innerPageSec) {
        var PositionInArray = parseInt(innerPageSec);
    }
    else {
        var PositionInArray = getPositionInArray(arrayNavMenu, getPageName());
    }


    switch (PositionInArray) {
        case 1: lis[0].style.fontWeight = "bold"; break;
        case 2: lis[1].style.fontWeight = "bold"; break;
        case 3: lis[2].style.fontWeight = "bold"; break;
        case 4: lis[3].style.fontWeight = "bold"; break;
        case 5: lis[4].style.fontWeight = "bold"; break;
        case 6: lis[5].style.fontWeight = "bold"; break;
    }
}

function BlogNavAct() {
    var lis = document.getElementById("localNav").getElementsByTagName("li");
    var arrayNavMenu = ["on_the_road_blog.htm", "wine_blog.htm", "food_blog.htm", "what_are_we_eating_blog.htm"];
    var pageName = getPageName();
    var pos = pageName.indexOf("#");
    if (pos >= 0) {
        pageName = pageName.substring(0, pos);
    }
    var PositionInArray = getPositionInArray(arrayNavMenu, pageName);
    if (PositionInArray >= 0 && PositionInArray < arrayNavMenu.length) {
        lis[PositionInArray + 1].style.fontWeight = "bold"
    }
}

function TravelNavAct() {
    var lis = document.getElementById("myGmtLocalNav").getElementsByTagName("li");
    var arrayNavMenu = ["", "gourmet_traveller_travel_awards_2008.htm", "travel_news.htm", "best_new_hotels_2008.htm", "travel_deals.htm", "travel_features.htm", ""];
    //var arrayNavMenu = ["", "gt_travel_awards.htm","TravelNews.htm","best_new_hotels.htm","travel_deals.htm", "travel_features.htm", ""];
    var PositionInArray = getPositionInArray(arrayNavMenu, getPageName());
    switch (PositionInArray) {
        case 0: lis[0].style.fontWeight = "bold"; break;
        case 1: lis[1].style.fontWeight = "bold"; break;
        case 2: lis[2].style.fontWeight = "bold"; break;
        case 3: lis[3].style.fontWeight = "bold"; break;
        case 4: lis[4].style.fontWeight = "bold"; break;
        case 5: lis[5].style.fontWeight = "bold"; break;
        case 6: lis[6].style.fontWeight = "bold"; break;
    }
}

function inTheMagazineNavAct() {
    var lis = document.getElementById("myGmtLocalNav").getElementsByTagName("li");
    var arrayNavMenu = ["", "wine_this_issue.htm", "wine_next_issue.htm", "gt_this_month.htm", "gt_next_month.htm"];
    //var arrayNavMenu = ["wine_next_issue.htm","wine_this_issue.htm", "gt_this_month.htm","gt_next_month.htm"];
    //alert(getPageName());

    var PositionInArray = getPositionInArray(arrayNavMenu, getPageName());
    switch (PositionInArray) {
        case 0: lis[0].style.fontWeight = "bold"; break;
        case 1: lis[1].style.fontWeight = "bold"; break;
        case 2: lis[2].style.fontWeight = "bold"; break;
        case 3: lis[3].style.fontWeight = "bold"; break;
        case 4: lis[4].style.fontWeight = "bold"; break;
    }
}


function myGourmetNavAct() {
    var lis = document.getElementById("myGmtLocalNav").getElementsByTagName("li");
    var pageName = getPageName();
    var pos = pageName.indexOf(".");
    if (pos >= 0) {
        pageName = pageName.substring(0, pos);
    }
    // page names without extensions here
    var arrayNavMenu = ["", "expert_advice_index", "expert_advice_submission_form", "", "competition_home_page", "calendar_home_page", "memberLogin", "downloads_index", "submit_your_say", "yoursay_index"];
    for (var i = 0; i < arrayNavMenu.length; i++) {
        arrayNavMenu[i] = arrayNavMenu[i].toLowerCase();
    }
    var PositionInArray = getPositionInArray(arrayNavMenu, pageName.toLowerCase());
    switch (PositionInArray) {
        case 0: lis[0].style.fontWeight = "bold"; break;
        case 1: lis[1].style.fontWeight = "bold"; break;
        case 2: lis[1].style.fontWeight = "bold"; break;
        case 3: lis[3].style.fontWeight = "bold"; break;
        case 4: lis[4].style.fontWeight = "bold"; break;
        case 5: lis[5].style.fontWeight = "bold"; break;
        case 6: lis[6].style.fontWeight = "bold"; break;
        case 7: lis[7].style.fontWeight = "bold"; break;
        case 8: lis[0].style.fontWeight = "bold"; break;
        case 9: lis[2].style.fontWeight = "bold"; break;
        case 10: lis[2].style.fontWeight = "bold"; break;
    }
}

function highlightSubMenu(localNavId, index) {
    var lis = document.getElementById(localNavId).getElementsByTagName("li");
    lis[index].style.fontWeight = "bold";
}

function getPositionInArray(arrayOBJ, PageName) {
    var Position = -1;
    for (var i = 0; i < arrayOBJ.length; i++) {
        if (PageName == arrayOBJ[i]) {
            Position = i;
            break;
        }
    }
    return Position;
}

function getPageName() {
    var arrayURL = window.location.href.split("/");
    return arrayURL[arrayURL.length - 1];
}
// second nav highlight end.


function openSendToFriendWindow(name, url, nWidth, nHeight) {

    var paramURL = location.href;

    paramURL = paramURL.replace(/&/g, "|"); /** hack.. .NET trims out &amp; symbol **/
    openWindow(name, url + '?EmailLinks=' + paramURL, nWidth, nHeight);
}


/********************************************
*   category home rightCol height offset
/********************************************/
var arrayCategoryHmpg = new Array();
arrayCategoryHmpg["recipe"] = "Recipe-Home-page.htm";
arrayCategoryHmpg["wineNdrnk"] = "wine_and_drink.htm";
arrayCategoryHmpg["restaurantNrvws"] = "rstaurants_and_reviews.htm";
arrayCategoryHmpg["travel"] = "travel.htm";

/***********************************
* window.onload collection 
************************************/
var winLoader = new Array();

function winLoaderAdd(func) {
    winLoader[winLoader.length] = func;
}

function runWinLoader() {
    for (var i = 0; i < winLoader.length; i++)
        eval(winLoader[i]);
}

winLoaderAdd('heightOffset()');
window.onload = runWinLoader;

function heightOffset() {
    if (document.getElementById("leftCol") && document.getElementById("rightCol")) {
        var heightLeft = document.getElementById("leftCol").clientHeight;
        var heightRight = document.getElementById("rightCol").clientHeight;
        if (heightLeft > heightRight) { document.getElementById("rightCol").style.height = heightLeft; }
    }
}

function boldSubnav(subnavID) {
    var lis = document.getElementById("myGmtLocalNav").getElementsByTagName("li");
    for (i = 0; i < lis.length; i++) lis(i).style.fontWeight = "normal";
    document.getElementById(subnavID).style.fontWeight = "bold";
    return;
}

function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}

/* Set background javascript taken from zoo */
function setBackground(section, subsection, bgStyle, clearFooterBg, startDate, endDate, previewCode) {
    var preview = false;
    var now = new Date();
    var skinCode = ninemsn.utilities.QueryStringHelper.getByName("skin");

    section = (typeof (section) == "undefined" || section == null) ? "" : section;
    subsection = (typeof (subsection) == "undefined" || subsection == null) ? "" : subsection;
    clearFooterBg = (typeof (clearFooterBg) == "undefined") ? true : clearFooterBg;
    startDate = (typeof (startDate) == "undefined" || startDate == null) ? null : startDate;
    endDate = (typeof (endDate) == "undefined" || endDate == null) ? null : endDate;
    previewCode = (typeof (previewCode) == "undefined" || previewCode == null) ? "" : previewCode.toLowerCase();

    _nmsnSection = (typeof (_nmsnSection) == "undefined") ? "" : _nmsnSection;
    _nmsnSubSection = (typeof (_nmsnSubSection) == "undefined") ? "" : _nmsnSubSection;

    skinCode = (skinCode == null) ? null : skinCode.toLowerCase();
    preview = (skinCode == previewCode)

    if (preview || ((startDate == null || startDate <= now) && (endDate == null || endDate >= now))) {
        if ((section == _nmsnSection || section.length == 0) && (subsection == _nmsnSubSection || subsection.length == 0)) {
            if (clearFooterBg)
                window.onload = clearFooterBackground;

            // set the background
            document.body.style.background = bgStyle;
        }
    }
}

function clearFooterBackground() {
    // clear the footers background
    if (document.getElementById("footer_container") != null)
        document.getElementById("footer_container").style.background = "none";
}
