// LANGUAGES: 1 - CATALÀ , 2 - CASTELLANO , 3 - ENGLISH
if (location.href.indexOf('cat') > -1){
var iqua_id=88;
var iqua_lang=1;
var dir_remoto="http://www.uoc.edu/web/cat/img/";
}else if (location.href.indexOf('esp') > -1){
var iqua_id=88;
var iqua_lang=2;
var dir_remoto="http://www.uoc.edu/web/esp/img/";
}else if (location.href.indexOf('eng') > -1){
var iqua_id=88;
var iqua_lang=3;
var dir_remoto="http://www.uoc.edu/web/eng/img/";
}else{
var iqua_id=88;
var iqua_lang=1;
var dir_remoto="http://www.uoc.edu/web/cat/img/";
}

	function inici(){
	var args = new Object(); 
	var query = location.search.substring(1); 
	var pairs = query.split("&");
	 for (var i = 0; i < pairs.length; i++) { 
	  var pos = pairs[i].indexOf('='); 
	  if (pos == -1) continue; 
	  var argname = pairs[i].substring(0,pos); 
	  var value = pairs[i].substring(pos+1); 
	  args[argname]=value; 
	  if (i==0){
	   document.formu.titol.value=unescape(value);   
	   document.formu.subject.value=unescape(value);   
	   }else if (i==1){
	   document.formu.url.value=unescape(value);   
	  }
	 }
	}

	function correcte(){
	
	email=window.document.formu.email;
	if (email.value== "" || email.value.indexOf ('@', 0) == -1 || email.value.indexOf ('.', 0) == -1 || email.value.length < 8) {
	alert("L'adreça electrònica introduïda no és vàlida.");
	email.focus();
	return(false);
	}
	email2=window.document.formu.recipient;
	if (email2.value== "" || email2.value.indexOf ('@', 0) == -1 || email2.value.indexOf ('.', 0) == -1 || email2.value.length < 8) {
	alert("L'adreça electrònica introduïda no és vàlida.");
	email2.focus();
	return(false);
	}
	window.document.formu.submit();
	return(true);
	}
  
  function _cf_validarecipient(){
		strEmail = document.formu.recipient.value;   
    email=false;	
		cont=0;
		cont2=0;
		for(var i=1;i<strEmail.length;i++)
    {
      if (strEmail.indexOf('@') > -1)  											
      	{ 
    			if ((strEmail.charAt(i)=='@') && (strEmail.charAt(i+1)!='.') && (strEmail.charAt(i-1)!='.')) {  
    			 var num=strEmail.indexOf('.');    																								
    			 if((strEmail.indexOf('.') > -1)  && (strEmail.charAt(num+1)!='') && (!(strEmail.indexOf(' ') > -1)) && (!(strEmail.indexOf('..') > -1)))   
    			 email=true; 
  	    	}
  	    }    	
    }	    	
    	if(email) { 	
    		return(true);
    	}else{
    		alert("L'adreça electrònica introduïda no és vàlida.");
    		strEmail.value = "";   		
    	  return(false);
    	}
}

  function _cf_agregar(){
	var texto = document.formu.recipient.value;
	if ( document.formu.llista.length >50 ){
		alert("No pots introduïr més de 50 destinataris.");
	}
	else{
	if (_cf_validarecipient()){
		option = new Option(texto,texto);
		var num = document.formu.llista.length;
		if (document.formu.llista.options[0].value == 0){
				document.formu.llista.options[0] = option;
		}else{
				document.formu.llista.options[num] = option;}
		document.formu.recipient.value = "";
		}
	}
}

  function _cf_borrar() {
	
	var i =0;
	if (document.formu.llista.length == 1){
		var option = new Option(' ',' ');
		document.formu.llista.options[0] = option;
	}else{
		if(document.formu.llista.selectedIndex <0){
			alert("Selecciona la adreça adreça electrònica que vols esborrar");
		}else{
			var val = document.formu.llista.selectedIndex ;	
			document.formu.llista.options[val] = null;		
		}
	}
}


  function esborrar() {
	var i =0;
	for (i=0;i<10;i++){
		if (document.formu.llista.length == 1){
			var option = new Option(' ',' ');
			document.formu.llista.options[0] = option;
		}else{
			document.formu.llista.options[0] = null;
		}
	}
}

  function valida()
  	{
  		var aux;
			aux = document.formu.fromN.value;
			if (aux.length < 1)
				{
					alert("Has d'omplir el teu nom");
					document.formu.fromN.select();
					return false;
				}
	
			if (document.formu.llista.options[document.formu.llista.length -1].value == 0)
				{
					alert("Ha d'afegir almenys un e-mail");
					document.formu.recipient.select();
					return false;
				}	
	
			return true;
		}

  function fer_submit()
    {
	    if (valida())
	    	{
  				lon = document.formu.llista.length;  					
					for (var i = 1; i < lon +1 ; i++)
						{
    							document.formu.llista[i-1].selected=true;
    							if (i == 1)
    								document.formu.toReal.value = document.formu.llista[i-1].value;
    							else
    								document.formu.toReal.value = document.formu.toReal.value + ',' + document.formu.llista[i-1].value;
						}					
  				//alert(document.formu.toReal.value);
  				document.formu.submit();
  			}
}



function pop(url) {
	window.open(url,'pop','width=541,height=530,location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,status=yes');
}

//funcions per canviar la mida de text

function putFont(sizeper){	
	
	//definimos las etiquetas el contenido de las cuales se quiera modificar de tamaño	
	var etiquetas = new Array("cos");		
		
		
	//buscamos en el documento cada una de las etiquetas del array 'etiquetas'
	//y de todos  los tags que contenga modificamos tamaño
	
	for (i=0;i<etiquetas.length;i++){ 
		
		var etiquetaActual= etiquetas[i];		
		
  	if (document.getElementById(etiquetaActual)){	  		  			
  		
				fontByTag('a',sizeper, etiquetaActual);
				fontByTag('p',sizeper, etiquetaActual);
				fontByTag('span',sizeper, etiquetaActual);
				fontByTag('td',sizeper, etiquetaActual);
				fontByTag('div',sizeper, etiquetaActual);
				fontByTag('h3',sizeper, etiquetaActual);
				fontByTag('li',sizeper, etiquetaActual);
				
			}//fi de if
		}//fi de for
}//fi de funcio


function fontByTag (tag,size,etiqueta) {
	
  			var objContenido = document.getElementById(etiqueta);  			
  			var divElements = objContenido.getElementsByTagName(tag); 
  			
				for (i=0;i<divElements.length;i++){
					obj=divElements[i];
					if (obj.style.fontSize==""){
						obj.style.fontSize="100%";
					}//fi de if	
					valor=12+size;
					obj.style.fontSize=valor+"px";
					if(size==0){
					obj.style.fontSize="";
					}//fi de if
				}//fi de for  	
  		 	
	//var objContenido = document.getElementById("caixaout"); 	

	
}

function Mostra(evnt,idCapa)
{
if (evnt.pageY){
	document.getElementById(idCapa).style.top = evnt.pageY;
}else if (evnt.clientY){
   document.getElementById(idCapa).style.top = evnt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :  document.body.scrollTop);
}

if (evnt.pageX){
	document.getElementById(idCapa).style.left = evnt.pageX;
}else if (evnt.clientX){
   document.getElementById(idCapa).style.left = evnt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :  document.body.scrollLeft);
}

document.getElementById(idCapa).style.visibility='visible';
}

function Oculta(idCapa)
{
	document.getElementById(idCapa).style.visibility='hidden';
}

