function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}
var NS = (navigator.appName == "Netscape");

window.onload = function ()
            {
              AT.navtxt=(AT.ns4)?document.layers['navtxt']:(AT.ie4)?document.all['navtxt']:(AT.w3c)?document.getElementById('navtxt'):null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  if(AT.ie4||AT.ie5&&dofade)AT.navtxt.style.filter="alpha(opacity=100)";
  AT.navtxt.onmouseover=function(){
  if(!mousefollow)clearTimeout(AT.dy);
  }
  AT.navtxt.onmouseout=function(){
  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);
  }
  if(AT.ns4)document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=moveobj;
  window.onresize=getwindowdims;
                if (!document.getElementsByTagName) return;
	            var anchors = document.getElementsByTagName("a");
	            for (var i=0; i<anchors.length; i++)
	            {
		            var anchor = anchors[i];
		            if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		                anchor.target = "_blank";
	            }
                var oTextbox = new AutoSuggestControl(document.getElementById('ctl00_SearchBar1_searchTextBox'), new RemoteStateSuggestions());      
            }

            autocomp = function ()
            {
        	    var sBox = document.getElementById('ctl00_SearchBar1_searchTextBox');
        		sBox.setAttribute('autocomplete', 'off');
            }
            
            try
            {
	            window.addEventListener("load", autocomp, true);
           	}
           	catch(e)
           	{
        		window.attachEvent("onload", autocomp);
        	}

function AutoSuggestControl(oTextbox, oProvider) {
    this.cur = -1;
    this.layer = null;
    this.provider = oProvider;
    this.textbox = oTextbox;
    this.init();
}

AutoSuggestControl.prototype.autosuggest = function (aSuggestions, bTypeAhead) {
    try {
    if (this.textbox.value.length < 1)
    {
    this.hideSuggestions();
    }
    else if (aSuggestions.length > 0) {       
        this.showSuggestions(aSuggestions);
    } else {
        this.hideSuggestions();
    } } catch(ex) { }
};

AutoSuggestControl.prototype.createDropDown = function () {

    var oThis = this;
    this.layer = document.createElement("div");
    this.layer.className = "suggestions";
    this.layer.style.visibility = "hidden";
    this.layer.style.width = this.textbox.offsetWidth + "px";
    this.layer.onmousedown = 
    this.layer.onmouseup = 
    this.layer.onmouseover = function (oEvent) {
        oEvent = oEvent || window.event;
        oTarget = oEvent.target || oEvent.srcElement;

        if (oEvent.type == "mousedown") {
            oThis.textbox.value = oTarget.firstChild.nodeValue;
            oThis.hideSuggestions();
            
        } else if (oEvent.type == "mouseover") {
            oThis.highlightSuggestion(oTarget);
        } else {
            oThis.textbox.focus();
        }
    };
    
    
    document.body.appendChild(this.layer);
};

AutoSuggestControl.prototype.getLeft = function () {

    var oNode = this.textbox;
    var iLeft = 0;
   
    while((oNode.tagName != "BODY") & (oNode.tagName != "HTML")) {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;        
    }

    return iLeft;
};

AutoSuggestControl.prototype.getTop = function () {

    var oNode = this.textbox;
    var iTop = 0;
    
    while((oNode.tagName != "BODY") & (oNode.tagName != "HTML")) {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
};

AutoSuggestControl.prototype.handleKeyDown = function (oEvent) {

    switch(oEvent.keyCode) {
        case 38:
            this.previousSuggestion();
            break;
        case 40:
            this.nextSuggestion();
            break;
        case 13:
            this.hideSuggestions();
            break;
    }

};

AutoSuggestControl.prototype.handleKeyUp = function (oEvent) {

    var iKeyCode = oEvent.keyCode;
    if (iKeyCode == 8 || iKeyCode == 46) {
        this.provider.requestSuggestions(this, false, document.getElementById('ctl00_SearchBar1_searchDropList').options[document.getElementById('ctl00_SearchBar1_searchDropList').selectedIndex].value);
        
    } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
    } else {
        this.provider.requestSuggestions(this, true, document.getElementById('ctl00_SearchBar1_searchDropList').options[document.getElementById('ctl00_SearchBar1_searchDropList').selectedIndex].value);

    }
   
};

AutoSuggestControl.prototype.hideSuggestions = function () {
    this.layer.style.visibility = "hidden";
};

AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
    
    for (var i=0; i < this.layer.childNodes.length; i++) {
        var oNode = this.layer.childNodes[i];
        if (oNode == oSuggestionNode) {
            oNode.className = "current"
        } else if (oNode.className == "current") {
            oNode.className = "";
        }
    }
};

AutoSuggestControl.prototype.init = function () {
    var oThis = this;
    this.textbox.onkeyup = function (oEvent) {
        if (!oEvent) {
            oEvent = window.event;
        }    
        oThis.handleKeyUp(oEvent);
    };

    this.textbox.onkeydown = function (oEvent) {
    
        if (!oEvent) {
            oEvent = window.event;
        }    
        
        oThis.handleKeyDown(oEvent);
    };
    
    this.textbox.onblur = function () {
        oThis.hideSuggestions();
    };
    
    this.createDropDown();
};

AutoSuggestControl.prototype.nextSuggestion = function () {
    var cSuggestionNodes = this.layer.childNodes;

    if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
        var oNode = cSuggestionNodes[++this.cur];
        this.highlightSuggestion(oNode);
        this.textbox.value = oNode.firstChild.nodeValue; 
    }
};

AutoSuggestControl.prototype.previousSuggestion = function () {
    var cSuggestionNodes = this.layer.childNodes;

    if (cSuggestionNodes.length > 0 && this.cur > 0) {
        var oNode = cSuggestionNodes[--this.cur];
        this.highlightSuggestion(oNode);
        this.textbox.value = oNode.firstChild.nodeValue;   
    }
};

AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*:int*/) {
    //if (this.textbox.createTextRange) {
    //  var oRange = this.textbox.createTextRange(); 
    //oRange.moveStart("character", iStart); 
    //oRange.moveEnd("character", iLength - this.textbox.value.length);      
    //oRange.select();
    //} else if (this.textbox.setSelectionRange) {
    //  this.textbox.setSelectionRange(iStart, iLength);
    //}     
    //this.textbox.focus();      
}; 

AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {

    var oDiv = null;
    this.layer.innerHTML = "";  //clear contents of the layer
    
    for (var i=0; i < aSuggestions.length; i++) {
        oDiv = document.createElement("div");
        oDiv.appendChild( document.createTextNode(aSuggestions[i].replace(/@/g, '"')) );
        this.layer.appendChild(oDiv);
    }
    
    this.layer.style.left = this.getLeft() + "px";
    this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";   
    this.layer.style.visibility = "visible";
    
    
    	for (var i=0; i < this.layer.childNodes.length; i++) {
			var oNode = this.layer.childNodes[i];
			if (i == 0) {
				oNode.className = "current"
			} else if (oNode.className == "current") {
				oNode.className = "";
			}
		}
};

function RemoteStateSuggestions() {

    if (typeof XMLHttpRequest != "undefined") {
        this.http = new XMLHttpRequest();
    } else if (typeof ActiveXObject != "undefined") {
        this.http = new ActiveXObject("MSXML2.XmlHttp");
    } else {
      //  alert("No XMLHttpRequest object available. This functionality will not work.");
    }

}

RemoteStateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl, bTypeAhead, databaseTable) {
                         
    var oHttp = this.http;   
    
    if (oHttp.readyState != 0)
    {
        oHttp.abort();       
    }                    
        
    var sURL = "SearchBox.aspx?k=" + encodeURIComponent(oAutoSuggestControl.textbox.value) + "&d=" + databaseTable;
    
    oHttp.open("get", sURL , true);
    
    oHttp.onreadystatechange = function () {
        if (oHttp.readyState == 4) {
			t = oHttp.responseText;
			t = t.substr(0, t.indexOf('~END'))
            var aSuggestions = eval(t);
            oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
        }    
    };
    oHttp.send(null);  

};

var dofade=true;
var centertext=false;
var xoffset=6;
var yoffset=20;
var mousefollow=true;
var hideDelay=300;
function altProps(){
this.w3c=(document.getElementById)?true:false;
this.ns4=(document.layers)?true:false;
this.ie4=(document.all && !this.w3c)?true:false;
this.ie5=(document.all && this.w3c)?true:false;
this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;
this.w_y=0;
this.w_x=0;
this.navtxt=null;
this.boxheight=0;
this.boxwidth=0;
this.ishover=false;
this.ieop=0;
this.op_id=0;
this.oktomove=false;
this.dy=0;
}

var AT=new altProps();

function toggle_centertext(){
centertext=!centertext;
}

function toggle_mousefollow(){
mousefollow=!mousefollow;
}

function toggle_dofade(){
dofade=!dofade;
if(!dofade)AT.ieop=100;
}


function getwindowdims(){
AT.w_y=(AT.ie5||AT.ie4)?document.body.clientHeight:window.innerHeight;
AT.w_x=(AT.ie5||AT.ie4)?document.body.clientWidth:window.innerWidth;
}

function getboxwidth(){
if(AT.ns4)AT.boxwidth=(AT.navtxt.document.width)? AT.navtxt.document.width : AT.navtxt.clip.width;
else if(AT.ie4)AT.boxwidth=(AT.navtxt.style.pixelWidth)? AT.navtxt.style.pixelWidth : AT.navtxt.offsetWidth;
else AT.boxwidth=(AT.navtxt.style.width)? parseInt(AT.navtxt.style.width) : parseInt(AT.navtxt.offsetWidth);
}

function getboxheight(){
if(AT.ns4)AT.boxheight=(AT.navtxt.document.height)? AT.navtxt.document.height : AT.navtxt.clip.height;
else if(AT.ie4)AT.boxheight=(AT.navtxt.style.pixelHeight)? AT.navtxt.style.pixelHeight : AT.navtxt.offsetHeight;
else AT.boxheight=parseInt(AT.navtxt.offsetHeight);
}

function movenavtxt(x,y){
if(AT.ns4)AT.navtxt.moveTo(x,y);
else{
AT.navtxt.style.left=x+'px';
AT.navtxt.style.top=y+'px';
}}

function getpagescrolly(){
if(AT.ie5||AT.ie4)return document.body.scrollTop;
else return window.pageYOffset;
}

function getpagescrollx(){
if(AT.ie5||AT.ie4)return document.body.scrollLeft;
else return window.pageXOffset;
}

function writeindiv(text){
if(AT.ns4){
AT.navtxt.document.open();
AT.navtxt.document.write(text);
AT.navtxt.document.close();
}
else AT.navtxt.innerHTML=text;
}

function writetxt(text){
if(dofade && (AT.ie4||AT.w3c))clearInterval(AT.op_id);
if(text!=0){
if(!mousefollow)clearTimeout(AT.dy);
AT.oktomove=true;
AT.ishover=true;
if(AT.ns4)text='<div class="navtext">'+((centertext)?'<center>':'')+text+((centertext)?'</center>':'')+'</div>';
if(AT.w3c||AT.ie4)AT.navtxt.style.textAlign=(centertext)?"center":"left";
writeindiv(text);
if(AT.ns4)AT.navtxt.visibility="show";
else{
AT.navtxt.style.visibility="visible";
AT.navtxt.style.display="block";
}
getboxheight();
if((AT.w3c||AT.ie4) && dofade){
if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity=0)";
if(AT.ns6)AT.navtxt.style.MozOpacity=0;
AT.ieop=0;
AT.op_id=setInterval('incropacity()',5);
}}else{
if(mousefollow)hideAlttxt();
else AT.dy=setTimeout('hideAlttxt()',hideDelay);
}}

function hideAlttxt(){
if(AT.ns4)AT.navtxt.visibility="hide";
else{
AT.navtxt.style.display="none";
AT.navtxt.style.visibility="hidden";
}
movenavtxt(-AT.boxwidth-10,0);
writeindiv('');
}

function incropacity(){
if(AT.ieop<=100){
AT.ieop+=7;
if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity="+AT.ieop+")";
if(AT.ns6)AT.navtxt.style.MozOpacity=AT.ieop/100;
}else clearInterval(AT.op_id);
}

function moveobj(evt){
mx=(AT.ie5||AT.ie4)?event.clientX:evt.pageX;
my=(AT.ie5||AT.ie4)?event.clientY:evt.pageY;
if(AT.ishover && AT.oktomove){
margin=(AT.ie4||AT.ie5)?5:25;
if(AT.ns6)if(document.height+27-window.innerHeight<0)margin=15;
if(AT.ns4)if(document.height-window.innerHeight<0)margin=10;
if(AT.ns4||AT.ns6)mx-=getpagescrollx();
if(AT.ns4)my-=getpagescrolly();
xoff=mx+xoffset;
yoff=(my+AT.boxheight+yoffset-((AT.ns6)?getpagescrolly():0)>=AT.w_y)? -5-AT.boxheight-yoffset: yoffset;
movenavtxt( Math.min(AT.w_x-AT.boxwidth-margin , Math.max(2,xoff))+getpagescrollx(), my+yoff+((!AT.ns6)?getpagescrolly():0));
if(!mousefollow)AT.oktomove=false;
}}


