/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function init(idioma){

    //1-Cargar Noticias

    new Ajax.Updater({ success: 'der_noticias'}, idioma+'News',{
        onCreate:function(xhr){
            $('der_noticias').innerHTML="<img src=\"img/43.gif\" />";
        },
        onSuccess:function(response){

       }
    });
//$('FlashID').setStyle('visibility','visible');

}

function showsubs(id){

    //var ars = $$('ul.subs_1');
    $$('ul.subs_'+id).each(function(d){
        d.style.display = 'block';
    });

}


function run(id){

    $('ls_'+id).show();
}

function cerrarAnuncio(){
	$('anuncio').style.display = 'none';
}


function enviarForm(){
	flag = true;

	nombre = $('nombre').value
	correo = $('correo').value
	empresa = $('empresa').value
	contacto = $('contacto').value
	mensaje = $('mensaje').value

	//check nombre
	if(nombre=="" || nombre.length < 2){
		flag= false;
		$('nombre').style.backgroundColor = '#c1c1c1';
	}else{
		$('nombre').style.backgroundColor = '#FFF';
	}




	//check correo
	if(correo=="" || correo.length < 2 || !isValidEmail(correo)){
		flag= false;
		$('correo').style.backgroundColor = '#c1c1c1';
	}else{
		$('correo').style.backgroundColor = '#FFF';
	}


	//check empresa
	if(empresa=="" || empresa.length < 2){
		flag= false;
		$('empresa').style.backgroundColor = '#c1c1c1';
	}else{
		$('empresa').style.backgroundColor = '#FFF';
	}

	//check fono
	if(contacto=="" || contacto.length < 2){
		flag= false;
		$('contacto').style.backgroundColor = '#c1c1c1';
	}else{
		$('contacto').style.backgroundColor = '#FFF';
	}

	//check mensaje
	if(mensaje=="" || mensaje.length < 2){
		flag= false;
		$('mensaje').style.backgroundColor = '#c1c1c1';
	}else{
		$('mensaje').style.backgroundColor = '#FFF';
	}


	if(flag){
		var myAjax = new Ajax.Request("enviar.php", {method: 'post', parameters: {'nombre':nombre,'correo':correo, 'empresa':empresa,'contacto':contacto,'mensaje':mensaje}});
		$('resultado').innerHTML = "<h2>Sus datos han sido enviados. Gracias.</h2>";
	}


}

function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);



}

