// JavaScript Document
function PopUp(mypage, myname, w, h, scroll, tool, resize, loc, menubar){
if (navigator.appVersion.indexOf('Mac') != -1 && navigator.appVersion.indexOf('Safari') != -1){
    h+= 9;
    w+= 1;
}
if (navigator.appVersion.indexOf('Mac') != -1 && navigator.appVersion.indexOf('MSIE') != -1){
    h-= 15;
    w-= 15;
}
    var PopUpWin;
    var leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    var topPosition = (screen.height) ? (screen.height-h)/2 : 0;
    var settings = "height = " + h + " ,width = " + w + " ,top = " + topPosition + " ,left = " + leftPosition;
    settings += " ,scrollbars = " + scroll + " ,toolbar = " + tool + " ,resizable = " + resize + " ,location = " + loc + " ,menubar = " + menubar;
    PopUpWin = window.open(mypage, myname, settings);
    //PopUpWin = window.focus();
}
// function for collapsible reference links
function show(list, item_num){
	if (document.getElementById && document.createTextNode){
		m = document.getElementById(list);
		new_display = m.getElementsByTagName("div").item(item_num).style.display;
		if (new_display == "block"){
			new_display="none";
		}else if (new_display=="" || new_display=="none"){
			new_display="block";
		}
		
		m.getElementsByTagName("div").item(item_num).style.display=new_display;
	}
}
// function for collapsible reference links
function showhide(hide, show){
		//show
		m = document.getElementById(hide);
		n = document.getElementById(show);
		//show		
		m.style.display="none";
		//hide
		n.style.display="block";
}

function emailvalidation(text, alertbox){
	with (text){
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2){
			alert(alertbox);
			return false;
		}else{
			return true;
		}
	}
}

function emptyvalidation(text, alertbox){
	with (text){
		if (text.value.length < 3 || text==""){
			alert(alertbox);
			return false;
		}else{
			return true;
		}
	}
}


function formvalidation(form){
	with (form){
		if (emptyvalidation(name,"Please enter your name little buddy...")==false) {
			name.focus(); 
			return false;
		}
		if (emailvalidation(email,"Please a valid email address little buddy...")==false) {
			email.focus(); 
			return false;
		}		
		if (emptyvalidation(message,"Please enter a message little buddy...")==false) {
			message.focus(); 
			return false;
		}
	}
}

