// JavaScript Document
function validEmail(s) {
	good=true;
	if (s.indexOf('"')!=-1 || s.indexOf("'")!=-1) good=false;
	else {
		parts=s.split('@');
		if (parts.length!=2) good=false;
		else {
			uname=parts[0].split('.');
			for (i=0;i<uname.length;i++) {
				if (uname[i].length==0) good=false;
			}
			if (good) { 
				domain=parts[1].split('.');
				if (domain.length>1) {
					for (i=0;i<domain.length;i++) {
						if (i==domain.length-1) {
							if (domain[i].length<2 || domain[i].length>3) good=false;
						} else {
							if (domain[i].length==0) good=false;
						}
					}
				} else good=false;
			}
		}
	}
	return good;
}

function mainNavDropdown(dropdown,show) {
	if (show) {
		document.getElementById('mainNavDropdown'+dropdown).style.display='block';
	} else {
		document.getElementById('mainNavDropdown'+dropdown).style.display='none';
	}
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function showEnlargedImage(src,dimensions,alt) {
	shadowDiv=document.getElementById('popupShadow');
	document.body.style.overflow='hidden';
	shadowDiv.style.width=(document.body.scrollWidth+20)+'px';
	shadowDiv.style.height=(document.body.scrollHeight+20)+'px';
	shadowDiv.style.display='block';
	popupDiv=document.getElementById('enlargedImage');
	//popupDiv.style.width=width+'px';
	//popupDiv.style.height=height+'px';
	if (isNaN(dimensions)) {
		dim=dimensions.split('|');
		width=parseInt(dim[0]);
		height=(dim.length>1)?parseInt(dim[1]):0;
	} else {
		width=dimensions;
		height=0;
	}
	maxHeight=f_clientHeight()-60;
	if (height>maxHeight) {
		ratio=height/maxHeight;
		width=Math.round(width/ratio);
		height=maxHeight;
	}
	if (width==0) {
		imageWidth='';
		alignWidth=800;
		alignHeight=600;
	} else {
		imageWidth=' width="'+width+'"';
		alignWidth=width;
		if (height==0) {
			imageHeight='';
			alignHeight=Math.round((alignWidth/4)*3);
		} else {
			imageHeight=' height="'+height+'"';
			alignHeight=height;
		}
	}
	HTML='<div class="enlargedHeader" align="right"><span style="float:left">'+alt+'&nbsp;</span><a href="javascript:hideEnlargedImage()"><strong>Close</strong></a></div>';
	HTML+='<a href="javascript:hideEnlargedImage()"><img src="'+src+'" alt="'+alt+'" title="'+alt+' - Click to close"'+imageWidth+imageHeight+' border="0" /></a>';
	popupDiv.innerHTML=HTML;
	//href=document.location.href;
	//newTop=(href.indexOf('/elearn.php')>-1)?0:Math.round(f_scrollTop()+(f_clientHeight()-height)/2);
	newTop=Math.round(f_scrollTop()+(f_clientHeight()-alignHeight)/2);
	if (newTop<f_scrollTop()) newTop=f_scrollTop();
	popupDiv.style.top=newTop+'px';
	newLeft=Math.round(f_scrollLeft()+(f_clientWidth()-alignWidth)/2);
	if (newLeft<0) newLeft=0;
	popupDiv.style.left=newLeft+'px';
	popupDiv.style.visibility='visible';
}
function hideEnlargedImage() {
	popupDiv=document.getElementById('enlargedImage');
	popupDiv.innerHTML='&nbsp;';
	popupDiv.style.visibility='hidden';
	popupDiv.style.top='0px';
	popupDiv.style.left='0px';
	//popupDiv.style.width='10px';
	//popupDiv.style.height='10px';
	shadowDiv=document.getElementById('popupShadow');
	shadowDiv.style.width='10px';
	shadowDiv.style.height='10px';
	shadowDiv.style.display='none';
	document.body.style.overflow='auto';
}
