///////////////////////
// NEW GLOBAL HEADER //
///////////////////////
var msglobalnav = (function() {


    //HEADER PROPERTIES
    var _isie = null; //CHECK FOR IE and NOT Strict
    var isie = (function() {
        if (_isie == null) {
            var d = document.doctype
            strict = (document.compatMode == "CSS1Compat")

 strict = (d && d.systemId ? (d.systemId.indexOf("strict") > -1 ? true : (d.publicId.indexOf("transitional") > -1 ? true : false)) : (d && d.publicId.indexOf("transitional") == -1 ? true : strict))

 strict = (d && d.name.indexOf(".dtd") > -1) ? true : strict

 _isie = !strict && navigator.userAgent.indexOf('MSIE') >= 0;
        }
        return _isie;
    } ());

    var framer = null; //IFRAME Reference

    //HEADER FIELDS
    var menuTopOffset = isie ? -3 : 0;
    var menuLeftOffset = isie ? -3 : 0;
    var linkOffset = isie ? 0 : -15;
    var output = {};
    var timerOut = null;
    var menuOutTime = 250;
    var currentItemId = null;

    
    function getItems(id) {
        return {
            'child':  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('subNav' + id),
            'parent':  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('nav' + id)

 };
    }
    function fixedSub(sub, parent) {
        //FIX FOR UHP
        var d =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('userdisplay');
        var uhpOffset = 0;
        if (d && d.className === 'module' && d.tagName === 'DIV') { uhpOffset = 1; }

        var items =  _proxy_jslib_handle(sub, 'getElementsByTagName', '', 1, 0)('LI');
        var max = 140;
        for (var i = 0; i < items.length; i++) {
            if (max <  _proxy_jslib_handle(items, (i), 0, 0).offsetWidth) { max =  _proxy_jslib_handle(items, (i), 0, 0).offsetWidth; }
        }
        if (max <  _proxy_jslib_handle(null, 'parent', parent, 0, 0).offsetWidth) max =  _proxy_jslib_handle(null, 'parent', parent, 0, 0).offsetWidth;

        sub.style.width = max + 'px';
        for (var i = 0; i < items.length; i++) {
             _proxy_jslib_handle(items, (i), 0, 0).style.width = max + 'px';
             _proxy_jslib_handle( _proxy_jslib_handle(items, (i), 0, 0), 'getElementsByTagName', '', 1, 0)('A')[0].style.width = (max + linkOffset + uhpOffset) + 'px';

        }
    }
    function hideDropDown(id) {
        var subNavDropDown = getItems(id);
         _proxy_jslib_handle(subNavDropDown, 'parent', '', 0, 0).className = '';
        framer.style.left = '-100000px';
        framer.style.display = 'none';
        subNavDropDown.child.style.left = '-100000px';
        timerOut = null;
        currentItemId = null;
    }
    function getSubNav(id) {
        var items = getItems(id);
        var subNavDropDown = {};
         _proxy_jslib_assign('', subNavDropDown, 'parent', '=', (  _proxy_jslib_handle(items, 'parent', '', 0, 0)));
        subNavDropDown.child = items.child;
        fixedSub(subNavDropDown.child,  _proxy_jslib_handle(subNavDropDown, 'parent', '', 0, 0))

 var pos = Sys.UI.DomElement.getLocation( _proxy_jslib_handle(items, 'parent', '', 0, 0));
         subNavDropDown.childLeft = pos.x + 'px';
        subNavDropDown.childTop = (pos.y +  _proxy_jslib_handle(items, 'parent', '', 0, 0).offsetHeight) + 'px';
        return subNavDropDown;
    }

    output.toggle = function(id, show) {
        if (show) {
            var subNavDropDown = getSubNav(id);
            //cancel the time
            if (timerOut) {
                clearTimeout(timerOut);
                timerOut = null;
            }

            //turn off previous					
            if (currentItemId != null) {
                var current = getItems(currentItemId);
                 _proxy_jslib_handle(current, 'parent', '', 0, 0).className = '';
                framer.style.left = '-100000px';
                current.child.style.left = '-100000px';
                currentItemId = null;
            }
            //turn-on new one
            subNavDropDown.child.style.left = subNavDropDown.childLeft

  _proxy_jslib_assign('', subNavDropDown.child.style, 'top', '=', ( subNavDropDown.childTop))

  _proxy_jslib_handle(subNavDropDown, 'parent', '', 0, 0).className = 'open';

            if (framer == null) { framer =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('framer'); }
            framer.style.left = subNavDropDown.childLeft

  _proxy_jslib_assign('', framer.style, 'top', '=', ( subNavDropDown.childTop))

 framer.style.width = subNavDropDown.child.offsetWidth + 'px'; ;
            framer.style.height = subNavDropDown.child.offsetHeight + 'px';
            framer.style.zIndex = subNavDropDown.child.style.zIndex + 1;
            framer.style.display = 'block';
            currentItemId = id;
        }
        else {
            timerOut =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() { hideDropDown(id); }, menuOutTime);
        }
    };
    output.subToggle = function(id, show) {

        if (show) {
            if (timerOut) {
                clearTimeout(timerOut);
                timerOut = null

 }
        }
        else {
            timerOut =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() { hideDropDown(id); }, menuOutTime);
        }
    }

    output.applyAlphaImageLoader = function(id, url, method) {
        var el =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(id);
        if (el == null) return;
        var img = new (Image)();
         _proxy_jslib_assign('', img, 'src', '=', ( url));
         _proxy_jslib_assign('', el.style, 'backgroundImage', '=', ( 'none'));
        $addHandler(window, 'load', function() {
            el.style.filter = 'progid:DXImagetransform.Microsoft.AlphaImageLoader(enabled="true", src="' + url + '", sizingMethod="' + method + '");';
        });
    }

    output.loadStrings=function(defs) {
		for(var classKey in defs){
			if(! _proxy_jslib_handle(MySpaceRes, (classKey), 0, 0)){  _proxy_jslib_assign('', MySpaceRes, (classKey), '=', ({})); }
			
			for(var resourceKey in  _proxy_jslib_handle(defs, (classKey), 0, 0)){
				 _proxy_jslib_assign('',  _proxy_jslib_handle(MySpaceRes, (classKey), 0, 0), (resourceKey), '=', ( _proxy_jslib_handle( _proxy_jslib_handle(defs, (classKey), 0, 0), (resourceKey), 0, 0)));
			}
		}
	};
	
    //HEADER SEARCH FUNCTION & FIELDS
    var searchTypesOn = 0;
    var searchTimer = null;


    //FOOTER FUNCTION & FIELDS
    var isIntlFooterOn = false;
    var isie = navigator.userAgent.indexOf('MSIE') >= 0
    output.toggleInternationalLinks = function() {
    var internationalLinks =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('internationalLinks');
            var intlLink =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('intlLink');
            if (isIntlFooterOn) {
                 internationalLinks.style.visibility = 'hidden';
		    }
            else {
                var pos = Sys.UI.DomElement.getLocation(intlLink);
                if (!isie) {
                    internationalLinks.style.marginLeft = (pos.x - (internationalLinks.offsetWidth / 2) - (intlLink.offsetWidth / 2) + 25) + 'px';
                }
                else {
                    var lo = (pos.x - (internationalLinks.offsetWidth / 2) - (intlLink.offsetWidth / 2) - ( _proxy_jslib_handle(document, 'body', '', 0, 0).offsetWidth / 2));
                    if (-lo > internationalLinks.offsetWidth) 
                        lo = lo + ( _proxy_jslib_handle(document, 'body', '', 0, 0).offsetWidth / 2);
                    internationalLinks.style.marginLeft = lo + 'px';
                }
                internationalLinks.style.visibility = 'visible';

            }
            isIntlFooterOn = !isIntlFooterOn;
    }

    return output;

} ());	



  var searchTypesOn = 0;
  var searchTimer = null;
  var framer = null;
  
  
  function  openSearchTypes(arg) {
        
        var isHeader = (arg.toLowerCase() === 'header');
		var searchMenuListBox = 'srchMenuListBox_' + arg;
        var searchList =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchMenuListBox);
        if (searchList == null) {
           return;
        }
        searchList.className = 'open';
        var pos =Sys.UI.DomElement.getLocation(searchList);
        if (isHeader)
        {
        if (framer == null) { framer =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('framer'); }
            if (framer) {
                framer.style.left = (pos.x ) + 'px';
                 _proxy_jslib_assign('', framer.style, 'top', '=', ( (pos.y - 2) + 'px'));
                framer.style.width = searchList.offsetWidth + 'px';
                framer.style.height = searchList.offsetHeight + 'px';
                framer.style.zIndex = searchList.style.zIndex + 1;
                framer.style.display = "block";
          
            }
            }
        clearTimeout(searchTimer);
        searchTimer = null;
    };	
    
   function hideSearchTypes (arg) {
        searchTimer =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {
         
		  	var searchMenuListBox = 'srchMenuListBox_' + arg;
			if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchMenuListBox))
                 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchMenuListBox).className = '';

            if (framer == null) { framer =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('framer'); }
            if (framer != null) { framer.style.display = "none"; }

            searchTimer = null;
        }, 500);
    };
    
    function switchSearchTypeTo( v, searchType) {
       var _after = '<small>&#9660;</small>';
       var types;
       var searchText = 'search_t_' + searchType;
	   var searchTypeValue = 'searchTypeValue_' + searchType;
	   var srchMenuListBox = 'srchMenuListBox_' + searchType;
	   var typeName = v + '_' + searchType;
        if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchText))
             _proxy_jslib_assign('',  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchText), 'value', '=', ( v));
		if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(typeName))
		{
			 if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchTypeValue))
                 _proxy_jslib_assign('',  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(searchTypeValue), 'innerHTML', '=', ( _proxy_jslib_handle( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(typeName), 'innerHTML', '', 0, 0) + _after));
              
		}
		      
        if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(srchMenuListBox))
             _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(srchMenuListBox).className = '';

        if (framer == null) { framer =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('framer'); }
        if (framer != null) { framer.style.display = "none"; }

        clearTimeout(searchTimer);
        searchTimer = null;
    };
    
     function srchMenuList(isOn,searchType) {
        if (isOn) {
            clearTimeout(searchTimer);
            searchTimer = null;
        }
        else {
            searchTimer =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {
				
				var srchMenuListBox = 'srchMenuListBox_' + searchType;
                if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(srchMenuListBox))
                     _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(srchMenuListBox).className = '';
                if (framer == null) { framer =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('framer'); }
                if (framer != null) { framer.style.display = "none"; }
                searchTimer = null;
            }, 500);
        }
    };
    
    function searchLocation(url,fuseaction,type,qry) {  
    var fuseAction =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(fuseaction);
    var typeElement =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(type);
    var qryElement =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(qry);
   if ( _proxy_jslib_handle(qryElement, 'value', '', 0, 0).length > 0)
   {
    var searchLocation = url +  fuseAction.name + "=" +  _proxy_jslib_handle(fuseAction, 'value', '', 0, 0) + "&" + typeElement.name + "=" +  _proxy_jslib_handle(typeElement, 'value', '', 0, 0)

 + "&"+ qryElement.name + "=" +  _proxy_jslib_handle(qryElement, 'value', '', 0, 0) + '&submit=Search';
     _proxy_jslib_assign('', window, 'location', '=', ( searchLocation));
       
    }
    return false;
    }  ;
_proxy_jslib_flush_write_buffers() ;