// JavaScript Document

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Su email no es válido")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Su email no es válido")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Su email no es válido")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Su email no es válido")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Su email no es válido")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Su email no es válido")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Su email no es válido")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.registro.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Por favor ingrese su email");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	return true
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("cont").getElementsByTagName("DIV");
		if(el.style.display == "none"){
			for (var i=0; i<ar.length; i++){
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}
function ChangeClass(menu, newClass) { 
	 if (document.getElementById) { 
	 	document.getElementById(menu).className = newClass;
	 } 
} 
document.onselectstart = new Function("return true");


function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage,myname,settings)
}


function NewWindowfull(mypage,myname,settings){
w = screen.width-5;
h = screen.height-55;
settings ='height='+h+',width='+w+',top=0,left=0,scrollbars=yes,resizable=yes'
win = window.open(mypage,myname,settings)
}