
function statusmsg(msg) { 
	window.status = msg ; return true 
}

function valiDate(inputDate) {//VALIDA QUE UN INPUT CONTENGA UNA FECHA VALIDA MEDIANTE UNA EXPRESION REGULAR
	var myRegex = new RegExp("^[0-9]{4}\-([0][0-9]|[1][0-2])\-([0-2][0-9]|[3][0-1])$");
	if (inputDate.value.match(myRegex))
		{
		var theDay = Math.round(inputDate.value.substr(8,2));
		var theMonth = Math.round(inputDate.value.substr(5,2));
		var theYear = Math.round(inputDate.value.substr(0,4));
		
		if ((theYear%4 == 0) && (theDay > 29) && (theMonth == 2)) {
			alert ("Fecha incorrecta.");
			return false;
			}
		else if ((theYear%4 != 0) && (theDay > 28) && (theMonth == 2)) {
			alert ("Fecha incorrecta.");
			return false;
			}
		else if ((theDay > 30) && (theMonth == 4 || theMonth == 6 || theMonth == 0 || theMonth == 11)) {
			alert ("Fecha incorrecta.");
			return false;
			}
		else {
			return true;
			}
		}
	else
		{
		alert ("Formato de fecha incorrecto, debe ser yyyy-mm-dd.");
		return false;
		}
}

function date_es(dateValue){//DEVUELVE LA FECHA LARGA EN ESPAŅOL

	fecha = dateValue;
	dia = fecha.getDate();
	dia_semana = fecha.getDay();
	mes = fecha.getMonth();
	ano = fecha.getFullYear();

	nombre_dias = new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	nombre_meses = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");

	document.write(nombre_dias[dia_semana] + " " + dia + " de " + nombre_meses[mes] + " de " + ano);

}


//BEGIN -- FUNCIONES QUE SE UTILIZAN PARA MOVER EL PUNTERO DE SEŅALIZACION EN LA BARRA DE NAVEGACION
function navigation_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=navigation_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function navigation_change(event, grpName) { //v6.0
  var i,img,nbArr,args=navigation_change.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = navigation_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = navigation_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = navigation_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = navigation_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
//FIN -- FUNCIONES QUE SE UTILIZAN PARA MOVER EL PUNTERO DE SEŅALIZACION EN LA BARRA DE NAVEGACION



//BEGIN -- FUNCIONES QUE SE UTILIZAN PARA CONTROLAR LISTAS DESPLEGABLES DEL MENU NAVEGACION

var ie=(document.all) ? 1:0;
var nc=(document.layers) ? 1:0;
var n6=(document.getElementById) ? 1:0;

var estSbM1 = 0;
var estSbM2 = 0;
var estSbM3 = 0;
var estSbM4 = 0;

function MOSubmenu(etqCapa, language)
{ 
  var estcapa = "none";
  if (etqCapa == 'CPPub') {
	if (estSbM1) estcapa = 'block'
	else estcapa = "none";
	estSbM1 = (estSbM1) ? 0:1;
  }
  else
  {	
	if (etqCapa == 'CPPros') {
	  if (estSbM2) estcapa = 'block'
	  else estcapa = "none";
	  estSbM2 = (estSbM2) ? 0:1;
	}
	else
	{
	  if (etqCapa == 'corp') {
		if (estSbM3) estcapa = "none"
		else estcapa = "block";
		estSbM3 = (estSbM3) ? 0:1;
		if (estSbM3){
		   if (language == 'es') visibleSection('ABOGADOS');
		   else  visibleSection('CORPORATE');
		}
  	    else {
			if (language == 'es') visibleSection('PROPIEDAD INTELECTUAL');
			else visibleSection('INTELLECTUAL PROPERTY');
		}
	  }
	  else
	  {
		if (etqCapa == 'pint') {
		  if (estSbM4) estcapa = 'none'
		  else estcapa = "block";
		  estSbM4 = (estSbM4) ? 0:1;
		  if (estSbM4){
			  if (language == 'es')  visibleSection('PROPIEDAD INTELECTUAL');
			  else  visibleSection('INTELLECTUAL PROPERTY')
		  }
		  else{
			  if (language == 'es')  visibleSection('ABOGADOS');
			  else visibleSection('CORPORATE');
		  }
		}
	  }
	}
  }

  if (ie) { document.all[etqCapa].style.display= estcapa; }
  if (n6) { document.getElementById(etqCapa).style.display = estcapa; }
  if (nc) { document.layers[etqCapa].display= estcapa;}
}

function displaya(etqCapa, estcapa){
  if (ie) { document.all[etqCapa].style.display= estcapa; }
  if (n6) { document.getElementById(etqCapa).style.display = estcapa; }
  if (nc) { document.layers[etqCapa].display= estcapa; }

}

function searchButton(name, areaName){
  var lang = "es";
  if ((areaName == 'CORPORATE') || (areaName == 'INTELLECTUAL PROPERTY')){lang = "en";}
  if (ie) { imgclick(document.all[name], lang);}
  if (n6) { imgclick(document.getElementById(name), lang); }
  if (nc) { imgclick(document.layers[name], lang);}

}
var clickedL  = "plus";
var clickedPI = "minus";

function visibleSection(areaName){
  if ((areaName == 'PROPIEDAD INTELECTUAL') || (areaName == 'INTELLECTUAL PROPERTY'))
	{
      displaya('pint', 'block');
      displaya('corp', 'none');
	  estSbM4 = 1 ;
	  estSbM3 = 0 ;
	  clickedL = "plus";
	  searchButton('corporate', areaName);
	  clickedPI = "minus";
	  searchButton('pi', areaName);
	}
  if ((areaName == 'ABOGADOS') || (areaName == 'CORPORATE'))
	{
      displaya('corp', 'block');
      displaya('pint', 'none');
	  estSbM3 = 1 ;
	  estSbM4 = 0 ;
	  clickedL = "minus";
	  searchButton('corporate', areaName);
	  clickedPI = "plus";
	  searchButton('pi', areaName);
    }
}

function imgclick(imgname, language){
  if (imgname.name == 'corporate'){
       if (clickedL == "plus"){imgname.src = "/common/images/box_corporate_title_col_" + language + ".jpg"; }
	   else{ imgname.src = "/common/images/box_corporate_title_exp_" + language + ".jpg";}
   }
   if (imgname.name == 'pi'){ 
       if (clickedPI == "plus"){imgname.src = "/common/images/box_pi_title_col_" + language + ".jpg"; }
       else{ imgname.src = "/common/images/box_pi_title_exp_" + language + ".jpg";}
   }
}
function imgOver(img, newImage){
	 img.src = newImage;
}

function imgOut(img, newImage){
	 img.src = newImage;
}

//END -- FUNCIONES QUE SE UTILIZAN PARA CONTROLAR LISTAS DESPLEGABLES DEL MENU NAVEGACION



function clik(src) {
  if(event.srcElement.tagName=='TD'){
    src.children.tags('A')[0].click();
  	}
  }
function over(src,clrOver) {
  if (!src.contains(event.fromElement)) {
    src.style.cursor = 'hand';
    src.bgColor = clrOver;
  }
}
function out(src,clrIn) {
  if (!src.contains(event.toElement)) {
    src.style.cursor = 'default';
    src.bgColor = clrIn;
  }
}

function open_news(remoteWin){
   remoteWin = window.open( remoteWin, "links", "left=150,top=20,width=640,height=659,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=yes" );
   if (window.focus) {remoteWin.focus()}
}
function open_personal(remoteWin){
   remoteWin = window.open( remoteWin, "links", "left=150,top=50,width=530,height=531,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=yes" );
   if (window.focus) {remoteWin.focus()}
}
function open_contact(remoteWin){
   remoteWin = window.open( remoteWin, "links", "left=150,top=50,width=635,height=620,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=yes" );
   if (window.focus) {remoteWin.focus()}
}
function open_request(remoteWin){
   remoteWin = window.open( remoteWin, "links", "left=150,top=50,width=430,height=395,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=yes" );
   if (window.focus) {remoteWin.focus()}
}
function open_credit(remoteWin){
   remoteWin = window.open( remoteWin, "links", "left=150,top=50,width=385,height=230,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=yes" );
   if (window.focus) {remoteWin.focus()}
}
function open_search(remoteWin){
   remoteWin = window.open( remoteWin, "links", "left=150,top=50,width=635,height=620,toolbar=no,resizable=yes,location=no,menubar=no,scrollbars=yes" );
   if (window.focus) {remoteWin.focus()}
}

function printPage() {
  if (window.print) { window.print();}
  else alert("Lo siento, pero a tu navegador no se le puede ordenar imprimir" +
      " desde la web.");
}

function closePage() {
    window.close();
}
function validateEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {    
    return (false);
  }
}
//FUNCION QUE SE UTILIZA EN EL SHOWHIDE DE LAS PUBLICACIONES
function ShowHide(id) {
	aux = document.getElementById(id).style.display;
	if (aux == 'block')	{aux = 'none';}
	else{aux = 'block';	}
    document.getElementById(id).style.display = aux;
}

