function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function confirmar()
{
	var resp = confirm("Realitzar acci\xf3?");
	
	return resp;
}

function nombre_caracters()
{
       document.forms[0].carac.value=document.forms[0].resum.value.length;
} 

var xmlHttp

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	/*if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}*/

	return xmlHttp;
}

function activa_tema(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("El vostre navegador no suporta HTTP Request")
	return
	}
	var url="tema.php?var=" + encodeURIComponent(str);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange=stateChanged; 
}

function activa_busca(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("El vostre navegador no suporta HTTP Request");
		return;
	}
	var url="buscaper.php?var=" + encodeURIComponent(str);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange=stateChanged2; 
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("subtematica").innerHTML=xmlHttp.responseText; 

	} 
}

function stateChanged2() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("buscaper").innerHTML=xmlHttp.responseText; 
		document.getElementById("subtematica").innerHTML="";
	} 
}

function print_embed(url)
{
	var plugin ="&amp;plugins=embed-1&amp;embed.title=Codi embed del v&iacute;deo.&amp;embed.instruction=Per veure aquest v&iacute;deo a la vostra p&agrave;gina web copieu el codi de sota.&amp;embed.close_text=Tanca finestra&amp;embed.copy_text=Copia text&amp;embed.copied_text=Text copiat&amp;embed.show_window_after_complete=true&amp;embed.code=<embed src='http://elteuvideo.cat/videos/player.swf' width='325' height='244' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' flashvars='file=" + url + "' />";
	
	var codi = "<object width=\"480\" height=\"300\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"> <param name=\"flashvars\" value=\"file=" + url + "\" /> <param name=\"movie\" value=\"http://elteuvideo.cat/videos/player.swf\" /> <param name=\"allowfullscreen\" value=\"true\"/> <param name=\"allowscriptaccess\" value=\"always\"> <embed src=\"http://elteuvideo.cat/videos/player.swf\" width=\"480\" bgcolor=\"#333\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" flashvars=\"file=" + url + plugin +"&amp;backcolor=#cc0001&amp;frontcolor=#ffffff&amp;lightcolor=#ffffff&amp;screencolor=#000000\" /></object>";
	
	return codi;
}

function obrir_reproductor(html, url, nom, descripcio) 
{
	var codi = print_embed(url);
	
	if (descripcio == undefined)
	{
		descripcio = "<br />";
	}
	else
	{
		descripcio = "<p>"+descripcio+"</p>";
	}
	
	var effect = new PopupEffect(html, {className: "popup_effect"});
    var win = new Window({className:"alert", width: 480, resizable:false, draggable:false, minimizable:false, maximizable:false,  showEffect:effect.show.bind(effect), hideEffect:effect.hide.bind(effect)})
    win.getContent().update("<div style='-moz-border-radius-topright:5px; -moz-border-radius-topleft: 5px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px; background: #cc0001; border-bottom: 3px solid #000; padding-top: 7px;'><img src='imatges/logo.png' alt='titol' width='250' height='30'/></div><div>"+codi+"</div>");
    win.showCenter(true);
    win.show();
}  