if(typeof($)!="function"){
	Include("/css/javascript/extensions.js");
}
function setLocationParams(params){
    var href = window.location.href;
    if(href.indexOf("#") > -1)
        href = href.substring(0,href.indexOf("#"));
    window.location.href = href + "#" + params;
}

/* String functions */
String.prototype.endsWith = function(str){
	return (this.match(str+"$")==str);
};
String.prototype.trim = function(){
    return this.replace(/^\s*/,"").replace(/\s*$/,"");
};
String.prototype.startsWith=function(str){
	return (this.indexOf(str)==0);
};


function StringBuffer(str){
    this.buf = [];
    if(str)
        this.buf.push(str);
    this.append = function(str){
        this.buf.push(str);
    };
    this.toString = function(){
        return this.buf.join("");
    };
}

Array.prototype.contains = function(val){
    var l = this.length, i = 0;
    for(i; i < l; i = i + 1)
        if(this[i] == val)
            return true;
    return false;
}
function Include(f){
    document.write("<" + "script" + " src=\"" + f + "\" type=\"text/javascript\">" + "<" + "/script" + ">");
}
//Get element's inner text
function $eit(obj){
    var t = obj.innerText;
    if(!t){
        t = obj.textContent;
    }
    return t;
}
var IE = window.navigator.userAgent.indexOf("MSIE") > -1;
var Mouse = new function(){
    this.X = 0;
    this.Y = 0;
    this.startTracking = function(){
        var t = this;
        document.onmousemove = function(e){
            if(IE){
                t.X = event.clientX + document.body.scrollLeft;
                t.Y = event.clientY + document.body.scrollTop
            }else{
                t.X = e.pageX;
                t.Y = e.pageY
            }
            if(t.X < 0){
                t.X = 0
            }
            if(t.Y < 0){
                t.Y = 0
            }
            return true
        };
    };
}
function getClientHeight(){
    return document.documentElement.clientHeight;
}
function f_filterResults(n_win,n_docel,n_body){
    var n_result = n_win?n_win:0;
    if(n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body))?n_body:n_result;
}
var resizing = false;
function resizeWithScreen(obj,minHeight,offset){
    if(typeof (Position) == "object"){
        obj.topPosition = Position.get(obj).top;
        obj.minHeight = minHeight;
        var oldResize = window.onresize;
        window.onresize = function(){
            try{
                if(oldResize)
                    oldResize();
            }catch(ignored){
            }
            var h = ((getClientHeight() - obj.topPosition) + offset);
            if(h > obj.minHeight)
                obj.style.height = h + "px";
            else
                obj.style.height = obj.minHeight + "px";
        };
        window.onresize();
    }else{
        alert("Need to include Position.js to use resizeWithScreen");
    }
}
function b_mOver(btnId){
    var btn = $(btnId);
    if(btn.className == 'middleButtonPart'){
        btn.style.color = "#0181c8"
    }
}
function b_mOut(btnId){
    var btn = $(btnId);
    if(btn.style.color == "#0181c8" || (btn.style.color + "") == "rgb(1, 129, 200)"){
        btn.style.color = "#000000"
    }
}
function b_click(btnId){
    var btn = $(btnId);
    if(btn.className.indexOf("ray") == -1){
        $("a_" + btnId).onclick();
    }
}
function b_kPress(btnId,obj,e,onclick){
    var keyCode = getKeyCode(e);
    if(keyCode == 13 || keyCode == 32){
        b_click(btnId);
    }else if(keyCode == 9){
        return true;
    }
    return false;
}
function searchClicked(){
    searchBlur($("searchQuery"));
    if($("searchButton").className.indexOf("Gray")==-1){
        $("searchButton").className="middleSearchButtonPartGray";
        $("searchButton").title="Searching...";
        window.setTimeout(function(){
            window.location.href="/lna/search.do?s=0&m="+($("fullText").checked?"f":"t")+"&q="+$("searchQuery").value;
        },100);
    }
}
function getKeyCode(e){
    return  e.keyCode?e.keyCode:e.which?e.which:e.charCode;
}

function sb_mOver(btnId){
    var btn = $(btnId);
    if(btn.className == 'middleSearchButtonPart'){
        btn.className = 'middleSearchButtonPartOver';
    }
}
function sb_mOut(btnId){
    var btn = $(btnId);
    if(btn.className == 'middleSearchButtonPartOver'){
        btn.className = 'middleSearchButtonPart';
    }
}
function sb_click(btnId){
    var btn = $(btnId);
    if(btn.className.indexOf("ray") == -1){
        $("a_" + btnId).onclick();
    }
}
function sb_kPress(btnId,obj,e,onclick){
    var keyCode = getKeyCode(e);
    if(keyCode == 13 || keyCode == 32){
        b_click(btnId);
    }else if(keyCode == 9){
        return true;
    }
    return false;
}
function getKeyCode(e){
    if(!e) e=window.event;
    return e.keyCode?e.keyCode:e.which?e.which:e.charCode;
}
function searchButtonKeyPressed(obj,e){   
    searchBlur();
    var keyCode = getKeyCode(e);
    if(keyCode == 13 || keyCode == 23){
        if(obj.value != ""){
            searchClicked();
        }
    }
    return false;
}
function searchPressCheck(obj,e){
    searchBlur(obj);
    var keyCode = getKeyCode(e);
    if(keyCode == 13){
        if(obj.value != ""){
            searchClicked();
        }
        return false;
    }else if(keyCode==53){
        cleanQuery(obj);
    }
    return true;
}
function searchBlur(obj){    
    cleanQuery(obj); 
    if(obj.value != ""){
        $("searchButton").className = "middleSearchButtonPart";
    }else{
        $("searchButton").className = "middleSearchButtonPartGray";
    }
}
function cleanQuery(obj){
    try{
    var val = obj.value, newval = val.replaceAll("\\","").replaceAll("&","").replaceAll("%", "");
    if(val != newval){
        obj.value = newval;
    }
    }catch(ex){}
}
function enableButton(btnId){
    var btn = $(btnId);
    if(btn){
        if(btn.className != "middleButtonPart" && btn.className != "middleButtonPartOver"){
            btn.className = "middleButtonPart";
        }
    }
}
function disableButton(btnId){
    var btn = $(btnId);
    if(btn){
        if(btn.className != "middleButtonPartGray"){
            btn.className = "middleButtonPartGray";
            btn.style.color="";
        }
    }
}

String.prototype.replaceAll = function(s1,s2){
    return this.split(s1).join(s2)
};
function pleaseWait(override){
    var o = new StringBuffer("<table width='100%' height='140px'><tr><td valign='middle' align='center' style='font-weight:bold; font-size:16px'>Please Wait...</td></tr></table>");
    Prompt(o.toString(),"div");
    if(!override){
        window.setTimeout(function(){
            document.forms[0].submit();
        },150);
    }
}
function printPage(title,content,cssFile){
	if(!$("print-form")){
        var f = document.createElement("form"), t=document.createElement("input"), c=document.createElement("input"), css = document.createElement("input"), d=document.createElement("div");
        with(d.style){
            position="absolute";
            height="1px";
            width="1px";
            top="-1px";
        }
        d.id="frameHolder";
       
        document.body.appendChild(d);
        $("frameHolder").innerHTML='<iframe name="printIframe" id="printIframe" style="height:1px; width:100%; border-style:none; position:absolute: top:-100px; left:0px" frameborder="0" src="about:blank"></iframe>';
        // Add iframe
        
        // Setup form
        f.style.margin="0";
        f.action="/lna/pages/printPage.jsp";
        f.method="post";
        f.name="print-form";
        f.id="print-form";
        f.target="printIframe";
        
        // Setup hidden parameters
        t.type="hidden";
        c.type="hidden";
        css.type="hidden";
        
        t.id="print-title";
        t.name="title";
        c.id="print-content";
        c.name="content";
        css.id="print-cssFile";
        css.name="cssFile";
        
        // Add elements to document
        document.body.appendChild(f)
        f.appendChild(t);
        f.appendChild(c);
        f.appendChild(css);
    }    
    $("print-title").value=title;
    $("print-content").value=content;
    $("print-cssFile").value=cssFile;
    $("print-form").submit();
}
function frameLoaded(){
    //document.printIframe.focus();
    //document.printIframe.print(); 
    frames["printIframe"].focus();
    frames["printIframe"].print();
}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires=";expires="+date.toGMTString();}else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
var help_window = null;
function openHelpWindow(){
    if(!help_window||help_window.closed){
        help_window = window.open ("about:blank", "HELP_WINDOW","location=1,status=1,scrollbars=1,resizable=1");
    }
    if(!help_window.closed){
        help_window.focus();
    }else{
        alert("Please disable your pop-up blocker and try again.");
    }
}
var toolTipTimeout = null, toolTipObj = null, toolTipShim = null, toolTipContent = null;
function showToolTip(triggerId,contentId,offset,width){
    position = Position.get($(triggerId));
    if(toolTipTimeout)
        hideToolTip();
    if(!width)
        width = 250;
    if(!offset)
        offset = { x :0, y :0 };
    if(!toolTipObj)
        toolTipObj = $("toolTipObj");
    if(!toolTipShim)
        toolTipShim = $("toolTipShim");
    if(!toolTipContent)
        toolTipContent = $("toolTipContent");
    toolTipContent.innerHTML = $(contentId).innerHTML;
    toolTipObj.style.width = width + "px";
    toolTipShim.style.width = width + "px";
    toolTipShim.style.display = "block";
    toolTipObj.style.display = "block";
    toolTipObj.style.top = ((position.top + offset.y) - toolTipObj.offsetHeight) + "px";
    toolTipShim.style.top = ((position.top + offset.y) - toolTipObj.offsetHeight) + "px";
    toolTipObj.style.left = (position.left - offset.x) + "px";
    toolTipShim.style.left = (position.left - offset.x) + "px";
    toolTipShim.style.height = toolTipObj.offsetHeight - 8;
}
function startToolTipTimer(){
    toolTipTimeout = window.setTimeout("hideToolTip()",1500);
}
function hideToolTip(){
    clearToolTipTimer();
    if(toolTipObj)
        toolTipObj.style.display = "none";
    if(toolTipShim)
        toolTipShim.style.display = "none";
}
function clearToolTipTimer(){
    if(toolTipTimeout)
        window.clearTimeout(toolTipTimeout);
}
Include("/css/javascript/extensions.js");