function BrowserInfo()
{
    this.BrowserEnum = {
    		none:0, 
    		ie8:1, 
    		ie7:2, 
    		ie6:3, 
    		ie:4, 
    		firefox:5, 
    		safari:6, 
    		chrome:7, 
    		opera:8, 
    		other:9}; 
    this.browserType = this.BrowserEnum.none;
    
    var agent = navigator.userAgent.toLowerCase();
    if(agent.indexOf("msie 8") > 0)
    	this.browserType = this.BrowserEnum.ie8;
    else if(agent.indexOf("msie 7") > 0)
    	this.browserType = this.BrowserEnum.ie7;
    else if(agent.indexOf("msie 6") > 0)
    	this.browserType = this.BrowserEnum.ie6;
    else if(agent.indexOf("msie") > 0)
    	this.browserType = this.BrowserEnum.ie;
    else if(agent.indexOf("firefox") > 0)
    	this.browserType = this.BrowserEnum.firefox;
    else if(agent.indexOf("shiretoko") > 0)
        this.browserType = this.BrowserEnum.firefox;
    else if(agent.indexOf("safari") > 0)
    	this.browserType = this.BrowserEnum.safari;
    else if(agent.indexOf("chrome") > 0)
    	this.browserType = this.BrowserEnum.chrome;
    else
    	this.browserType = this.BrowserEnum.other;

    this.browser = function()
    {
        return this.browserType;
    };
    
    this.isIE = function()
    {
        return (this.browserType == this.BrowserEnum.ie8 || this.browserType == this.BrowserEnum.ie7 ||
    	    this.browserType == this.BrowserEnum.ie6 ||this.browserType == this.BrowserEnum.ie);
    };
    
    this.isIE6 = function()
    {
    	return this.browserType == this.BrowserEnum.ie6;
    };
};

function setCss(theClass, element, value) 
{
    //Last Updated on June 23, 2009
    //documentation for this script at
    //http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
    var cssRules;
    
    var added = false;
    for (var S = 0; S < document.styleSheets.length; S++)
    {
        if (document.styleSheets[S]['rules']) 
        {
            cssRules = 'rules';
        } 
        else if (document.styleSheets[S]['cssRules']) 
        {
            cssRules = 'cssRules';
        } 
        else 
        {
            //no rules found... browser unknown
        }
    
        for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) 
        {
            if (document.styleSheets[S][cssRules][R].selectorText == theClass) 
            {
                if(document.styleSheets[S][cssRules][R].style[element])
                {
                    document.styleSheets[S][cssRules][R].style[element] = value;
                    added=true;
                    break;
                }
            }
        }
        
        if(!added)
        {
            if(document.styleSheets[S].insertRule)
            {
                document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
            } 
            else if (document.styleSheets[S].addRule) 
            {
                document.styleSheets[S].addRule(theClass,element+': '+value+';');
            }
        }
    }
}

function getCss(theClass, element)
{
    var cssRules;
    
    for (var S = 0; S < document.styleSheets.length; S++)
    {
        if (document.styleSheets[S]['rules']) 
        {
            cssRules = 'rules';
        } 
        else if (document.styleSheets[S]['cssRules']) 
        {
            cssRules = 'cssRules';
        } 
        else 
        {
            //no rules found... browser unknown
        }
    
        for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) 
        {
            if (document.styleSheets[S][cssRules][R].selectorText == theClass) 
            {
                return document.styleSheets[S][cssRules][R].style[element];
            }
        }
    }
}

var popupClosingHandler = null;
var showPopup = function(e, message, closingHandler)
{
	try
	{
		popupClosingHandler = closingHandler;
	    document.getElementById("popupMessage").innerHTML = message;
	    document.getElementById("popupDiv").style.visibility = "visible";
	    document.getElementById("popupDiv").style.posLeft = e.clientX+100;
	    document.getElementById("popupDiv").style.posTop = e.clientY-15;
	}
	catch(Exception) {}
};

var hidePopup = function()
{
	try
	{
		if(popupClosingHandler != null)
			popupClosingHandler();
		popupClosingHandler = null;
	    document.getElementById("popupDiv").style.visibility = "hidden";
	}
	catch(Exception) {}
};

