function toggleShowHide(element){ //show or hide an element
	var ref = document.getElementById(element);
	if(ref.style.display == "none"){
		ref.style.display = "block";	
	}else{
		ref.style.display = "none";
	}
}

function CheckEmail(sEmail){
	str = document.getElementById(sEmail).value;
	var Errors = false;
	var Emailerrors = false;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if(str == ""){
		Emailerrors = true;	
	}
	if (str.indexOf(at)==-1){
	  Emailerrors = true;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   Emailerrors = true;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		Emailerrors = true;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		Emailerrors = true;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		Emailerrors = true;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		Emailerrors = true;
	 }
	
	 if (str.indexOf(" ")!=-1){
		Emailerrors = true;
	 }
	 if(Emailerrors){
		//alert("Sorry, your email address is invalid!");
		alert("Sorry, your email address is invalid!");
		//Errors = true;
		return false;
	 }else{
		return true;	 
	 }
}
function CheckFields(sFields){
	var errors = false;
	var ErrorMsg = "Please enter your:\n\n";
	var temp = 0;
	ElementArr = sFields.split("|");
	for(i=0; i<ElementArr.length; i++){
		if(!document.getElementById(ElementArr[i]).value){
			ErrorMsg += ElementArr[i] + "\n";
			errors = true;
		}
	}
	if(errors == true){
		alert(ErrorMsg);
		//FieldFocus("UserName");
		//document.getElementById("CheckMark").style.display = 'none';
		return false;
	}else{
		if(sFields.indexOf("Email") != -1){
			var validEmail = CheckEmail("Email");
			if(!validEmail){
				return false;	
			}else{
				return true;	
			}
		}else{	
			return true;
		}
	}
}
