﻿/*********************************************************************************************************************
Bus Strategy IMap Application  Main JavaScript File
Author : Mark Mackenzie
Date   : December 2009

History:
FileVersion     AppVersion	Who		When				Why
----------------------------------------------------------------------------------------------------------------------
1.0.0.0         0.0.0.0     MM      December 2009		Created file

1.1.0.0         0.0.0.0     MM      11th February 2010  Removed setSafariChromeOperaCSS() function as this is now
                                                        handled by server side code.
      
1.1.0.0         1.0.0.0     MM      18th March 2010     Version 1.
                                                  
*********************************************************************************************************************/

function IEVersion()
{
    var rv = -1; // Return value assumes failure
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
        {
            rv = parseFloat( RegExp.$1 );
        }
    }
    return rv;
}

function IsIE()
{
   return ((navigator.appVersion.toUpperCase().indexOf("MSIE")!= -1)&&!window.opera);
}

function IsIE5()
{
    return (navigator.appVersion.indexOf("MSIE 5.5") != -1);
}

function IsIE6()
{
    return (navigator.userAgent.indexOf('MSIE 6.0') != -1);
}

function IsIE7()
{
    return (navigator.userAgent.indexOf('MSIE 7.0') != -1);
}

function IsOpera()
{
    return navigator.userAgent.indexOf("Opera") != -1;
}

function IsChrome()
{
    return (navigator.userAgent.indexOf("Chrome") != -1);
}

function IsSafari()
{
    return (navigator.userAgent.indexOf("Safari") != -1);
}

function IsFirefox()
{
    return (navigator.userAgent.indexOf("Firefox") != -1);
}

function IsNetscape()
{
    return (navigator.userAgent.indexOf('Netscape') >= 0); 
}

function getAspID(realID)
{ 
    return eval("ids."+realID);
}

function setSelectedValue(selectElementID, value)
{    
    var select = document.getElementById(selectElementID);
    if (select == null) select = document.getElementById(getAspID(selectElementID));
    if (select != null)
    {
        for (var i = 0; i < select.options.length; i++)
        {        
            if (value == select.options[i].value) select.options[i].selected = "SELECTED";           
        }
    }
}

//functionality to cope with the lack of min-width in IE6 and below
function calcWidth()
{
    switch (getActiveStyleSheet())
    {
        case "default" :
            document.getElementsByTagName('body')[0].style.width = document.documentElement.clientWidth < 1000 ? '980px' : null;
            break;
        case "large" :
            document.getElementsByTagName('body')[0].style.width = document.documentElement.clientWidth < 950 ? '930px' : null;
            break;
        case "xlarge" :
            document.getElementsByTagName('body')[0].style.width = document.documentElement.clientWidth < 1210 ? '1230px' : null;
            break;
    }
}
if (IsIE5() || IsIE6())
{   
    onresize = calcWidth;
}
//////

function goBack()
{
    window.history.go(-1);
}
