function createNamedWindowEx(page, name, w, h, refresh){
    var xOffset, yOffset, wname, ua;
	if (page == '') 
		return;
	if (w == '') 
	 	w = 640;
	if (h == '') 
	  	h = 480;
	xOffset = 50;
	yOffset = 50;
	wname = name
	if (refresh == '1')
		wname = wname + '_refresh';	
	remote=window.open('',wname,'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=1,toolbar=0,directories=0,status=1,menubar=0,resizable=1'); 	
	temp = "" + page; // temporary holder
	remote.location.href = temp;
	if (remote.opener == null) 
		remote.opener = window; 
	remote.opener.name = "opener";
	remote.focus();  
}
function getObj(name) {
  	if (document.getElementById) {
    	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  	}
  	else if (document.all) {
    	this.obj = document.all[name];
		this.style = document.all[name].style;
  	}
  	else if (document.layers) {
   		this.obj = document.layers[name];
   		this.style = document.layers[name];
  	}
}
function showdiv(nm) {
	var x = new getObj(nm);
	if (!x) return;
	x.style.display='';
}
function hidediv(nm) {
	var x = new getObj(nm);
	if (!x) return;
	x.style.display='none';
}	
function togglediv(nm) {
	var x = new getObj(nm);
	if (!x) return;
	if (x.style.display=='none')
		x.style.display='';
	else
		x.style.display='none'
}
function validateRequired(field, field_name) {
	if(field.value == "") {
		alert(field_name + " is required.");
		field.focus();
	    return false; // bad 
	} 
	return true;
}

function validateRequiredRadio(field, field_name) {
	var counter;
	var radio_choice = false;
	
	for (counter = 0; counter < field.length; counter++) {
		if (field[counter].checked)
			radio_choice = true; 
	}
	if(!radio_choice) {
		alert(field_name + " is required.");
		return false; // bad
	} 
	return true;
}

function validateRequiredDropDown(field, field_name) {
	if (field.options[field.selectedIndex].value == '') {
		alert(field_name + " is required.");
		return false; // bad
	} 
	return true;
}

function validateMaxLength(field, field_name, maxlength) {
	if(field.value.length > maxlength) {
		alert(field_name + " may only be " + maxlength + " characters.");
		field.focus();
	    return false; // bad email
	} 
	return true;
}

function validateEmail(field, field_name) {
	var atCounter = 0;
	var dotCounter = 0;
	var atPlace = 0;
	var dotPlace = 0;

	if(field.value == "") {
		alert(field_name + "is required.");
		field.focus();
	    return false; // bad email
	} 
	for (x=0; x<field.value.length; x++) {
		var oneChar = field.value.charAt(x);
		if (oneChar == "@") {
			atCounter++;
			atPlace = x;
			}
		if (oneChar == ".") {
			dotCounter++;
			dotPlace = x;
			}
	}
	if (atCounter == 0 || dotCounter == 0 || atPlace > dotPlace || dotPlace- atPlace == 1) {
		alert("The value you entered is not a valid E-Mail address.");
		field.focus();
	    return false; // bad email
	}
	return true; // good email
}

function validateEmailForm(form) {
	if (!validateRequired(form.email, 'Email')) {
		return false;
	}
	if (!validateMaxLength(form.email, 'Email', 100)) {
		return false;
	}
	if (!validateEmail(form.email, 'Email')) {
		return false;
	}
	return true;
}
