var contribarray = new Array('Select the type of content that you want to contribute:', 'Applications, Technologies, Events are all examples of categories', 'An subject is some sub-category of information (e.g. COMDEX is an subject under Events)', 'Select the type of content that you want to contribute:', 'Building content is the process of filling in the information for a subject.');
function hdlContrib(sXMLSrc)
{	frmContribute.backtourl.value = window.document.URL;
	
	sSelection = selContrib.value;
	
	if(sSelection == "1")
		frmContribute.action = "../utility/createnewcat.asp";
	else if(sSelection == "2")
		frmContribute.action = "../utility/createnewsub.asp";
	else if(sSelection == "4")
	{	event.returnValue = false;
		//window.navigate("buildcontent.asp?xmlsrc=" + sXMLSrc);
	}
	else
		event.returnValue = false;
		
}
function acomoda_skycrapper()
{
	window.document.getElementById('skycrapper').style.position='absolute';
	window.document.getElementById('skycrapper').style.top=0;
	window.document.getElementById('skycrapper').style.left=(document.body.clientWidth / 2)-425;
}


function abrir_ventana(theURL,w,h) {
	var v_top = (window.screen.height-600)/2;
	var v_left = (window.screen.width-800)/2;
	var windowprops ="top="+v_top+",left="+v_left+",toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=" + w + ",height=" + h; 
	window.open(theURL,"titulo",windowprops);
	
}

function message_box(v_tipo,v_mensaje,v_parametros){
	abrir_ventana("caja_mensaje.asp?men="+v_mensaje+"&"+"tip="+v_tipo+"&"+v_parametros,300,100);
}


function emailCheck (emailStr) {
/* Se establece un patrón para separar el usuario y el dominio */
var emailPat=/^(.+)@(.+)$/
/* La siguiente cadena representa el patrón para todos los caracteres especiales no permitidos*/
var specialChars="\\(\\)<>@,ñÑ·/*+$#!¡¿´%?|{}'ç¨^áéíóúº&\ª=üÿÁÉÍÓÚÜ;:~\\\\\\\"\\.\\[\\]"
/* La siguiente cadena representa el patrón para los carácteres válidos*/
var validChars="\[^\\s" + specialChars + "\]"
/* El siguiente patrón permite direcciones entrecomilladas para cuando se usan espacios */
var quotedUser="(\"[^\"]*\")"
/* El siguiente patrón permite formatos de dominio por dirección IP */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* La cadena atom representa un grupo de caracteres válidos*/
var atom=validChars + '+'
/* La cadena representa un carácter de cadena no entrecomillado */
var word="(" + atom + "|" + quotedUser + ")"
/* El siguiente patrón describe la estructura del usuario */
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* El siguiente patrón describe la estructura del dominio */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

/* Ahora se procede a revisar la cadena suministrada */

/* La cadena se parte en dos para analizar el usuario y el dominio */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Se activa sí es que hay más @ de lo normal o simplemente no existen */
	alert("La dirección e-mail parece incorrecta (verifique su @)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// Se procede a validar el usuario 
if (user.match(userPat)==null) {
    // Si el usuario no es válido
    alert("El nombre de la dirección no es válido.")
    return false
}

/* Si el dominio es de tipo IP se procede a validar. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // Entonces es dirección IP
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("La dirección IP del dominio no es válida.")
		return false
	    }
    }
    return true
}

// Si el dominio es por nombre
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("El nombre del dominio no es válido.")
    return false
}

/* Si el nombre del dominio es válido, se procede a revisar como finaliza con 3 letras (gob, com, etc.) o con 2 letras (uk, mx, etc.). */

/* Se procede a partir el nombre del dominio */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // La dirección debe terminar en 2 o 3 letras
   alert("La dirección del dominio debe terminar en 3 letras (gob, edu, com) o en 2 letras para el país (mx, uk, co).")
   return false
}

// Se re.
if (len<2) {
   var errStr="La dirección del dominio no tiene declarado un nombre de servidor"
   alert(errStr)
   return false
}

// si no existe ningún error, es válida
return true;
}
