﻿// JScript File

/*************************************************
New window popup for templates
*************************************************/
var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','height=500,width=400,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) 
	{
	    newwindow.focus()
	}
}

/*************************************************
Shows/Hides when user clicks on image or text
*************************************************/

imgout=new Image(9,9);
imgin=new Image(9,9);
imgHelpout=new Image(9,9);
imgHelpin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
	imgout.src="/images/u.gif";
	imgin.src="/images/d.gif";
	imgHelpout.src="/images/u.gif";
	imgHelpin.src="/images/d.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show OR hide funtion depends on if element is shown or hidden
function shoh(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}

//this switches expand collapse icons
function filterHelp(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show OR hide funtion depends on if element is shown or hidden
function shoHelp(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filterHelp(("img"+id),'imgHelpin');			
		} else {
			filterHelp(("img"+id),'imgHelpout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filterHelp(("img"+id),'imgHelpin');
			} else {
				filterHelp(("img"+id),'imgHelpout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filterHelp(("img"+id),'imgHelpout');
				document.all.id.style.display = 'none';
			}
		}
	}
}

//show OR hide funtion depends on if element is shown or hidden
function shoComments(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filterHelp(("img"+id),'imgin');			
		} else {
			filterHelp(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filterHelp(("img"+id),'imgin');
			} else {
				filterHelp(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filterHelp(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}


/*Javascript for Bubble Tooltips by Alessandro Fulciniti
http://pro.html.it - http://web-graphics.com */

function enableTooltips(id){
    var links,i,h;
    
    if(document.getElementById(id) != null)            
    {
        if(!document.getElementById || !document.getElementsByTagName) return;
            
        AddCss();
        h=document.createElement("span");
        h.id="btc";
        h.setAttribute("id","btc");
        h.style.position="absolute";
        document.getElementsByTagName("body")[0].appendChild(h);
        
        if(id==null) {
            links=document.getElementsByTagName("a");
        } else {
            links = document.getElementById(id).getElementsByTagName("a");
        }
        
        for(i=0;i<links.length;i++){
            Prepare(links[i]);
        }
    }
}

function Prepare(el){
    var tooltip,t,b,s,l;
    t=el.getAttribute("title");
    if(t==null || t.length==0) t="link:";
    el.removeAttribute("title");
    tooltip=CreateEl("span","tooltip");
    s=CreateEl("span","top");
    s.appendChild(document.createTextNode(t));
    tooltip.appendChild(s);
    b=CreateEl("b","bottom");
    //l=el.getAttribute("href");
    l="";
    if(l.length>28) l=l.substr(0,25)+"...";
    b.appendChild(document.createTextNode(l));
    tooltip.appendChild(b);
    setOpacity(tooltip);
    el.tooltip=tooltip;
    el.onmouseover=showTooltip;
    el.onmouseout=hideTooltip;
    el.onmousemove=Locate;
}

function showTooltip(e){
    document.getElementById("btc").appendChild(this.tooltip);
    Locate(e);
}

function hideTooltip(e){
    var d=document.getElementById("btc");
    if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
    el.style.filter="alpha(opacity:95)";
    el.style.KHTMLOpacity="0.95";
    el.style.MozOpacity="0.95";
    el.style.opacity="0.95";
}

function CreateEl(t,c){
    var x=document.createElement(t);
    x.className=c;
    x.style.display="block";
    return(x);
}

function AddCss(){
    var l=CreateEl("link");
    l.setAttribute("type","text/css");
    l.setAttribute("rel","stylesheet");
    l.setAttribute("href","bt.css");
    l.setAttribute("media","screen");
    document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(e){
    var posx=0,posy=0;
    if(e==null) e=window.event;
    if(e.pageX || e.pageY){
        posx=e.pageX; posy=e.pageY;
        }
    else if(e.clientX || e.clientY){
        if(document.documentElement.scrollTop){
            posx=e.clientX+document.documentElement.scrollLeft;
            posy=e.clientY+document.documentElement.scrollTop;
            }
        else{
            posx=e.clientX+document.body.scrollLeft;
            posy=e.clientY+document.body.scrollTop;
            }
        }
    document.getElementById("btc").style.top=(posy+10)+"px";
    document.getElementById("btc").style.left=(posx-20)+"px";
}

///////////////////////////////////////////////////////////////////////////////////////////
// Auto-select listbox
// mike pope, Visual Basic UE
// This script and the listbox on this page illustrates one 
// way to create an "auto-complete" listbox, where the
///////////////////////////////////////////////////////////////////////////////////////////

var toFind = "";            // Variable that acts as keyboard buffer
var timeoutID = "";         // Process id for timer (used when stopping the timeout)
timeoutInterval = 2000;      // Milliseconds. Shorten to cause keyboard buffer to be cleared faster
var timeoutCtr = 0;         // Initialization of timer count down
var timeoutCtrLimit = 2;	// Number of times to allow timer to count down
var oControl = "";          // Maintains a global reference to the control that the user is working with.

function listbox_onkeypress(){
   // This function is called when the user presses a key while focus is in 
   // the listbox. It maintains the keyboard buffer.
   // Each time the user presses a key, the timer is restarted. 
   // First, stop the previous timer; this function will restart it.
   window.clearInterval(timeoutID)

   // Which control raised the event? We'll need to know which control to 
   // set the selection in.
   oControl = window.event.srcElement;

   var keycode = window.event.keyCode;
   if(keycode >= 32 ){
       // What character did the user type?
       var c = String.fromCharCode(keycode);
       c = c.toUpperCase(); 
       // Convert it to uppercase so that comparisons don't fail
       toFind += c ; // Add to the keyboard buffer
       find();    // Search the listbox
       timeoutID = window.setInterval("idle()", timeoutInterval);  
       // Restart the timer
    }
}

function listbox_onblur(){
   // This function is called when the user leaves the listbox.

   window.clearInterval(timeoutID);
   resetToFind();
}

function idle(){
   // This function is called if the timeout expires. If this is the 
   // third (by default) time that the idle function has been called, 
   // it stops the timer and clears the keyboard buffer

   timeoutCtr += 1
   if(timeoutCtr > timeoutCtrLimit){
      resetToFind();
      timeoutCtr = 0;
      window.clearInterval(timeoutID);
   }
}

function resetToFind(){
   toFind = ""
}


function find(){
    // Walk through the select list looking for a match

    var allOptions = document.all.item(oControl.id);

    for (i=0; i < allOptions.length; i++){
       // Gets the next item from the listbox
       nextOptionText = allOptions(i).text.toUpperCase();

       // By default, the values in the listbox and as entered by the  
       // user are strings. This causes a string comparison to be made, 
       // which is not correct for numbers (1 < 11 < 2).
       // The following lines coerce numbers into an (internal) number 
       // format so that the subsequent comparison is done as a 
       // number (1 < 2 < 11).

       if(!isNaN(nextOptionText) && !isNaN(toFind) ){
              nextOptionText *= 1;        // coerce into number
              toFind *= 1;
       }

        // Does the next item match exactly what the user typed?
        if(toFind == nextOptionText){
            // OK, we can stop at this option. Set focus here
            oControl.selectedIndex = i;
            window.event.returnValue = false;
            break;
        }

        // If the string does not match exactly, find which two entries 
        // it should be between.
        if(i < allOptions.length-1){

           // If we are not yet at the last listbox item, see if the 
           // search string comes between the current entry and the next 
           // one. If so, place the selection there.

           lookAheadOptionText = allOptions(i+1).text.toUpperCase() ;
           if( (toFind > nextOptionText) && 
              (toFind < lookAheadOptionText) ){
              oControl.selectedIndex = i+1;
              window.event.cancelBubble = true;
               window.event.returnValue = false;
              break;
           } // if
           } // if

        else{

           // If we are at the end of the entries and the search string 
           // is still higher than the entries, select the last entry

           if(toFind > nextOptionText){
               oControl.selectedIndex = allOptions.length-1 // stick it 
                                                            // at the end
               window.event.cancelBubble = true;
               window.event.returnValue = false;
               break;
           } // if
       } // else
    }  // for
} // function