
////////////////////////////////////////////////////////////////////
///////////////// Submit Form onkeypress (Enter) ///////////////////
////////////////////////////////////////////////////////////////////

// need to add onKeyPress event <input type="text" onKeyPress="checkEnter(event)">
function checkEnter(e){ //e is event object passed from function invocation

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
document.forms[0].submit() //submit the form
return false
}
else{
return true
}

}

////////////////////////////////////////////////////////////////////
///////////////////////// Show/Hide onclick ////////////////////////
////////////////////////////////////////////////////////////////////

//imgout=new Image(9,9);
//imgin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
	//imgout.src="../images/icons/icon_plus_tiny.gif";
	//imgin.src="../images/icons/icon_minus_tiny.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';
			}
		}
	}
}


////////////////////////////////////////////////////////////////////
//////////////////////// Drop Down List ////////////////////////////
////////////////////////////////////////////////////////////////////

function startList(){   
    navRoot = document.getElementById("nav");
	navRootLIs = navRoot.getElementsByTagName("li");
	for (var k=0; k<navRootLIs.length; k++){
		navRootLIs[k].className += " out";
		makeDropDown(navRootLIs[k]);
	}
}

function makeDropDown(node){
    node.onmouseover=function(){
        this.className=this.className.replace(" out", "");
        this.className=this.className.replace("out", "");
        this.className+=" over";
    }
    node.onmouseout=function(){
        this.className=this.className.replace(" over", "");
        this.className=this.className.replace("over", "");
        this.className+=" out";
    }
}

////////////////////////////////////////////////////////////////////
//////////////////////// Rollover Script ///////////////////////////
////////////////////////////////////////////////////////////////////

// needs class="imgover" and will swap for an image with the same name + _o + .ext
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

////////////////////////////////////////////////////////////////////
///////////////////// Clear Text Function  /////////////////////////
////////////////////////////////////////////////////////////////////

// give the input text a placeholder="something"
function activatePlaceholders() {
var detect = navigator.userAgent.toLowerCase();
if (detect.indexOf("safari") > 0) return false;
var inputs = document.getElementsByTagName("input");
for (var i=0;i<inputs.length;i++) {
  if (inputs[i].getAttribute("type") == "text") {
   if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
    inputs[i].value = inputs[i].getAttribute("placeholder");
    inputs[i].onclick = function() {
     if (this.value == this.getAttribute("placeholder")) {
      this.value = "";
     }
     return false;
    }
    inputs[i].onblur = function() {
     if (this.value.length < 1) {
      this.value = this.getAttribute("placeholder");
     }
    }
   }
  }
}
}

// Another version: needs onFocus="cl(this);"
function cl(t){if (t.defaultValue==t.value) t.value = '';}
 
////////////////////////////////////////////////////////////////////
//////////////////// Open Window Function  /////////////////////////
////////////////////////////////////////////////////////////////////

function openNewWindow(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

var window1;
var window2;
function popUp(htmLoc,width,height,theWindow) {
	//window.open(htmLoc, theWindow, 'titlebar=YES,toolbar=NO,width=' + width + ',height=' + height + ',directories=NO,status=YES,scrollbar=no,resizable=YES,menubar=yes');
var winleft = (screen.width / 2) - (width / 2); // center the window right to left
var wintop = (screen.height / 2) - (height / 2); // center the window top to bottom
window.open(htmLoc,"mainwindow","top="+wintop+",left="+winleft+",width="+width+",height="+height+",buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");//YesorNo				
}


////////////////////////////////////////////////////////////////////
////////////////// Call to On Load Functions ///////////////////////
////////////////////////////////////////////////////////////////////

function windowLoad() {
	initRollovers();
	//startList();
}

window.onload = windowLoad;
