function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


/* popup centrat */
function popup(url,windowname,width,height,features) { 
width=(width)?width:screen.width/2; 
height=(height)?height:screen.height/2; 
var screenX = (screen.width/2 - width/2); 
var screenY = (screen.height/2 - height/2); 
if (features) {
var features= "width=" + width + ",height=" + height + "," + features; 	
} 
else {
var features= "width=" + width + ",height=" + height +",scrollbars=yes,status=no,resizable=no"; 
}
features += ",screenX=" + screenX + ",left=" + screenX; 
features += ",screenY=" + screenY + ",top=" + screenY; 

var mywin=window.open(url, windowname, features); 
if (mywin) 
mywin.focus(); 
return mywin; 
} 



//javascript que obre el popup
function obre_finestra (pagina) {
var opcions="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=508, height=365, top=85, left=140";
window.open(pagina,"",opcions);
}
function obre_finestra_wh (pagina,width,height) {
var opcions="toolbar=no, location=no, directories=no,dialog=yes, status=no, menubar=no, scrollbars=no, resizable=no, width="  + width+ ", height=" + height + ", top=85, left=140";
window.open(pagina,"",opcions);
}

//INICIALITZACIÓ DEL CERCADOR
function ini_cercador(text_defecte){
	id_text = "#text";
	id_form = "#form_cercador";
	//El text agafa el focus
	$(id_text).focus(function () {
		if ($(this).val() == text_defecte) $(this).val("");
	});	
	//El text perd el focus
	$(id_text).blur(function () {
		if ($(this).val() == "") $(this).val(text_defecte);
	});	
	//Enviar el formulari
	$(id_form).submit(function() {
		if (($(id_text).val() == text_defecte) || ($(id_text).val() == "")) return false;
		else return true;
	});
}
