//Esta funcion sustituye a las pregeneradas por Dreamweaver
//para el manejo del los efectos de over de las imagenes de los menues
function imageswap(img, gif)
{
  document.images[img].src=gif;
}

var a_img = new Array();
var i = 0;
function addimage(gif)
{ 
  a_img[i] = new Image;
  a_img[i++].src = gif;
}



function displayWindow(url, width, height, scroll)
{
  var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + 'resizable=yes,scrollbars=' + scroll + ',status=no');
}



function goTo(url){
  window.location.href = url;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function backWindow(url)
{
  window.opener.location.href = url;
}


function JumpTo(form)
{
 
 var opcion=form.MenuDerecha.selectedIndex;
 var url=form.MenuDerecha[opcion].value;
 if (url != "#")
   //var Win = window.open(url,"displayWindow");
   window.location.href=url;
}


/********************
Esta función se encarga de ejecutar la validacion de acuerdo a modulo y enviar la forma
si no hubo error
*************/

function EnviarForma(form,idioma){
       
     switch(idioma)
     {   case "esp":
         error = validaEsp(form);
         break;

         case "eng":
         //error = validaEng(form);
		 form.submit()
         break;

      }

 if (!error)
 {
       // alert('enviando forma');
       form.submit();
 }
 
}


/************
Funciones de validación de formularios
*************/
function ValidEmail(item)
{
         var lsAT;
         var lsDOT;

         lsAT = item.value.indexOf("@");
         lsDOT = item.value.indexOf(".");
         IsUltArr = item.value.lastIndexOf("@");
         IsUltPunto = item.value.lastIndexOf(".");
         longitud= (item.value.length -1);
         if (lsAT == -1 || lsDOT == -1 || item.value.indexOf(" ") != -1  || lsAT != IsUltArr || IsUltPunto == longitud) {
            return false;
            }
         return true;
}  



function validaEsp(form)
{
    error=false;
    cadena="";

  if (form.elements['datos[nombre]'].value.length == 0)
  {
     cadena += "El campo Nombre es requerido \n";
     error = true;
  }

 
  if (form.elements['datos[email]'].value.length == 0)
  {
     cadena += "El campo Correo Electrónico es requerido \n";
     error = true;
  }
      else
     if (!ValidEmail(form.elements['datos[email]']))
    {
         cadena += "Dirección de Correo Electrónico no válida \n";
       error = true;
    }
    else
    error=false;

if (form.elements['datos[mensaje]'].value.length == 0)
   {
     cadena += "El campo Mensaje es requerido \n";
     error = true;
   }

form.elements['datos[strtema]'].value = form.elements['datos[tema]'].options [form.elements['datos[tema]'].selectedIndex].text;

 if (error)
    alert (cadena);
  return error;

}


function validaEng(form)
{
    error=false;
    cadena="";

  if (form.elements['datos[nombre]'].value.length == 0)
  {
     cadena += "Field Name is required \n";
     error = true;
  }

 
  if (form.elements['datos[email]'].value.length == 0)
  {
     cadena += "Field E-Mail is required \n";
     error = true;
  }
      else
     if (!ValidEmail(form.elements['datos[email]']))
    {
         cadena += "E-Mail Address not valid \n";
       error = true;
    }
    else
    error=false;

if (form.elements['datos[mensaje]'].value.length == 0)
   {
     cadena += "Field Message is required \n";
     error = true;
   }


 if (error)
    alert (cadena);
  return error;

}

function EnviarAmigo()
{
  document.forma.direccion.value=window.opener.location.href;
  alert(document.forma.direccion.value);
  document.forma.submit();
}
