
// JavaScript Document
	// div: nombre del div en el que partira, cont:empieza en 0 numero de ciclos, numDiv: el numero del div creado actualmente para el nuevo div creado solo para uso del resultado del get(), div1: nombre del primer div, permitirUrl:para  validacion de url solo se pasa, url:la url solo se pasa, php: el id del php en cuestion 
//get_bloqueDiv('divTemptextocortoyoco', 0, 0, '', ".$permitirEditarLink.", '".$url."', '".$idPhp."', 'crear', '$clase')
	//var cadenaAnterior = '';
	function setSession(v, n) {
		 //solo lo puse para que no salga el error en el calendario.
 	}

	var ycdvauxgral= new Array();
	var ycmetodos= new Array();
	var ycmedidas= new Array();
	var nodos_a_eliminar = new Array();
	
	function delay(milisegundos){
		var ok=0;
		for(i=0;i<=milisegundos;i++)
		{
			ok=ok+1;
		}
	}	
	
	function get_bloqueDiv(div, permitirUrl, url, php, cual, clase, metodo, ancho, alto){
		var idNombre='';
        var hijo = document.getElementById(div);
        idNombre=hijo.parentNode.getAttribute("id");
		//if(idNombre == 'editable_uno_titulo')
			//alert(idNombre+' div'+div+' cual: '+cual);
		
		eliminarDivReferencia(idNombre, div); //eliminar el div divTemptexto___yoco creado al inicio
		if(cual=='mostrar_interno'){			
			//if(document.getElementById('divTempyoco'))
			
			var nombreAuxiliar = div.split('_');
			
			if(nombreAuxiliar[1]){
				//alert(nombreAuxiliar[1]);
				eliminarDivReferencia(idNombre, 'divTempyoco_'+nombreAuxiliar[1]);
			}else
				eliminarDivReferencia(idNombre, 'divTempyoco');
		}
		
		var names = idNombre.split("_");
		if(names[0]=='editable'){
				
			var nameCual = cual.split("_");	
			
			if(cual=='edicion'){
				insertEditar(idNombre, php, metodo);
			}
			if(nameCual[1]=='interno'){				
				
				cerrado=0;
				
				padreAux2 = document.getElementById(idNombre).parentNode.id;
				
				if(document.getElementById(padreAux2).style.display=='none'){
					cerrado = 1;
					document.getElementById(padreAux2).style.display='block';
				}
				
				if(ancho=='' || ancho==0)
					var ancho = document.getElementById(idNombre).offsetWidth;		
				
				if(alto=='' || alto==0)
					var alto = document.getElementById(idNombre).offsetHeight;
				
				
				if(cerrado==1){
					cerrado=0;
					document.getElementById(padreAux2).style.display='none';
				}
								
				insertFuncionsAll(idNombre, php, metodo, ancho, alto);
				ycdvauxgral.push(idNombre); 
				ycmetodos.push(metodo); 
				ycmedidas.push(ancho+'_'+alto); 
			}
			//alert(idNombre);
			if(idNombre!=''){ 
				//if(idNombre == 'editable_uno_titulo')
					//alert(idNombre+' ::: '+ permitirUrl+' ::: '+ url+' ::: '+ php+' ::: cual: '+ cual+' ::: '+ clase+' ::: '+ metodo+' ::: '+ ancho+' ::: '+ alto);
				getLlamarasincrono(idNombre, permitirUrl, url, php, cual, clase, metodo, ancho, alto );
			}
		} 
	}
		
	function getLlamarasincrono(idNombre, permitirUrl, url, php, cual, clase, metodo, ancho, alto){		
		//if(idNombre == 'editable_uno_titulo')
			//alert(idNombre+' ::: '+ permitirUrl+' ::: '+ url+' ::: '+ php+' ::: cual: '+ cual+' ::: '+ clase+' ::: '+ metodo+' ::: '+ ancho+' ::: '+ alto);				
		llamarasincrono('yococms/getExistencia.php?d1='+idNombre+'&bandurl='+permitirUrl+'&url='+url+'&php='+php+'&cual='+cual+'&clase='+clase+'&metodo='+metodo+'&alto='+alto+'&ancho='+ancho, idNombre);

	}
	
	function yocoeditarDiv(divPadre, pagina, metodo, ancho, alto){
		
		var ystrin='';
		UnTip();
		var a = document.getElementById(divPadre); 
		a.removeAttribute("onMouseOver");
		var b = document.getElementById(divPadre); 
		b.removeAttribute("onMouseOut");
		var c = document.getElementById(divPadre);
		c.removeAttribute("onclick");//yocoeditarBloque(divPadre, pagina, lapiz, guardar)
		
		//alert('ancho: '+ancho+' alto: '+alto+' div: '+divPadre+' pagina:'+pagina);

		if(ancho!='' && alto!='' && ancho!=0 && alto!=0){
			//ystrin='z-index:100;background:#ffffff;position:absolute;display:block;color:#000000;width:'+ancho+'px; min-height:'+alto+'px;';			
		
			ystrin='width:'+ancho+'px; min-height:'+alto+'px;';
			
		}else{			
			//ystrin='z-index:100;background:#ffffff;position:absolute;display:block;color:#000000;'; 
			ystrin='';
		}
		var a = document.getElementById(divPadre); 
		a.setAttribute("style", ystrin);
		
		

		var nombreDivHijo = divPadre.split("_");
			if ((nombreDivHijo[0] == 'editable')){
				llamarasincrono('yococms/edicion.php?pagina='+pagina+'&divPadre='+divPadre+'&operacion=editar&ancho='+ancho+'&alto='+alto, divPadre);
				
			}
		setTimeout('insertEditar(\''+divPadre+'\', \''+pagina+'\', \''+metodo+'\')',1500);	
		
		//var inputs=document.getElementById('textocorto'+divPadre+pagina);
		if(metodo=='textocorto'){
			if(document.getElementById('textocorto'+divPadre+pagina))
				document.getElementById('textocorto'+divPadre+pagina).focus();
		}else{
			//var inputs1=document.getElementById('textoplano'+divPadre+pagina);
			if(document.getElementById('textoplano'+divPadre+pagina)){
				document.getElementById('textoplano'+divPadre+pagina).focus();
			}else{
				//var inputs2=document.getElementById('textohtml'+divPadre+pagina);
				if(document.getElementById('textohtml'+divPadre+pagina)){
					document.getElementById('textohtml'+divPadre+pagina).focus();
				}
			}
		}
	   
	}

	function buscar(){
       var elementos = document.getElementsByTagName('*');
       //alert(elementos);
	   for (var k=0;k<elementos.length;k++){
           for (var i=0;i<elementos[k].childNodes.length;i++){
               var hijo = elementos[k].childNodes[i];
               if ((hijo.nodeType == 3 && !/\S/.test(hijo.nodeValue))||(hijo.nodeType==8)){
                   nodos_a_eliminar[nodos_a_eliminar.length] = hijo;
               }
           }
       }
       destruir();
    }
      
    function destruir(){
       for(var d=0;d<nodos_a_eliminar.length;d++){
           nodos_a_eliminar[d].parentNode.removeChild(nodos_a_eliminar[d]);
       }
    }
	
	function insertFuncionsAll(div1, php, metodo, ancho, alto){	
		
		cadenaAnterior = document.getElementById(div1).getAttribute("style");
		
		
		var a = document.getElementById(div1); 
		a.setAttribute("onMouseOver", "resaltarEdicion('"+div1+"', 'ycind', '"+ancho+"', '"+alto+"'); toolTip(\'Cambiar\');");
		var b = document.getElementById(div1); 
		b.setAttribute("onMouseOut", "quitarFondo('"+div1+"','"+ancho+"','"+alto+"','"+cadenaAnterior+"'); UnTip();");
		
		var c = document.getElementById(div1);
		c.setAttribute("onclick", "yocoeditarDiv('"+div1+"','"+php+"','"+metodo+"','"+ancho+"','"+alto+"');");
		
		document.getElementById(div1).style.width=ancho+'px';
		document.getElementById(div1).style.height=alto+'px';
		//yocoeditarBloque(divPadre, pagina)
	}

	function insertFuncions(div1, php, metodo, ancho, alto){
		//alert(' insert functions entra');
		var a = document.getElementById(div1);
		a.setAttribute("onMouseOver", "toolTip(\'Cambiar\');");
		var b = document.getElementById(div1); 
		b.setAttribute("onMouseOut", "UnTip();");
		var c = document.getElementById(div1);		
		c.setAttribute("onclick", "yocoeditarDiv('"+div1+"','"+php+"','"+metodo+"','"+ancho+"','"+alto+"');");//yocoeditarBloque(divPadre, pagina)
	}


    function clonar(div, x){
    	var clon = document.getElementById(div).cloneNode(x);
        document.getElementById(div).parentNode.insertBefore(clon,document.getElementById(div));
    }
	function searchFatherGeneral(divHijo){
		var hijo = document.getElementById(divHijo);
		var idPadre=hijo.parentNode.getAttribute("id");
		//alert(idPadre);
		if(idPadre!=null){
			var padres = idPadre.split("_");	
			if(padres[0]=='general'){
					var papaDiv=idPadre;
			}else{
				searchFatherGeneral(idPadre);
			}
		}else{ papaDiv=divHijo;}
		return(papaDiv);
	}
	
	function crearDivAuxiliar(div, sufijo, ancho, alto){
		 
		 //var ancho = document.getElementById(div).offsetWidth;
		 //var alto = document.getElementById(div).offsetHeight;
		 if(sufijo!='imagen'){
		 	//alto=parseInt(alto,10)+20;	
			//ancho=parseInt(ancho,10)+20;	
		 }
		//alert(ancho);
        var hijo = document.getElementById(div);
        var idPadre=hijo.parentNode.getAttribute("id");
		//var idPadre=searchFatherGeneral(div);		
		var div2; 	
		div2 = document.createElement('div');	
		
		var idDiv=document.createAttribute('id');
		idDiv.nodeValue='ycdvaux_'+div;
		
		var estilos=document.createAttribute('style');
		estilos.nodeValue='width:'+ancho+'px; height:'+alto+'px;'; 
		
		div2.setAttributeNode(idDiv);
		div2.setAttributeNode(estilos); 
		var pad=document.getElementById(idPadre);
		
       if(document.getElementById(div).nextSibling){ 
          //alert('ok1');
		  document.getElementById(idPadre).insertBefore(div2, document.getElementById(div).nextSibling); 
        }else{ 
			//alert('ok2');
            document.getElementById(idPadre).appendChild(div2); 
        }
		pad='';
		
	}
	
	function resaltarEdicion(div1, sufijo, ancho, alto){
		
		var cadenas;
		//document.getElementById('yocofondoEm').style.display='block';
		
		padreDiv = document.getElementById(div1).parentNode.id;
		
		if(ancho=='' || ancho == 0)
			ancho = document.getElementById(div1).offsetWidth;
			
		if(alto=='' || alto == 0)
			alto = document.getElementById(div1).offsetHeight;
		
		cadenas = 'cursor:pointer; border: 3px dashed #1F9CD4; margin:-3px; width:'+ancho+'px; height:'+alto+'px;';
		
		

		var a = document.getElementById(div1);
		//alert(div1);		
		a.style.cursor='pointer';
		a.style.border='3px dashed #1F9CD4';
		a.style.margin='-3px';
		a.style.width=''+ancho+'px';
		a.style.height=''+alto+'px';
		//a.setAttribute("style", cadenas);

		var d=document.getElementById('ycdvaux_'+div1); 
		if(d==null){
			
			//crearDivAuxiliar(div1, sufijo, ancho, alto);			
			
		}
		//crearDivAuxiliar(div1, sufijo);
		//alert('salio');
	}
	function cambiarFunciones(php){
		var nameMedida;
		var v=document.getElementById('ycfcmostrarzona').value; 
		//alert(v);
		if(v==0){
			for (var z=0;z<ycdvauxgral.length;z++){
				var xDiv=ycdvauxgral[z];
				//var d=document.getElementById('ycdvaux_'+xDiv);
				
				
				var a = document.getElementById(xDiv);
				//a.setAttribute("style", "z-index:1;background:none;position:inherit;");
				
				ancho = a.offsetWidth;
				alto = a.offsetHeight;
				
				a.style.border="none";
				a.style.margin="0px";
				a.style.width=ancho+'px';
				a.style.height=alto+'px';
				//a.setAttribute("style", "z-index:1;background:none;position:inherit;");
	
				//var ycidFather=d.parentNode.getAttribute("id");
				/*
				if(ycidFather!=null){
					document.getElementById(ycidFather).removeChild(document.getElementById('ycdvaux_'+xDiv));
				}
				*/
				
				nameMedida = ycmedidas[z].split("_");	
				insertFuncionsAll(xDiv, php, ycmetodos[z], nameMedida[0],nameMedida[1]);
			}
			
			var todosElementos = document.body;
			var elementAux = '';
			var estiloAdmin = "";
			
			for(j=0; j<todosElementos.getElementsByTagName("DIV").length; j++){
								
				var idAux = todosElementos.getElementsByTagName("DIV")[j].id;
				
				if(idAux!=''){
					elementAux = document.getElementById(idAux).id.split("_");
										
					switch(elementAux[0]){
						case 'yocoFotoNoticiaTexto':
						
							document.getElementById(idAux).setAttribute("style",estiloAdmin);
						
						break;
						
						case 'yocoImagen':
							
							document.getElementById(idAux).setAttribute("style",estiloAdmin);
							
						break;
					}
				
				}
			
			}
			
			
			document.getElementById('yocofondoEm').style.display='none';
			document.getElementById('ycfcmostrarzona').value=1;
			document.getElementById('ycimagenmarcarzonas').src='yococms/yocoimages/marcar.png';
						
			
		}else{			
			for(var z=0;z<ycdvauxgral.length;z++){
				var xDiv=ycdvauxgral[z];
				//alert(xDiv);
				nameMedida = ycmedidas[z].split("_");	
				insertFuncions(xDiv, php, ycmetodos[z], nameMedida[0],nameMedida[1]);
				resaltarEdicion(xDiv, 'ycgral_', nameMedida[0],nameMedida[1]);
			}
			
			var todosElementos = document.body;
			var elementAux = '';
			var estiloAdmin = "cursor:pointer; border: 3px dashed #1F9CD4; margin:-3px;";
			
			for(j=0; j<todosElementos.getElementsByTagName("DIV").length; j++){
								
				var idAux = todosElementos.getElementsByTagName("DIV")[j].id;
				
				if(idAux!=''){
					elementAux = document.getElementById(idAux).id.split("_");
										
					switch(elementAux[0]){
						case 'yocoFotoNoticiaTexto':
						
							document.getElementById(idAux).setAttribute("style",estiloAdmin);
						
						break;
						
						case 'yocoImagen':
							
							document.getElementById(idAux).setAttribute("style",estiloAdmin);
							
						break;
					}
				
				}
			
			}	
			
			document.getElementById('ycfcmostrarzona').value=0;
			document.getElementById('ycimagenmarcarzonas').src='yococms/yocoimages/desmarcar.png';
						
		}
		
		
		
	}
	
	function quitarFondo(div1, ancho, alto, cadenaAnterior){

		var a = document.getElementById(div1); 
				
		var cadenas;		
				
		if(ancho!='' && alto!=''){
			
			//cadenas='"border:none;';
		}else{
			ancho = document.getElementById(div1).offsetWidth;
			alto = document.getElementById(div1).offsetHeight;
					
			//cadenas='"border:none;';
		}       
		//alert(div1);
		
		a.setAttribute("style", cadenaAnterior);
		//document.getElementById('yocofondoEm').style.display='none';
		
		var ycidPadre=a.parentNode.getAttribute("id");
		//document.getElementById(ycidPadre).removeChild(document.getElementById('ycdvaux_'+div1));
		document.getElementById(div1).style.width=ancho+'px';
		document.getElementById(div1).style.height=alto+'px';

		
	}
	
	function insertEditar(nombreDiv, php, metodo){
		nodos_a_eliminar='';
		buscar();
		
		//alert(nombreDiv);
		
		var padre=document.getElementById(nombreDiv);
		var div;	
		div = document.createElement('div');	
		
		var idDiv=document.createAttribute('id');
		idDiv.nodeValue='ycEdicion_'+nombreDiv; 

		var idClass=document.createAttribute('class');
		idClass.nodeValue='ycEdicion'; 
		
		div.setAttributeNode(idDiv);
		div.setAttributeNode(idClass);
		padre.appendChild(div);
		
    	document.getElementById(nombreDiv).insertBefore(div, document.getElementById(nombreDiv).firstChild);
		
		//var newDad = document.getElementById(nombreDiv).parentNode.id; // Me sirve para el sondeo		
		//if(document.getElementById(newDad).firstChild.id == nombreDiv)
			//newDad = nombreDiv; // Me sirve para el sondeo
		//else
			//newDad = document.getElementById(nombreDiv).parentNode.id; // Me sirve para el sondeo
			newDad='editable_sondeo'; //lo puse asi mientras encuentro como buscar el padre del div
			
		if(metodo=='blog'){
			document.getElementById('ycEdicion_'+nombreDiv).innerHTML='<img src="yococms/yocoimages/x.png" border="0" onclick="UnTip();ycreFresh();" onMouseOver="toolTip(\'Cancelar\');" onMouseOut="UnTip();" height="16" width="16" /></div><input type="hidden" name="guardar" id="guardar" value=""/>';
			
			document.getElementById(nombreDiv).className='edicion';
			
		}else if(metodo=='sondeoNew'){
			
			iconosSondeo('ycEdicion_'+nombreDiv, 'nuevo', newDad, nombreDiv);
		}else if(metodo=='sondeo'){			
			
			iconosSondeo('ycEdicion_'+nombreDiv, 'edicion', newDad, nombreDiv);
		}else if(metodo=='imagen'){
			document.getElementById('ycEdicion_'+nombreDiv).innerHTML='<img onclick="subirImagen();" src="yococms/yocoimages/iconoimagen.png" width="16" height="16"/><img onclick="document.getElementById(\'yocofondoEm\').style.display=\'block\';document.getElementById(\'yococont_final\').style.display=\'block\'; llamarasincrono(\'yococms/ventana_emergente.php?div1='+nombreDiv+'&php='+php+'\',\'yococont_final\');" src="yococms/yocoimages/iconotexto.png" width="16" height="16"/><img src="yococms/yocoimages/palomita.png" border="0" onMouseOver="toolTip(\'Aceptar\');" onMouseOut="UnTip();" onclick="UnTip();yocosubmitform();" height="16" width="16"/></div><img src="yococms/yocoimages/x.png" border="0" onclick="UnTip();ycreFresh();" onMouseOver="toolTip(\'Cancelar\');" onMouseOut="UnTip();" height="16" width="16" /></div><input type="file" id="yocofiledata" name="yocofiledata" style="display:none;"/><input type="hidden" name="guardar" id="guardar" value=""/>';  
		}else{
			document.getElementById('ycEdicion_'+nombreDiv).innerHTML='<img src="yococms/yocoimages/palomita.png" border="0" onMouseOver="toolTip(\'Aceptar\');" onMouseOut="UnTip();" onclick="UnTip();yocosubmitform();" height="16" width="16"/></div><img src="yococms/yocoimages/x.png" border="0" onclick="UnTip();ycreFresh();" onMouseOver="toolTip(\'Cancelar\');" onMouseOut="UnTip();" height="16" width="16" /></div><input type="hidden" name="guardar" id="guardar" value=""/>';
		}
	}
	
	function quitarInsertEditar(nombreDiv){
		document.getElementById(nombreDiv).className='blogComentarios';
		document.getElementById('ycEdicion_'+nombreDiv).innerHTML='';
	}
	
	function iconosSondeo(divIconos, modulo, newDad, nombreDiv){
		
		var sondeoMostrar = nombreDiv.split("_");
		
		if(modulo=='nuevo'){
			document.getElementById(divIconos).innerHTML='<img src="yococms/yocoimages/palomita.png" border="0" onMouseOver="toolTip(\'Aceptar\');" onMouseOut="UnTip();" onclick="UnTip();yocosubmitformSondeo(\''+newDad+'\',\''+modulo+'\',\''+nombreDiv+'\');" height="16" width="16"/></div><img src="yococms/yocoimages/x.png" border="0" onclick="UnTip();cerrarEmergente();" onMouseOver="toolTip(\'Cancelar\');" onMouseOut="UnTip();" height="16" width="16" /></div><input type="hidden" name="guardar" id="guardar" value=""/>';
		}else{
			document.getElementById(divIconos).innerHTML='<img src="yococms/yocoimages/nuevo-sondeo.png" border="0" onMouseOver="toolTip(\'Crear Sondeo\');" onMouseOut="UnTip();" onclick="UnTip();verSondeo(\'nuevo\','+sondeoMostrar[1]+');" height="16" width="16"/></div><img src="yococms/yocoimages/ver-sondeos.png" border="0" onMouseOver="toolTip(\'Ver Sondeos\');" onMouseOut="UnTip();" onclick="UnTip();verSondeo(\'ver\','+sondeoMostrar[1]+');" height="16" width="16"/></div><img src="yococms/yocoimages/estadisticas.png" border="0" onMouseOver="toolTip(\'Votos Actuales\');" onMouseOut="UnTip();" onclick="UnTip();verSondeo(\'actual\','+sondeoMostrar[1]+');" height="16" width="16"/></div><img src="yococms/yocoimages/palomita.png" border="0" onMouseOver="toolTip(\'Aceptar\');" onMouseOut="UnTip();" onclick="UnTip();yocosubmitformSondeo(\''+newDad+'\',\''+modulo+'\',\''+nombreDiv+'\');" height="16" width="16"/></div><img src="yococms/yocoimages/x.png" border="0" onclick="UnTip();marcarSondeo(\'off\');" onMouseOver="toolTip(\'Cancelar\');" onMouseOut="UnTip();" height="16" width="16" /></div><input type="hidden" name="guardar" id="guardar" value=""/>';
		}
	}	
	
	/*
	function subirImagen(){
		yocoForm.yocofiledata.click();	
	}*/
	
	function subirImagen(yocoFormBox,yocoFileInput, yocoframe){
		frames[yocoframe].document.getElementById(yocoFileInput).click();	
	}
	
	function subirTextoImagen(yocoSite,yocoFile,parametroEspecial,principal,galeria,yocoNewFoto){		
		document.getElementById('yocofondoEm').style.display='block';
		document.getElementById('yococont_final').style.display='block'; 
		document.getElementById('yococont_final').style.position='absolute';		
				
		if(parametroEspecial == 'cargar')
			llamarasincrono('yococms/yocoImagenes.php?parametroEspecial='+parametroEspecial+'&nombreImg='+yocoFile+'&yocoSite='+yocoSite+'&principal='+principal+'&yocoGaleria='+galeria+'&yocoNewFoto='+yocoNewFoto,'yococont_final');
		else			
			post('yococms/yocoImagenes.php?parametroEspecial='+parametroEspecial+'&nombreImg='+yocoFile+'&yocoSite='+yocoSite+'&principal='+principal+'&yocoGaleria='+galeria+'&yocoNewFoto='+yocoNewFoto, 'yococont_final','yocoFormTexto_'+yocoSite+'_'+yocoFile);
		
	}
	
	function yocoSubmit(phppost, divHijo, yocoFormId){
		var dady = document.getElementById(divHijo).parentNode.id;		
		
		//alert (dady+' '+yocoFormId+' '+phppost);
		post(phppost, dady ,yocoFormId);
		
	}
	
	
	function ycreFresh(){
		location.reload(true);
	}	
	
	function yocosubmitform(){
		 var theForm = document.forms['yocoForm'];
		 if (!theForm) {
			 theForm = document.yocoForm;
		 }
		 theForm.submit();
		 //document.getElementById('guardar').click();		 
	}
	
	function yocosubmitformSondeo(newDad, modulo, nombreDiv){
		if(modulo=='nuevo'){
			post('yococms/yocoSondeo.php?guardar=1',nombreDiv,'formSondeoNew');
		}else{
			
			var sondeoForm = nombreDiv.split("_");
			
			post('yococms/yocoSondeo.php?guardar=2',newDad,'formSondeo_'+sondeoForm[1]);
			//llamarasincrono('yococms/yocoSondeo.php?sondeo='+sondeo+'&operacion=nuevo',divOp);
			
		}
		 
		 //document.getElementById('guardar').click();
	}

	function insertAfter(e,i){ 
       /* if(e.nextSibling){ 
            e.parentNode.insertBefore(i, e.nextSibling); 
        }else{ 
            e.parentNode.appendChild(i); 
        } */
		
        if(document.getElementById(div).nextSibling){ 
            document.getElementById(idPadre).insertBefore(div2, document.getElementById(div).nextSibling); 
        }else{ 
            hijo.parentNode.appendChild(div2); 
        }
		
    }
	
	function mostrarBloqueEdit(div, cont, numDiv, div1, permitirUrl, url, php, cual){
		
		var div_bloque;
		get_bloqueDiv(div, cont, numDiv, div1, permitirUrl, url, php, cual);
		
	}

	function crearDivH(divPadre){
		
		var padre=document.getElementById(divPadre);
		//var c=parseInt(document.getElementById('divHNc').value,10)+1;	
		var div;	
		div = document.createElement('div');	
		
		var idDiv=document.createAttribute("id");
		idDiv.nodeValue='divYH'; 
			
		div.setAttributeNode(idDiv);
		
		padre.appendChild(div);
		//document.getElementById('divHNc').value=c;
	}	
	
	function eliminarDivReferencia(divPadre, div){		

		var padre=document.getElementById(divPadre);

		var d = document.getElementById(divPadre); 
		var ycd_nesteds = document.getElementById(div);	
		
		var ycthrowawayNodos = d.removeChild(ycd_nesteds);		
		
	
	}
	

//div se referencia a la busqueda, cont es el numero del ciclo el numero de div que ha pasado,  num el numero del div nuevo creado el numero  incrementado, div1 el nombre del primer encontrado el padre inmediato.



function enviarNews(f, tipo){
		var url='cms/newsletter.php?tipo='+tipo+'&email='+f.emailcmsNews.value;
		get(url, tipo);   
		borrarNew(f);  
	}
	
	function borrarNew(f) {
		f.emailcmsNews.value="";
	}
	function verificaNews(){
			var band=true;
			var texto='Favor de llenar el siguiente campo:\n\n';
			if(document.cmsGeneralForm.emailcmsNews.value=='' || document.cmsGeneralForm.emailcmsNews.value=='Ingresa tu correo electrónico'){
				band=false;
				texto+='- Email\n';
			}
			if(!band)
			alert(texto);
			return(band);
	}

function agregarFiles(){
	var padre=document.getElementById('inputFiles');
	var c=parseInt(document.getElementById('cuantosInputs').value,10)+1;	
	
	var file,divPadre,divAlt,inputAlt;
	
	divPadre = document.createElement('div');   
	
		var id=document.createAttribute("id");  
		id.nodeValue='divImg'+c;  
		   
		divPadre.setAttributeNode(id);
	
	file = document.createElement('input');	  
	
		var type=document.createAttribute("type");
		type.nodeValue='file';
		
		var id=document.createAttribute("id");
		id.nodeValue='imagen'+c;
		
		var nombre=document.createAttribute("name");
		//nombre.nodeValue='imagen'+c;	
		nombre.nodeValue='imagen[]';	
	
		file.setAttributeNode(type);
		file.setAttributeNode(nombre);
		file.setAttributeNode(id);
	
	divAlt = document.createElement('div');	
	
		var idAlt=document.createAttribute("id");
		idAlt.nodeValue='divAlt'+c;		
				
		divAlt.setAttributeNode(idAlt);	
	
	divAlt.appendChild(document.createTextNode("Texto Alterno: "));
	
	inputAlt = document.createElement('input');
	
		var typeAlt=document.createAttribute("type");
		typeAlt.nodeValue='text';		
		
		var valueAlt=document.createAttribute("value");
		valueAlt.nodeValue='Texto Alterno';
		
		var nameAlt=document.createAttribute("name");
		nameAlt.nodeValue='inputAlt'+c;
		
		inputAlt.setAttributeNode(typeAlt);
		inputAlt.setAttributeNode(nameAlt);
		inputAlt.setAttributeNode(valueAlt);
	
	divAlt.appendChild(inputAlt);	
	
	divPadre.appendChild(file);
	divPadre.appendChild(divAlt);
	
	padre.appendChild(divPadre);
		
	document.getElementById('cuantosInputs').value=c;
}

function eliminarFiles(){
	var padre=document.getElementById('inputFiles');
	var c=parseInt(document.getElementById('cuantosInputs').value,10);
	
	if(padre.hasChildNodes()){
		padre.removeChild(padre.lastChild);
		c--;
	}
	document.getElementById('cuantosInputs').value=c;
}
function esEmail(box,botSubmit)
{
	if(box.value != "")
	{
		var reg1 = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-])+\.([A-Za-z]{2,4})$/;
		var reg2 = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-])+\.([A-Za-z]{2,4})+\.([A-Za-z]{2,4})$/;
		if(!reg1.test(box.value) && !reg2.test(box.value))
		{	alert("Formato de E-mail incorrecto.");
			box.focus();
			document.getElementById(botSubmit).disabled=true;
		}else{
			document.getElementById(botSubmit).disabled=false;
		}
	}
}

function editarBloqueIndex(bloque,pagina,num,lapiz,guardar){
	//llamarasincrono('edicion.php?pagina='+pagina+'&num='+num+'&tipo=titulo&operacion=editar','tituloC2_P');
	llamarasincrono('edicion.php?pagina='+pagina+'&num='+num+'&tipo=texto&operacion=editar','temporadaDesc');
	llamarasincrono('edicion.php?pagina='+pagina+'&num='+num+'&tipo=subtitulo&operacion=editar','subtitulo_1');
	document.getElementById(lapiz).style.display='none';
	document.getElementById(guardar).style.display='inline-table';	
}

function editarTituloIndex(bloque,pagina,num,lapiz,guardar){
	llamarasincrono('edicion.php?pagina='+pagina+'&num='+num+'&tipo=titulo&operacion=editar','tituloC2_P');
	document.getElementById(lapiz).style.display='none';
	document.getElementById(guardar).style.display='inline-table';
}

function editarFotos(id,tipo,div){
	document.getElementById('ventanaEmergente').style.display='block';
	llamarasincrono('edicionImg.php?id='+id+'&tipo='+tipo+'&div='+div+'&operacion=editar','ventanaEmergente');	
}


function actualizarFecha(sufijo){
	var anio=document.getElementById('anio' + sufijo);
	var mes=document.getElementById('mes' + sufijo);
	var dia=document.getElementById('dia' + sufijo);
	var fecha=document.getElementById('fecha' + sufijo);
	var testDate=new Date(mes.options[mes.selectedIndex].value + '/' + dia.options[dia.selectedIndex].value + '/' + anio.options[anio.selectedIndex].value);
	
	if(anio.value!='' && mes.value!='' && dia.value!=''){
		if(parseInt(testDate.getMonth()+1,10)!=parseInt(mes.options[mes.selectedIndex].value,10)){
			alert("La fecha no es válida. Intente de nuevo.");
			anio.className='yocoErrado';
			mes.className='yocoErrado';
			dia.className='yocoErrado';
		}
		else{
			fecha.value=anio.options[anio.selectedIndex].value + '-' + mes.options[mes.selectedIndex].value + '-' + dia.options[dia.selectedIndex].value;
			anio.className='';
			mes.className='';
			dia.className='';
		}
	}
	//alert(fecha.value);
}

function cerrar(){
	document.getElementById('ventanaEmergente').innerHTML=''; 
	document.getElementById('ventanaEmergente').style.display='none';
	document.getElementById('ventanaEmergente').style.position='static';
}

function guardarUsuario(){
	if(document.getElementById('contraseniaAux3').value==document.getElementById('contraseniaAux2').value && document.getElementById('contraseniaAux3').value!='' && document.getElementById('contraseniaAux2').value!=''){
		if(document.getElementById('contraseniaAux3').value != document.getElementById('usuarioContrasenia').value)
			document.getElementById('usuarioContrasenia').value = hex_sha1(document.getElementById('contraseniaAux3').value);
			
		return true;
	}else{
		alert('Las contraseñas no coinciden'); 
		document.getElementById('contraseniaAux2').value=''; 
		document.getElementById('contraseniaAux3').value=''; 
		return false;
	}
}

function recargar(div){
	document.getElementById(div).innerHTML='';
}

function mostrarPreview(kuki){
	document.getElementById('kukiview').style.display='block';
	get('kukibitesView.php?kuki='+kuki,'kukiview','pgbar',false);		
}

function mostrarAvisos(cuantosMuestra){	
	document.getElementById('yocofondoEm').style.display='block';
	document.getElementById('yococont_final').style.display='block'; 
	document.getElementById('yococont_final').style.position='absolute';
	llamarasincrono('yococms/yocoAvisos.php?cuantos='+cuantosMuestra,'yococont_final');
}

function cerrarEmergente(){	
	document.getElementById('yocofondoEm').style.display='none';
	document.getElementById('yococont_final').style.display='none';
	document.getElementById('yococont_final').style.position='fixed';
	document.getElementById('yococont_final').style.left='';
	document.getElementById('yococont_final').style.marginLeft='';
	document.getElementById('yococont_final').innerHTML=''; 
}


function nuevoAviso(){
	document.getElementById('yocofondoEm').style.display='block';
	document.getElementById('yococont_final').style.display='block'; 
	post('yococms/yocoAvisoPublicar.php?autorizarAviso=0&aviso=0&operacion=nuevo','yococont_final','avisoForm');
	
	formulario = 'emailAviso|tituloAviso|comentarioAviso';
	textoFormulario = 'E-mail...|Titulo...|Comentario...';
		
	limpiarFormulario(formulario,textoFormulario);
	
}

function limpiarFormulario(formulario,textoFormulario){
	formuAux = formulario.split("|");
	textoFormuAux = textoFormulario.split("|");
	
	for(c=0; c<formuAux.length; c++){
		document.getElementById(formuAux[c]).value=textoFormuAux[c];
	}
}

function publicarAviso(tipo,aviso, cuantosMostrar){
	var claseAviso;	
	
	var newDadAvisos = document.getElementById('yocoMostrarTodosAvisos').parentNode.id; //Hay que revisar que si se cambia el id en yococms
	
	llamarasincrono('yococms/yocoAvisoPublicar.php?autorizarAviso='+tipo+'&aviso='+aviso+'&operacion=editar&cuantos='+cuantosMostrar,'ventanaPublicar');	
		
	if(tipo==1){
		claseAviso = 'botonNoPublicar';
		onclickAviso = 'publicarAviso(0,'+aviso+','+cuantosMostrar+')';
		llamarasincrono('yococms/yocoAvisoPublicar.php?aviso=&operacion=actualizar&cuantosM='+cuantosMostrar, newDadAvisos);
	}else{			
		claseAviso = 'botonPublicar';
		onclickAviso = 'publicarAviso(1,'+aviso+','+cuantosMostrar+')';		
		llamarasincrono('yococms/yocoAvisoPublicar.php?aviso=&operacion=actualizar&cuantosM='+cuantosMostrar,newDadAvisos);
	}	
		
	document.getElementById('botoncin_'+aviso).setAttribute('class',claseAviso);
	document.getElementById('botoncin_'+aviso).setAttribute('onClick',onclickAviso);
	
}

function eliminarAviso(aviso, cuantosMostrar){
	var newDadAvisos = document.getElementById('yocoMostrarTodosAvisos').parentNode.id
	
	llamarasincrono('yococms/yocoAvisoPublicar.php?aviso='+aviso+'&operacion=eliminar','ventanaPublicar');
	//llamarasincrono('avisos.php','editable_avisos');
	llamarasincrono('yococms/yocoAvisoPublicar.php?aviso=&operacion=actualizar&cuantosM='+cuantosMostrar,newDadAvisos);
	document.getElementById('cuerpoAviso_'+aviso).innerHTML='';
}


function editarBloqueBlog(bloque,blog,lapiz,guardar,news,cancelar){
	llamarasincrono('yococms/edicionBlog.php?blog='+blog+'&tipo=titulo&operacion=editar', 'tituloBlog'+blog);
	llamarasincrono('yococms/edicionBlog.php?blog='+blog+'&tipo=texto&operacion=editar', 'textoBlog'+blog);
	llamarasincrono('yococms/edicionBlog.php?blog='+blog+'&tipo=fecha&operacion=editar', 'fechaBlog'+blog);
	document.getElementById(lapiz).style.display='none';
	document.getElementById(guardar).style.display='inline-table';
	document.getElementById(cancelar).style.display='inline-table';
	document.getElementById(news).style.display='none';	
}

function verSondeo(tipo,sondeo){
	if(tipo=='nuevo'){
		document.getElementById('yocofondoEm').style.display='block';
		document.getElementById('yococont_final').style.display='block'; 
		document.getElementById('yococont_final').style.position='absolute';
		llamarasincrono('yococms/yocoSondeo.php?sondeo=&operacion=nuevo','yococont_final');
		insertEditar('yocosondeo_emergente', '', 'sondeoNew');
	}
	
	if(tipo=='ver'){
		
		document.getElementById('yocofondoEm').style.display='block';
		document.getElementById('yococont_final').style.display='block'; 
		document.getElementById('yococont_final').style.position='absolute';
		llamarasincrono('yococms/yocoSondeo.php?sondeo=&operacion=vertodo','yococont_final');
		
	}
	
	if(tipo=='actual'){
		newDad = document.getElementById('yocosondeo_'+sondeo).parentNode.id;
		llamarasincrono('yococms/yocoSondeo.php?sondeo='+sondeo+'&operacion=estadisticas',newDad);
		insertEditar('yocosondeo_'+sondeo, '', 'sondeo');
	}
	
}

function nuevaOpcionSondeo(sondeo, divOp){	
	llamarasincrono('yococms/yocoSondeo.php?sondeo='+sondeo+'&operacion=nuevo',divOp);
	delay(1000);
	marcarSondeo('on');	
	insertEditar('yocosondeo_'+sondeo, '', 'sondeo');// ver como sacar siempre este div sin tener que mandarlo de esta manera

}

function eliminarOpcionSondeo(sondeo, divOp){
	llamarasincrono('yococms/yocoSondeo.php?sondeo='+sondeo+'&operacion=eliminar',divOp);
	delay(1000);
	marcarSondeo('on');	
	insertEditar('yocosondeo_'+sondeo, '', 'sondeo');

}

function verEditable(como,sondeo){
	if(como == 'normal'){
		
		//newDad = document.getElementById('yocosondeo_'+sondeo).parentNode.id;
		
		insertEditar('yocosondeo_'+sondeo, '', 'sondeo');
		marcarSondeo('on'); 
		UnTip();
	}else{
		insertEditar('yocosondeo_'+sondeo, '', 'sondeo');
		marcarSondeo('on'); 
		UnTip();
	}
	
	
}

function marcarSondeo(modo){	
	if(modo=='on'){
		var idOpcionSondeoAux = document.getElementById('idOpcionSondeo').value;
		var idImagenSondeoAux = document.getElementById('idImagenSondeo').value;
		var idSondeoActual = document.getElementById('sondeoActual').value;
		
		var tipoOpcionClick = document.getElementById('modoclick'+idSondeoActual).value;
		
		var idOpcionSondeo = idOpcionSondeoAux.split("|");
		var idImagenSondeo = idImagenSondeoAux.split("|");
		if(tipoOpcionClick=='off'){
			document.getElementById('trsondeo_'+idSondeoActual).style.display='table-row';
			document.getElementById('nuevosondeo_'+idSondeoActual).style.display='inline-table';
			document.getElementById('eliminarsondeo_'+idSondeoActual).style.display='inline-table';
			
			
			/* para cambiar las fechas*/
			
			valorHTML = document.getElementById('fechasondeo_'+idSondeoActual).innerHTML;
			valorFechaIni = document.getElementById('fechainicio_'+idSondeoActual).value;
			valorFechaFin = document.getElementById('fechafinal_'+idSondeoActual).value;
			cambioHTML = 'Inici&oacute; <input name="fechainicio" id="fechainicio" type="text" readonly="yes" size="10" onfocus="showCalendarControl(this);" value="'+valorFechaIni+'" /> Termina: <input name="fechafinal" id="fechafinal" type="text" readonly="yes" size="10" onfocus="showCalendarControl(this);" value="'+valorFechaFin+'" />';
			document.getElementById('fechas_'+idSondeoActual).value = valorHTML;
			document.getElementById('fechasondeo_'+idSondeoActual).innerHTML = cambioHTML;
			/**************************/
			
			/* ************ Para cambiar el titulo ************ */
			valorHTML = document.getElementById('editable_sondeotitulo_'+idSondeoActual).innerHTML;
				
			anchoOpcion = document.getElementById('editable_sondeotitulo_'+idSondeoActual).offsetWidth;
			altoOpcion = document.getElementById('editable_sondeotitulo_'+idSondeoActual).offsetHeight;
			
			cambioHTML = '<textarea onFocus="this.select();" name="textoplanotitulosondeo'+idSondeoActual+'" id="textoplanotitulosondeo'+idSondeoActual+'" style="width:'+anchoOpcion+'px" class="textareaSondeo">'+valorHTML+'</textarea><input type="hidden" name="textoAuxPlanoTitulo'+idSondeoActual+'" id="textoAuxPlanoTitulo'+idSondeoActual+'" value="'+valorHTML+'" />';
						
			document.getElementById('editable_sondeotitulo_'+idSondeoActual).innerHTML = cambioHTML;
			
			/****************************************/		
			
			
			/* ************ Para cambiar las opciones ************ */
			
			//if(idOpcionSondeo.length>0){
				for(c=0; c<idOpcionSondeo.length; c++){			
					valorHTML = document.getElementById('editable_sondeo_'+idOpcionSondeo[c]).innerHTML;
					
					anchoOpcion = document.getElementById('editable_sondeo_'+idOpcionSondeo[c]).offsetWidth;
					altoOpcion = document.getElementById('editable_sondeo_'+idOpcionSondeo[c]).offsetHeight;
					
					cambioHTML = '<textarea onFocus="this.select();" name="textoplanosondeo'+idOpcionSondeo[c]+'" id="textoplanosondeo'+idOpcionSondeo[c]+'" style="width:'+anchoOpcion+'px" class="textareaSondeo">'+valorHTML+'</textarea><input type="hidden" name="textoAuxPlano'+idOpcionSondeo[c]+'" id="textoAuxPlano'+idOpcionSondeo[c]+'" value="'+valorHTML+'" />';
								
					document.getElementById('editable_sondeo_'+idOpcionSondeo[c]).innerHTML = cambioHTML;
				}
			//}
			/****************************************/
						
			divSondeo = document.getElementById('yocosondeo_'+idSondeoActual);
			
			divSondeo.setAttribute("onmouseover", "");
			divSondeo.setAttribute("onmouseout", "");
			divSondeo.setAttribute("onclick", "");
			
			document.getElementById('modoclick'+idSondeoActual).value='on';			
		}
	}else{
		/*
		document.getElementById('trsondeo_'+idSondeoActual).style.display='none';
		document.getElementById('nuevosondeo_'+idSondeoActual).style.display='none';
		document.getElementById('eliminarsondeo_'+idSondeoActual).style.display='none';
		
		// ************ Para cambiar la fecha ************ 
		cambioHTML = document.getElementById('fechas_'+idSondeoActual).value;
		document.getElementById('fechasondeo_'+idSondeoActual).innerHTML = cambioHTML;
		
		// ****************************************************
		
		
		// ************* Para cambiar el titulo ************
		document.getElementById('editable_sondeotitulo_'+idSondeoActual).innerHTML = document.getElementById('textoAuxPlanoTitulo'+idSondeoActual).value;
		// ****************************************
		
		/* ************ Para cambiar las opciones ************
		for(c=0; c<idOpcionSondeo.length; c++){						
			document.getElementById('editable_sondeo_'+idOpcionSondeo[c]).innerHTML = document.getElementById('textoAuxPlano'+idOpcionSondeo[c]).value;
			//document.getElementById('editable_sondeoIm_'+idOpcionSondeo[c]).innerHTML="";
		}
		
		// ***************************************
		
		//divSondeoA = document.getElementById('yocosondeo_'+idSondeoActual);
			
		//divSondeoA.setAttribute("onmouseover", "toolTip('Cambiar');");
		//divSondeoA.setAttribute("onmouseout", "UnTip();");		
		//divSondeoA.setAttribute("onclick", "marcarSondeo('on'); UnTip();");
		
		document.getElementById('modoclick'+idSondeoActual).value='off';
		*/
		
		ycreFresh(); // Esto lo puse momentaneo, quitarlo cuando se encuentre como quitar los iconos de edicion sin tener que recargar pagina
	}
	
}

function moverIzquierda(divHijo, altoFoto){	
	parametros = document.getElementById('ids').value.split(',');
	izq="";
	der="";
	cadena="";
	d=0;
	longitud=parametros.length;
	for(i=0; i<parametros.length; i++){
		d++;
		if(i==0){
			der=parametros[i];			
			id=der;
		}
		
		if(d==(parseInt(longitud,10)-1)){
			izq=parametros[i];		
		}		
		
		if(d==parametros.length){		
			id=parametros[i];		
		}		
	}
	
	f=0;
	for(k=0; k<longitud; k++){
		f++;
		if(f!=longitud){
			cadena=cadena+","+parametros[k];
		}
		
		if(f==longitud){
			cadena=parametros[k]+cadena;
		}
	}	
	
	document.getElementById('ids').value=cadena;
	
	newDad = document.getElementById(divHijo).parentNode.id;
		
	llamarasincrono("yococms/yocoFotoNoticia.php?altoFoto="+altoFoto+"&id="+id+"&izq="+izq+"&der="+der+'&idArray='+cadena, newDad);
	
}

function moverDerecha(divHijo,altoFoto){
	parametros = document.getElementById('ids').value.split(',');
	izq="";
	der="";
	cadena="";
	d=0;
	for(i=0;i<parametros.length; i++){
		d++;
		if(i==0){
			izq=parametros[i];
			id=izq;
		}
		if(i==1){
			id=parametros[i];
			cadena=parametros[i];
		}
		if(i==2)
			der=parametros[i];
			
		if(i!=0 && i!=1)
			cadena=cadena+","+parametros[i];
		
		if(d==parametros.length)
			cadena=cadena+","+parametros[0];		
		
	}	
	
	document.getElementById('ids').value=cadena;
	
	newDad = document.getElementById(divHijo).parentNode.id;

	llamarasincrono("yococms/yocoFotoNoticia.php?altoFoto="+altoFoto+"&id="+id+"&izq="+izq+"&der="+der+'&idArray='+cadena, newDad);
}


function publicarComentario(tipo,blog,modo){
	var claseAviso;
	
	switch (modo){
		case 'comentario':
			llamarasincrono('yococms/yocoBlog.php?autorizarAviso='+tipo+'&blog='+blog+'&operacion=editar&modo='+modo,'ventanaEmergenteBlog');	
			
			if(tipo==1){
				claseAviso = 'botonNoPublicar';
				onclickAviso = 'publicarComentario(0,'+blog+',\''+modo+'\')';
			}else{			
				claseAviso = 'botonPublicar';
				onclickAviso = 'publicarComentario(1,'+blog+',\''+modo+'\')';
			}	
				
			document.getElementById('botoncin_'+blog).setAttribute('class',claseAviso);
			document.getElementById('botoncin_'+blog).setAttribute('onClick',onclickAviso);
			break;

		case 'entrada':
			document.getElementById('yocofondoEm').style.display='block';
			document.getElementById('ventanaEmergente').style.innerHTML='';
			document.getElementById('ventanaEmergente').style.display='block';
			document.getElementById('ventanaEmergente').style.position="fixed";
			llamarasincrono('yococms/yocoBlog.php?autorizarAviso='+tipo+'&blog='+blog+'&operacion=nuevo&modo='+modo,'ventanaEmergente');	
			break;
		
		case 'entradaNueva':
			post('yococms/yocoBlog.php?autorizarAviso='+tipo+'&blog='+blog+'&operacion=guardarnuevo&modo='+modo,'ventanaEmergente','yocoFormNewBlog');
			break;
		
		case 'publicarentrada':
			llamarasincrono('yococms/yocoBlog.php?autorizarAviso='+tipo+'&blog='+blog+'&operacion=editar&modo='+modo,'ventanaEmergente');	
			
			if(tipo==1){
				claseAviso = 'botonNoPublicar';
				onclickAviso = 'publicarComentario(0,'+blog+',\''+modo+'\')';
			}else{			
				claseAviso = 'botonPublicar';
				onclickAviso = 'publicarComentario(1,'+blog+',\''+modo+'\')';
			}	
				
			document.getElementById('botoncinent_'+blog).setAttribute('class',claseAviso);
			document.getElementById('botoncinent_'+blog).setAttribute('onClick',onclickAviso);
			break;
	}
	
}

function eliminarComentario(blog, modo){
	
	switch (modo){
		case 'comentario':
			llamarasincrono('yococms/yocoBlog.php?blog='+blog+'&operacion=eliminar&modo='+modo,'ventanaEmergenteBlog');
			document.getElementById('editable_divComentarios_'+blog).style.display='none';
			break;
		
		case 'entrada':			
			llamarasincrono('yococms/yocoBlog.php?blog='+blog+'&operacion=eliminar&modo='+modo,'ventanaEmergente');
			delay(2000);
			window.location='blog.php';
			break;
	}
	
}

function yocomostrar(elemento){	
	var father = document.getElementById(elemento);
	var varAux = '';
	for(i=0;i<father.childNodes.length;i++){		
		varAux = father.childNodes[i].id.split("_");		
		if(varAux[0] == 'yocoBotonesImagen'){			
			document.getElementById(father.childNodes[i].id).style.display="block";
			break;
		}
		
	}
}

function yocoocultar(elemento){		
	document.getElementById(elemento).style.display="none";	
}

function fadeImagen(imagen){	
	document.getElementById(imagen).style.opacity='0.45';	
}

function noFadeImagen(imagen){
	document.getElementById(imagen).style.opacity='1';
}

function yocoimagencancelar(form, imgNombre, yocoframe){

	frames[yocoframe].document.getElementById(form).action = "yocoImagenes.php?tipo=cancelar&nombreImg="+imgNombre;	
	frames[yocoframe].document.getElementById(form).submit();
	
	
}

function yocoimagenguardar(form, imgNombre, yocoframe){	
	frames[yocoframe].document.getElementById(form).action = "yocoImagenes.php?tipo=guardar&nombreImg="+imgNombre;	
	frames[yocoframe].document.getElementById(form).submit();
}


var formAux = '';

function validar(f, inputFile)	{
	enviar = /\.(gif|jpg|png|ico|bmp)$/i.test(document.getElementById(inputFile).value);
	if (!enviar)	alert("seleccione imagen");
	return enviar;
}


function limpiar(imgNombre)	{	
	document.getElementById("inputFile_"+imgNombre).value='';	
}

function checkear(f, formulario)	{
	function no_prever() {
		alert("El fichero seleccionado no es válido...");
		var imgNombre = '';
		for(i=0;i<f.form.elements.length; i++){		
			varAux = f.form.elements[i].name.split("_");
			switch (varAux[0]){
				case 'inputFile' :					
					imgNombre2 = varAux[1]+'_'+varAux[2];
				break;				
			}	
			
		}
		
		
		limpiar(imgNombre2);
	}
	function prever() {
		
		var newCampos = new Array();
		var imgNombre = '';		
		
		for(i=0;i<f.form.elements.length; i++){		
			varAux = f.form.elements[i].name.split("_");
			switch (varAux[0]){
				case 'maxpeso' :
					newCampos.push(f.form.elements[i].name);
					imgNombre = varAux[1];
				break;
				
				case 'maxalto' :
					newCampos.push(f.form.elements[i].name);
					imgNombre = varAux[1];
				break;
				
				case 'maxancho' :
					newCampos.push(f.form.elements[i].name);
					imgNombre = varAux[1];
				break;
				
			}	
			
		}
		
		actionActual = document.getElementById(formulario).action;		
		document.getElementById(formulario).action = "yocoImagenes.php?tipo=precarga&nombreImg="+imgNombre;
		window.top.parent.document.getElementById('yocofondoEm').style.display='block';
		window.top.parent.document.getElementById('yococont_loading').style.display='block';
		document.getElementById(formulario).submit();		
				
		document.getElementById(formulario).action = actionActual;		
		
	}

	(/\.(gif|jpg|png|ico|bmp)$/i.test(f.value)) ? prever() : no_prever();
}

function datosImagen(peso, ancho, alto, error, formAux)	{
	
	function mostrar_error()	{
		enviar = false;					
		mensaje = "Ha habido un error (error nº " + error + "):";
		if (error % 2 == 1) // tipo incorrecto
			mensaje += "\nel fichero no es válido";
		error = parseInt(error / 2);
		if (error % 2 == 1) // excede en peso
			mensaje += "\nla imagen pesa mucho (" + peso + ").";
		error = parseInt(error / 2);
		if (error % 2 == 1) // excede en anchura
			mensaje += "\nla imagen es menor en anchura (" + ancho + ").";
		error = parseInt(error / 2);
		if (error % 2 == 1) // excede en altura
			mensaje += "\nla imagen es menor en altura (" + alto + ").";
		error = parseInt(error / 2);
		alert (mensaje);
		
		varAuxView = formAux.split("_");
		
		imgNombre = varAuxView[1]+'_'+varAuxView[2];
		
		limpiar(imgNombre);
	}

	if (error == 0){		
		//varAuxView = formAux.split("_");
		//window.top.parent.document.getElementById('yocoImgView_'+varAuxView[1]+'_'+varAuxView[2]+'').src = datosImg;
		//document.forms.formAux.actualizar(peso, ancho, alto, formAux);
		
	}
	else
		mostrar_error();
}

function yocoBotonTextoFN(divHijo, fn, yocoProceso){
	
	var dady = document.getElementById(divHijo).parentNode.id

	switch (yocoProceso){
		case 'cargar':
			llamarasincrono('yococms/yocoFotoNoticia.php?yocoProceso='+yocoProceso+'&idNoticia='+fn, dady);
			break;
				
	}
	
}

function yocoFckTexto(yocoTexto, yocoTextoAux){
	
	document.getElementById(yocoTexto).value=FCKeditorAPI.GetInstance(yocoTextoAux).GetData();
	
}

function yocoBotonFuncion(tipo, phppost, divHijo, yocoFormId){
	
	var dady = document.getElementById(divHijo).parentNode.id
	
	switch (tipo){
		case 'nuevo':
			llamarasincrono(phppost,dady);
						
			break;
					
		case 'eliminar':
			llamarasincrono(phppost,dady);
			
			delay(1000);
			
			window.location.reload();
			break;
		
		case 'aceptar':			
			yocoSubmit(phppost, divHijo, yocoFormId);
			break;
		
		case 'cancelar':
			yocoSubmit(phppost, divHijo, yocoFormId);
			break;
		
		
	}

	
}

var numb = '0123456789.';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function isValid(parm,val) {
  if (parm == "") return false;
  for (i=0; i<parm.length; i++) {
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}

function isNum(parm) {return isValid(parm,numb);}

function checkNum(campoNum,btnenviar){
	if(!isNum(campoNum.value)){
		campoNum.focus();
		campoNum.style.background='#FF0000';
		btnenviar.disabled=true;
		alert(campoNum.value + ' no es número');
		return false;
	}
	else{
		campoNum.style.background='#FFFFFF';
		btnenviar.disabled=false;
		return true;
	}
}

function mostrarBazarProd(cualMuestra){
	
	document.getElementById('yocofondoEm').style.display='block';
	document.getElementById('yococont_final').style.display='block'; 
	document.getElementById('yococont_final').style.position='absolute';
	document.getElementById('yococont_final').style.left='50%';
	document.getElementById('yococont_final').style.marginLeft='-260px';
	llamarasincrono('yococms/yocoBazar.php?yocoTipo=mostrar&cualMuestra='+cualMuestra,'yococont_final');
	
}


function publicarArticulo(tipo,articulo){
	var claseArticulo;	
	
	llamarasincrono('yococms/yocoBazar.php?autorizarArticulo='+tipo+'&articulo='+articulo+'&yocoTipo=editar','yocoVentanaBazarAux');
	
	if(tipo==1){
		claseArticulo = 'botonNoVender';
		onclickArticulo = 'publicarArticulo(0,'+articulo+')';		
	}else{
		claseArticulo = 'botonVender';
		onclickArticulo = 'publicarArticulo(1,'+articulo+')';
	}
	
	document.getElementById('botoncin_'+articulo).setAttribute('class',claseArticulo);
	document.getElementById('botoncin_'+articulo).setAttribute('onClick',onclickArticulo);
	
}

function eliminarArticulo(articulo){	
	
	llamarasincrono('yococms/yocoBazar.php?articulo='+articulo+'&operacion=eliminar','yocoVentanaBazarAux');

	llamarasincrono('yococms/yocoBazar.php?articulo=&yocoTipo=actualizar','yocoVentanaBazarAux');
	document.getElementById('cuadroInfo_'+articulo).innerHTML='';
}


function yocoMoverIzq(mostrar, retroceso){
	var comienza = parseInt(retroceso,10) - parseInt(mostrar,10);
	
	if(comienza<0)
		comienza = 0;
	
	llamarasincrono('yococms/yocoBazar.php?yocoTipo=mostrar&comienza='+comienza+'&mostrar='+mostrar,'yococont_final');
}

function yocoMoverDer(mostrar, adelante){
	var comienza = parseInt(adelante,10) + parseInt(mostrar,10);
	
	llamarasincrono('yococms/yocoBazar.php?yocoTipo=mostrar&comienza='+comienza+'&mostrar='+mostrar,'yococont_final');
}

function reacomodarNubes(){
	padre = document.getElementById('pagina');
	var nombreDiv = '';
	
	for(j=0; j<padre.getElementsByTagName("DIV").length; j++){
		
							
		nombreDiv = padre.getElementsByTagName("DIV")[j].id.split("_");		
		divHijo = padre.getElementsByTagName("DIV")[j].id;
		if(nombreDiv[0] == 'yoconube'){		
			
			
			
			switch(nombreDiv[1]){
				
				case 'master':
				
					divMaster = divHijo;					
					
					break;
				
								
				case 'top':		
				
					divTop = divHijo;
					
				break;
				
				case 'cen':	
					divCen = divHijo;
					
					divContenedorAncho = document.getElementById(divHijo).offsetWidth;
					divContenedorAlto = document.getElementById(divHijo).offsetHeight;
					
					//divContenedorAlto2 = document.getElementById(divMaster).offsetHeight;
					
					//if(divHijo=='yoconube_cen_contenido_1_2')
						//alert(' centro: divContenedor: '+divContenedorAlto2);
					
					if((parseInt(divContenedorAncho,10)%28)!=0){
						
						anchoAux = 0;
						do{
							anchoAux += 28;					
						}while(parseInt(divContenedorAncho,10)>parseInt(anchoAux,10));
						
					}else{
						anchoAux = parseInt(divContenedorAncho,10);
					}					
					
					
					//if(divHijo=='yoconube_cen_nube_1_2')
						//alert('divHijo: '+divHijo+' centro: anchoAux: '+anchoAux);
					
					if((parseInt(divContenedorAlto,10)%28)!=0){
						altoAux = 0;
						do{
							altoAux += 28;					
						}while(parseInt(divContenedorAlto,10)>parseInt(altoAux,10));
					}else{
						altoAux = parseInt(divContenedorAlto,10);
					}
					
					document.getElementById(divHijo).setAttribute('style','height:'+altoAux+'px; width:100%;');
					
				break;
				
				case 'bot':
				
					divBot = divHijo;				
					
					divAncho = document.getElementById(divCen).offsetWidth;
					
					//divAlto = document.getElementById(divCen).offsetHeight;
					
					//divAlto2 = document.getElementById(divMaster).style.height;
					
					//if(divHijo=='yoconube_bot_contenido_1_2')
						//alert('alto nuevo del botom: '+divAlto+' otro alto: '+divAlto2);
					if(parseInt(divAncho,10)==0)
						divAncho = document.getElementById(divMaster).style.width;
						
						//if(divHijo=='yoconube_bot_contenido_1_3')
							//alert('ancho nuevo del botom: '+divAncho);
						
						if((parseInt(divAncho,10)%28)!=0){
							anchoAux = 0;
							do{
								anchoAux += 28;					
							}while(parseInt(divAncho,10)>parseInt(anchoAux,10));
						}else{
							anchoAux = divAncho;
						}
					
					
					document.getElementById(divMaster).style.width=''+anchoAux+'px';
					document.getElementById(divTop).style.width=''+anchoAux+'px';
					document.getElementById(divCen).style.width=''+anchoAux+'px';
					document.getElementById(divBot).style.width=''+anchoAux+'px';
					
				
				break;				
				
			}
		
		}
	
	}

}


function yocoCambiarFondo(fondo, lugar, totalElementos, connube){
	var elementosCambiar = totalElementos.split("|");
	
	for(i=0;i<elementosCambiar.length; i++){
		
		document.getElementById('u'+elementosCambiar[i]).setAttribute('style','font-size:14px;');
	
		document.getElementById('u'+elementosCambiar[i]).className="textoNegro";
		if(connube==1){			
			document.getElementById('yocoPadre_'+elementosCambiar[i]).style.display="none";				
		}
		
	
	}
	
	
	$(lugar).fade(0.5);
	
	document.getElementById('u'+fondo).setAttribute('style','text-decoration:none; font-size:14px; cursor:auto;');
	
	document.getElementById('u'+fondo).className="textoRojo";
	
	setTimeout('document.getElementById(\''+lugar+'\').src="recursos/imagenes/'+fondo+'.jpg"; $(\''+lugar+'\').fade(1);',500);	
	
	if(connube==1){
		document.getElementById('yocoPadre_'+fondo).style.display="block";
	}	

}


function yocoValidar (elementos, valores){
	
	var elem = elementos.split("|");
	
	var nomElem = valores.split("|");
	
	yocoListo=true
	
	yocoCampos = '';

	for(i=0; i<elem.length; i++){
		
		if(document.getElementById(elem[i]).value==''){		
			yocoListo = false;
			yocoCampos+='- '+nomElem[i]+'\n';
		}
	}
	
	
	if(yocoCampos!='')
		alert('Favor de llenar los siguientes espacios:\n\n'+yocoCampos);
		
	return yocoListo;
}

function yocoMostrarTexto(prefijo, textoElegido, totalElementos, idElemento){
	var elementosCambiar = totalElementos.split("|");
	
	for(i=0;i<elementosCambiar.length; i++)
		document.getElementById(prefijo+elementosCambiar[i]).style.display="none";		
	
	
	document.getElementById(prefijo+textoElegido).style.display="block";		
	document.getElementById('galletaElegida').value = idElemento;
}

function verificarIgualdad(campo1, campo2, botonEnviar){
	
	if(document.getElementById(campo1).value != document.getElementById(campo2).value){
		alert('No coinciden los valores');
		document.getElementById(botonEnviar).disabled = true;
		
	}else{
		document.getElementById(botonEnviar).disabled = false;
	}
	
}
