var on = '#e8f2b0';
on = '#F9FFD9';
on = '#F6FFED';
on = '#aace50';
on = '#c4cfa7';
on = '#cdd1c3';
var off = '#FFF';
off = '#eff6ec';
var offTemp = '#f4f4f4';
var onTemp = '#f6ffed';

function redireccionar()
  {window.location='/';}

function mostrarSubMenu(ruta,type,direccio)
{
//	window.alert('a');
//	secs = 6000;
	var url = ruta + direccio;
	$.get(url, {},
		 function(html) {
		// window.alert(html);
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				$('#'+type).html(html);
				return;
			}
		}
	);
	//return
}

function onhover(row){
row.style.backgroundColor = on;
}

function offhover(row){
row.style.backgroundColor = off;
}

function onhoverTemp(row){
row.style.backgroundColor = onTemp;
}

function offhoverTemp(row){
row.style.backgroundColor = offTemp;
}


   
function afegirEmoticonComent(emot)
{
  document.formComent.sTexte.value = document.formComent.sTexte.value + emot;
  document.formComent.sTexte.focus();
}

function afegirEmoticonConversa(emot)
{
  document.fresponder.texte.value = document.fresponder.texte.value + emot;
  document.fresponder.texte.focus();
}



function carregarPlana(plana)
{

	if (plana != "-1")
	{
		window.location.href=plana;	
	}
//	window.alert(plana);
}

function irkhaces(id)
{
	var url = 'http://www.khaces.com/khacesid.php?id=' + id;

        $.get(url, {},
                 function(html) {
//window.alert(html);
                        if (html == 'INCORRECTE') {
				window.alert('Imposible encontrar este khaces');
                        }
                        else
                        {
				window.location.href=html;
                        }

                }
        );
        return; 
}

function treureTexteGente()
{
 //      window.alert('a');
 //       window.alert(document.formBuscarGente.sAlies.value);
        if (document.form3.sAlies.value == "Buscar gente...")
        {
                document.form3.sAlies.value = "";
                document.form3.sAlies.focus();
        }

}

function NewPhotoToUpload(fileUploadControl){
            var itemMessageLoading = document.getElementById('ctl00_ContentPlaceHolder1_uie_Loading');
            var itemMessageError = document.getElementById('ctl00_ContentPlaceHolder1_uie_PhotoFileTypeError');
            var itemFileUploader = document.getElementById('ctl00_ContentPlaceHolder1_frm_Photo');
            var fileExtension;
            var fileNameLenght;           
            
            itemMessageLoading.style.display = '';            
            itemMessageError.style.display = 'none';
            fileNameLenght = itemFileUploader.value.length;            
            fileExtension = itemFileUploader.value.substring(fileNameLenght-3,fileNameLenght);
            fileExtension = fileExtension.toUpperCase();
            
            //only image files
            if ((fileExtension!=gifExtension) && (fileExtension!=jpgExtension) && (fileExtension!=bmpExtension)) 
            {                
                itemMessageLoading.style.display = 'none';                
                itemMessageError.style.display = '';
                return;
            }                        
            document.forms[0].submit();
            fileUploadControl.disabled=true;
        }
/*
function connecta4 (type, field, f2)
{
	//$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'estas dins' + '</p></div>'  + '</span>');

	var url = 'login2.php?val=' +  field+'&val2='+f2;
	//window.alert(url);
	var tonto = 'fdsfds';

	$.get(url,  
		 function(html) {
			if (html == 'INCORRECTE') {
				//$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'usuari o password no valid' + '</p></div>'  + '</span>');
				tonto = "jjj";
				return;
			} 
			else 
			{
				//$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'estas dins' + '</p></div>'  + '</span>');
				//$('#'+type2).html('<img src="eliminar.gif" onClick="borrarAmic(\'missatge\',\'' + field + '\',\'checkit\')"/>');
				tonto = "kkk";
				return;
			}
		
		}
	);
	window.alert(tonto);
	return false;
}  
*/

function borrarFoto(id,user)
{
 var url = '/borrarFoto.php?val=' + id;
  $.get(url, {},
              function(html) {
                        if (html == 'NOIDENTIFICAT') {
                                window.alert('Esta foto no puede ser borrada');
                                return;
                        } else {
				mostrarSubMenu('../','contingut','../mostrarFotos.php?val=' + user);	
				window.alert('Foto eliminada.');

			}
	}
  );                               
}

function votarKhaces (type, field, type2,ruta)
{
	
	
	
	var url = ruta + 'votarkhaces.php?val=' +  field;
	//window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				//window.alert('ya lo has votado');
				return;
			} else {
				//window.alert(html);
				$('#'+type).html(html);
				if (type2=='')
				{
				}
				else
				{
					$('#'+type2).html('<img  src="' + ruta + '/imatges/votar0V2.gif" border=0 />');				
				}
				
				
				
				
				//$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Contacto añadido a favoritos' + '</p></div>'  + '</span>');
				//$('#'+type2).html('<a style="cursor:pointer" onClick="borrarFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\');\"><font size=2>  Eliminar como favorito</font>');
				return;
			}
		}
	);
	//return false;
} 


function votarKhaces3 (type, field, type2,ruta)
{
	var url = ruta + 'votarkhaces3.php?val=' +  field;
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				$('#'+type).html(html);
				return;
			}
		}
	);
	//return false;
} 
/*
function votarKhaces (type, field, type2,ruta)
{
	
	
	
	var url = ruta + 'votarkhaces.php?val=' +  field;
	//window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				//window.alert('ya lo has votado');
				return;
			} else {
				//window.alert(html);
				$('#'+type).html(html);				
				
				
				//$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Contacto añadido a favoritos' + '</p></div>'  + '</span>');
				//$('#'+type2).html('<a style="cursor:pointer" onClick="borrarFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\');\"><font size=2>  Eliminar como favorito</font>');
				return;
			}
		}
	);
	//return false;
} 
*/

function votarComentarioPositivo (type, field, type2,ruta)
{
	var url = ruta + 'votarComentario.php?val=' +  field + '&v=1';
//	window.alert(url);	
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
//				window.alert('ya lo has votado');
				return;
			} else {
//				window.alert(html);
				$('#'+type).html(html);				
				return;
			}
		}
	);
} 

function votarComentarioNegativo (type, field, type2,ruta)
{
	var url = ruta + 'votarComentario.php?val=' +  field + '&v=-1';
//	window.alert(url);	
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
//				window.alert('ya lo has votado');
				return;
			} else {
//				window.alert(html);
				$('#'+type).html(html);				
				return;
			}
		}
	);
} 

function borrarFavorit(type, field, type2, ruta)
{
	var url = ruta + 'borrarFavorit.php?val=' +  field;
//	window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Favorito eliminado' + '</p></div>'  + '</span>');
				$('#'+type2).html('<a  style="cursor:pointer" onClick="afegirFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\');\"><img src="' + ruta + 'imatges/favorites.png"  width=16 alt="Añadir a favoritos" title="Añadir a favoritos" onClick="afegirFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\')"/><font size=2> Añadir a favoritos</font size>');
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
}


function borrarFavorit2(type, field, type2, ruta)
{
	var url = ruta + 'borrarFavorit.php?val=' +  field;
//	window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				window.location.reload();
/*				$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Favorito eliminado' + '</p></div>'  + '</span>');
				$('#'+type2).html('<img src="../imatges/favorites.png"  width=32 alt="Añadir a favoritos" title="Añadir a favoritos" onClick="afegirFavorit(\'missatge\',\'' + field + '\',\'checkit\')"/>');*/
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
}
        
function afegirFavorit (type, field, type2,ruta)
{
	var url = ruta + 'grabFavorit.php?val=' +  field;
	//window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				//window.alert('NO');
				return;
			} else {
				//window.alert(html);
				$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Contacto añadido a favoritos' + '</p></div>'  + '</span>');
				$('#'+type2).html('<a style="cursor:pointer" onClick="borrarFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\');\"><font size=2>  Eliminar como favorito</font>');
/*				$('#'+type2).html('<a style="cursor:pointer" onClick="borrarFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\');\"><img src="' + ruta + 'imatges/borraramic.gif" alt="Eliminar como favorito" title="Eliminar como favorit"  width=16 onClick="borrarFavorit(\'missatge\',\'' + field + '\',\'checkit\',\'' + ruta + '\')"/><font size=2> Eliminar como favorito</font>');
				*/
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
} 




function afegirFavoritReload (type, field, type2,ruta)
{
	var url = ruta + 'grabFavorit.php?val=' +  field;
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {				
				return;
			} else {
				//window.alert(html);
				window.location.reload();
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
} 

function afegirBloqueig (type, field, type2,ruta)
{
	var url = ruta + 'grabBloqueig.php?id1=' +  field;
//window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				//window.alert(html);
				$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Contacto marcado como bloqueado' + '</p></div>'  + '</span>');
				$('#'+type2).html('<a style="cursor:pointer" onclick="javascript:borrarBloqueig(\'missatge\',\'' + field + '\',\'checkit4\',\'' + ruta + '\');">Desbloquear usuario</a>');
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
} 

function borrarBloqueig(type, field, type2, ruta)
{
	var url = ruta + 'borrarBloqueig.php?id1=' +  Trim(field);
	//window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'Contacto desbloqueado' + '</p></div>'  + '</span>');
				$('#'+type2).html('<a style="cursor:pointer" onclick="javascript:afegirBloqueig(\'missatge\',\'' + field + '\',\'checkit4\',\'' + ruta + '\');">Bloquear usuario</a>');
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
}

function borrarBloqueigReload(type, field, type2,ruta)
{
	var url = ruta + 'borrarBloqueig.php?id1=' +  Trim(field);
	//window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				window.location.reload();

				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
	return false;
}

function carregarCiutats2 (type, field, type2)
{
	var url = 'poblacionsProvincia?val=' +  field;
	//url = 'grabAmic.php?val=' +  field;
	window.alert(url);
	$.get(url, {}, 
		 function(html) {
			if (html == 'NOIDENTIFICAT') {
				return;
			} else {
				//window.alert(html);
				$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'usuario amigo' + '</p></div>'  + '</span>');
				return;
			}
		//	reportAjaxStats('/check_field');
		}
	);
//	window.alert(html);
	return false;
} 
var glob="inicial";
  function carregarCiutats3(type)
  {
		url="poblacionsProvincia.php?val=1655";
		var a = "respescat";
		$.get(url, function(xml){
							glob=xml;
			//if (xml == 'NOIDENTIFICAT') {
				//window alert("NO");//return;
///			} else {
				//window.alert(html);
				//$('#'+type).html('<span style="color:black">' +  '<div class="notice"><p>' +  'usuario amigo' + '</p></div>'  + '</span>');
//				return;
//window.alert("SI");
//			glob = xml;
			//}
			//window.alert(a);
		})
		window.alert(glob);
  }

function carregarCiutats(type)
{
	// Creamos la variable parametro
parametro = 'Datos pasados por GET';
// Creamos el objeto 
oXML = AJAXCrearObjeto(); 
// Preparamos la petición con parametros
oXML.open('GET', 'pagina.php?parametro=' + escape(parametro)); 
// Preparamos la recepción 
oXML.onreadystatechange = leerDatos; 
// Realizamos la petición 
oXML.send('');  
}

function leerDatos()
{
	window.alert('2');
}




anadirN= new Image(98,100);
//wlAddOffN= new Image(98,100);
//subN= new Image(98,100);


anadirN.src= 'anadir.gif' ;
//wlAddOffN.src= 'http://www.collective2.com/images/whitelabel_off.gif' ;
//subN.src='http://www.collective2.com/images/subscribebutton_off.gif' ;

//hover or rollover image

anadirH= new Image(98,100);
//wlAddOffH= new Image(98,100);
//subH= new Image(98,100);


anadirH.src= 'anadirhover.gif' ;
//wlAddOffH.src= 'http://www.collective2.com/images/whitelabel_hover.gif' ;
//subH.src='http://www.collective2.com/images/subscribebutton_HOVER.gif' ;

function myOn(myImgName) {

document[myImgName].src=eval(myImgName+ 'H' ).src;

}

function myOut(myImgName) {

document[myImgName].src=eval(myImgName+ 'N' ).src;

}

function Trim( str ) {
var resultStr = "";

resultStr = TrimLeft(str);
resultStr = TrimRight(resultStr);

return resultStr;
}

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;

   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

function TrimRight( str ) {
var resultStr = "";
var i = 0;
// Return immediately if an invalid value was passed in
if (str+"" == "undefined" || str == null) 
return null;
// Make sure the argument is a string
str += "";

if (str.length == 0) 
resultStr = "";
else {
// Loop through string starting at the end as long as there
// are spaces.
i = str.length - 1;
while ((i >= 0) && (str.charAt(i) == " "))
i--;

// When the loop is done, we're sitting at the last non-space char,
// so return that char plus all previous chars of the string.
resultStr = str.substring(0, i + 1);
}

return resultStr; 
}


    var http_request = false;


    function makeRequest(url,tipus) {

        http_request = false;
//window.alert('entro al make');
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // Ver nota sobre esta linea al final
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Falla :( No es posible crear una instancia XMLHTTP');
            return false;
        }
		//window.alert('segueixo al make');
		if (tipus=="poblacions")
		{
	        http_request.onreadystatechange = mostrarPoblacionsURL;
		}
		else if (tipus=="provincies")
		{
	        http_request.onreadystatechange = mostrarProvinciesURL;
		}		
		else if ((tipus=="usuaris") || (tipus=="usuaris3") || (tipus=="usuaris1") || (tipus=="usuaris2"))
		{
	        http_request.onreadystatechange = mostrarUsuarisURL;
		}				
		else if (tipus=="foto")
		{
			//alert('Es una foto');
	        http_request.onreadystatechange = mostrarResultatPujarFoto;
		}
		else if (tipus=="borrarComentario")
		{
			//alert(url);
	        http_request.onreadystatechange = mostrarResultatBorrarComentari;
		}
		else if (tipus=="borrarComentario1")
		{
			//alert(url);
	        http_request.onreadystatechange = mostrarResultatBorrarComentari;
		}		
		else if (tipus=="borrarMensaje")
		{
			//alert(url);
	        http_request.onreadystatechange = mostrarResultatBorrarMensaje;
		}			
		else if (tipus=="borrarTema")
		{
			//alert(url);
	        http_request.onreadystatechange = mostrarResultatBorrarTema;
		}			
		else if (tipus=="borrarTema2")
		{
			// Borrar el tema i tornar a lindex
	        http_request.onreadystatechange = mostrarResultatBorrarTema2;
		}	
		else if (tipus=="borrarTema4")
		{
			//alert(url);
	        http_request.onreadystatechange = mostrarResultatBorrarTema4;
		}	
		else if (tipus=="borrarFeed")
		{
			//alert(url);
	        http_request.onreadystatechange = mostrarResultatBorrarFeed;
		}		

		else if (tipus=="addtema")
		{
			// Borrar el tema i tornar a lindex
	        http_request.onreadystatechange = mostrarResultatAddTema;
		}	
		else if (tipus=="addComment")
		{
			// sense ruta
	        http_request.onreadystatechange = mostrarResultatAddComment;
		}			
		else if (tipus=="addComment1")
		{
			// amb un de ruta
	        http_request.onreadystatechange = mostrarResultatAddComment;
		}			
		else if (tipus=="addComment2")
		{
			// amb 3 de ruta
	        http_request.onreadystatechange = mostrarResultatAddComment;
		}			
		else if (tipus=="addPrivat")
		{
		http_request.onreadystatechange = mostrarResultatAddPrivat;
		}
		else if (tipus=="addBloqueig")
		{
			// Borrar el tema i tornar a lindex
	        http_request.onreadystatechange = mostrarResultatAddBloqueig;
		}		
		else if (tipus=="addAbus")
		{
			// Borrar el tema i tornar a lindex
	        http_request.onreadystatechange = mostrarResultatAddAbus;
		}					
		else if (tipus=="perfil")
		{
			// Borrar el tema i tornar a lindex
	        http_request.onreadystatechange = mostrarResultatPerfil;
		}		
		else if (tipus=="conversa")
		{
			// Borrar el tema i tornar a lindex
	        http_request.onreadystatechange = mostrarResultatConversa;
		}				
		//window.alert("La pagina es:" + url);
        http_request.open('GET', url, true);
        http_request.send(null);

    }



    function mostrarPoblacionsURL() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				//$('#poblacions').html('<span style="color:black">' +  '<div class="notice"><p>' +  http_request.responseText + '</p></div>'  + '</span>');
				$('#poblacions').html(http_request.responseText);
if (document.formentrada.selectpa.value > 25)
{
$('#poblacioCopia').html('<input type="text" name="poblacio" id="poblacio" value="' + document.formentrada.poblacio.value + '">');
 $('#poblacions').html('');
 $('#pob').html('');
}
else
{
         $('#pob').html('Poblacion');
}
//                alert(http_request.responseText);
            } else {
//                alert('Hubo problemas con la petición.');
            }
        }

    }
	
    function mostrarUsuarisURL	() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) 
			{
//window.alert(http_request.responseText);
				$('#buscarUsuaris').html(http_request.responseText);
            } else 
			{
            }
        }

    }	
	

    function mostrarProvinciesURL() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				//$('#poblacions').html('<span style="color:black">' +  '<div class="notice"><p>' +  http_request.responseText + '</p></div>'  + '</span>');
				$('#provincies').html(http_request.responseText);
				
				
				//$('#poblacions').html('<select name="poblacio"><option value=-99>Selecciona primero la provincia</select>');
				carregarURL('poblacions');

if (document.formentrada.selectpa.value > 25) 
{
$('#provinciaCopia').html('<input type="text" name="selectp" id="selectp" value="' + document.formentrada.selectp.value + '">');
 $('#provincies').html(''); 
 $('#prov').html('');
/*  $('#poblacions').html(''); 
 $('#pob').html(''); */
//window.alert('new countries');
}
else
{
	 $('#prov').html('Provincia');
	 $('#pob').html('Población');
}
	/*			if (document.formE.selectpa.value != 2)
				{
					$('#provincies').html('');
					$('#prov').html('');
				}
				else
				{
					$('#prov').html('Provincia');
				} */
//				$('#provincies').html('');
				
//                alert(http_request.responseText);
            } else {
//                alert('Hubo problemas con la petición.');
            }
        }

    }	
	
    function mostrarResultatPujarFoto() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				//$('#poblacions').html('<span style="color:black">' +  '<div class="notice"><p>' +  http_request.responseText + '</p></div>'  + '</span>');
				//$('#poblacions').html(http_request.responseText);				
//                alert(http_request.responseText);
alert('ok');
            } else {
				
                alert('Hubo problemas con la petición.');
            }
        }

    }	
	
    function mostrarResultatBorrarComentari() 
	{
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }	
     
    function mostrarResultatBorrarMensaje() 
	{
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }		 
	   

    function mostrarResultatBorrarTema() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }	
        
    function mostrarResultatBorrarTema2() {
	// Borrar el tema i tornar a lindex    
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					javascript:location.href="/";
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }	    



    function mostrarResultatBorrarTema4() {
	// Borrar el tema i tornar a lindex    
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					javascript:location.href="/";
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }	    


    function mostrarResultatBorrarFeed() {
	// Borrar el feed i tornar a carregar la plana del feed    
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					javascript:window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }	    


    function mostrarResultatAddTema() {
	// Borrar el tema i tornar a lindex   
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				var cadena = http_request.responseText;
	//			window.alert("-" + cadena.substr(0,8) + "-");				
				if ((cadena.substr(0,8) == "Correcte"))
				{
	//				window.alert('OK');
					//window.alert(noRecarregar);
if (noRecarregar != '1')
{
                                        url = 'autoindexV2.php';
	//				window.alert(url);
                                 $.get(url, {},
                                         function(html) {
                                            if (html == 'NOIDENTIFICAT') {
                                                        return;
                                            }
                                           else {
                                                temporal = unescape(html);
                                                document.getElementById('contingut').innerHTML = temporal;
                                                document.formQuefas.sNom.value = '';
                                       		document.formQuefas.sNom.className = "estilblanc";
						document.getElementById('enviando2').style.display = 'none';
                                                document.formQuefas.sNom.focus();
                                           }
                                }
                                ); 
}
else
{

//					javascript:location.href="/";
					window.location.reload();
}
				}
				else
				{
					javascript:location.href="/entradaUser.php";
				}
            } else {
					javascript:location.href="/entradaUser.php";
            }
        }
    }	
	
    function mostrarResultatAddAbus() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }


    function mostrarResultatPerfil() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				cadn = http_request.responseText;				
				$('#masinfo').html('<span>' + cadn + '</span>');
				$('#titolmasinfo').html('<span>' + '</span>');	
				
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }

    function mostrarResultatConversa() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				cadn = http_request.responseText;			
				$('#t' + nomSpan).html('<span>' + cadn + '</span>');
				$('#l' + nomSpan).html('<span>' + '<span class=\"linkpetit\"><a href=\"javascript:cerrar(\'' + nomSpan + '\')\">Cerrar conversaci&oacute;n</a></span></span>');
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }
	

    function mostrarResultatAddBloqueig() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }

    function mostrarResultatPeticio() {
//alert(http_request.responseText);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
					window.location.reload();
            } else {
                alert('Hubo problemas con la petición.');
            }
        }
    }
	
	function mostrarResultatAddComment() {
        if (http_request.readyState == 4) {		
            if (http_request.status == 200) {
				var cadena = http_request.responseText;
			//	window.alert(cadena);				
				if (cadena.substr(0,8) == "Correcte")
				{
					url = '../../../autokhacesultimcomentariV2.php?val=' + param + '&lastCom=' + lastCom + '&ruta=' + '3' + '&carrega=1';
				 $.get(url, {},
			                 function(html) {
                        		    if (html == 'NOIDENTIFICAT') {
			                                return;
			                    } 
					   
					   else {
//					window.alert(html);
		                                temporal = unescape(html);
	//				window.alert(temporal.length);	
	//				window.alert(temporal);
						if (temporal.length < 500)
						{
							window.location.reload();
						}
						else
						{
						document.getElementById('contingut').innerHTML = temporal;
						document.formComent.sTexte.value = '';
	//					document.formComent.sTexte.text = '';
						document.formComment.sTexte.focus();
						}
					   }
				}
				); 
//				window.location.reload();
				}
				else
				{
					javascript:location.href="/entradaUser.php";
				}
            } else {
					javascript:location.href="/entradaUser.php";
            }	
		}
	}


function mostrarResultatAddPrivat() {
	if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                     var cadena = http_request.responseText;
//                     window.alert(cadena);
                     if (cadena.substr(0,8) == "Correcte")
                     {
                            url = 'autoPrivatsV2.php?id1=' + jo + '&id2=' + laltre;
//                            window.alert(url);
                            $.get(url, {},
                             function(html) {
                                      if (html == 'NOIDENTIFICAT') {
                                                  return;
                                       }

                                      else {
//                                      window.alert(html);
                                                temporal = unescape(html);
        //                              window.alert(temporal.length);
        //                              window.alert(temporal);
                                        if (temporal.length < 500)
                                        {
                                             window.location.reload()
                                        }
                                        else
                                        {
                                              document.getElementById('mastemes').innerHTML = temporal;
                                              document.fresponder.texte.value = '';
                                              document.formComment.sTexte.focus();
                                        }
                                     }
                                }
                                );
//                              window.location.reload();
                  }
		else 
		{
//window.alert(cadena);
		}
            }
     }
}	

	function carregarURL(tipus)
	{
//		window.alert('carallot');
		var b = "";
		var cadena = "";
		if (tipus=="poblacions")
		{
			b = document.getElementById('selectp').value;
			cadena = "poblacionsProvincia.php?val=" + b;
		}
		else if (tipus=="provincies")
		{
			b = document.getElementById('selectpa').value;
			cadena = "provinciesPais.php?val=" + b;
		}		
		else if (tipus=="foto")
		{
			b = document.getElementById('ctl00_ContentPlaceHolder1_frm_Photo').value;
			window.alert(b);
			cadena = "pujarFoto2.php?val=" + b;
		}
		else if (tipus=="usuaris3")
		{
			b = document.getElementById('sAlies').value;
			cadena = "../../../llistatUsuaris.php?val=" + b + "&ruta=3";
		}		
                else if (tipus=="usuaris")
                {
                        b = document.getElementById('sAlies').value;
                        cadena = "llistatUsuaris.php?val=" + b + "&ruta=0";
                }
                else if (tipus=="usuaris1")
                {
                        b = document.getElementById('sAlies').value;
                        cadena = "../llistatUsuaris.php?val=" + b + "&ruta=1";
                }
                else if (tipus=="usuaris2")
                {
                        b = document.getElementById('sAlies').value;
                        cadena = "../../llistatUsuaris.php?val=" + b + "&ruta=2";
                }


		makeRequest(cadena,tipus);
	}
	
	var nomSpan = "";
	var noRecarregar ="0";
		
	function carregarURL2(tipus,param1,param2)
	{
//		window.alert('carallot' + tipus + param1);
		var continuar = 1;
		var b = "";
		var c = "";
		var d = "";
		var e = "";
		var f = "";


		var cadena = "";
		if (tipus=="poblacions")
		{
			b = document.getElementById('selectp').value;
			cadena = "poblacionsProvincia.php?val=" + b;
		}
		else if (tipus=="foto")
		{
			b = document.getElementById('ctl00_ContentPlaceHolder1_frm_Photo').value;
			window.alert(b);
			cadena = "pujarFoto2.php?val=" + b;
		}
		else if (tipus=="borrarComentario")	
		{
			b = param1;
			c = param2;
//			window.alert(b + '-' + c);
			cadena = "../../../borrarComentario.php?val=" + b + "&tema=" + c;			
		}
		else if (tipus=="borrarComentario1")	
		{
			b = param1;
			c = param2;
//			window.alert(b + '-' + c);
			cadena = "../borrarComentario.php?val=" + b + "&tema=" + c;			
		}
		else if (tipus=="borrarMensaje")	
		{
			b = param1;
			c = param2;
//			window.alert(b + '-' + c);
			cadena = "borrarMensaje.php?val=" + b + "&mensaje=" + c;			
		}		
		else if (tipus=="borrarTema")	
		{
			b = param1;
			c = param2;
			cadena = "borrarkhaces.php?val=" + b + "&Aliesusuari=" + c;			
			//window.alert(cadena);
		}		
		else if (tipus=="borrarTema2")	
		{
			//Borrar tema i tornar a lindex perque ve de la pagina del tema mateix
			b = param1;
			c = param2;
			cadena = "borrarkhaces.php?val=" + b + "&Aliesusuari=" + c;			
		}	
		else if (tipus=="borrarTema3")	
		{
			//Borrar tema i tornar a lindex perque ve de la pagina del tema mateix
			b = param1;
			c = param2;
			tipus = "borrarTema";
			cadena = "../borrarkhaces.php?val=" + b + "&Aliesusuari=" + c;			
		}			
		else if (tipus=="borrarTema4")	
		{
			//Borrar tema i tornar a lindex perque esta a la pagina del tema
			b = param1;
			c = param2;
			cadena = "../../../borrarkhaces.php?val=" + b + "&Aliesusuari=" + c;			
		}	

		else if (tipus=="borrarFeed")	
		{
			//Borrar feed i recargar la plana dels feeds
			b = param1;
			c = param2;			
			cadena = "borrarFeed.php?val=" + b + "&idUsuari=" + c;			
/*			window.alert(cadena);
			return;*/
		}	
/*		elseif (tipus=="votarKhaces")	
		{
			b = param1;
			c = param2;
//			cadena = "votarKhaces.php?val=" + b + "&Aliesusuari=" + c;			
			cadena = "votarKhaces.php?val=" + b;						
			//window.alert(cadena);
		}		
		else if (tipus=="votarKhaces1")	
		{
			//Votar tema amb ruta1
			b = param1;
			c = param2;
			tipus = "votarKhaces";
//			cadena = "../votarKhaces.php?val=" + b + "&Aliesusuari=" + c;			
			cadena = "../votarKhaces.php?val=" + b;
		}			
		else if (tipus=="votarKhaces3")	
		{
			//Votar tema amb ruta3
			b = param1;
			c = param2;
			tipus = "votarKhaces";			
//			cadena = "../../../votarKhaces.php?val=" + b + "&Aliesusuari=" + c;			
			cadena = "../../../votarKhaces.php?val=" + b;		
		}			
*/		
		
		else if (tipus=="addtema")
		{
//			b = document.getElementById('ctl00_ContentPlaceHolder1_frm_Photo').value;
			b = param1;
			c = param2;
			b=b.replace(/^(\s|\&nbsp;)*|(\s|\&nbsp;)*$/g,"");

			if ((b=="") || (b.length < 3))
			{
				{
					document.formQueFas.sNom.focus();
					continuar = 0;
				}				
			}
			if (continuar)
			{
				// Mirar caracters raros
				b = mirarcaractersraros(b);
				cadena = c + "grabTema2.php?val=" + b;

				// que recarregui tota la plana
				// actualitzar el troç nomes va amb la plana principal
	                        if (c!='')
	                        {
	                          noRecarregar = '1';
	        //                      window.alert(noRecarregar);
	                        }
	                        else
	                        {
 //                                       document.formQuefas.sNom.className = "estilverd";
	//				document.formQuefas.sNom.style.bgcolor = "#ff0000";
					document.formQuefas.sNom.value='';
	//                                document.formQuefas.sNom.value = '         ...actualizando...';
					document.getElementById('enviando2').style.display = "block";
//return;
	                        }
			}
		}
		else if (tipus=="addComment")
		{
			b=document.forms[1].iTipusComentari.value;
			c=document.forms[1].idComentat.value;
			d=document.forms[1].sTitol.value;
			e=document.forms[1].sTexte.value;
			e=e.replace('&','and');			
//			replace(e,'&','and');
			f=document.forms[1].id.value;			
			if (e.length <  2)
			{
				window.alert("Hace falta poner algo");
				continuar = 0;
			}				
			cadena = "grabComentari2.php?iTipusComentari=" + b  + "&idComentat=" + c + "&sTitol=" + d + "&sTexte=" + e + "&id=" + f ;
			//window.alert(cadena);
		}		
		else if (tipus=="addComment1")
		{
			b=document.forms[1].iTipusComentari.value;
			c=document.forms[1].idComentat.value;
			d=document.forms[1].sTitol.value;
			e=document.forms[1].sTexte.value;
			e=e.replace('&','and');			
//			replace(e,'&','and');
			f=document.forms[1].id.value;			
			if (e.length <  2)
			{
				window.alert("Hace falta poner algo");
				continuar = 0;
			}				
			cadena = "../grabComentari2.php?iTipusComentari=" + b  + "&idComentat=" + c + "&sTitol=" + d + "&sTexte=" + e + "&id=" + f ;
		}			
		else if (tipus=="addComment2")
		{
			b=document.formComent.iTipusComentari.value;
			c=document.formComent.idComentat.value;
			d=document.formComent.sTitol.value;
			e=document.formComent.sTexte.value;
//			replace(e,'&','and');
			e=e.replace('&','and');	
			f=document.formComent.id.value;			
			if (e.length <  2)
			{
				window.alert("Hace falta poner algo");
				continuar = 0;
			}				
			cadena = "../../../grabComentari2.php?iTipusComentari=" + b  + "&idComentat=" + c + "&sTitol=" + d + "&sTexte=" + e + "&id=" + f ;
			//window.alert(cadena);
		}		
		else if (tipus=="addPrivat")
		{
			b=document.fresponder.texte.value;
			c=document.fresponder.Usuari2.value;
//window.alert(b);
			if (b == "")
			{
				window.alert("Hace falta poner algo");
				continuar = 0;
			}
	//		window.alert(b);
			cadena = "grabMissatgeNou.php?id1=" + c + "&sTexte=" + b;
	//		window.alert(cadena);
		}
		else if (tipus=="addBloqueig")	
		{
			//Bloquejar a un usuari
			b = param1;
			//window.alert(b);
			cadena = "grabBloqueig.php?id1=" + b;			
		}	
/*		else if (tipus=="addBloqueig2")	
		{
			//Bloquejar a un usuari
			b = param1;
			tipus = "addBloqueig";
			cadena = "../grabBloqueig.php?id1=" + b;			
		}	
		else if (tipus=="borrarBloqueig2")	
		{
			//Bloquejar a un usuari
			b = param1;
			tipus = "borrarBloqueig";
			cadena = "../borrarBloqueig.php?id1=" + b;			
		}*/			
		else if (tipus=="addAbus")	
		{
			//Notificar abus
			b = param1;
			c = param2;
			cadena = "grabAbus.php?id1=" + b + "&id2=" + c;			
		}			
		else if (tipus=="addAbus2")	
		{
			//Notificar abus
			b = param1;
			c = param2;
			tipus = "addAbus";			
			cadena = "../grabAbus.php?id1=" + b + "&id2=" + c;			
		}		
		else if (tipus=="perfil")
		{
			b=param1;
			cadena = "../perfil.php?val=" + b;
//			alert(cadena);
		}	
		else if (tipus=="modPerfil")
		{
			//continuar=0;
			b=param1;
			cadena = "../grabPerfil2.php?" + b;
			alert(cadena);
		}
		else if (tipus=="conversa")
		{
			//continuar=0;
			b=param1;
			nomSpan=param2;
			cadena = "../conversaciones_ajax.php?val=" + b;
//			alert(cadena);
		}		
		if (continuar)
			makeRequest(cadena,tipus);
	}	
	
	
	function  mirarcaractersraros(b)
	{
		// 26 &
		// 25 %
		// 23 #
		// 2b +
		// 2d -
		var c = '';
		var i;
		//c = b;
		
		//window.alert('entro' + b[3]);
		for (i=0;i<b.length;i++)
		{
			switch(b.substring(i,i+1))
			{
				case '-': 
					c = c + "%2d"; 
					break;
				case '+': 
					c = c + "%2b"; 
					break;
				case '#': 
					c = c + "%23"; 
					break;
				case '%': 
					c = c + "%25"; 
					break;
				case '&': 
					c = c + "%26"; 
					break;
				default: 
					//window.alert('default:' + b.substring(i,i+1));
					c = c + b.substring(i,i+1);
					break;
			}
		}
		//window.alert(c);
		return c;
	}
	
	
	function votar(a)
	{
		window.alert(a);
	//var url = 'http://localhost/levcoses/ssd.php?type='+type+'&name=' + encodeURIComponent(field.value);
		var url = 'validarusuari.php?sAlies=Manolit53';
		//window.alert(url);
		$.get(url, {}, 
			 function(html) {
				if (html == 'OK') {
					window.alert('OK');
//					$('#'+type+'checkitvalue').html('<span style="color:black">"' + field.value + '": ' + html + '</span>');
	//				form.submit.disabled = 'enabled';
				} else {
										window.alert('MAL');
					//$('#'+type+'checkitvalue').html('<b><span style="color:red">"' + field.value + '": ' + html + '</span></b>');
					//form.submit.disabled = 'disabled';
				}
			//	reportAjaxStats('/check_field');
			}
		);
		return false;
		
	}
	/*
	function mesllarg(a,b)
	{
			if (a.length > b.length) retun a;
			else return b;
	}*/
	function procescarregarFoto(ruta)
	{
		//alert(ruta);
		//$('#carregant').html('<span>' + '<table border=0><tr><td><img src=\"../imatges/waiting4.gif\">' +  '</td><td>Cargando...</td></tr></table></span>');	
		var cadena = '<span><img src=\"' + ruta + 'imatges/waiting4.gif\"><img src=\"' + ruta + 'imatges/waitingCarregant.gif\"></span>';
$('#carregant').html(cadena);			
		return;
	}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


function treureTexte()
{
	//window.alert(document.form1.textBusqueda.value);
	if (document.form1.textBusqueda.value == "   Buscar en Khaces...")
	{
		document.form1.textBusqueda.value = "";
		document.form1.textBusqueda.focus();
	}
	//return;
}

