//convert everything to lowercase to make testing easier
var agt = navigator.userAgent.toLowerCase();

//get the major and minor version numbers
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

//get the platform
var is_mac = (agt.indexOf("mac") != -1);
var is_win = (agt.indexOf("win") != -1);

//get the Netscape version
var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1) && (agt.indexOf('webtv') == -1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));

//get the Internet Explorer version
var is_ie = (agt.indexOf("ie") != -1) && (agt.indexOf('opera') == -1);
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0") == -1));
var is_ie4up = (is_ie && (is_major >= 4));


var DoOnLoad = false;

var base = ""
var nrm = new Array();
var omo = new Array();
//Images
var stuff = new Array();


// preload images
if (document.images)
{
    for (i = 0; i < stuff.length; i++)
    {
        nrm[i] = new Image;
        nrm[i].src = base + stuff[i];
        omo[i] = new Image;
        omo[i].src = base + stuff[i];
    }
}


// The functions: first mouseover, then mouseout

function over(no)
{
    if (document.images)
    {
        document.images[stuff[no]].src = omo[no].src
    }
}

function out(no)
{
    if (document.images)
    {
        document.images[stuff[no]].src = nrm[no].src
    }
}

//function to do highlighting of menu
BgMenu1Over = '#ff9900';
BgMenu1Out = '#ffffff';

BgMenu2Over = '#FFCC66';
BgMenu2Out = '#FFCC99';

function ChangeMenuBgColor(id, color)
{
    var el1 = getCell(id + '_1');
    el1.bgColor = color;
    var el2 = getCell(id + '_2');
    el2.bgColor = color;
}
function getCell(id)
{
    return document.all ? document.all(id) : document.getElementById ? document.getElementById(id) : document.layers ? document['NS_' + id].document.layers[0] : null
}

var Browser = CheckBrowser();


//Returns the document object
function getImage(id)
{
    if (Browser.IE4plus || Browser.IEmac) return document.all[id];
    if (Browser.NS4) return document.images[id];
    if (Browser.NS6 || navigator.userAgent.indexOf("Mozilla") || navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf("Safari")) return document.getElementById(id);
}

//Returns the document object
function getElement(id)
{
    if (Browser.IE4plus || Browser.IEmac) return document.all[id];
    if (Browser.NS4) return document[id];
    if (Browser.NS6 || navigator.userAgent.indexOf("Mozilla") || navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf("Safari")) return document.getElementById(id);
}


function SwapClass(id, className)
{
    var el = getElement(id).className = className;
}

function CheckBrowser()
{
    var br = new Object();
    br.isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
    br.NS4 = (document.layers) ? true : false;
    br.IEmac = ((document.all) && (br.isMac)) ? true : false;
    br.IE4plus = (document.all) ? true : false;
    br.IE4 =
    ((document.all) && (navigator.appVersion.indexOf("MSIE 4.") != -1)) ? true : false;
    br.IE5 =
    ((document.all) && (navigator.appVersion.indexOf("MSIE 5.") != -1)) ? true : false;
    br.IE6 =
    ((document.all) && (navigator.appVersion.indexOf("MSIE 6.") != -1)) ? true : false;
    ver4 = (br.NS4 || br.IE4plus) ? true : false;
    br.NS6 =
    (!document.layers) && (navigator.userAgent.indexOf('Netscape') != -1)?true:false;

    br.IE5plus = br.IE5 || br.IE6;
    br.IEMajor = 0;

    if (br.IE4plus)
    {
        var start = navigator.appVersion.indexOf("MSIE");
        var end = navigator.appVersion.indexOf(".", start);
        br.IEMajor = parseInt(navigator.appVersion.substring(start + 5, end));
        br.IE5plus = (br.IEMajor >= 5) ? true : false;
    }
    return br
}


function cmsOpenPopup(href, name, width, height, x, y, menu, status, scroll, loc, resize, title, toolbar)
{

    var attributes = '';
    if (width.length > 0) attributes = attributes + ',width=' + width;
    if (height.length > 0) attributes = attributes + ',height=' + height;
    if (x.length > 0) attributes = attributes + ',screenx=' + x;
    if (x.length > 0) attributes = attributes + ',left=' + x;
    if (y.length > 0) attributes = attributes + ',screeny=' + y;
    if (y.length > 0) attributes = attributes + ',top=' + y;
    attributes = attributes + ',menubar=' + (menu == 1?'yes':'no');
    attributes = attributes + ',status=' + (status == 1?'yes':'no');
    attributes = attributes + ',scrollbars=' + (scroll == 1?'yes':'no');
    attributes = attributes + ',location=' + (loc == 1?'yes':'no');
    attributes = attributes + ',titlebar=' + (title == 1?'yes':'no');
    attributes = attributes + ',toolbar=' + (toolbar == 1?'yes':'no');
    attributes = attributes + ',resizable=' + (resize == 1?'yes':'no');
    attributes = attributes.substring(1, attributes.length);
    var cmsPopup = window.open(href, name, attributes)
}

function ParamcmsOpenPopup(href, name, width, height, x, y, menu, status, scroll, loc, resize, title, toolbar)
{
    var attributes = '';
    if (width.length > 0) attributes = attributes + ',width=' + width;
    if (height.length > 0) attributes = attributes + ',height=' + height;
    if (x.length > 0) attributes = attributes + ',screenx=' + x;
    if (x.length > 0) attributes = attributes + ',left=' + x;
    if (y.length > 0) attributes = attributes + ',screeny=' + y;
    if (y.length > 0) attributes = attributes + ',top=' + y;
    attributes = attributes + ',menubar=' + (menu == 1?'yes':'no');
    attributes = attributes + ',status=' + (status == 1?'yes':'no');
    attributes = attributes + ',scrollbars=' + (scroll == "Y"?'yes':'no');
    attributes = attributes + ',location=' + (loc == 1?'yes':'no');
    attributes = attributes + ',titlebar=' + (title == 1?'yes':'no');
    attributes = attributes + ',toolbar=' + (toolbar == 1?'yes':'no');
    attributes = attributes + ',resizable=' + (resize == "Y"?'yes':'no');
    attributes = attributes.substring(1, attributes.length);
    var cmsPopup = window.open(href, name, attributes)
}


//function to close a window
function closeWin() {
    aWindow = window.close()
}


//function to open popup window for country purchase
function openLargePopupWin(URL) {
    aWindow =
    window.open(URL, "largepopup", "toolbar=no,width=750,height=620,status=no,scrollbars=auto,resizable=no,menubar=no");
}


function openInfoWin(URL) {
    aWindow =
    window.open(URL, "thewindow", "toolbar=no,width=450,height=320,status=no,scrollbars=auto,resizable=no,menubar=no");
}


function openWin_shop(url)
{
    obj =
    open(url, "shop_popup", "width=450,height=314,directories=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no")
    obj.window.focus()
}


//function to open popup window for Right Now Integration
function openLargePopupWin2(URL) {
    aWindow =
    window.open(URL, "largepopup", "toolbar=no,width=750,height=580,status=no,scrollbars=yes,resizable=yes,menubar=no");
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x =
                                                            MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}
function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i,j = d.MM_p.length,a = MM_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];
            }
    }
}

function MM_swapImgRestore() { //v3.0
    var i,x,a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc;
         i++) x.src = x.oSrc;
}

function MM_swapImage() { //v3.0
    var i,j = 0,x,a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) {
            document.MM_sr[j++] = x;
            if (!x.oSrc) x.oSrc = x.src;
            x.src = a[i + 2];
        }
}