
  function swapDiv(branch){
    var objBranch = document.getElementById(branch).style;
    if(objBranch.display=="block")
      objBranch.display="none";
    else
      objBranch.display="block";
      objBranch.visibility="visible";
  }
  
  /*
	* swapDiv(branch, linkbranch, text)
	*
	* Funcion que oculta o muestra un div y modifica
	* el texto de un elemento en funcion de si se encuentra
	* el div abierto o cerrado
	*/
  function swapBuscadorDiv(branch, linkbranch, imgBranch, inputSiguiente, inputAnterior, textClose, textOpen, imgClose, imgOpen) {
    var objBranch = document.getElementById(branch).style;
    if(objBranch.display=="block") {
      objBranch.display="none";
      document.getElementById(linkbranch).innerHTML=textOpen;
      document.getElementById(imgBranch).innerHTML=imgOpen;
      if (document.getElementById(inputSiguiente)!=null) {
      	document.getElementById(inputSiguiente).value='on';
      }
      if (document.getElementById(inputAnterior)!=null) {
      	document.getElementById(inputAnterior).value='on';
      }
    } else {
      objBranch.display="block";
      objBranch.visibility="visible";
      document.getElementById(linkbranch).innerHTML=textClose;
      document.getElementById(imgBranch).innerHTML=imgClose;
      if (document.getElementById(inputSiguiente)!=null) {
      	document.getElementById(inputSiguiente).value='off';
      }
      if (document.getElementById(inputAnterior)!=null) {
      	document.getElementById(inputAnterior).value='off';
      }
    } 
  }

  /*
	* swapDiv(branch, linkbranch, text)
	*
	* Funcion que oculta o muestra un div y modifica
	* el texto de un elemento en funcion de si se encuentra
	* el div abierto o cerrado
	*/
  function swapCampanaDiv(branch, linkbranch, textClose, textOpen, imgBranch, imgClose, imgOpen) {
    var objBranch = document.getElementById(branch).style;
    if(objBranch.display=="block") {
      objBranch.display="none";
      document.getElementById(linkbranch).innerHTML=textOpen;
      document.getElementById(imgBranch).src=imgOpen;
    } else {
      objBranch.display="block";
      objBranch.visibility="visible";
      document.getElementById(linkbranch).innerHTML=textClose;
      document.getElementById(imgBranch).src=imgClose;
    } 
  }
  /*
	* seleccionarUnInputCheck(formName, checkName, inputArray )
	*
	* Funcion que deselecciona todos los campos imput excepto uno
	* formName nombre del formulario donde estan los checks
	* chekName nombre del check que se debe activar
	* inputArray lista de todos los checks que se deben contemplar para activar o desactivar 
	*/
	function seleccionarUnInputCheck(form, checkName, inputArray ) {
		for (x=0; x<form.length ; x++ ) {
		    if (form.elements[x].type=="checkbox") { // ?nicamente evalua los que son de tipo checkBox
		    	for (y=0; y<inputArray.length; y++){ // ?nicamente evalua aquellos que se encuentran dentro de la lista
		    		if (inputArray[y]==form.elements[x].name) {
		    			if (form.elements[x].name==checkName ) {  // Caso que se tenga que activar
							form.elements[x].checked=1;
						} else {
							form.elements[x].checked=0;
						}
		    		}
		    	}
			}
		}

	} 
	
	/*
	* checkEnablesInput(form, input, chkInput, defaultValue)
	*
	* Function que al habilitar o deshabilitar un check box habilita o deshabilita
	* un input. En caso de deshabilitar pone el valor por defecto de defaultValue.
	*/
	function checkEnablesInput(form, input, chkInput, defaultValue) {
 		enable = false;
		for (x=0; x<form.length ; x++ ) {
	 		if (chkInput==form.elements[x].name) {
	 			if (form.elements[x].checked) {
	 				enable = true;
	 			}
	 		}
	 	}
	 	for (x=0; x<form.length ; x++ ) {
	 		if (input==form.elements[x].name) {
	 			if (enable) {
		 			form.elements[x].disabled=false;
		 		} else {
			 		form.elements[x].disabled=true;
			 		form.elements[x].value=defaultValue;
		 		}
	 		}
	 	}
 	}
 	
 	/*
	* cleanInputAndCheck(form, inputArray, inputChkArray, defaultValue)
	*
	* Function que deshabilita una lista de inputs y de check, poniendo en los
	* inputs un valor por defecto.
	*/
 	function cleanInputAndCheck(form, inputArray, inputChkArray, defaultValue) {
		for (x=0; x<form.length ; x++ ) {
		    if (form.elements[x].type=="checkbox") { // unicamente evalua los que son de tipo checkBox
		    	for (y=0; y<inputChkArray.length; y++){ // unicamente evalua aquellos que se encuentran dentro de la lista
		    		if (inputChkArray[y]==form.elements[x].name) {
						form.elements[x].checked=0;
		    		}
		    	}
			} else {
				for (y=0; y<inputArray.length; y++){ // unicamente evalua aquellos que se encuentran dentro de la lista
		    		if (inputArray[y]==form.elements[x].name) {
						form.elements[x].disabled=true;
				 		form.elements[x].value=defaultValue;
		    		}
		    	}
			}
		}
	}
	/*
	* validateTotalPlazasValues(form, input, inputArray, msgError) 
	*
	* Esta funci?n valida que el numero total de plazas sea igual o superior al numero 
	* de subvalores de plazas ( tipos distintos tarificables ) que el usuario haya 
	* definido
	*
	* form Nombre del formulario
	* input Nombre del input que tiene el total de plazas seleccionadas por el usuario
	* inputArray Array de inputs que en los que el usuario puede indicar subvalores
	* msgError Mensaje de error
	*/
	function validateTotalPlazasValues(form, input, inputArray, msgError) {
 		total = 0;
 		tmpTotal = 0;
		for (x=0; x<form.length ; x++ ) {
	 		if (input==form.elements[x].name) {
	 			total = form.elements[x].value;
	 		}
	 	}
	 	for (x=0; x<form.length ; x++ ) {
			for (y=0; y<inputArray.length; y++){ 
	    		if (inputArray[y]==form.elements[x].name) {
		    		if (form.elements[x].disabled==false) {
	    				tmpTotal = tmpTotal + parseInt(form.elements[x].value,10);
	    			}
	    		}
	    	}
	 	}
	 	
	 	if (tmpTotal>total) {
	 		alert(msgError);
	 		return false;
	 	} else {
		 	return true;
		}
 	}
 	
 	/**
 	 * Funciones para tratar iframes.
 	 */
 	 
	function getDocHeight(doc) {
		var docHt = 0, sh, oh;
		if (doc.height) docHt = doc.height;
		else if (doc.body) {
			if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
			if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
			if (sh && oh) docHt = Math.max(sh, oh);
		}
		return docHt;
	}

	function setIframeHeight(iframeName) {
		var iframeWin = window.frames[iframeName];
		var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
		if ( iframeEl && iframeWin ) {
			iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
			var docHt = getDocHeight(iframeWin.document);
			// need to add to height to be sure it will all show
			if (docHt) iframeEl.style.height = docHt + 0 + "px";
		}
	}
