

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


function cap_qdn(){
	//document.write('<div id="cabecera"><h1><a href="/pprogrames/qdn/qdnSeccio.jsp"></a></h1></div>');
	document.write('<div id="cabecera"><h1><a href="http://www.tv3.cat/quartsdenou"></a></h1></div>');

}

function menuhome(){
document.write("<ul>"+
"<li id=\"li-1\"><a href=\"http://www.tv3.cat/quartsdenou/videos \">Tots els videos </a></li>"+
"<li id=\"li-2\"><a href=\"http://www.tv3.cat/quartsdenou/agenda\">Reserva plaça </a></li>"+
"<li id=\"li-3\"><a href=\"http://www.tv3.cat/quartsdenou/ranquing\">La faixa i la lliga </a></li>"+
"<li id=\"li-4\"><a href=\"http://www.tv3.cat/quartsdenou/imatges\">Les teves imatges </a></li>"+
"<li id=\"li-5\"><a href=\"http://www.facebook.com/quartsdenou\" target=\"_blank\">El facebook </a></li>"+
"<li id=\"li-6\"><a href=\"http://www.tv3.cat/quartsdenou/vincles\">Enllaços </a></li>"+
"<li id=\"li-7\"><a href=\"/quartsdenou/programa\">El programa </a></li>"+
"<li id=\"li-8\"><a href=\"/quartsdenou/equip\">L'Equip </a></li>"+
"<li id=\"li-9\"><a href=\"/quartsdenou/contacta\">Contacte </a></li>"+
"<li id=\"li-10\"><a href=\"/quartsdenou\">Inici </a></li>"+
"</ul>")
}


function peu_qdn()
{
document.write ("<div id=\"pie\"><h5 id=\"ccrtv\"><a href=\"http://www.ccrtvi.cat\">ccrtv interactiva</a></h5><h5 id=\"tvdcat\"><a href=\"http://www.tv3.cat\">Televisi&oacute; de Catalunya </a></h5><h6>&copy; CCRTV Interactiva, S.A. | Televisi&oacute; de Catalunya, S.A. <br /><a href=\"http://www.tv3.cat/quartsdenou/mapa_web.htm\">Mapa Web</a> | <a href=\"http://www.tv3.cat/avis\">  Av&iacute;s&nbsp;Legal</a> | <a href=\"javascript:void(null);\" onclick=\"window.open('http://www.tv3.cat/iqua/', 'iqua', 'width=430,height=400,top=100,left=200');\">Segell de qualitat</a> | <a href=\"http://www.tv3.cat/quartsdenou/interior_contacte.htm\">Atenció a l'Audiència<img height='13' width='11' alt='Contacta' src='http://www.ccma.cat/atencio/img/logoatencio_peu.gif' border='0'/></a></h6></div>");
document.write("<script src=\"http://www.tv3.cat/js/tvc/ojd.js\"></script>");

}

var videoId;

/*function insetarVideo(id, width, height){
	var ConfigData = new Object()
		ConfigData.VIDEO_ID =					id;
		if(width!=null){
			ConfigData.WIDTH =						width;
		}else{
			ConfigData.WIDTH =						245;
		}
		if(width!=null){
			ConfigData.HEIGHT =						height-37;
		}else{
			ConfigData.HEIGHT =						200;
		}
		ConfigData.HEIGHT =						200;
		ConfigData.USE_RIGHTCLICKMENU = "true";
		ConfigData.USE_CRONO = "false";
		ConfigData.HIDE_DEPRECATED_MSG = "true"; 

	  var FlashParams = new Object()
		FlashParams.src = 						"http://www.tv3.cat/svp2/svp2.swf";
		FlashParams.bgcolor = 					"#ffffff";
		if(width!=null){
			FlashParams.width =						width;
		}else{
			FlashParams.width =						245;
		}
		if(width!=null){
			FlashParams.height =						height;
		}else{
			FlashParams.height =						237;
		}
		FlashParams.quality =					"high";
		FlashParams.swLiveConnect =				"true";
		FlashParams.menu =						"true";
		FlashParams.scale =						"noscale";
		FlashParams.salign =					"tl";
		FlashParams.align =						"l";
		FlashParams.allowFullScreen =			"true";

		insertaSVP( "flashcontent", ConfigData , FlashParams )  
}*/

function insetarVideo(id){
	 var flashvars = {};
               flashvars.videoid = id; //TODO: Posar el vídeo que correspon
			  var params = {};
			  var size = {};
			  size.width = "480";
			  size.height = "307";
			  var refName = insertaEVP('flashcontent', flashvars, params, size);
}

function showVideo(int)
{
	currentFoto = int+1;
	insetarVideo(photoCollection.id[currentFoto-1]);
	videoId = photoCollection.id[currentFoto-1];
	carregaComentaris();
	var text = "<p><strong>"+photoCollection.title[currentFoto-1]+"</strong><br/>";
	text += "<p>"+photoCollection.text[currentFoto-1]+"</p>";
	document.getElementById("photoDescripcio").innerHTML = text;
	currentFoto = int+1;
}

function startVideoGallery(int,dataObj)
{
	dataObj=dataObj;
	galleryLenght = dataObj.foto.length;
	if(galleryLenght<1){
		document.getElementById("dospartes").style.display="none";
		document.getElementById("fotos_videos").style.display="none";
		document.getElementById("fletxa_abajo_inferior").style.display="none";
		document.getElementById("notit").style.display="none";
		document.getElementById("comentarios").style.display="none";
		var galleryCode= '<div class="news_items" id="galleryThumbsList">';
		galleryCode += '<div class="no_news_items">No s\'han trobat vídeos</div><div>';
		document.getElementById("scroller").innerHTML = galleryCode;
	}
	else{
		var thumbsToShow = Math.min(maxPhotoDisplay,galleryLenght);
		var galleryCode = '<div class="prev"><img src="/quartsdenou/img/fletxa_tornar.gif" alt="Anterior" border="0" /></div>';
		galleryCode += '<div class="news_items" id="galleryThumbsList">';	
		galleryCode += '<ul>';	
		for(var i=0;i<thumbsToShow;i++){		
			galleryCode += '<li id="f'+i+'"><a href="javascript:ajaxSite_DoHit();showVideo('+i+');"><img src="'+dataObj.foto[i]+'" alt="'+dataObj.alt[i]+'" border="0" /></a></li>'            
		}		
		galleryCode += '</ul>';		
		if(thumbsToShow < galleryLenght){
			galleryCode += '</div><div class="next"><a href="javascript:ajaxSite_DoHit();updateVideoThumbs(\'next\');"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" onmouseover="this.src=\'/quartsdenou/img/fletxa.gif\'"  onmouseout="this.src=\'/quartsdenou/img/fletxa.gif\'" /></a></div>';
		}else{
			galleryCode += '</div><div class="prev"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" /></div>';
		}		
		document.getElementById("scroller").innerHTML = galleryCode;
		showVideo(int);
	}
}



function updateVideoThumbs(which)
{
	
	if(which == "next"){galleryStartIndex++}else{galleryStartIndex--};	
	if(galleryStartIndex > 0){
		var galleryCode = '<div class="prev"><a href="javascript:updateVideoThumbs(\'prev\');"><img src="/quartsdenou/img/fletxa_tornar.gif" alt="Anterior" border="0" onmouseover="this.src=\'/quartsdenou/img/fletxa_tornar.gif\'"  onmouseout="this.src=\'/quartsdenou/img/fletxa_tornar.gif\'" /></a></div>';
	}else{
		var galleryCode = '<div class="prev"><img src="/quartsdenou/img/fletxa_tornar.gif" alt="Anterior" border="0" /></div>';
	}	
	galleryCode += '<div class="news_items" id="galleryThumbsList">';	
	galleryCode += '<ul>';
	var g = 0;	
	for(var i=galleryStartIndex;i<galleryStartIndex+maxPhotoDisplay;i++){		
		galleryCode += '<li id="f'+g+'"><a href="javascript:ajaxSite_DoHit();showVideo('+i+');"><img src="'+photoCollection.foto[i]+'" alt="'+photoCollection.alt[i]+'" border="0" /></a></li>' ;g++;
	}		
	galleryCode += '</ul>';		
	if((galleryStartIndex+maxPhotoDisplay) < galleryLenght){
		galleryCode += '</div><div class="next"><a href="javascript:updateVideoThumbs(\'next\');"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" onmouseover="this.src=\'/quartsdenou/img/fletxa.gif\'"  onmouseout="this.src=\'/quartsdenou/img/fletxa.gif\'" /></a></div>';
	}else{
		galleryCode += '</div><div class="prev"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" /></div>';
		}		
	document.getElementById("scroller").innerHTML = galleryCode;	
}
	
	

function updateVideoGallery(which)
{
	if(which == "next" && currentFoto < galleryLenght){
		currentFoto++;
		showVideo(currentFoto-1);
	}else if(which == "prev" && currentFoto > 1){
		currentFoto--;
		showVideo(currentFoto-1);
	}	
	if((currentFoto-1) >= (galleryStartIndex+maxPhotoDisplay) && (currentFoto-1) < galleryLenght){
		updateVideoThumbs('next');
	}else if((currentFoto-1) <= galleryStartIndex && (currentFoto-1) > 0){
		updateVideoThumbs('prev');
	}
}




function showVideoEspectador(int)
{
	insetarVideo(photoCollection.id[int]);
	currentFoto = int+1;
	document.getElementById("photoTitle").innerHTML = photoCollection.alt[currentFoto-1];
	document.getElementById("photoDescription").innerHTML = "<strong>AUTOR</strong>  "+photoCollection.author[currentFoto-1]+" &bull;  <strong>UBICACIÓ</strong>  "+photoCollection.country[currentFoto-1]+" &bull;  <strong>DATA</strong>  "+photoCollection.data[currentFoto-1];
    document.getElementById("photoLongDesc").innerHTML = photoCollection.desc[currentFoto-1];
}


function updateVideoGalleryEspectador(which)
{
	galleryLenght = photoCollection.foto.length;
	if(which == "next" && currentFoto < galleryLenght){
		currentFoto++;
		showVideoEspectador(currentFoto-1);
	}else if(which == "prev" && currentFoto > 1){
		currentFoto--;
		showVideoEspectador(currentFoto-1);
	}
}

function carregaComentaris(){
	carregaCommenting(videoId);
}

function submitComentaris(form){
	if(document.getElementById("COMMENT_ANON_ID").value==''){
		alert('ATENCIÓ:\nEl camp Usuari no pot ser un valor buit.');
		return false;
	}
	document.getElementById("COMMENT_CONTENT_ID").value=videoId;
	submitCommenting(form);
}

function captchaRandom(){
	return Math.random();
}

function captcha(){
	document.getElementById("imageShared").src='/su/shared/image.jsp?imgId='+captchaRandom();
}

function showPhoto(int)
{
	document.getElementById("fotoGaleria").src = photoCollection.foto[int];
	document.getElementById("galleryIndex").innerHTML = (int+1)+" de "+photoCollection.foto.length;
	currentFoto = int+1;
	var textPhoto =  "<strong>" + photoCollection.alt[currentFoto-1] + "</strong> <br/>";
	textPhoto += " <br/> " + photoCollection.aut[currentFoto-1] + " <br/> " + photoCollection.place[currentFoto-1];
	document.getElementById("photoMain").innerHTML = textPhoto;
    document.getElementById("photoLongDesc").innerHTML = photoCollection.desc[currentFoto-1];
}

function startGallery(int,dataObj)
{
	dataObj=dataObj;
	galleryLenght = dataObj.foto.length;
	var thumbsToShow = Math.min(maxPhotoDisplay,galleryLenght);
	var galleryCode = '<div class="prev"><img src="/quartsdenou/img/fletxa_tornar.gif" alt="Anterior" border="0" /></div>';
	galleryCode += '<div class="news_items" id="galleryThumbsList">';	
	galleryCode += '<ul>';	
	for(var i=0;i<thumbsToShow;i++){		
		galleryCode += '<li id="f'+i+'"><a href="javascript:ajaxSite_DoHit();showPhoto('+i+');"><img src="'+dataObj.foto[i]+'" alt="'+dataObj.alt[i]+' (foto: '+dataObj.aut[i]+')" border="0" /></a></li>'            
		}		
		galleryCode += '</ul>';		
		if(thumbsToShow < galleryLenght){
			galleryCode += '</div><div class="next"><a href="javascript:ajaxSite_DoHit();updateThumbs(\'next\');"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" onmouseover="this.src=\'/quartsdenou/img/fletxa.gif\'"  onmouseout="this.src=\'/quartsdenou/img/fletxa.gif\'" /></a></div>';
		}else{
			galleryCode += '</div><div class="prev"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" /></div>';
			}		
		document.getElementById("scroller").innerHTML = galleryCode;
		document.getElementById("galleryIndex").innerHTML = (int+1)+" de "+galleryLenght;		
	showPhoto(int);
}

function updateThumbs(which)
{
	
	if(which == "next"){galleryStartIndex++}else{galleryStartIndex--};	
	if(galleryStartIndex > 0){
		var galleryCode = '<div class="prev"><a href="javascript:updateThumbs(\'prev\');"><img src="/quartsdenou/img/fletxa_tornar.gif" alt="Anterior" border="0" onmouseover="this.src=\'/quartsdenou/img/fletxa_tornar.gif\'"  onmouseout="this.src=\'/quartsdenou/img/fletxa_tornar.gif\'" /></a></div>';
		}else{
		var galleryCode = '<div class="prev"><img src="/quartsdenou/img/fletxa_tornar.gif" alt="Anterior" border="0" /></div>';
		}	
	galleryCode += '<div class="news_items" id="galleryThumbsList">';	
	galleryCode += '<ul>';
	var g = 0;	
	for(var i=galleryStartIndex;i<galleryStartIndex+maxPhotoDisplay;i++){		
		galleryCode += '<li id="f'+g+'"><a href="javascript:showPhoto('+i+');"><img src="'+photoCollection.foto[i]+'" alt="'+photoCollection.alt[i]+'" border="0" /></a></li>' ;g++;
		}		
		galleryCode += '</ul>';		
		if((galleryStartIndex+maxPhotoDisplay) < galleryLenght){
			galleryCode += '</div><div class="next"><a href="javascript:updateThumbs(\'next\');"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" onmouseover="this.src=\'/quartsdenou/img/fletxa.gif\'"  onmouseout="this.src=\'/quartsdenou/img/fletxa.gif\'" /></a></div>';
		}else{
			galleryCode += '</div><div class="prev"><img src="/quartsdenou/img/fletxa.gif" alt="Anterior" border="0" /></div>';
			}		
		document.getElementById("scroller").innerHTML = galleryCode;	
}

function updateGallery(which)
{
	if(which == "next" && currentFoto < galleryLenght){
			currentFoto++;
			showPhoto(currentFoto-1);
		}else if(which == "prev" && currentFoto > 1){
			currentFoto--;
			showPhoto(currentFoto-1);
		}	
	if((currentFoto-1) >= (galleryStartIndex+maxPhotoDisplay) && (currentFoto-1) < galleryLenght){
			updateThumbs('next');
		}else if((currentFoto-1) <= galleryStartIndex && (currentFoto-1) > 0){
			updateThumbs('prev');
		}
}

function showPhotoEspectador(int)
{
	document.getElementById("fotoGaleria").src = photoCollection.foto[int];
	document.getElementById("galleryIndex").innerHTML = (int+1)+" de "+photoCollection.foto.length;
	currentFoto = int+1;
	var textPhoto =  "<strong>" + photoCollection.alt[currentFoto-1] + "</strong> <br/>";
	textPhoto += " <br/> " + photoCollection.aut[currentFoto-1] + " <br/> " + photoCollection.place[currentFoto-1];
	document.getElementById("photoMain").innerHTML = textPhoto;
    document.getElementById("photoLongDesc").innerHTML = photoCollection.desc[currentFoto-1];
}

function updateGalleryEspectador(which)
{
	galleryLenght = photoCollection.foto.length;
	if(which == "next" && currentFoto < galleryLenght){
			currentFoto++;
			showPhotoEspectador(currentFoto-1);
		}else if(which == "prev" && currentFoto > 1){
			currentFoto--;
			showPhotoEspectador(currentFoto-1);
		}
}

function modificarTemporada(){
var index = document.getElementById("temporada").selectedIndex;
	if(index==0){
		modificarCategoria(7);
	}else if(index==1){
		modificarCategoria(6);
	}else if(index==2){
		modificarCategoria(5);
	}else if(index==3){
		modificarCategoria(4);
	}else if(index==4){
		modificarCategoria(3);
	}else if(index==5){
		modificarCategoria(2);
	}else if(index==6){
		modificarCategoria(1);
	}else{
		modificarCategoria(0);
	}
}

function modificarCategoria(temporada){
	var index = document.getElementById("eleccion").selectedIndex;
	if(temporada!=0){
//		if(index==0){
			document.getElementById("ocat").innerHTML = '<input type="hidden" value="QDN_T'+temporada+'" name="ocat"/>';
//		}else if(index==1){
//			document.getElementById("ocat").innerHTML = '<input type="hidden" value="QDNT'+temporada+'_PROG" name="ocat"/>';
//		}else if(index==2){
//			document.getElementById("ocat").innerHTML = '<input type="hidden" value="QDNT'+temporada+'_MILLOR" name="ocat"/>';
//		}else if(index==3){
//			document.getElementById("ocat").innerHTML = '<input type="hidden" value="QDNT'+temporada+'_EDU" name="ocat"/>';
//		}
	}else{
		var categoria;
		var hiddens = "";
//		if(index==0){
			for(var i=1;i<8;i++){
				hiddens += '<input type="hidden" value="QDN_T'+i+'" name="ocat"/>';
			}
//		}
//		else{
//			if(index==1){
//				categoria = "_PROG";
//			}else if(index==2){
//				categoria = "_MILLOR";
//			}else if(index==3){
//				categoria = "_EDU";
//			}
//			for(var i=1;i<7;i++){
//				hiddens += '<input type="hidden" value="QDN_T'+i+''+categoria+'" name="ocat"/>';
//			}
//		}
		document.getElementById("ocat").innerHTML=hiddens;
	}
	document.cercador.submit();
}

