var isPopUp = true;

//******************************************************************
// Validates content of fields
//******************************************************************
function checkfield(fieldlabel,fieldname,acceptonly){
var s= new String();
	characters = new RegExp ("[^A-Za-z ]","i");
	numbers = new RegExp ("[^0-9]","i");
	numchar = new RegExp ("[^0-9-^A-Za-z ]","i");
	s = document.form1[fieldname].value;2/2/2006
	result = s.search(eval(acceptonly));
	if (result != -1){
		if (acceptonly == "numchar")
		{
			msg = fieldlabel + " can only contain numbers and characters" + ".";
		}
		else if  (acceptonly == "numbers")
		{
			msg = fieldlabel + " can only contain numbers" + ".";
		}
		else
		{
			msg = fieldlabel + " can only contain characters" + ".";
		}
		document.form1[fieldname].value = ""
		alert(msg);
		document.form1[fieldname].focus();
		return false;
	}
}
//----------------------------------------------------------	
function isFirstNameOK(){
	var field_val=document.form1.firstname.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your first name');
		document.form1.firstname.value=""
		document.form1.firstname.focus();
		return false;
		}
	return true;
}

function isLastNameOK(){
	var field_val=document.form1.lastname.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your last name');
		document.form1.lastname.value=""
		document.form1.lastname.focus();
		return false;
		}
	return true;
}

function isGenderOK(){
	var field_val=document.form1.gender.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please select your gender.');
		document.form1.gender.focus();
		return false;
	}
return true;
}

function isAgeOK(){
	var field_val=document.form1.age.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please select your Age group.');
		document.form1.age.focus();
		return false;
	}
return true;
}

function isZipOK(){
	var field_val=document.form1.zip.value.replace(/[ ]/g, "");
	if (field_val.length<5){
		alert('Please type your postal Zip Code.');
		document.form1.zip.value=""
		document.form1.zip.focus();
		return false;
		}
	return true;
}


function isEMailOK(){
	var emstr;  // e-mail string
	var emstr_confirm;  // e-mail string
	var sht;    // '@' position in e-mail
	var dot;    // '.' position in e-mail
	var Wrongsim='"' + " :*'!%+=;,/#";
	
	emstr=document.form1.email.value.toLowerCase();

	sht=emstr.indexOf('@');
	dot=emstr.indexOf('.');

	if(sht==-1 || dot==-1)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(sht==0||dot==0)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(emstr.charAt(emstr.length-1)=='@'||emstr.charAt(emstr.length-1)=='.')
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(emstr.split('@').length!=2)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(emstr.split('@')[1].indexOf('.')==-1||emstr.split('@')[1].indexOf('.')==0)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	for(i=0;i<emstr.length;i++)
		{
		if(Wrongsim.indexOf(emstr.charAt(i))!=-1)
			{
			alert("Invalid E-mail!\nPlease Type Again.");
			document.form1.email.value="";
			document.form1.email.focus();
			return false;
			}
		}
	return true;
}

function changeObjectVisibility(objectId, newVisibility, newDisplay) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
        styleObject.display = newDisplay;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject


function hideDiv(objectId){
  changeObjectVisibility(objectId,'hidden','none');
}
function showDiv(objectId){
  changeObjectVisibility(objectId,'visible','block');
}


function unhide(divID) {
 var item = document.getElementById(divID);
 if (item) {
 item.className=(item.className=='hidden')?'unhidden':'hidden';
 }
 }
