<!--//
/*
	Created By: Aaron Benton
	Created On: 4/5/2005
	Description: Global Javascript Include
	
	Updated On: 4/20/2005
	Updated By: Aaron Benton
	Changes: Added Form upload extension filter
*/

/*
	Start of Form Upload Extension Function 
*/
//Valid Extensions Array
extArray = new Array(".gif", ".jpg", ".png");
function LimitAttach(form, file) {
	allowSubmit = false;
	if (!file) {
		alert("You must select a file to be uploaded.");
		return;
	}
	while (file.indexOf("\\") != -1) {
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();
	}
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { allowSubmit = true; break; 
		}
	}
	if (allowSubmit) {
		form.submit();
	}
	else {
		alert("Please only upload files that end in types:  " + (extArray.join("  ")) + "\nPlease select a new " + "file to upload and submit again.");
	}
}
/*
	End of Form Upload Extension Function 
*/

//Show/hide "other" box on change
function showHideOther(selectName, otherValue, otherName) {
	if(document.getElementById(selectName).value == otherValue) {
		showItem(otherName);
	} else {
		hideItem(otherName);
	}
	return false;
}
//Show/hide any item by ID
function showItem(showItemID) {
	document.getElementById(showItemID).setAttribute("class", "visibleItem");
	document.getElementById(showItemID).setAttribute("className", "visibleItem");
	return false;
}
function hideItem(hideItemID) {
	document.getElementById(hideItemID).setAttribute("class", "hiddenItem");
	document.getElementById(hideItemID).setAttribute("className", "hiddenItem");
	return false;
}

//Add things to the onLoad
function addLoadEvent(func) {
	//Copied from http://www.webreference.com/programming/javascript/onloads/
	//Function written by Simon Willison (http://simonwillison.net/)
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {	
				oldonload();
			}
			func();
		}
	}
}

function limitText(limitField, limitCount, limitNum) {
	//Copied from http://www.mediacollege.com/internet/javascript/form/limit-characters.html
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

var winOpts = 'toolbar=no,menubar=yes,resizeable=no,scrollbars=yes,left=1,top=10,width=625,height=400,copyhistory=no';

function popUp(pPage) {
	popUpWin = window.open(pPage,'popWin',winOpts);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
	if (ie5&&dragapproved&&event.button==1){
		document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
		document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
	}
	else if (ns6&&dragapproved){
		document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
		document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
	}
}

function initializedrag(e){
	offsetx=ie5? event.clientX : e.clientX
	offsety=ie5? event.clientY : e.clientY
	document.getElementById("dwindowcontent").style.display="none" //extra
	tempx=parseInt(document.getElementById("dwindow").style.left)
	tempy=parseInt(document.getElementById("dwindow").style.top)
	dragapproved=true
	document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
	if (!ie5&&!ns6)
		window.open(url,"","width=width,height=height,scrollbars=1")
	else{
		document.getElementById("dwindow").style.display=''
		document.getElementById("dwindow").style.width=initialwidth=width+"px"
		document.getElementById("dwindow").style.height=initialheight=height+"px"
		document.getElementById("dwindow").style.left="30px"
		document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
		document.getElementById("cframe").src=url
	}
}

function maximize(){
	if (minrestore==0){
		minrestore=1 //maximize window
		document.getElementById("maxname").setAttribute("src","restore.gif")
		document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
		document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
	}
	else{
		minrestore=0 //restore window
		document.getElementById("maxname").setAttribute("src","max.gif")
		document.getElementById("dwindow").style.width=initialwidth
		document.getElementById("dwindow").style.height=initialheight
	}
	document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
	document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
	document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
	dragapproved=false;
	document.getElementById("dwindow").onmousemove=null;
	document.getElementById("dwindowcontent").style.display="" //extra
}


function custom_print() {
    if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            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);
            WebBrowser1.outerHTML = "";
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}

//-->
