
// Browser Detection
var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
var NS4 = (document.layers) ? true : false;
var IEmac = ((document.all)&&(isMac)) ? true : false;
var IE4plus = (document.all) ? true : false;
var IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
var IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
var IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
var IE7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false;
var ver4 = (NS4 || IE4plus) ? true : false;
var NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
	else if  (window.onload)
	{
		if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
		window.onload = f;
}

function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]();
}

/* ************************************************************ */
/*Canviar l'estil en cas de ser explorer*/
function CanviarEstilExplorer(){
 var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == "explorer") a.disabled = false;	  
    }
  }
}

if(IE4 || IE5 || IE6 || IE7) {
	SafeAddOnload(CanviarEstilExplorer);	
}


/* ************************************************************ */
/* contador de caracters*/

function ContadorUpdate(){
	var text_area, contador;
	contador = document.getElementById("contador");
	if(contador != null){
			text_area = document.getElementById("text");
			text_area.onchange = ContadorUpdateText;			
			text_area.onkeyup = ContadorUpdateText;		
			contador.firstChild.nodeValue = 1000;
	}	
}

function ContadorUpdateText(){
	var text_area, contador;
	contador = document.getElementById("contador");
	text_area = document.getElementById("text");
	
	contador.firstChild.nodeValue = 1000 - text_area.value.length;	
}



SafeAddOnload(ContadorUpdate);	


/*****************************************************************/
/* Script per comprovar que un usr no està buit */

function nou_usuari()
{

	if(document.crearusuari.usr.value=="")
		alert("Nom d'usuari incorrecte");
	else
		document.crearusuari.submit();

}

function zoom_img(img)
{
	Reus=window.open("imatge.php?src="+img,"Zoom","scrollbars=no,menubar=no,toolbar=no,resizable=no,status=no,directories=no,location=no,width=10,height=10");

} 


