var $jq = jQuery.noConflict();



var sectores = new Array();
var franquicias = new Array();
var frequencias = new Array();


var current_header_ic = false; 
var current_header = false; 

function submit_busqueda_home( ){
	var l =$F("search_searchword").length;
	if( $F('selectSectorBusqueda' ) != 0 || ( $F("search_searchword") && $F("search_searchword")  !=null ) ){
	     if (l <3 && l>0 ){
	   alert("Los términos a buscar deben tener un mínimo de 3 caracteres");
	 } else{
		document.formularioBusqueda.submit();  
	     }
	 }else {	    
	     alert("Debe introdur datos para la búsqueda");	     
	}
}

  function switchHeadmode( ) {
	return $("upshrinkHeader").style.display = 'none' ? false  : true  ; 
  }
  
  function shrinkHeader(mode)
		{
			if (  $("upshrinkHeader").style.display  == 'none' ) {
				mode = '';
				$jq("#upshrinkHeader").show();
			} else {
				mode = 'none' ;
				$jq("#upshrinkHeader").hide();
			}
			if (cms_user_status ) {
					document.cookie = "upshrinkIC=" + (mode ? 1 : 0);
			} else {
					smf_setThemeOption("collapse_header", mode ? 1 : 0, null, smf_session_id  );
			}
			$("upshrink").src = smf_images_url + (mode ? "/board_select_spot_d.gif" : "/board_select_spot.gif");
			current_header = mode;
		}

			function texto_cabecera(element,mode){
				if (  $("upshrinkHeader").style.display  == 'none' ) {
					element.innerHTML="Ocultar Tarjeta personal y Utilidades"; 
				} else {
					element.innerHTML="Mostrar Tarjeta personal y Utilidades";
				}	
			}		
		
			function shrinkHeaderIC(mode)
			{
				mode = switchHeadmode();
				

	//			document.cookie = "upshrinkIC=" + (mode ? 1 : 0);
				
				if (cms_user_status ) {
					document.cookie = "upshrinkIC=" + (mode ? 1 : 0);
				} else {
					smf_setThemeOption("collapse_header", mode ? 1 : 0, null, smf_session_id  );
				}
					
				document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

				document.getElementById("upshrinkHeaderIC").style.display = (mode='' ) ? "none" : "";

				current_header_ic = mode;
			}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  /*
  

 function shrinkHeader(mode)  { 
	document.cookie = "upshrink=" + (mode ? 1 : 0);   document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif"); 
	document.getElementById("upshrinkHeader").style.display = mode ? "none" : ""; 
	// document.getElementById("upshrinkHeader2").style.display = mode ? "none" : ""; 
	current_header = mode; 
} 

function shrinkHeaderIC(mode)  {
	if (cms_user_status ) {
		document.cookie = "upshrinkIC=" + (mode ? 1 : 0);
	} else {
		smf_setThemeOption("collapse_header", mode ? 1 : 0, null, smf_session_id  );
	}
	document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif"); 
	document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : ""; 
	current_header_ic = mode; 
	} 
	
*/	
function inicializar_controles_buscador(cadena1, cadena2) {


}
/*
function texto_cabecera(elemento , actual ) {
	if ( elemento.innerHTML == 'Ocultar Tarjeta personal y Utilidades' ) {
		elemento.innerHTML = 'Mostrar Tarjeta personal y Utilidades' ;
	} else {
		elemento.innerHTML = 'Ocultar Tarjeta personal y Utilidades' ;
	}

}
  */

/* Event.observe(window, 'load', cargar_datos_personales, false); */
 
function cargar_datos_personales() {
 	var url = '/ajax/ficha.php';
 			var pars = 'option=' + cms_action ;
			var myAjax = new Ajax.Updater(
					'divPersonal', url, 
					{method: 'post', parameters: pars});
	
}



function loginCajaPersonal(doForm, cur_session_id)
{	
	doForm.source.value = cms_action;
	doForm.params.value = cms_ficha;
	
	hashLoginPassword(doForm, cur_session_id) ;
	return true ;
	 
}



			function rellenar_sectores(posicion, id, nombre, arrayFranquicias){
				linea_sector = new Array(3);
				linea_sector[0] = id;
				linea_sector[1] = nombre;
				linea_sector[2] = arrayFranquicias;
				sectores[posicion] = linea_sector;
			}

			function rellenar_franquicia_sector(posicion, id, nombre){
				var linea_franquicia = new Array(2);
				linea_franquicia[0] = id;
				linea_franquicia[1] = nombre;
				franquicias_sector[posicion] = linea_franquicia;
			}


			function rellenar_franquicia(posicion, id, nombre){
				var linea_franquicia = new Array(2);
				linea_franquicia[0] = id;
				linea_franquicia[1] = nombre;
				franquicias[posicion] = linea_franquicia;
			}


			function rellenar_frequencia(posicion, id, nombre,dias){
				var linea_frequencia = new Array(3);
				linea_frequencia[0] = id;
				linea_frequencia[1] = nombre;
				linea_frequencia[2] = dias;
				frequencias[posicion] = linea_frequencia;
			}



	


	 

			function inicializa_franquicias(){
					franquiciaSelect = document.getElementById("selectFranquicia");

					var tam = franquiciaSelect.length;
					for (var j = 1; j < tam ; j++){
						franquiciaSelect.options[tam-j] = null;
					}

					for(var i=0;i<arrayFranquicias.length;i++){
							var opt = new Option (arrayFranquicias[i][1]);
							franquiciaSelect.options[i+1] = opt;
							franquiciaSelect.options[i+1].value = (arrayFranquicias[i][0]);
					}
			}


			function actualiza_franquicias(){
				checkFranquicia= document.getElementById("idCheckFranquicia");
				checkSector= document.getElementById("idCheckSector");
				sector_seleccionado = document.getElementById("selectSector");
				franquiciaSelect = document.getElementById("selectFranquicia");


				if(checkFranquicia.checked==true){
					var tam = franquiciaSelect.length;
					for (var j = 1; j < tam ; j++){
						franquiciaSelect.options[tam-j] = null;
					}
					
					
					if (sector_seleccionado.value != 0){
						var arrayFranqSect=null;
						for(var i=0;i<sectores.length;i++){
							if(sector_seleccionado.value == sectores[i][0]) {
								arrayFranqSect=sectores[i][2];
								break;
							}
						}

						for(var i=0;i<arrayFranqSect.length;i++){
								var opt = new Option (arrayFranqSect[i][1]);
								franquiciaSelect.options[i+1] = opt;
								franquiciaSelect.options[i+1].value = (arrayFranqSect[i][0]);
						}

						franquiciaSelect.disabled= false;
					} else {
						var tam = franquiciaSelect.length;
						for (var j = 1; j < tam ; j++){
							franquiciaSelect.options[tam-j] = null;
						}
						
						for(var i=0;i<arrayFranquicias.length;i++){
								var opt = new Option (arrayFranquicias[i][1]);
								franquiciaSelect.options[i+1] = opt;
								franquiciaSelect.options[i+1].value = (arrayFranquicias[i][0]);
						}
					}
				}

			}

			function inicializar_controles(){
				checkTodos= document.getElementById("idCheckTodos");
				checkGeneral= document.getElementById("idCheckGeneral");
				checkSector= document.getElementById("idCheckSector");

			    selecSector = document.getElementById("selectSector");
			    selecFranquicia = document.getElementById("selectFranquicia");


				checkTodos.checked=true;

				selecSector.disabled= true;
				selecSector.options[0].selected=true;
				selecFranquicia.disabled= true;
				selecFranquicia.options[0].selected=true;
			}


		function inicializar_buscador(){
  		    var formulario = document.getElementById("formularioBusqueda");
  		    formulario.submit();
  		    
		}

			function inicializar_controles_buscador(sector,orden){
			
			    selecSector = document.getElementById("selectSectorBusqueda");
			    selecOrden = document.getElementById("selectSectorOrdenacion");
				
				if(sector!=null && sector!=""){
					var tam = selecSector.length;
					for(var i=1;i<tam;i++){
						if(selecSector.options[i].value==sector){
							selecSector.options[i].selected=true;
							break;
						}
					}
				}
					
				if(orden!=null && orden!=""){
					var tam = selecOrden.length;
					for(var i=1;i<tam;i++){
						if(selecOrden.options[i].value==orden){
							selecOrden.options[i].selected=true;
							break;
						}
					}
				}
			}




			function inicializar_controles_filtrado(filtro,sector,franquicia,frequencia){

				checkTodos= document.getElementById("idCheckTodos");
				checkGeneral= document.getElementById("idCheckGeneral");
				checkSector= document.getElementById("idCheckSector");
				checkFranquicia= document.getElementById("idCheckFranquicia");

			    selecSector = document.getElementById("selectSector");
			    selecFranquicia = document.getElementById("selectFranquicia");
			    selecFrequencia = document.getElementById("selectFrequencia");


				if(filtro=="ftodos")
					checkTodos.checked=true;

				if(filtro=="fgeneral")
					checkGeneral.checked=true;

				if(filtro=="fsector"){
					checkSector.checked=true;
					selecSector.disabled= false;
					
					var tam = selecSector.length;
					for(var i=1;i<tam;i++){
						if(selecSector.options[i].value==sector){
							selecSector.options[i].selected=true;
							break;
						}
					}
				}

				if(filtro=="ffranquicia"){
					checkFranquicia.checked=true;
					selecSector.disabled= true;
					selecFranquicia.disabled= false;

					$('selectSector').value = sector ;
					// traemos las franquicias :
					var objDrz  =  new drzJs() ;
					objDrz.changeSelectContent(  $("selectFranquicia") , '0: --Cargando Franquicias-- ') ; 
					
					$('ajWaitF').innerHTML= ' <img src="/imagenes/wait.gif" height="16" width="16" style="margin-top: 2px; margin-left: 5px;" />' ;
					var myAjax = new Ajax.Request(
						 '/ajax/ajax.php', 
						{
							method: 'post', 
							parameters: 'accion=franquicias', 
							onComplete: function( valor) {
								var objDrz  =  new drzJs() ;
								objDrz.changeSelectContent(  $("selectFranquicia") , valor.responseText, 
									function() { 
										$('ajWaitF').innerHTML= ''; 
										$('selectFranquicia').value = franquicia ; 

									}
								) ; 	
								$("selectFranquicia").disabled = false ;
								
							
							}
						}
					);

 
					
					}

				$('selectFrequencia').value = frequencia ;
 
			}



			function inicializar_controles_ordenacion(criterio,direccion){
				checkAscendente=document.getElementById("checkAscendente");
				checkDescendente=document.getElementById("checkDescendente");
				selectOrdenes = document.getElementById("selectOrdenes");

				if(direccion=="ascendente")
					checkAscendente.checked=true;

				if(direccion=="descendente")
					checkDescendente.checked=true;
				$("selectOrdenes").value = criterio ;
			}




			function onChangeListener(source){

				if(source=="selectSector"){
						// actualiza_franquicias();

					checkSector= document.getElementById("idCheckSector");
					if(checkSector.checked==true)
						submit_formulario_utilidades();
				}

				if(source=="selectFranquicias"){
					

					checkFranquicia= document.getElementById("idCheckFranquicia");
					if(checkFranquicia.checked==true)
					submit_formulario_utilidades();
				}


				if(source=="selectFrequencias"){

					submit=true;

					selecFrequencias = document.getElementById("selectFrequencia");
					diasFrequencia= document.getElementById("diasFrequencia");

					checkSector= document.getElementById("idCheckSector");
					checkFranquicia= document.getElementById("idCheckFranquicia");
					selecSector = document.getElementById("selectSector");
			        selecFranquicia = document.getElementById("selectFranquicia");

					if(checkSector.checked==true && selecSector.value == 0){
						alert("Seleccione un sector");
						selecFrequencias.options[0].selected=true;
						submit=false;
					}

					if(checkFranquicia.checked==true && selecFranquicia.value == 0){
						alert("Seleccione una franquicia");
						selecFrequencias.options[0].selected=true;
						submit=false;
					}

					if(submit){
						submit_formulario_utilidades();
					}

				}
			}





function obtenerDiasFrequencia(idFrequencia){

		var dias=0;

		for(var i=0;i<frequencias.length;i++){
			if(idFrequencia == frequencias[i][0]){
				dias=frequencias[i][2];
				break;
			}

		}
		return dias;
}


function submit_formulario_utilidades(){

	var formulario = document.getElementById("formularioOrdenacion");
	orden_seleccionado = document.getElementById("selectOrdenes");
	checkDescendende = document.getElementById("checkDescendente");


	if(checkDescendende.checked==true)
		formulario.desc.disabled=false;
	else
		formulario.desc.disabled=true;


	if(orden_seleccionado.value!=0){
		if(orden_seleccionado.value==1)
			formulario.sort.value="frq";

		if(orden_seleccionado.value==2)
			formulario.sort.value="sect";

		if(orden_seleccionado.value==3)
			formulario.sort.value="sectfrq";

		if(orden_seleccionado.value==4)
			formulario.sort.value="replies";

		if(orden_seleccionado.value==5)
			formulario.sort.value="views";

		if(orden_seleccionado.value==6)
			formulario.sort.value="last_post";

		if(orden_seleccionado.value==7)
			formulario.sort.value="subject";

		if(orden_seleccionado.value==8)
			formulario.sort.value="starter";

	}else{
		<!-- Por defecto, se hace esta ordenacion -->
		<!-- Por ?ltimo mensaje y por orden descendente -->
		formulario.sort.value="last_post";
		formulario.desc.disabled=false;
	}

	<!-- Se establece el n? de dias de la frequencia seleccionada -->
	selecFrequencias = document.getElementById("selectFrequencia");
	diasFrequencia= document.getElementById("diasFrequencia");
	diasFrequencia.value=obtenerDiasFrequencia(selecFrequencias.value);

	formulario.submit();
}


function activar_sectores(){
    selecSector = document.getElementById("selectSector");
    selecFranquicia = document.getElementById("selectFranquicia");

	selecSector.disabled= false;
	selecSector.options[0].selected=true;




	selecFranquicia.disabled= true;

	selecFranquicia.options[0].selected=true;

}

function activar_sectoresYfranquicias(){
	$("selectSector").disabled = true ;
	
	selecFranquicia = $("selectFranquicia");

 	// selecSector.options[0].selected=true;

	selecFranquicia.disabled= true;
	
	// selecFranquicia.options[0].selected=true;
	
	
	
	if  ( $("selectFranquicia").options.length < 2  ) {
		var objDrz  =  new drzJs() ;
		objDrz.changeSelectContent(  $("selectFranquicia") , '0: --Cargando Franquicias-- ') ; 
		
		$('ajWaitF').innerHTML= ' <img src="/imagenes/wait.gif" height="16" width="16" style="margin-top: 2px; margin-left: 5px;" />' ;
		var myAjax = new Ajax.Request(
			 '/ajax/ajax.php', 
			{
				method: 'post', 
				parameters: 'accion=franquicias', 
				onComplete: function( valor) {
					var objDrz  =  new drzJs() ;
					objDrz.changeSelectContent(  $("selectFranquicia") , valor.responseText, function() { $('ajWaitF').innerHTML= ''  }) ; 	
					$("selectFranquicia").disabled = false ;
					
				
				}
			}
		);

	} else {
	$("selectFranquicia").disabled = false ;
	}


}





function desactivar_sectores(){
    selecSector = document.getElementById("selectSector");
    selecFranquicia = document.getElementById("selectFranquicia");

	selecSector.disabled= true;
	selecSector.options[0].selected=true;
	selecFranquicia.disabled= true;
	selecFranquicia.options[0].selected=true;
}





function activar_sectores_post(){
    selecSectorPost = document.getElementById("selectSectorPost");
    selecFranquiciaPost = document.getElementById("selectFranquiciaPost");

	selecSectorPost.disabled= false;
	selecSectorPost.options[0].selected=true;
	selecFranquiciaPost.disabled= false;
	selecFranquiciaPost.options[0].selected=true;
}






function desactivar_sectores_post(){
    selecSectorPost = document.getElementById("selectSectorPost");
    selecFranquiciaPost = document.getElementById("selectFranquiciaPost");

	selecSectorPost.disabled= true;
	selecSectorPost.options[0].selected=true;
	selecFranquiciaPost.disabled= true;
	selecFranquiciaPost.options[0].selected=true;
}



function submit_AhadirUsuario(){

	var formulario = document.getElementById("formularioOrdenacion");

	usuarios_favoritos = document.getElementById("to_users_favoritos");
     
   if (formulario.nunUserFavoritos.value <5){
	if (usuarios_favoritos.value == null  ||  usuarios_favoritos.value == "") {
		formulario.tipoUsuario.value="noSeleccionado";
	
		alert("Debe seleccionar alg?n usuario o franquicia");
	
	}else {
		formulario.userFavoritosEnviados.value=usuarios_favoritos.value;
	formulario.tipoUsuario.value="user";
          formulario.submit();
	    
	}
   }else{
    alert("El n?mero m?ximo de usuarios favoritos es 5");
   }
	
}

				





function submit_eliminarUsuario(idUsuarioEliminado ){

	var formulario = document.getElementById("formularioOrdenacion");
		
	if ( confirm("Desea eliminar el usuario favorito")) {
         formulario.usuarioEliminado.value=idUsuarioEliminado;
	   formulario.submit();
	}else{
      formulario.usuarioEliminado.value="noEliminar";
      } 


}


function filtrarPorUsuario(idUsuarioEliminado ){
	
	  var formulario = document.getElementById("formularioOrdenacion");
	
	  formulario.iduserfav.value=idUsuarioEliminado;
	  formulario.filtroUsuario.value="fusuario";

	  submit_formulario_utilidades();
     


}


function submit_AhadirForo(){

 	var formulario = document.getElementById("formularioOrdenacion");
	franquiciaFavorita = document.getElementById("selectFranquiciaFavorita");
	sectorFavorita = document.getElementById("selectSectorFavorito");

	if (formulario.numFavoritos.value <5){
	if(franquiciaFavorita.value ==0 && sectorFavorita.value ==0){
	   formulario.tipoOperacion.value="noAnhadir";
	      alert("Debe seleccionar alg?n sector o franquicia");
	}else if(franquiciaFavorita.value !=0 && sectorFavorita.value ==0){
	   formulario.tipoOperacion.value="anhadirForoFavorito";
	   formulario.submit();        
	}else if(franquiciaFavorita.value ==0 && sectorFavorita.value !=0){
	        
	   
	   formulario.tipoOperacion.value="anhadirForoFavorito";
	      formulario.submit();  
	   
	 
	}else if(franquiciaFavorita.value !=0 && sectorFavorita.value !=0){
 	   if (formulario.numFavoritos.value <4){
		 formulario.tipoOperacion.value="anhadirForoFavorito";
		 formulario.submit();        
		}else{
	      alert("S?lo tiene sitio para un foro");
	    }     
	} else{
	     formulario.tipoOperacion.value="noAnhadir";
	   
	}
	
	}else{
	 alert("error");
	}


}
	
function submit_eliminarSectorFavorito(idSector ){

	var formulario = document.getElementById("formularioOrdenacion");
		
	if ( confirm("Desea eliminar el sector favorito")) {
           formulario.IdElementoEliminado.value=idSector;
            formulario.IdTipoEliminado.value="sector";
         formulario.submit();      
           
      }
}
	

function submit_eliminarFranquiciaFavorita(idFranquicia ){

	var formulario = document.getElementById("formularioOrdenacion");
		
	if ( confirm("Desea eliminar el sector favorito")) {
            formulario.IdElementoEliminado.value=idFranquicia;
            formulario.IdTipoEliminado.value="franquicia";
            formulario.submit();      
      }
}


function filtrarPorSector(idSector){
	
	activar_sectores();
	sector_seleccionado = document.getElementById("selectSector");
	sector_seleccionado.disabled=false;
	sector_seleccionado.options[idSector].selected=true;
    
	checkSector= document.getElementById("idCheckSector");
	checkSector.checked=true;
	
	
	inicializa_franquicias();
	
	submit_formulario_utilidades();
}


function getSectorDeFranquicia(idFranquicia){
	for(var i=0;i<sectores.length;i++){
			arrayFranquicias=sectores[i][2];
			for(var j=0;j<arrayFranquicias.length;j++){
					if(arrayFranquicias[j][0]==idFranquicia){
						return sectores[i][0];
					}
			}
	}
	}



function filtrarPorFranquicia(idFranquicia){	
	/*
	checkFranquicia= document.getElementById("idCheckFranquicia");
	checkFranquicia.checked=true;
	sector_seleccionado = document.getElementById("selectSector");
	sector_seleccionado.disabled=false;
	franquicia_seleccionado = document.getElementById("selectFranquicia");
	franquicia_seleccionado.disabled=false;
	
	idSector=getSectorDeFranquicia(idFranquicia);
	
	indexSector=0;
	var tam = sector_seleccionado.length;
	for(var i=0;i<tam;i++){
		id=sector_seleccionado.options[i+1].value
		if(id == idSector){
			indexSector=i+1;
			break;
		}
	}

	if(indexSector!=0){
		sector_seleccionado.options[indexSector].selected=true;


		actualiza_franquicias();

		var tam = franquicia_seleccionado.length;
		indexFranquicia=0;
		for(var i=0;i<tam;i++){
			id=franquicia_seleccionado.options[i+1].value;
			if(id == idFranquicia){
				indexFranquicia=i+1;
				break;
			}
		}

	
		if(indexFranquicia!=0)
			franquicia_seleccionado.options[indexFranquicia].selected=true;
	}
	
	submit_formulario_utilidades(); */
}


function gestorPanel(id){

    var formulario = document.getElementById("formularioOrdenacion");
	if (id == 1){	
      formulario.IdPanel.value="busqueda";
      
    }else if (id ==2){
     
      formulario.IdPanel.value="encuesta";
    }  else{
      formulario.IdPanel.value="busqueda";
    } 


    formulario.submit();      
}

function gestorPanelBuscador(id){

    var formulario = document.getElementById("formularioBusqueda");
	if (id == 1){	
      formulario.IdPanel.value="buscador";
      
    }else if (id ==2){
     
      formulario.IdPanel.value="encuesta";
    }  else{
      formulario.IdPanel.value="buscador";
    } 


    formulario.submit();      
}

function comprobarCampoBusqueda(){

    var formulario = document.getElementById("searchForm");
     
    var criterio = document.getElementById("searchCriterio");
    
    
	if(criterio.value==null || criterio.value=="" || criterio.value==" " || criterio.value=="  " || criterio.value=="   "){
		alert("Debe introducir un criterio para buscar.");	
		return false;
	}
	else{    
	    formulario.submit();      
	    return true;
	}

}

 function abre_popUp()  {
	    var dirt ='/cms/index2.php?option=com_content&amp;task=foroFavorito&amp;id=4&amp;itemid=9' ;
		window.open(dirt,null,"status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,width=255,height=120,left=450,top=300");
   }

  function abre_popUp_user()  {
	    var dirt ='/cms/index2.php?option=com_content&amp;task=usuarioFavorito&amp;id=4&amp;itemid=9';
		window.open(dirt,null,"status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,width=255,height=135,left=450,top=300");
 }
 
 
 
 
 function actualiza_franquicias_post( el ) {
 
 		var objDrz  =  new drzJs() ;
		objDrz.changeSelectContent(  $("selectFranquiciaPost") , '0: --Cargando Franquicias-- ') ; 
 		var myAjax = new Ajax.Request(
			 '/ajax/ajax.php', 
			{
				method: 'post', 
				parameters: 'accion=franquiciasporsector&id=' + el.value , 
				onComplete: function( valor) {
					var objDrz  =  new drzJs() ;
					objDrz.changeSelectContent(  $("selectFranquiciaPost") , valor.responseText, function() {  }) ; 	
					$("selectFranquiciaPost").disabled = false ;
					
				
				}
			}
		);


 
 }



/*
 * jQuery corner plugin
 *
 * version 1.7 (1/26/2007)
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

/**
 * The corner() method provides a simple way of styling DOM elements.  
 *
 * corner() takes a single string argument:  $().corner("effect corners width")
 *
 *   effect:  The name of the effect to apply, such as round or bevel. 
 *            If you don't specify an effect, rounding is used.
 *
 *   corners: The corners can be one or more of top, bottom, tr, tl, br, or bl. 
 *            By default, all four corners are adorned. 
 *
 *   width:   The width specifies the width of the effect; in the case of rounded corners this 
 *            will be the radius of the width. 
 *            Specify this value using the px suffix such as 10px, and yes it must be pixels.
 *
 * For more details see: http://methvin.com/jquery/jq-corner.html
 * For a full demo see:  http://malsup.com/jquery/corner/
 *
 *
 * @example $('.adorn').corner();
 * @desc Create round, 10px corners 
 *
 * @example $('.adorn').corner("25px");
 * @desc Create round, 25px corners 
 *
 * @example $('.adorn').corner("notch bottom");
 * @desc Create notched, 10px corners on bottom only
 *
 * @example $('.adorn').corner("tr dog 25px");
 * @desc Create dogeared, 25px corner on the top-right corner only
 *
 * @example $('.adorn').corner("round 8px").parent().css('padding', '4px').corner("round 10px");
 * @desc Create a rounded border effect by styling both the element and its parent
 * 
 * @name corner
 * @type jQuery
 * @param String options Options which control the corner style
 * @cat Plugins/Corner
 * @return jQuery
 * @author Dave Methvin (dave.methvin@gmail.com)
 * @author Mike Alsup (malsup@gmail.com)
 */
jQuery.fn.corner = function(o) {
    function hex2(s) {
        var s = parseInt(s).toString(16);
        return ( s.length < 2 ) ? '0'+s : s;
    };
    function gpc(node) {
        for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode  ) {
            var v = jQuery.css(node,'backgroundColor');
            if ( v.indexOf('rgb') >= 0 ) { 
                rgb = v.match(/\d+/g); 
                return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
            }
            if ( v && v != 'transparent' )
                return v;
        }
        return '#ffffff';
    };
    function getW(i) {
        switch(fx) {
        case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
        case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
        case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
        case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
        case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
        case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
        case 'curl':   return Math.round(width*(Math.atan(i)));
        case 'tear':   return Math.round(width*(Math.cos(i)));
        case 'wicked': return Math.round(width*(Math.tan(i)));
        case 'long':   return Math.round(width*(Math.sqrt(i)));
        case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
        case 'dog':    return (i&1) ? (i+1) : width;
        case 'dog2':   return (i&2) ? (i+1) : width;
        case 'dog3':   return (i&3) ? (i+1) : width;
        case 'fray':   return (i%2)*width;
        case 'notch':  return width; 
        case 'bevel':  return i+1;
        }
    };
    o = (o||"").toLowerCase();
    var keep = /keep/.test(o);                       // keep borders?
    var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
    var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
    var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
    var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
    var fx = ((o.match(re)||['round'])[0]);
    var edges = { T:0, B:1 };
    var opts = {
        TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o),
        BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o)
    };
    if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
        opts = { TL:1, TR:1, BL:1, BR:1 };
    var strip = document.createElement('div');
    strip.style.overflow = 'hidden';
    strip.style.height = '1px';
    strip.style.backgroundColor = sc || 'transparent';
    strip.style.borderStyle = 'solid';
    return this.each(function(index){
        var pad = {
            T: parseInt(jQuery.css(this,'paddingTop'))||0,     R: parseInt(jQuery.css(this,'paddingRight'))||0,
            B: parseInt(jQuery.css(this,'paddingBottom'))||0,  L: parseInt(jQuery.css(this,'paddingLeft'))||0
        };

        if (jQuery.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = jQuery.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
            var d = document.createElement('div');
            var ds = d.style;

            bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

            if (bot && cssHeight != 'auto') {
                if (jQuery.css(this,'position') == 'static')
                    this.style.position = 'relative';
                ds.position = 'absolute';
                ds.bottom = ds.left = ds.padding = ds.margin = '0';
                if (jQuery.browser.msie)
                    ds.setExpression('width', 'this.parentNode.offsetWidth');
                else
                    ds.width = '100%';
            }
            else {
                ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                    (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
            }

            for (var i=0; i < width; i++) {
                var w = Math.max(0,getW(i));
                var e = strip.cloneNode(false);
                e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
            }
        }
    });
};

$jq(document).ready( 
	 divRedondeados  
	
	 );
 
function divRedondeados() {
	$jq('div.rnaranja').prepend('<div class="cajaEncabezado"></div>').append('<div class="cajaPie"><div class="cajaEncabezadoBordeDerecha"></div></div>') ;
	

	
}

 
/*
 
var image_count_franquicia_destacada = 0 ;
var current_image_franquicia_destacada=0;

$jq(document).ready(function(){

  image_count_franquicia_destacada = $jq("div.rnaranjaOld div.centrado").hide().size();
   $jq("div.rnaranjaOld div.centrado:eq("+current_image_franquicia_destacada+")").show();
  if ( image_count_franquicia_destacada > 0 ) {
	setInterval(rotar_franquicia_destacada,5000); //time in milliseconds
  }
});

function rotar_franquicia_destacada() {
  old_image = current_image_franquicia_destacada%image_count_franquicia_destacada;
  new_image = ++current_image_franquicia_destacada%image_count_franquicia_destacada;
  $jq("div.rnaranjaOld div.centrado:eq(" + new_image + ")").fadeIn("slow", function() {
    $jq("div.rnaranjaOld div.centrado:eq(" + old_image + ")").fadeOut("slow");
  });
}
*/

function actualiza_municipios_from_provincias(){
 	if ($F('selectState' ) > '0' ) {
 		$('selectCity' ).disabled = false;		
		var objDrz = new drzJs() ;
		objDrz.changeSelectContent(  $("selectCity") ,'0:-- Cargando Municipios --' ) ;
		$('ajWaitF').innerHTML= ' <img src="/imagenes/wait.gif" height="16" width="16" style="vertical-align: middle;"/>' ;		
		var myAjax = new Ajax.Request(
		 '/ajax/ajax.php', 
		{
			method: 'post', 
			parameters: 'accion=municipios&id=' + $F("selectState"), 
			onComplete: function( valor) {
 				var objDrz = new drzJs() ;
				objDrz.changeSelectContent(  $("selectCity") , valor.responseText , function() { $('ajWaitF').innerHTML= ''  }) ; 
				
			
			}
		});
	} else {
 		$('selectCity' ).disabled = true;			
	}
	
	

	
	
	
	
	
	return ;
	
	 

	

}