<!--
///////////////////////////////////////////////////////////////////
//
//	- Modulo de funciones Script para el navegador
//
//	Creado por David González 10/11/2009 | david@dagonsoft.com
//
///////////////////////////////////////////////////////////////////
	
	
	
	//JQUERY
	jQuery.noConflict();

	jQuery(document).ready(function(){ 
		
		jQuery("li").bind('click', function(event){					   
			if(jQuery(this).children().attr("id") != "")
			{
				window.location.href = "?section=" + jQuery(this).children().attr("id");
	  			
			}
			event.stopPropagation();
		}); 
		
		jQuery(".flag").bind('click', function(event){						  
			window.location.href = "?lng=" + jQuery(this).attr("id");
	  		event.stopPropagation();				   
		}); 
		
	});


//////////////////////////////////////////////////////////////////////
//
//	process() - recarga y envia el dormulario con los parametros
//
//////////////////////////////////////////////////////////////////////	
	function process(frm,action,option,id)
	{
		frm = document.getElementById(frm);
		frm.action.value = action;
		frm.option.value = option;
		frm.id.value = id;
		frm.submit();
	}
//////////////////////////////////////////////////////////////////////
//
//	confirmAlert() - Alerta de confirmacion
//
//////////////////////////////////////////////////////////////////////
	function confirmAlert(txt) 
	{ 
		var msg = confirm(txt);
		if (msg) return true;
		else return false ;
	}
//////////////////////////////////////////////////////////////////////
//
//	sendForm() - envia el fomulario de contacto
//
//////////////////////////////////////////////////////////////////////	
	function sendForm(id)
	{
		
		var nom = document.getElementById('nom');
		var cognoms = document.getElementById('cognoms');
		var telefon = document.getElementById('telefon');
		var email = document.getElementById('email');
		var comentaris = document.getElementById('comentaris');
		var err = "";
		
		// validacion de datos
		
		if(nom.value == "")
		{
			err+= "Cal omplir el camp: Nom\n";
		}
		if(cognoms.value == "")
		{
			err+= "Cal omplir el camp: Cognoms\n";
		}
		if(telefon.value == "")
		{
			err+= "Cal omplir el camp: Telefon\n";
		}
		if (email.value == "")
		{
			err+= "Cal omplir el camp: E-mail\n";
		}
		if(comentaris.value == "")
		{
			err+= "Cal omplir el camp: Comentaris\n";
		}
		
		if(err!= "")
		{
			alert(err);
		}
		else
		{
			var url = "../dagonsoft/functions.php?action=sendForm";
			url+= "&nom=" + nom.value;
			url+= "&cognoms=" + cognoms.value;
			url+= "&telefon=" + telefon.value;
			url+= "&email=" + email.value;
			url+= "&comentaris=" + comentaris.value;					
			getRequest(url, 'resposta');
		}
		
		
	}	

//////////////////////////////////////////////////////////////////////
//
//	clearForm() - limpia el fomulario de contacto
//
//////////////////////////////////////////////////////////////////////	
	function clearForm()
	{
		
		document.getElementById('nom').value= '';
		document.getElementById('cognoms').value= '';
		document.getElementById('telefon').value= '';
		document.getElementById('email').value= '';
		document.getElementById('comentaris').value= '';

	}
//////////////////////////////////////////////////////////////////////
//
// 	Funciones para AJAX	
//
//////////////////////////////////////////////////////////////////////	
	function getRequest(url, id_obj)
	{
		var pageRequest = false;
		if (window.XMLHttpRequest)// Mozilla, Safari etc
		{
			pageRequest = new XMLHttpRequest ();
		} 
		else if (window.ActiveXObject)// IE
		{
			try 
			{
				pageRequest = new ActiveXObject ("Msxml2.XMLHTTP");
			}
			catch (e)// old version
			{
				try
				{
					pageRequest = new ActiveXObject ("Microsoft.XMLHTTP");
				}
				catch (e)
				{
				}
			}
		} 
		else
			return false;
		pageRequest.onreadystatechange = function ()
		{
			//if(showPreload)
				//document.getElementById(id_obj).innerHTML = "<img src='img/loading.gif'/>";// imagen de espera
			pageLoad (pageRequest, id_obj);
		}
		pageRequest.open ('GET', url, true);
		pageRequest.send (null);
	}
	
	function pageLoad (pageRequest, id_obj)
	{
		if (pageRequest.readyState == 4 && (pageRequest.status == 200 || window.location.href.indexOf ("http") == - 1))
		{
			document.getElementById (id_obj).innerHTML = pageRequest.responseText;
			showPreload = true;
			////////// esto ejecuta el js del request //////////
			js = pageRequest.responseText.split('<!--JS-->');
			if(js.length>1) eval(js[1]);
		}
	}
	
//-->
