//AGREGAR A FAVORITOS
function agregarfavoritos(){
	title = "Acrocomia Solutions"; 
 	url = "http://www.acrocomiasolutions.com/";
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	} else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}
}

//SUBMENU
function showLayers() { //v3.0
  var i,p,v,obj,args=showLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


/**
 * MISCELANEOS
 *
 */

function has_data(Valor) {
	for (var i=0; i<Valor.length; i++){
		if ((" \t\n\r").indexOf(Valor.charAt(i))==-1) return true;
	}
	return false;
}


/**
 * CONTROL DE ENVIO
 *
 */


function enviar_formulario_contacto(lang,nombre,email,ciudad,pais,mensaje,form_div,respuesta_div){
	if(lang == "es_"){
		mensaje_enviado			= "<b>Mensaje Enviado!</b><br />En breve contactaremos con Usted.";
		mensaje_no_enviado		= "<b>Mensaje NO Enviado!</b><br />Chequee si completó todos los campos obligatorios, e inténtelo de nuevo.";
		mensaje_no_procesado	= "<b>Mensaje NO Enviado!</b><br />Ocurrió un error durante el procesamiento de su mensaje. Por favor, inténtelo de nuevo.";
		mensaje_no_email		= "<b>La dirección de E-mail es incorrecta!</b><br />El formato debe ser <i>usuario@dominio.extension</i>. Por favor, inténtelo de nuevo.";
		enviando				= "Enviando...";
	}else if(lang == "en_"){
		mensaje_enviado			= "<b>Message Sent!</b><br />Shortly we're going to be in touch with you.";
		mensaje_no_enviado		= "<b>Message NOT Sent!</b><br />Check if you completed correctly every mandatory field, and later try to send it again.";
		mensaje_no_procesado	= "<b>Message NOT Sent!</b><br />An error occured during the proccesing of your message. Please, try to send it again.";
		mensaje_no_email		= "<b>Incorrect E-mail Address!</b><br />The e-mail pattern is <i>user@domain.extension</i>. Please try again.";
		enviando				= "Sending...";
	}else if(lang == "de_"){
		mensaje_enviado			= "<b>Kontakt gesendet!</b><br />Kontakt Sie in Kürze.";
		mensaje_no_enviado		= "<b>gesendete Kontakt!</b><br />Prüfen Sie, ob abgeschlossen alle erforderlichen Felder aus, und versuche es erneut.";
		mensaje_no_procesado	= "<b>gesendete Kontakt!</b><br />Ein Fehler bei der Verarbeitung Ihrer Nachricht. Bitte versuchen Sie es erneut.";
		mensaje_no_email		= "<b>Falsche E-Mail-Adresse!</b><br />Die E-Mail-Muster ist <i>benutzer@domäne.erweiterung</i>. Bitte versuchen Sie es erneut.";
		enviando				= "Senden...";
	}
	
	nombre = document.getElementById(nombre);
	email = document.getElementById(email);
	ciudad = document.getElementById(ciudad);
	pais = document.getElementById(pais);
	mensaje = document.getElementById(mensaje);
	form_div = document.getElementById(form_div);
	respuesta_div = document.getElementById(respuesta_div);
	
	
	respuesta_div.className = 'ajax';
	respuesta_div.innerHTML = enviando;
	
	var exp=new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	var test=exp.test(email.value);
	
	if(has_data(nombre.value) && has_data(email.value) && has_data(mensaje.value) && test){
		agregar = xajax.call("agregar_contacto",{ parameters: [nombre.value,email.value,ciudad.value,pais.value,mensaje.value], mode: 'synchronous' });
		if(agregar == true){
			respuesta_div.className = 'ajax-ok';
			respuesta_div.innerHTML = mensaje_enviado;
			form_div.innerHTML = '';
		}else{
			respuesta_div.className = 'ajax-error';
			respuesta_div.innerHTML = mensaje_no_procesado;
		}
	}else{
		respuesta_div.className = 'ajax-error';
		if(has_data(nombre.value) && has_data(email.value) && has_data(mensaje.value) && !test){
			respuesta_div.innerHTML = mensaje_no_email;
		}else{
			respuesta_div.innerHTML = mensaje_no_enviado;
		}
	}
}


function enviar_comentario(lang,id_noticia,nombre,email,mensaje,form_div,respuesta_div){
	
	if(lang == "es_"){
		comentario_agregado		= "Comentario Agregado!";
		en_breve 				= "En breve será publicado. Gracias.";
		comentario_no_agregado	= "Comentario No Agregado!";
		chequee					= "Chequee si completó correctamente el formulario, e inténtelo de nuevo. Todos los campos son obligatorios.";
		email_incorrecto		= "Dirección de E-mail Incorrecta!";
		email_formato			= "El formato debe ser <i>usuario@dominio.extension</i>. Por favor, inténtelo de nuevo.";
		enviando				= "Enviado...";
	}else if(lang == "en_"){
		comentario_agregado		= "Comment Added!";
		en_breve 				= "It will be published soon. Thank you.";
		comentario_no_agregado	= "Comment Not Added!";
		chequee					= "Check if you filled the form correctly and try again. Every field is mandatory.";
		email_incorrecto		= "Incorrect E-mail Address!";
		email_formato			= "The e-mail pattern is <i>user@domain.extension</i>. Please try again.";
		enviando				= "Sending...";
	}else if(lang == "de_"){
		comentario_agregado		= "Comentario Agregado!";
		en_breve 				= "Es wird in Kürze veröffentlicht. Danke.";
		comentario_no_agregado	= "Kommentar nicht hinzugefügt!";
		chequee					= "Überprüfen Sie, ob Sie das Formular korrekt ausgefüllt und versuche es erneut. Jedes Feld ist zwingend erforderlich.";
		email_incorrecto		= "Falsche E-Mail-Adresse!";
		email_formato			= "Die E-Mail-Muster ist <i>benutzer@domäne.erweiterung</i>. Bitte versuchen Sie es erneut.";
		enviando				= "Senden...";
	}
	
	
	nombre = document.getElementById(nombre);
	email = document.getElementById(email);
	mensaje = document.getElementById(mensaje);
	form_div = document.getElementById(form_div);
	respuesta_div = document.getElementById(respuesta_div);
	
	respuesta_div.className = 'ajax';
	respuesta_div.innerHTML = enviando;
	
	var exp=new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	var test=exp.test(email.value);
	
	if(has_data(nombre.value) && has_data(email.value) && has_data(mensaje.value) && test){
		agregar = xajax.call("agregar_comentario",{ parameters: [id_noticia,nombre.value,email.value,mensaje.value], mode: 'synchronous' });
		if(agregar == true){
			form_div.className = 'ajax-ok';
			form_div.innerHTML = '<b>' + comentario_agregado + '</b><br />' + en_breve;
		}else{
			respuesta_div.className = 'ajax-error';
			respuesta_div.innerHTML = '<b>' + comentario_no_agregado + '</b><br />' + chequee;
		}
	}else{
		respuesta_div.className = 'ajax-error';
		if(has_data(nombre.value) && has_data(email.value) && has_data(mensaje.value) && !test){
			respuesta_div.innerHTML = '<b>' + email_incorrecto + '</b><br />' + email_formato;
		}else{
			respuesta_div.innerHTML = '<b>' + comentario_no_agregado + '</b><br />' + chequee;
		}
	}
}