var arrLang = new Array();
arrLang[1] = {
				empresa:"El campo Empresa es obligatorio",
				nombre:"El campo Nombre es obligatorio",
				cargo:"El campo Cargo es obligatorio",
				telefono:"El campo Telefono es obligatorio",
				email:"El campo Email debe tener un valor valido",
				respuesta:"Tu inscripción se realizó con éxito.",
				enviando:"Enviando..."
			 }

arrLang[2] = {
				empresa:"The field Company is required",
				nombre:"The field Name is required",
				cargo:"The field  Position is required",
				telefono:"The field Phone is required",
				email:"The email field must have a valid value",
				respuesta:"Your registration was successful.",
				enviando:"Sending..."
			 }

function enviarInscripcion(){

	var forma = document.forms.inscripcion;
	var session = forma.session.value;
	var msj = "";

	if (forma.empresa.value=="")
		msj += arrLang[session]["empresa"] + "\n";

	if (forma.nombre.value=="")
		msj += arrLang[session]["nombre"] + "\n";

	if (forma.cargo.value=="")
		msj += arrLang[session]["cargo"] + "\n";

	if (forma.telefono.value=="")
		msj += arrLang[session]["telefono"] + "\n";

	if (!validaEmail(forma.email.value))
		msj += arrLang[session]["email"] + "\n";


	if (msj!="")
		alert(msj);
	else{
		 procesoAjaxForm('inscripcion','respuestaInscripcion',arrLang[session]["enviando"]);

		new PeriodicalExecuter(function(pe) {

			//VALIDAMOS ESTE OBJETO PARA HACER REDIRECCION  SELECCIONAR EL PREMIO
			if ($('respuesta')!=null){
				alert(arrLang[session]["respuesta"]);
				closeDialog();
				pe.stop();
			}

		}, 1.5);

	}

}

function validaEmail(email){

	var error = "";
	var regEx = new RegExp("^[\\w\.=-][^+]+@([\\w\-]+\\.)+[a-z]{2,4}$");
	if(!regEx.test(email))
		return false;

	return true;
}

function cambiarEstilo(tipo){

	var indiceCSS = getCookie("indiceCSS");
	var indice;
	indice = 0;
	if (typeof(indiceCSS)=="string");
		indice = parseInt(indiceCSS);


	var obj = $("tamanoTexto");
	var nuevoIndice = 0;

	if (tipo=="+")
		nuevoIndice = indice + 1;
	else if (tipo=="-")
		nuevoIndice = indice - 1;
	else if (tipo=="normal")
		nuevoIndice = 0;


	if (nuevoIndice==0)
		setActiveStyleSheet('normal');
	else if (nuevoIndice>=-3 && nuevoIndice<=3)
		setActiveStyleSheet('estilo' + nuevoIndice);

	if (nuevoIndice>=-3 && nuevoIndice<=3)
		setCookie("indiceCSS", nuevoIndice);


}

function setCookie(name, value, expires, path, domain, secure)
{
  document.cookie =
    name+"="+escape(value)+
    (expires ? "; expires="+expires.toGMTString() : "")+
    (path    ? "; path="   +path   : "")+
    (domain  ? "; domain=" +domain : "")+
    (secure  ? "; secure" : "");
}

// ***** setCookieLT *****
// PARAMETERS: lifetime - cookie lifetime in seconds
function setCookieLT(name, value, lifetime, path, domain, secure)
{
  if (lifetime) lifetime = new Date(Date.parse(new Date())+lifetime*1000);
  setCookie(name, value, lifetime, path, domain, secure);
}

// ***** getCookie *****
function getCookie(name)
{
  var cookie, offset, end;
  cookie  = " "+document.cookie;
  offset  = cookie.indexOf(" "+name+"=");
  if (offset == -1) return undefined;
  offset += name.length+2;
  end     = cookie.indexOf(";", offset)
  if (end    == -1) end = cookie.length;
  return unescape(cookie.substring(offset, end));
}

// ***** delCookie *****
function delCookie(name, path, domain)
{
  if (getCookie(name))
    setCookie(name, "", new Date("January 01, 2000 00:00:01"), path, domain);
}

