function windowPop(id) {
    window.open('<%=Home("/qwindow/anon/?id="+id)%>','qwindow','scrollBars=Yes,width=300,height=500,left=400');
}

//setTimeout('windowPop()', 12000);
pageResize = function(){
    window.resizeTo(430,550);
}

cp_redirect = function(url) {
    if (window.opener.closed) {
        window.open(url, "nav", "", "");
    } else {
        window.opener.location = url;
    }
}

openGlossary = function(accountId, language){
    window.open('glossary.rails?id='+ accountId + '&language=' + language, 'glossary', 'scrollBars=Yes,width=510,height=200,left=100');
}

openQwindow = function(companionPageId){
    window.open('qwindow.rails?id='+companionPageId, 'qwindow', 'scrollBars=No,width=620,height=550,left=400');
}

setInputValue = function(inputId, value){
    var inputEl = document.getElementById(inputId);
    inputEl.value = value;
    return;
}
setInnerHtml = function(id, value){
    var inputEl = document.getElementById(id);
    inputEl.innerHTML = value;
    return;
}
            
sfHover = function() {
    var sfMenuEl = document.getElementById("Menu");
    if(!sfMenuEl) return;
	var sfEls = sfMenuEl.getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover = function() {
			this.className += " sfhover";
			hideSelect();
		}
		sfEls[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
			showSelect();
		}
	}
}
hideSelect = function(){
    var selNodes = document.getElementsByTagName('select')
    var i=0;
    if (!selNodes.item(0)){
        return false;
    } else {
        do{
            selNodes.item(i).style.visibility = 'hidden';
        }
        while(++i < selNodes.length);
    }
}
showSelect = function(){
    var selNodes = document.getElementsByTagName('select')
    var i=0;
    if (!selNodes.item(0)){
        return false;
    } else {
        do{
            selNodes.item(i).style.visibility = 'visible';
        }
        while(++i < selNodes.length);
    }
}
qwindowThankyou = function() {
    window.resizeTo(300,300);
    setTimeout("window.close()",3000);
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

function addNewLoadEvent(func)
{
      var oldonload = window.onload;
      if (typeof window.onload != 'function')
            window.onload = func;
      else
            window.onload = function()
            {
                  oldonload();
                  func();
            }
}
setCaretToEnd = function(id)
{
	el = $(id);
	if (el.createTextRange) {
		var v = el.value;
		var r = el.createTextRange();
		r.moveStart('character', v.length);
		r.select();
	}
}
addNewLoadEvent(sfHover);