/* drop down menus */

function fDOM(obj) {
	if (document.getElementById) return (document.getElementById(obj));
	else return (0);
}
function dropdown(obj,stat) {
	idx=fDOM(obj);
	if (idx) idx.style.visibility=(stat) ? "visible" : "hidden";
}

/* pop up window */

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=450,left=350,top=200');");
}


/* image gallery pop-ups */

var popbackground="fee4ca" 
var windowtitle="Image Window"

function detectexist(obj){
return (typeof obj !="undefined")
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){

function getpos(){
leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
if (window.opera){
leftpos-=screenLeft
toppos-=screenTop
}
}

getpos()
var winattributes='width='+popwidth+',height='+popheight+',resizable=no,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{

jkpopwin.resizeTo(popwidth, popheight+30)
}
jkpopwin.document.open()
jkpopwin.document.write('<html><title>'+windowtitle+'</title><body '+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom: 0.5em"><br>'+textdescription+'</body></html>')
jkpopwin.document.close()
jkpopwin.focus()
}


/* mailing list form validation */

function fnValidate(f) {
	if (f.email.value.length == 0){
		alert('Please enter your Email to continue.');
		f.email.focus();
		return false;
	}
	if (!IsValidEmail(f.email.value)){
		alert('Please enter a valid Email to continue.');
		f.email.focus();
		return false;
	}
	return true;
}

function IsValidEmail(val) {
	var iLen = val.length;
	if 	((iLen < 6) || (val.indexOf('@') < 1) || ((val.charAt(iLen - 3) != '.') && (val.charAt(iLen - 4) != '.') && (val.charAt(iLen - 5) != '.')) ) return false;
	return true;
}

function IsNumeric(val) {
	var ValidChars = "0123456789.-()";
	for (i=0; i<val.length; i++) {
		if (ValidChars.indexOf(val.charAt(i)) == -1) return false;
	}
	return true;
}	


function fnUpdatePayPalForm(oForm){
	oSelect = oForm.elements.os0;
	if (oSelect.selectedIndex < 0) return false;
	
	oOption = oSelect.options[oSelect.selectedIndex];
	
	strAmount = oOption.getAttribute('amount');
	
	oForm.elements.amount.value = strAmount;
	
	return true;
}


