function nwindow(mypage,myname,w,h,scroll,pos)
{
  if (pos=="random")
  {
    LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
    TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
  }
  else if (pos=="center")
  {
    LeftPosition=(screen.width)?(screen.width-w)/2:100;
    TopPosition=(screen.height)?(screen.height-h)/2:100;
  }
  else
  {
    LeftPosition=0;
    TopPosition=20;
  }

  settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
  win=window.open(mypage,myname,settings);

  if(win.focus)
  {
    win.focus();
  }
}

function redimensionar (ancho, alto)
{
  LeftPosition=(screen.width)?(screen.width-ancho)/2:100;
  TopPosition=(screen.height)?(screen.height-alto)/2:100;

  window.moveTo(LeftPosition,TopPosition);
  window.resizeTo(ancho,alto);
  window.focus();
}


function redondear(value, precision)
{
  value = "" + value //convert value to string
  precision = parseInt(precision);

  var whole = "" + Math.round(value * Math.pow(10, precision));
  var decPoint = whole.length - precision;

  if(decPoint != 0)
  {
    result = whole.substring(0, decPoint);
    result += ".";
    result += whole.substring(decPoint, whole.length);
  }
  else
  {
    result = 0;
    result += ".";
    result += whole.substring(decPoint, whole.length);
  }
  return (result);
}


function detenerError(){
return true
}
window.onerror=detenerError


var rector=3
var stopit=0 
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
function verifica_fechas(fechaa,fechab)//si fechaa es mayor que fechab devolverá true, sino false
{ 
	var fecha_uno=new Array;
	var fecha_dos=new Array;
	fecha_uno=fechaa.split('/');
	fecha_dos=fechab.split('/');
	if(fecha_uno[2]<fecha_dos[2]) return false;
	else if(fecha_uno[2]==fecha_dos[2]&&fecha_uno[1]<fecha_dos[1]) return false;
	else if(fecha_uno[2]==fecha_dos[2]&&fecha_uno[1]<=fecha_dos[1]&&fecha_uno[0]<fecha_dos[0]) return false;
	else return true;
	
} 
function quita_marco(Nflash,Tw,Th)
{
//Nflash -> nombre del flash
//Tw -> ancho del video
//Th -> alto del video
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+Tw+"' height='"+Th+"'>");
	document.write("<param name='movie' value='"+Nflash+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<embed src='"+Nflash+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+Tw+"' height='"+Th+"''></embed>");
	document.write("</object>");
}
function emailCheck (emailStr) {
/* Verificar si el email tiene el formato user@dominio. */
var emailPat=/^(.+)@(.+)$/ 

/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 

/* Verifica los caracteres que son válidos en una dirección de email */
var validChars="\[^\\s" + specialChars + "\]" 

var quotedUser="(\"[^\"]*\")" 

/* Verifica si la dirección de email está representada con una dirección IP Válida */ 


var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/


/* Verificar caracteres inválidos */ 

var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
//domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
alert("La dirección de Email debe tener tanto @ como .")
return false
}
var user=matchArray[1]
var domain=matchArray[2]

// Si el user "user" es valido 
if (user.match(userPat)==null) {
// Si no
alert("El nombre de usuario de su email no es válido.")
return false
}

/* Si la dirección IP es válida */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("IP de destino del email inválida.")
return false
}
}
return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("El dominio de su email parece no ser válido.")
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 dicrección debe tener 3 letras si es ."com" o 2 si en de algún pais.");
return false
}*/

if (len<2) {
var errStr="La dirección de email es errónea."
alert(errStr)
return false
}

// La dirección de email ingresada es Válida
return true;
}