// JavaScript Document
function abrir_ventana(url,l,t,w,h,s){
	window.open(url,'ventana','left=' + l +',top=' + t + ',width=' + w + ',height=' + h + ',scrollbars=' + s);
}

function findObj(theObj, theDoc){
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}

function cambiar_contenido_div(div,contenido){
	var d = findObj(div);
	d.innerHTML=contenido;
}

//Cambiar visibilidad

IE4 = (document.all) ? 1 : 0; // initialize browser.. 
NS4 = (document.layers) ? 1 : 0; // identification and... 
ver4 = (IE4 || NS4) ? 1 : 0; // DHTML variables 


function cambiar_visibilidad_a(i,vis){
	var e = document.getElementById(i);
	e.className=vis;
}

function form_verify(f){
	var i=0;
	for(i=0; i<f.elements.length; i++){
		if(f.elements[i].alt=='MANDATORY' && f.elements[i].value==""){
			alert('Please enter '+f.elements[i].title);
			f.elements[i].focus();
			return(false);
		}
	}
	return(true);
}


function check_email(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
}
function confirmar(mensaje,url){
	if(confirm(mensaje)==true){
		window.location=url;
	}
}
