/* Called when the Webupdate window is closed. */
function OnClientClose(radWindow)
{ 
    var oValue = radWindow.Argument;
    window.location.href = window.location.href; //refresh window          
}


function menuOff() {
    $('#nav').hide();
}

/* 
Methods for resizing the flash stage at runtime.

setFlashWidth(divid, newW)
divid: id of the div containing the flash movie.
newW: new width for flash movie

setFlashWidth(divid, newH)
divid: id of the div containing the flash movie.
newH: new height for flash movie

setFlashSize(divid, newW, newH)
divid: id of the div containing the flash movie.
newW: new width for flash movie
newH: new height for flash movie

canResizeFlash()
returns true if browser supports resizing flash, false if not. 
*/
function setFlashWidth(divid, newW){
	document.getElementById(divid).style.width = newW+"px";
}
function setFlashHeight(divid, newH){
	document.getElementById(divid).style.height = newH+"px";		
}
function setFlashSize(divid, newW, newH){
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}

/**
 * COMMON DHTML FUNCTIONS
 * These are handy functions I use all the time.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

/**
 * X-browser event handler attachment and detachment
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */ 
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
 *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
function getViewportWidth() {
	var offset = 17;
	var width = null;
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
}

/**
 * Gets the real scroll top
 */
function getScrollTop() {
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}
function getScrollLeft() {
	if (self.pageXOffset) // all except Explorer
	{
		return self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollLeft;
	}
}


/*
Taken from http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript
Gets a CSS rule on a page by class name
modified by remove the "delete" option
*/

function getCSSRule(ruleName)                                   // Return requested style obejct
{                           
    ruleName = ruleName.toLowerCase();                          // Convert test string to lower case.
    if (document.styleSheets)                                   // If browser can play with stylesheets
    {
        for (var i = 0; i < document.styleSheets.length; i++)   // For each stylesheet
        {
            var styleSheet = document.styleSheets[i];           // Get the current Stylesheet
            var ii = 0;                                         // Initialize subCounter.
            var cssRule = false;                                // Initialize cssRule. 
            do                                                  // For each rule in stylesheet
            {
                if (styleSheet.cssRules)                        // Browser uses cssRules?
                {
                    cssRule = styleSheet.cssRules[ii];          // Yes --Mozilla Style
                } else {                                        // Browser usses rules?
                    cssRule = styleSheet.rules[ii];             // Yes IE style. 
                }                                               // End IE check.
                if (cssRule)                                    // If we found a rule...
                {
                    if (cssRule.selectorText.toLowerCase()==ruleName)  //  match ruleName?
                    {
                        return cssRule;                         // return the style object.
                    }                                           // End found rule name
                }                                               // end found cssRule
                ii++;                                           // Increment sub-counter
            } while (cssRule)                                   // end While loop
        }                                                       // end For loop
    }                                                           // end styleSheet ability check
    return false;                                               // we found NOTHING!
}                                                               // end getCSSRule 

/***************************************************
 SiteCatalyst-related functions
***************************************************/
function scEventTracking(eventId)
{
    // 20100208 FKC: Assumes that the page calling this method has SiteCatalyst embedded in it.
    if (s != null)
    {
        if (s.events != null)
        {
            var exists = false;
            var events = s.events.split(",");
            for (var i = 0; i < events.length; i++)
            {
                if (events[i] == eventId)
                {
                    exists = true;
                    break;
                }
            }

            if (!exists)
                s.events = s.events + "," + eventId;
        }
        else
        {
            s.events = eventId;
        }

        s.t();
    }
}
