// JavaScript Document
function checkContact()
{	
	check = new Array();
	check[0] = new Array(document.getElementById('realname'), "- fullname\n", "");
	check[1] = new Array(document.getElementById('email'), "- email\n", "email");
	check[2] = new Array(document.getElementById('dayphone'), "- dayphone\n", "");	
	
	error = "";
	for(var i=0;i<check.length;i++)
	{
		eField = check[i][0];
		if(check[i][2] == ""){
			eValue = eField.value;
			if(eValue != null){
				eValue = eValue.trim();
				if(eValue.length == 0) error += check[i][1];
			}else{
				error += check[i][1];
			}
		}else if(check[i][2] == 'email'){
			eValue = eField.value;		
			if(eValue.indexOf("@") == -1 || eValue.length <= 3) error += check[i][1];
		}else if(check[i][2] == 'dropdown'){
			if(eField.selectedIndex == 0) error += check[i][1];
		}
	}
	if(error != ""){
		error = "The following fields are required:\n" + error;
		alert(error)
		return false;
	}else{
		return true;
	}
}
String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}