function OpenWindow(query,w,h,scroll)
	{
		var l = (screen.width - w) / 2;
		var t = (screen.height - h) / 2;
		
		winprops = 'resizable=1, height='+h+',width='+w+',top='+t+',left='+l+'w';
		if (scroll) winprops+=',scrollbars=1';
		var f = window.open(query, "_blank", winprops);
	}	
	
	
	function OpenWindow_noResize(query,w,h,scroll)
	{
		var l = (screen.width - w) / 2;
		var t = (screen.height - h) / 2;
		
		winprops = 'resizable=1, height='+h+',width='+w+',top='+t+',left='+l+'w';
		if (scroll) winprops+=',scrollbars=1';
		var f = window.open(query, "_blank", winprops);
	}	
	
	function isBrowserIE(){
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
			return true;
		}
		else {
			return false;
		}
	}
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} 
		else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}
	
function newWindow(mypage, myname, w, h) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var settings = "height=" + h + ",";
    settings += "width=" + w + ",";
    settings += "top=" + wint + ",";
    settings += "left=" + winl + ",";
    settings += "scrollbars=no" + ",";
    settings += "resizable=no";
    win = window.open(mypage, myname, settings);
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}

// limit number of charachters
function doKeypress(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}

// Cancel default behavior
function doBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}

function swapFields(){
	var control_wrap = document.getElementById("user_info")
	if (YAHOO.util.Dom.hasClass(control_wrap,"show_info"))
		YAHOO.util.Dom.replaceClass(control_wrap,"show_info","edit_info");
	else
		YAHOO.util.Dom.replaceClass(control_wrap,"edit_info","show_info");
}

function newScrWindow(mypage, myname, w, h) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var settings = "height=" + h + ",";
    settings += "width=" + w + ",";
    settings += "top=" + wint + ",";
    settings += "left=" + winl + ",";
    settings += "scrollbars=yes" + ",";
    settings += "resizable=yes";
    win = window.open(mypage, myname, settings);
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}










// Initialize and render the menu bar when it is available in the DOM

YAHOO.util.Event.onContentReady("upper_menu", function () {

// Animation object

var oAnim;


// "beforeshow" event handler for each submenu of the menu bar

function onMenuBeforeShow(p_sType, p_sArgs) {

    var oBody,
        oShadow,
        oUL;

    if (this.parent) {

        oShadow = this.element.lastChild;

        oShadow.style.height = "0px";
    
        if (oAnim && oAnim.isAnimated()) {
        
            oAnim.stop();
            oAnim = null;
        
        }

        oBody = this.body;
        oUL = oBody.getElementsByTagName("ul")[0];

        YAHOO.util.Dom.setStyle(oBody, "overflow", "hidden");
        YAHOO.util.Dom.setStyle(oUL, "marginTop", ("-" + oUL.offsetHeight + "px"));
    
    }

}

function onTween(p_sType, p_aArgs, p_oShadow) {

    if (this.cfg.getProperty("iframe")) {
    
        this.syncIframe();

    }

    if (p_oShadow) {

        p_oShadow.style.height = this.element.offsetHeight + "px";
    
    }

}

function onAnimationComplete(p_sType, p_aArgs, p_oShadow) {

    var oBody = this.body,
        oUL = oBody.getElementsByTagName("ul")[0];

    if (p_oShadow) {
    
        p_oShadow.style.height = this.element.offsetHeight + "px";
    
    }

    YAHOO.util.Dom.setStyle(oUL, "marginTop", "auto");
    YAHOO.util.Dom.setStyle(oBody, "overflow", "visible");
    
    if (YAHOO.env.ua.ie) {
    
        YAHOO.util.Dom.setStyle(oBody, "zoom", "1");
    
    }
    
}


// "show" event handler for each submenu of the menu bar

function onMenuShow(p_sType, p_sArgs) {

    var oElement,
        oShadow,
        oUL;

    if (this.parent) {

        oElement = this.element;
        oShadow = oElement.lastChild;
        oUL = this.body.getElementsByTagName("ul")[0];
    
        oAnim = new YAHOO.util.Anim(oUL, 
            { marginTop: { to: 0 } },
            .3, YAHOO.util.Easing.easeBothStrong);


        oAnim.onStart.subscribe(function () {

            oShadow.style.height = "100%";
        
        });


        oAnim.animate();


        /*
             Refire the event handler for the "iframe" 
             configuration property with each tween so that the  
             size and position of the iframe shim remain in sync 
             with the menu.
        */

        if (YAHOO.env.ua.ie) {
            
            oShadow.style.height = oElement.offsetHeight + "px";

            oAnim.onTween.subscribe(onTween, oShadow, this);

        }

        oAnim.onComplete.subscribe(onAnimationComplete, oShadow, this);
    
    }

}


// Instantiate and render the menu bar

var oMenuBar = new YAHOO.widget.MenuBar("upper_menu", { autosubmenudisplay: true, hidedelay: 750, zindex:100, lazyload: true });

oMenuBar.subscribe("beforeShow", onMenuBeforeShow);
oMenuBar.subscribe("show", onMenuShow);


/*
     Call the "render" method with no arguments since the markup for 
     this menu already exists in the DOM.
*/

oMenuBar.render();            

});

