	function sendSearch () {
		var frmSrch = document.getElementById('cercador');

		if (frmSrch.val.value != '') {
			frmSrch.submit();
		}
	}
	
	function sendSurvey (numRespostes) {
		var frmSurvey = document.getElementById('survey');

		var uri = 'survey_proc.asp?id=' + frmSurvey.idSurvey.value;
		var isEmpty = true;

		for (i=0;i<numRespostes;i++ ) {
			if (frmSurvey.resposta[i].checked) {
				uri += '&r=' + i;
				isEmpty = false;		
			}
		}

		if (isEmpty) {
			alert('per favor, marca alguna de les respostes');
		} else {
			var objSurvey;
			objSurvey = CreateXmlHttpObj();
			
//			alert(uri);

			if (objSurvey) {
				objSurvey.onreadystatechange = function () {
					if (objSurvey.readyState == 1) {				
						document.getElementById('loadingSurvey').style.visibility='visible';
					}

					if(objSurvey.readyState == 4) {

						if(objSurvey.status == 200) {
							document.getElementById('answers').innerHTML = objSurvey.responseText;
//							alert(objSurvey.responseText);
//							document.getElementById('loadingSurvey').style.visibility='hidden';
						} else {
							alert('Código de error: '  + objSurvey.status + '\n\n' + uri);
						}
					}
				}
				objSurvey.open('POST', uri, true );
				objSurvey.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				objSurvey.send('');		
			}
		}
	}

	//-------------------------------------------------------------------------
	
	function checkSocisLogin () {
		var frmSoci = document.getElementById('socisLogin');

		var uri = 'socis_login.asp?usr=' + frmSoci.usr.value + '&pwd=' + frmSoci.pwd.value;

		if ((frmSoci.usr.value == '') || (frmSoci.pwd.value == '')) {
			alert('per favor, escriu l\'usuari i la contrasenya per a validarte');
		} else {
			var objLogin;
			objLogin = CreateXmlHttpObj();
			
			//alert(uri);

			if (objLogin) {
				objLogin.onreadystatechange = function () {
					if (objLogin.readyState == 1) {				
						document.getElementById('loadingSoci').style.visibility='visible';
					}

					if(objLogin.readyState == 4) {

						if(objLogin.status == 200) {
							//alert(objLogin.responseText);
							if (objLogin.responseText == 'OK') {
								document.location.reload();
							} else {
								document.getElementById('loadingSoci').style.visibility='hidden';
								alert('Usuari i/o contrasenya no valids');
								frmSoci.usr.value = '';
								frmSoci.pwd.value = '';
								frmSoci.usr.focus();
							}
						} else {
							alert('Código de error: '  + objLogin.status + '\n\n' + uri);
						}
					}
				}
				objLogin.open('POST', uri, true );
				objLogin.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				objLogin.send('');		
			}
		}
	}

	//-------------------------------------------------------------------------

	function loadOnline(uri, capa, interval) {
		Obj[capa] = CreateXmlHttpObj();

		//alert(uri);

		if(Obj[capa]) {	
			Obj[capa].onreadystatechange = function () {
				if (Obj[capa].readyState == 1) {				
					document.getElementById(capa).innerHTML='<br /><img src=\"img/loading_mini.gif\" border=\"0\" align=\"absmiddle\" />';									
				}

				if(Obj[capa].readyState == 4) {

					if(Obj[capa].status == 200) {
						//alert(Obj[capa].responseText);
						document.getElementById(capa).innerHTML=Obj[capa].responseText;

						if (interval > 0) setTimeout('loadOnline(\'' + uri + '\', \'' + capa + '\', ' + interval + ')', interval);
					}
					else {
						alert('Código de error: '  + Obj[capa].status + '\n\n' + uri);
					}
				}
			}
			Obj[capa].open('POST', uri, true );
			Obj[capa].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			Obj[capa].send('');		
		}
	}

	//--------------------------------------------------------------------------
	
	function sendForm (processFile, obligedFields) {

		var formulario = document.getElementById('formulario');
		var cadenaEnvio = processFile + '?';
		var isOk = true;

		//Comprobacion de campos obligatorios
		//-----------------------------------
		var obligados = obligedFields;
		var noRellenados = '';

		for (var i=0; i<formulario.length; i++) {
			var elemento = formulario.elements[i].name;
			var esObligado = obligados.indexOf(elemento);
			var valor = formulario.elements[i].value;

			if (valor.replace(' ', '') != '') {
				cadenaEnvio += elemento + '=' + valor + '&';
			} 
			else {
				if (esObligado >= 0) {
					isOk = false;
					noRellenados += elemento + ', ';
					//formulario.elements[i].className = 'void';
				}
			}
		}
		//Reemplazamos valores de retorno de carro por html
		//-------------------------------------------------
		cadenaEnvio = cadenaEnvio.replace(/\n/g,'<br />');


		//Comprobacion final y envio por AJAX
		//-----------------------------------
		if (isOk) {
			if (confirm ('dessitges enviar el formulari?')) {

				formulario.submit();

/*				alert('Enviando\n' + cadenaEnvio);
			
				CreateXmlHttpObj();
				
				if(XmlHttpObj) {	
					XmlHttpObj.onreadystatechange = function () {
						if (XmlHttpObj.readyState == 1) {				
							document.getElementById('theForm').innerHTML='<p><br /><img src=\"img/loading_mini.gif\" border=\"0\" align=\"absmiddle\">&nbsp;&nbsp;Enviando datos...</p>';									
						}

						if(XmlHttpObj.readyState == 4) {

							if(XmlHttpObj.status == 200) {			
								document.getElementById('theForm').innerHTML=XmlHttpObj.responseText;
							}
							else {
								alert("Código de error: "  + XmlHttpObj.status);
							}
						}
					}
					XmlHttpObj.open("POST", cadenaEnvio, true );
					XmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
					XmlHttpObj.send('');		
				}
*/
			}  
		} else {
			alert('has d\'omplir els camps obligatoris: ' + noRellenados);
			//alert(cadenaEnvio);
		}

	}

	//-------------------------------------------------------------------------
	
	function sendMenu(enlace) {
//		var edicion = document.getElementById("edicion")

//		if (edicion.ed.value != '') {
//			enlace = enlace + '&ed=' + edicion.ed.value;
//		}

		//alert(enlace);

		document.location = enlace;
	}

	//-------------------------------------------------------------------------

	var Obj = new Array();

	//-------------------------------------------------------------------------


	function loadAjaxCode(uri, capa) {
		Obj[capa] = CreateXmlHttpObj();

		//alert(uri);

		if(Obj[capa]) {	
			Obj[capa].onreadystatechange = function () {
				if (Obj[capa].readyState == 1) {				
					document.getElementById(capa).innerHTML='<br /><img src=\"img/loading_mini.gif\" border=\"0\" align=\"absmiddle\" />';									
				}

				if(Obj[capa].readyState == 4) {

					if(Obj[capa].status == 200) {
						//alert(Obj[capa].responseText);
						//document.getElementById(capa).innerHTML=Obj[capa].responseText;
						SetContainerHTML(capa, Obj[capa].responseText, true);
					}
					else {
						alert('Código de error: '  + Obj[capa].status + '\n\n' + uri);
					}
				}
			}
			Obj[capa].open('POST', uri, true );
			Obj[capa].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			Obj[capa].send('');		
		}
	}

	//================ AJAX Functions =======================

	function CreateXmlHttpObj() {
		try {
			XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try	{
				XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc) {
				XmlHttpObj = null;
			}
		}
			
		if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") {
			XmlHttpObj = new XMLHttpRequest();
		}

		return XmlHttpObj;
	}

	//·········································································

	function SetContainerHTML(id,html,processScripts)
	{
		mydiv = document.getElementById(id);
		mydiv.innerHTML = html;
		if(processScripts!=false) {
			var elementos = mydiv.getElementsByTagName('script');
			for(i=0;i<elementos.length;i++) {
				var elemento = elementos[i];
				nuevoScript = document.createElement('script');
				nuevoScript.text = elemento.innerHTML;
				nuevoScript.type = 'text/javascript';
				if(elemento.src!=null && elemento.src.length>0)
				nuevoScript.src = elemento.src;
				elemento.parentNode.replaceChild(nuevoScript,elemento);
			}
		}
	}

	//============= END AJAX =======================


	function setYesNo(checkObject, valueNo) {
		//var objeto = document.getElementById(checkObject);

		if (checkObject.checked) {
			checkObject.value = 'Si';
		} else {
			checkObject.value = valueNo;
		}
	}