function mOvr( src,clrOver, clrOverF ) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.className = clrOver;
		//src.children.tags('IMG')[0].src = 'imgs/vacio.gif';
	}
}

function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default'
		src.className = clrIn;
		//src.children.tags('IMG')[0].src = 'imgs/ico_flecha.gif';
	}
}

function mClk(src) {
	if(event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click();
	}
}


function PopUpWindow(sURL,iAncho,iAlto,sScrollbars,sResize,sToolbar,sDirectories,sMenuBar,sStatus,sVentana,sLocation){
	if (!sURL) sURL = 'http://www.berkleyOnline.com';
	if (!iAncho) iAncho = 500
	if (!iAlto) iAlto = 400
	if (!sScrollbars) sScrollbars = 'no'
	if (!sResize) sResize = 'yes'
	if (!sToolbar) sToolbar = 'no'
	if (!sDirectories) sDirectories = 'no'
	if (!sMenuBar) sMenuBar = 'no'
	if (!sStatus) sStatus = 'no'
	if (!sVentana) sVentana = 'no'
	if (!sLocation) sLocation = 'no'
	window.open(sURL,sVentana,'width=' + iAncho + ',height=' + iAlto + ',toolbar=' + sToolbar + ',directories=' + sDirectories + ',menubar=' + sMenuBar + ',status=' + sStatus + ',scrollbars=' + sScrollbars + ',resizable=' + sResize + ',left='+ ((screen.width/2)-(iAncho/2)) +',top='+ ((screen.height/2)-(iAlto/2)) +',location=' + sLocation + '');
}

function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var firstChars=validChars
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom="(" + firstChars + validChars + "*" + ")"
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("La direccion de Email es incorrecta")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
	    alert("La direccion de Email es incorrecta")
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("La direccion de Email es incorrecta")
			return false
		    }
	    }
	    return true
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("La direccion de Email es incorrecta")
	    return false
	}
	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) {
	   alert("La direccion de Email es incorrecta")
	   return false
	}

	if (domArr[domArr.length-1].length==3 && len<2) {
	   var errStr="La direccion de Email es incorrecta"
	   alert(errStr)
	   return false
	}

	return true;
}


function trim(arg) {
	var trimvalue = "";
	arglen = arg.length;
	if (arglen < 1) return trimvalue;
	i = 0;
	pos = -1;
	while (i < arglen) 
	{
		if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) {
			pos = i;
			break;
		}
		i++;
	}
	var lastpos = -1;
	i = arglen;
	while (i >= 0)
	{
		if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) 
		{
			lastpos = i;
			break;
		}
		i--;
	}
	trimvalue = arg.substring(pos,lastpos + 1);
	return trimvalue;
}


function ltrim(arg) 
{
	var trimvalue = "";
	arglen = arg.length;
	if (arglen < 1) return trimvalue;
	i = 0;
	pos = -1;
	while (i < arglen) 
	{
		if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) 
		{
			pos = i;
			break;
		}
		i++;
	}
	trimvalue = arg.substring(pos,arglen-1);
	return trimvalue;
}


function rtrim(arg) {
	var trimvalue = "";
	arglen = arg.length;
	if (arglen < 1) return trimvalue;
	var lastpos = -1;
	i = arglen;
	while (i >= 0) 
	{
		if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) 
		{
			lastpos = i;
			break;
		}
		i--;
	}
	trimvalue = arg.substring(0,lastpos+1);
	return trimvalue;
}



function ComprobarValor(Valor, Caracteres, Objeto)
{
	if(Valor != "" && Valor.length < Caracteres)
	{
		alert("El Campo " + Objeto.name + " deben tener al menos " + Caracteres + " caracteres")
		Objeto.focus()
		return false
	}
	return true
}


function SoloNumerico(e)
{	
	if ((event.keyCode < 48) || (event.keyCode > 57))
		event.keyCode = 0;
}


function isValidDate(dateStr,nomFecha) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	var matchArray = dateStr.match(datePat);
	if (!nomFecha) 
		nomFecha = '' 
	else 
		nomFecha = ' ' + nomFecha
	if (matchArray == null) {
		alert('La fecha' + nomFecha + ' es incorrecta.')
		return false;
	}
	month = matchArray[3];
	day = matchArray[1];
	year = matchArray[4];	
	if (month < 1 || month > 12) {
		alert("El mes debe ser entre 1 y 12");
		return false;
	}
	if (day < 1 || day > 31) {
		alert("El dia debe ser entre 1 y 31");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("El mes "+month+" no tiene 31 dias!")
		return false
	}
	if (month == 2) {
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert("Febrero del " + year + " no tiene " + day + " dias!");
			return false;
		}
	}
	if ((year < 1900) || (year > 2078))
	{
		alert("Debe ingresar un aņo mayor a 1900 y menor a 2078");
		return false;		
	}
	return true;
}

