//<SCRIPT>

//window.onerror = null

var ie4 = (document.all!=null)
var ns4 = (document.layers!=null)



var gSessionTimeout=10	//session timeout, in minutes



function submitForm(){
	if(validate){
		document.form1.submit();
	}
}

function startTimeoutCountdown(){
	//display message one minute before session expires
	setTimeout('sesExpiring()',(gSessionTimeout-1)*60000)
}

function sesExpiring(){
	popWin("../util/timeout.asp",300,150)

}


//handle Netscape resize bug
function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);



function popWin(goURL,w,h,features){
	var featureSTR = 'width=' + w + ",height=" + h
	featureSTR += ",resizable=yes"
	if(features){
		if(features.indexOf("scrollbars")>-1 || features.indexOf("scroll")>-1) { featureSTR+=",scrollbars=yes"  }
		if(features.indexOf("location")>-1 || features.indexOf("address")>-1){ featureSTR+=",location=yes"  }
		if(features.indexOf("menubar")>-1 || features.indexOf("menu")>-1)	{ featureSTR+=",menubar=yes"  }
		if(features.indexOf("status")>-1 || features.indexOf("statusbar")>-1)	{ featureSTR+=",status=yes"  }
		if(features.indexOf("toolbar")>-1 || features.indexOf("tool")>-1)	{ featureSTR+=",toolbar=yes"  }
		if(features.indexOf("all")>-1)		{ featureSTR+=",scrollbars=yes,location=yes,menubar=yes,status=yes,toolbar=yes"  }
	}
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	//center window
	featureSTR+=",top="+wint+",left="+winl

	openPopupWindow(goURL,'poppy',featureSTR)
}

var gNewWindow=null
function openPopupWindow(theURL,winName,features) {
	//stamp random num to end of URL to assure it's refreshed
	theURL=changeURL(theURL); 

	if (!gNewWindow || gNewWindow.closed) {
		gNewWindow = window.open(theURL,winName,features);
	} else {
	// window already exists, so close it and reload new window
	if(gNewWindow){ gNewWindow.close(); }
		gNewWindow = window.open(theURL,winName,features);
	}
	
	gNewWindow.focus();
}


function getFile(id){
	goURL="../util/viewFile.asp?id=" + id
	popWin(goURL,600,500,"scroll,menu,toolbar")
}	

//append date/time to URL to assure that page is refreshed
function changeURL(goURL){
	if(goURL.indexOf("?") < 0)
		goURL = goURL + "?rand=" + ((new Date()).getTime());
	else
		goURL = goURL + "&rand=" + ((new Date()).getTime());
	return goURL;
}

function gotoURL(goURL){
	window.location=changeURL(goURL);
}

function refreshPage(){
	goURL=String(window.location);
	gotoURL(goURL)	;
}


function nothing(){
	//null
}


function alertWin(msg){
	popWin("../util/alert.asp?msg=" + escape(msg),325,120)
	
}

window.defaultStatus = "EduWorkshops";
function winStatus(msg){
	window.status = msg;
}

function goBack(){
	history.go(-1)
}




function getSelectVal(field){
	if(field.selectedIndex==-1) return null;
	else return(field.options[field.selectedIndex].value)
}
function getSelectText(field){
	if(field.selectedIndex==-1) return null;
	return(field.options[field.selectedIndex].text)
}

function setSelectItem(theList,val){
	for(var i=1;i<theList.length;i++){
		if(theList.options[i].value==val){ theList.selectedIndex=i; return }
	}
	theList.selectedIndex=0
}

function deleteRec(){
	var deleteOK = confirm("Are you sure you want to delete this record?")
	if(deleteOK){
		document.form1.mode.value="delete";
		document.form1.submit();
	}
}




function uploadImg(type,targetField,targetCell){
	var goURL = '../util/upload/upload.asp?type=' + type
	if(targetField) { goURL += "&targetField=" + targetField }
	if(targetCell) { goURL += "&targetCell=" + targetCell }
	popWin(goURL,360,175)
}
function RemoveImg(type,targetField,targetCell){
	if(!targetField) { targetField="imageURL" }
	if(!targetCell) { targetCell="picture" }
	eval('document.form1.' + targetField + '.value=""');
	cell = eval('document.all.' + targetCell);
	cell.innerHTML="<a href=\"Javascript:uploadImg('"+type+"','"+targetField+"','"+targetCell+"')\" class=small>Upload Image</a>"
}



function goHome(){
	gotoURL('../home/home.asp')
}

function showPrintLink(){
	if(window.print) { //browser supports javascript print
		document.write('<a href="Javascript:window.print();" class=small>Print</a>');
	}
}


function printThisPage(){
	if(window.print) { //browser supports javascript print
		window.print();
	}
}