/*Shadowbox.init({
			displayNav : false,
			showOverlay : true,
			overlayColor : "#272727"
		});*/

	//------ START SHOW LOGIN FORM
        // It is used to print LogOut button and form. It is possible to customize it.
	function showLogin(divId, frmId, serviceId) {
		if (nick != null) {
			var lc = '<a href="javascript:doLogout(\''
					+ frmId
					+ 'Out\',\''
					+ frmId
					+ 'OutService\')" title="Tanca sessió"  class="noborder nopaddingright">Surt</a>'
					+ '<form name="' + frmId + 'Out" id="' + frmId + 'Out" action="' + URL_CAS_SECURE_LOGOUT + '" method="get">'
					+ '<input type="hidden" name="gateway" value="true" />'
					+ '<input type="hidden" id="' + frmId + 'OutService" name="service" value="" /></form>';
			
			
			var ctrl = document.getElementById(divId);
			if (ctrl != null) {
				ctrl.innerHTML = lc;
			}
			document.getElementById('preloginlink').style.display="none";
			
			//afegim control pels concursos
			var divConcurs = document.getElementById("inici_sessio_concurs");
			if (divConcurs != null) {
				hideElement("inici_sessio_concurs");
				showElement("envia_item_concurs");
			}
			
			doGetUserData('divDadesUsuari',"showLoginComenting();limitedText();");
			
		} else {
			showLoginComenting();
		}
	}
	
	function limitedText(){		
		var ccrtvi_nom_cognom = ccrtvi_nom + ' ' + ccrtvi_cognom;
		if (ccrtvi_nom_cognom.length>23) $("a","#divDadesUsuari").html(ccrtvi_nom_cognom.substring(0,21)+'...');
		$("a","#divDadesUsuari").attr({'title': ccrtvi_nom_cognom});
	}

	// ------ END SHOW LOGIN FORM

	// ------ START LOGOUT
  // It is used to logout. Teams will be able to choose between reloading the whole page (this part is commented) or only the 
  // divDadesUsuari and divLogin
	function doLogout(frmId, serviceId) {
		
		var frmLogout = document.getElementById(frmId);
		var ctrlService = document.getElementById(serviceId);
		if (ctrlService!=null) ctrlService.value = escape(window.location);
		
		if (frmLogout!=null) {
			// Refresca página entera
			//frmLogout.action=URL_CAS_SECURE_LOGOUT;
			// frmLogout.submit();
			// Refresca solamente divDadesUsuari y  divLogin (via Ajax)
			var ssoIframe = document.getElementById("logoutFrame");
			ssoIframe.src= URL_CAS_SECURE_LOGOUT;
			
		}
	}
	// ------ END LOGOUT

	// ------ START CLEAN LOGOUT FRAME
  // It is used to clean divLogin and divDadesUsuari. Teams will be able to customize this part, adding what ever they prefer.
  function cleanLogoutIFrame(){ 
		var logoutFrame = document.getElementById("logoutFrame");
		if(logoutFrame.src==URL_CAS_SECURE_LOGOUT){
			var ifrId = document.getElementById("ifrId");
			doValidate('divLogin','frmLogin','ctrlServiceLogin','frmPostIframe','ifrId');

			var divDadesUsuari = document.getElementById("divDadesUsuari");
			divDadesUsuari.innerHTML = "";

			var divLogin = document.getElementById("divLogin");
			divLogin.innerHTML = '<a class="noborder nopaddingright" title=""  rel="shadowbox[maqueta];width=696;height=551;options={ displayNav : false, showOverlay : true, displayCounter : false }" href="http://www.tv3.cat/su/ru/common_login.jsp?hiRegServiceIdParam=TVC_REG" id="logLink"> <span>Inicia sessió</span> </a>'; // NOTA:Cada Equip podrà afegir AQUÍ, el codi html per defecte que vulgui (exemple:inicia sessió)
			
			document.getElementById('preloginlink').style.display="";
			
			//afegim control pels concursos
			var divConcurs = document.getElementById("inici_sessio_concurs");
			if (divConcurs!=null){
				showElement("inici_sessio_concurs");
				hideElement("envia_item_concurs");
			}
			
			logoutFrame.src="";
			Shadowbox.clearCache(); 
			Shadowbox.setup();
		}
	}
 	// ------ END CLEAN LOGOUT FRAME	
	
	function showElement( elementId ) {
		document.getElementById(elementId).style.display="block";
	}
	
	function hideElement( elementId ) {
		document.getElementById(elementId).style.display="none";
	} 
	
	function showLoginComenting() {}

