/**************************************************************

	Script	: Image Menu
	Version	: 2.2
	Authors	: Samuel Birch
	Desc	: 
	Licence	: Open Source MIT Licence

**************************************************************/

var ImageMenu=new Class({
	
	getOptions: function(){
		return {
			onOpen: true,
			onClose: Class.empty,
			openWidth: 310,
			transition: Fx.Transitions.quadOut,
			duration: 350,
			open: null,
			border: 0
		};
	},

	initialize: function(elements, options){
		this.setOptions(this.getOptions(), options);
		
		this.elements=$$(elements);
		
		this.widths={};
		this.widths.closed=this.elements[0].getStyle('width').toInt();
		this.widths.openSelected=this.options.openWidth;
		this.widths.openOthers=Math.round(((this.widths.closed*this.elements.length) - (this.widths.openSelected+this.options.border)) / (this.elements.length-1))
		
		
		this.fx=new Fx.Elements(this.elements, {wait: false, duration: this.options.duration, transition: this.options.transition});
		
		this.elements.each(function(el,i){
			el.addEvent('mouseenter', function(e){
				new Event(e).stop();
				this.reset(i, 0);
				
			}.bind(this));
			
			el.addEvent('mouseleave', function(e){
				new Event(e).stop();
				this.reset(this.options.open, 1);
				
			}.bind(this));
			
			var obj=this;
			
			el.addEvent('click', function(e){

				if(obj.options.onOpen){
					new Event(e).stop();
					if(obj.options.open== i){
						obj.options.open=null;
						obj.options.onClose(this.href, i);
					}else{
						obj.options.open=i;
						obj.options.onOpen(this.href, i);
					}
					
					
				}
				
			})
			
		}.bind(this));
		
		if(this.options.open){
			if($type(this.options.open)== 'number'){
				this.reset(this.options.open, 0);
			}else{
				this.elements.each(function(el,i){
					if(el.id== this.options.open){
						this.reset(i, 0);
					}
				},this);
			}
		}
		
	},

	reset: function(num, todos){
		if($type(num)== 'number' && todos== 0){
			var width=this.widths.openOthers;
			if(num+1== this.elements.length){
				width+= this.options.border;
			}
		}else{
			var width=this.widths.closed;
		}
		
		var obj={};
		this.elements.each(function(el,i){
			var w=width;
			if(i== this.elements.length-1){
				w=width+5
			}
			obj[i]={'width': w};
		}.bind(this));
		
		if($type(num)== 'number' && todos== 0){
			obj[num]={'width': this.widths.openSelected};
		}
				
		this.fx.start(obj);
	}
	
});

ImageMenu.implement(new Options);
ImageMenu.implement(new Events);


/*************************************************************/

/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
if(typeof(oldonload)=='function')
    window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","/js/niftyCorners.css");
l.setAttribute("media","screen");
//document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}

/**************************************************************/
/**************************************************************/
/**************************************************************/


function validarfecha(nombre) {
	for (i=0; i<document.form.elements.length; i++) {
    if ((document.form.elements[i].name== nombre) && (document.form.elements[i].value != '')) {
      anio=document.form.elements[i].value.substr(0, 4);
      mes=document.form.elements[i].value.substr(5, 2);
      dia=document.form.elements[i].value.substr(8, 2);
      if (((anio > '2006' && anio<'2100') && (mes >= '01' && mes<= '12') && (mes >= '01' && dia<= '31'))== false) {
				alert('La fecha ingresada no tiene un formato valido. El formato correcto es: aaaa/mm/dd');
        document.form.elements[i].focus();
      }
    }
  }          
}


function validartext(a_elemento, a_img, a_marcador) {
	var el=document.getElementById(a_elemento); 
	if (el.value== '') {	 
		return false;
	} else {
		return true;
	}
}


function validarlista(a_elemento, a_img, a_marcador, a_minimo) {
	var el=document.getElementById(a_elemento); 
	if (el.options.length<a_minimo) {
		return false;
	} else {
		return true;
	}
}

function validarselect(a_elemento, a_default) {
	var el=document.getElementById(a_elemento); 
	if (el.options[el.selectedIndex].value== a_default) {
		return false;
	} else {
		return true;
	}
}

function validarradio(a_radio){
  // comprobamos que en el grupo de radio haiga uno seleccionado
	var el=a_radio; 
		if (el.length > 1) {
			for(var ctr=0;ctr<el.length; ctr++){
				if(el[ctr].checked){
						return true
				}
			}
		} else {
			if(el.checked){ return true}
		}
  // Si no hay ninguno seleccionado
	return false;
} 

function enviarcomentario(a_codigo) {
	mensaje='--';
					
	form=document.getElementById('frmcomentario');
	// valido el codigo
	if (form.edtcodigo.value != a_codigo) {
		mensaje='El codigo de validación ingresado no es válido.';
	}
	
	if (document.getElementById('edtnombre')) {
		nombre=form.edtnombre.value;
	} else { nombre=''; }
	if (document.getElementById('edtmail')) {
		mail=form.edtmail.value;
	} else { mail=''; }

	if (mensaje== '--') {
		if ((form.hdidusuario.value== -1) && (form.edtnombre.value== '')) {
			alert('Tienes que ingresar un nombre');
		} else {
/*			for(var i=0; i<form.rbintencion.length; i++) {
				if (form.rbintencion[i].checked) {
					intencion=form.rbintencion[i].value}
			} 
			for(var i=0; i<form.rbclasifica.length; i++) {
				if (form.rbclasifica[i].checked) {
					clasifica=form.rbclasifica[i].value}
			}		*/		
			cmdata('/ajax/aj_comentarfin.php','div_ajcomentar','edtid='+ form.edtid.value+'&edtidcat='+form.edtidcat.value+'&edtnombre='+nombre+'&edtcomentario='+form.edtcomentario.value+'&edtmail='+mail+'&edtidcom='+form.hdidcom.value+'&edtidusuario='+form.hdidusuario.value,'');
		}
	} else {
		alert(mensaje);
	}	
}

function enviarseccion(a_id,a_accion) {
	mensaje='--';
					
	form=document.getElementById('frmseccion');

	if ((form.edtnombre.value== '')) {
		mensaje='Tienes que ingresar un nombre para la sección';
	}
	if ((form.edtsubdominio.value== '')) {
		mensaje='Tienes que ingresar un subdominio para la sección';
	}

for(var i=0; i<form.rbhome.length; i++) {
		if (form.rbhome[i].checked) {
			rbhome=form.rbhome[i].value}
	}		

	if (mensaje== '--') {
			cmdata('/admin/secciones/aj_seccion.php?iu='+a_id+'&accion='+a_accion,'div_ajseccion'+a_id,'&edtnombre='+ form.edtnombre.value+'&edtsubdominio='+form.edtsubdominio.value+'&edtdescripcion='+form.edtdescripcion.value+'&edturl='+form.edturl.value+'&cbidpadre='+form.cbidpadre.value+'&rbhome='+rbhome+'&cbestado='+form.cbestado.value,'');
	} else {
		alert(mensaje);
	}	
}

function enviaraviso(a_codigo) {
	mensaje='--';
					
	formaux=document.getElementById("form");
	// valido el codigo
	if (formaux.edtcodigo.value != a_codigo) {
		mensaje='El código de validación ingresado no es válido.';
	}

	if (mensaje== '--') {
		cmdata('/boxs/aj_reportarfin.php','div_ajreportar','hdid='+ formaux.hdid.value+'&hdidinfo='+formaux.hdidinfo.value+'&edtnombre='+formaux.edtnombre.value+'&edtasunto='+formaux.edtasunto.value+'&edttexto='+formaux.edttexto.value+'&edtmail='+formaux.edtmail.value,'');
	} else {
		alert(mensaje);
	}	
}


function setfirma(a_accion, a_id) {
	mensaje='--';
					
	formaux=document.getElementById("frmfirma");
	// valido el codigo
	if (formaux.edtnombre.value== '') {
		mensaje='Debe ingresar un nombre para poder identificar la firma.';
	}

	if (mensaje== '--') {
		if (a_accion== 'editar') {
			url="/usuarios/perfil/firmas/aj_firma.php?iu="+a_id+"&accion="+ a_accion;
			destino='div_ajfirma'+a_id;
		} else {
			url="/usuarios/perfil/firmas/aj_setfirma.php?accion="+ a_accion;
			destino='div_ajsetfirma';
		}
		parametros="nombre="+formaux.edtnombre.value+"&texto="+formaux.edttexto.value+"&idlogotipo="+formaux.hdidlogotipo.value+"&webtexto="+formaux.edtwebtexto.value+"&weburl="+formaux.edtweburl.value+"&correo="+formaux.edtcorreo.value;
		cmdata(url, destino, parametros, 'chico');
	} else {
		alert(mensaje);
	}	
}

function setpassword() {
	mensaje='--';					
	formaux=document.getElementById("frmpassword");
	// valido el codigo
	if (formaux.edtnueva.value != formaux.edtconfirmar.value) {mensaje='La nueva contraseña y la confirmación no coinciden';}

	if (formaux.edtnueva.value.length<5) {mensaje='La nueva contraseña debe tener al menos 5 caracteres';}

	if (mensaje== '--') {
		cmdata('/usuarios/perfil/aj_setpassword.php','div_ajeditpassword','actual='+ formaux.edtactual.value+'&nueva='+formaux.edtnueva.value,'');
	} else {
		alert(mensaje);
	}	
}

function verificarnick() {
	mensaje='--';					
	formaux=document.getElementById("frmregistro");
	// valido el codigo
	if (mensaje== '--') {
		cmdata('/usuarios/ajax_general/aj_nick.php','div_ajnick','nick='+ formaux.edtnick.value+'&nombre='+ formaux.edtnombre.value+'&apellido='+ formaux.edtapellido.value+'&correo='+ formaux.edtcorreo.value,'Verificando...');
	} else {
		alert(mensaje);
	}	
}

function setregistro() {
	mensaje='--';					
	formaux=document.getElementById("frmregistro");
	// valido el codigo
	if (mensaje== '--') {
		cmdata('/usuarios/ajax_general/aj_setregistro.php','div_ajsetregistro','nick='+ formaux.edtnick.value+'&nombre='+ formaux.edtnombre.value+'&apellido='+ formaux.edtapellido.value+'&correo='+ formaux.edtcorreo.value+'&pass='+ formaux.edtpassword.value+'&pass2='+ formaux.edtpassword2.value,'Controlando datos ingresados...');
	} else {
		alert(mensaje);
	}	
}



function setimagen(a_id, a_param, a_divdestino, a_form) {
	form=document.getElementById(a_form);
	url="/usuarios/imagenes/aj_setimagen.php?"+ a_param+a_id;
	destino=a_divdestino;
	parametros="edtnombre="+form.edtnombre.value+"&estado="+form.cbestado.value;
	cmdata(url, destino, parametros, 'chico');
}

function enviarlogin($a_ubicacion) {
	mensaje='--';
	form=document.getElementById('frmlogin');
	if (form.chkrecordarme.checked) {recordarme=1;} else {recordarme=0;}
	// valido el codigo
	if ($a_ubicacion== 'top') {
	cmdata('/usuarios/ajax_general/aj_loginfin.php?ubicacion=top','div_ajlogintop','edtusuario='+ form.edtusuario.value+'&edtpassword='+form.edtpassword.value+'&chkrecordarme='+recordarme,'chico');
	} else {
	cmdata('/usuarios/ajax_general/aj_loginfin.php','div_ajlogin','edtusuario='+ form.edtusuario.value+'&edtpassword='+form.edtpassword.value+'&chkrecordarme='+recordarme,'chico');		
	}
}




function enviarimagen(a_codigo) {
	mensaje='--';
	form=document.getElementById('frmsubirimagen');
	// valido el codigo
	if (form.edtcodigo.value!=a_codigo) {
		mensaje='El código de validación ingresado no es válido.';
	}

	if (mensaje=='--') {
			form.submit();
	} else {
		alert(mensaje);
	}	
}


function filtro_marcartodos(a_componente){
for(var i=0;i<a_componente.length; i++){  
		a_componente[i].checked=true;
	}	
}

function filtro_desmarcartodos(a_componente){
for(var i=0;i<a_componente.length; i++){  
		a_componente[i].checked=false;
	}	
}

function get_indicexorden(a_urlweb, a_id, a_url_formateada, a_subdominio, a_homesubdominio, a_orden) {

	orden=a_orden;
	
  urlhost=document.location.href;
	if ((urlhost.indexOf("http://localhost") != -1) || (urlhost.indexOf("http://pc") != -1)) {
	  	url='/seccion.php?iu='+a_id+'&url='+a_url_formateada;
	} else {
		if (a_subdominio != '') {
				url='http://'+a_subdominio+'.'+a_urlweb+'/';
			} else {
				url='http://www.'+a_urlweb+'/';
		}	

		url=url+'i'+a_id+'/'+a_url_formateada;
	}
	document.cookie="filtro_orden="+escape(orden)+"; path=/";	
	window.open(url,'_self');
}

function zoomText(Accion,Elemento,maximo,normal,minimo){
	//inicializacion de variables y parmetros
	var obj=document.getElementById(Elemento);
	var max=maximo //tamao mximo del fontSize
	var min=minimo //tamao mnimo del fontSize
	if (obj.style.fontSize==""){
		obj.style.fontSize=normal+"px";
	}
	actual=parseInt(obj.style.fontSize); //valor actual del tamao del texto
	incremento=1;// el valor del incremento o decremento en el tamao
	
	//accion sobre el texto
	if( Accion=="reestablecer" ){
		obj.style.fontSize=normal+"px"
	}
	if( Accion=="aumentar" && ((actual+incremento)<= max )){
		valor=actual+incremento;
		obj.style.fontSize=valor+"px"
	}	
	if( Accion=="disminuir" && ((actual-incremento) >= min )){
		valor=actual-incremento;
		obj.style.fontSize=valor+"px"
	}
}

function muestra_ocultar(id){
	if (document.getElementById){ //se obtiene el id
	var el=document.getElementById(id); //se define la variable "el" igual a nuestro div
	el.style.display=(el.style.display== 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
	}
}

function mostrar(id){
	if (document.getElementById){ //se obtiene el id
	var el=document.getElementById(id); //se define la variable "el" igual a nuestro div
	el.style.display='block'; 
	}
}
function ocultar(id){
	if (document.getElementById){ //se obtiene el id
	var el=document.getElementById(id); //se define la variable "el" igual a nuestro div
	el.style.display='none'; //damos un atributo display:none que oculta el div
	}
}

function mostrarpaso(a_paso, a_pasos) {
	for (i = 1; i <= a_pasos; ++i) {
		var divmenu=document.getElementById('div_menu'+i);	
		var divpaso=document.getElementById('div_paso'+i);	
		if (i == a_paso) {
			divmenu.style.backgroundColor='#f8f8f8';
			divmenu.style.borderTop='2px solid #e5e5e5';
			divmenu.style.borderLeft='2px solid #e5e5e5';
			divmenu.style.borderRight='2px solid #e5e5e5';
			divmenu.style.fontSize='18px';
			divpaso.style.display='block';
		} else {
			divmenu.style.backgroundColor='#ffffff';	
			divmenu.style.border='none';
			divmenu.style.fontSize='12px';
			divpaso.style.display='none';
		}
	}
}

function cerrarsesion() {
	document.cookie="id=-1"+"; path=/";
	document.cookie="nick="+"; path=/";	
}

function ucfirst(frmObj) {
	tmpStr=frmObj.value.toLowerCase();
	if (tmpStr.length > 0) {
		tmpStr=tmpStr.substring(0,1).toUpperCase()+tmpStr.substring(1,tmpStr.length);
	}
	frmObj.value=tmpStr;
}

function setcomentario(a_accion, a_numdiv) {
	mensaje='--';
	form=document.getElementById('frmcomentario'+a_numdiv);

	id=form.hdid.value;
	
	if (mensaje== '--') {
		if (form.edtcomentario.value== '' && a_accion != 'borrar') {
			alert('El comentario no puede estar en blanco');
		} else {
			cmdata('/usuarios/comentarios/aj_comentario.php?iu='+id+'&accion='+a_accion,'div_ajcomentario'+a_numdiv,'edtcomentario='+ form.edtcomentario.value+'&hdpos='+form.hdpos.value,'grande');
		}
	} else {
		alert(mensaje);
	}	
}

function checklen(a_max, a_elemento, a_eldisplay) {
	txt=document.getElementById(a_elemento);
	display=document.getElementById(a_eldisplay);
	var n=txt.value.length;
	if (n>a_max)	{
	txt.value=txt.value.substring(0, a_max);
	}
	if (display != false) {
		resto=a_max - n - 1;
		if (resto<0) { resto=0;}
			display.value=resto;
	}	
}


function loadajax(a_url, a_destino, a_datos, a_formulario, a_mensaje) {
	if (!document.getElementById(a_destino)) {
			alert((a_destino || "no existe")); //Evitamos que la propiedad no exista
	}
	// mensaje o texto a mostrar mientras se carga
	HTML='';
	if(a_mensaje != '') {
		HTML='<div style="margin: 9px 6px">'+a_mensaje+'</div>';
	}	
	if(a_mensaje== 'chico') {
	  HTML='<div><img src="/imagenes/iconos/ajax-chico.gif" />Cargando...</div>'; }
	if(a_mensaje== 'grande'){
		HTML='<div align="center" ><img src="/imagenes/iconos/ajax-grande.gif" width="55" height="55" /><br />Cargando contenido...</div>'; }

	if(a_formulario== 1) {
		datos=$(a_datos)
	} else {
		datos=a_datos
	}

	var miAjax=new Ajax(a_url, {
	method: 'get', //Elegimos el método de envio
	data:datos, //las variables que pasamos a php
	onRequest: function() {this.options.update.setHTML(HTML);},
	update: $(a_destino) //el div con id respuesta1 es donde se podrá visualizar el resultado
	});
	miAjax.request(); //Enviamos la petición
}

function enviarcontacto(a_codigo) {
	mensaje='--';
					
	formaux=document.getElementById("frmcontacto");
	// valido el codigo
	if (formaux.edtcodigo.value != a_codigo) {
		mensaje='El código de validación ingresado no es válido.';
	}

	if (mensaje== '--') {
		if (formaux.edtmaildesde.value== '') {
			alert('Por favor ingresa una dirección de correo para contacto');
		} else {
			cmdata('/ajax/aj_contactofin.php','div_ajcontacto','edtde='+ formaux.edtde.value+'&edtmaildesde='+formaux.edtmaildesde.value+'&edtasunto='+formaux.edtasunto.value+'&edttexto='+formaux.edttexto.value,'');
		}
	} else {
		alert(mensaje);
	}	
}

function enviarinvitacion(a_codigo) {
	mensaje='--';
					
	formaux=document.getElementById("form");
	// valido el codigo
	if (formaux.edtcodigo.value != a_codigo) {
		mensaje='El código de validación ingresado no es válido.';
	}

	if (mensaje== '--') {
		if (formaux.edtmail.value== '') {
			alert('Tienes que ingresar una dirección de correo de destino');
		} else {
			loadajax('/ajax/aj_recomendarfin.php', 'div_ajrecomendar', 'form', 1, '');
		}
	} else {
		alert(mensaje);
	}	
}


function agregar(){
	//Para internet explorer
	if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
	var url=location.href; 
	var titulo=document.title; 
	window.external.AddFavorite(url,titulo);
	}
	//Para Netscape y Firefox
	else {
	if(navigator.appName == "Netscape")
	alert ("Presione Crtl+D para agregar a este sitio en sus marcadores");  //Puedes personalizar este mensaje
	}
}

function setvoto(a_pos) {
	var d=document;
	if (a_pos== 0) {
		for(i=1; i<= 5;++i) {
			d.getElementById('divvoto_'+i).style.backgroundImage='url(/imagenes/iconos/ic-votar-off.gif)';
		}
	} else {
		for(i=1; i<= a_pos;++i) {
			d.getElementById('divvoto_'+i).style.backgroundImage='url(/imagenes/iconos/ic-votar-on.gif)';
		}
	}
}


/*
	Slimbox v1.53 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox;(function(){var G=0,F,L,B,S,T,O,b,E,M,J=new Image(),K=new Image(),X,a,P,H,W,Z,I,Y,C;window.addEvent("domready",function(){b=V.bindWithEvent();$(document.body).adopt($$([X=new Element("div",{id:"lbOverlay"}),a=new Element("div",{id:"lbCenter"}),Z=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));P=new Element("div",{id:"lbImage"}).injectInside(a).adopt(H=new Element("a",{id:"lbPrevLink",href:"#"}),W=new Element("a",{id:"lbNextLink",href:"#"}));H.onclick=D;W.onclick=R;var d;I=new Element("div",{id:"lbBottom"}).injectInside(Z).adopt(d=new Element("a",{id:"lbCloseLink",href:"#"}),Y=new Element("div",{id:"lbCaption"}),C=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}));d.onclick=X.onclick=N;E={overlay:X.effect("opacity",{duration:500}).set(0),image:P.effect("opacity",{duration:500,onComplete:A}),bottom:I.effect("margin-top",{duration:400})}});Slimbox={open:function(f,e,d){F=$extend({loop:false,overlayOpacity:0.80,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,animateCaption:true,showCounter:true,counterText:"Imagen {x} de {y}"},d||{});if(typeof f=="string"){f=[[f,e]];e=0}L=f;F.loop=F.loop&&(L.length>1);c();Q(true);O=window.getScrollTop()+(window.getHeight()/15);E.resize=a.effects($extend({duration:F.resizeDuration,onComplete:A},F.resizeTransition?{transition:F.resizeTransition}:{}));a.setStyles({top:O,width:F.initialWidth,height:F.initialHeight,marginLeft:-(F.initialWidth/2),display:""});E.overlay.start(F.overlayOpacity);G=1;return U(e)}};Element.extend({slimbox:function(d,e){$$(this).slimbox(d,e);return this}});Elements.extend({slimbox:function(d,g,f){g=g||function(h){return[h.href,h.title]};f=f||function(){return true};var e=this;e.forEach(function(h){h.onclick=function(){var i=e.filter(f,this);return Slimbox.open(i.map(g),i.indexOf(this),d)}});return e}});function c(){X.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function Q(d){["object",window.ie?"select":"embed"].forEach(function(f){$each(document.getElementsByTagName(f),function(g){if(d){g._slimbox=g.style.visibility}g.style.visibility=d?"hidden":g._slimbox})});X.style.display=d?"":"none";var e=d?"addEvent":"removeEvent";window[e]("scroll",c)[e]("resize",c);document[e]("keydown",b)}function V(d){switch(d.code){case 27:case 88:case 67:N();break;case 37:case 80:D();break;case 39:case 78:R()}d.preventDefault()}function D(){return U(S)}function R(){return U(T)}function U(d){if((G==1)&&(d>=0)){G=2;B=d;S=((B||!F.loop)?B:L.length)-1;T=B+1;if(T==L.length){T=F.loop?0:-1}$$(H,W,P,Z).setStyle("display","none");E.bottom.stop().set(0);E.image.set(0);a.className="lbLoading";M=new Image();M.onload=A;M.src=L[d][0]}return false}function A(){switch(G++){case 2:a.className="";P.setStyles({backgroundImage:"url("+L[B][0]+")",display:""});$$(P,I).setStyle("width",M.width);$$(P,H,W).setStyle("height",M.height);Y.setHTML(L[B][1]||"");C.setHTML((F.showCounter&&(L.length>1))?F.counterText.replace(/{x}/,B+1).replace(/{y}/,L.length):"");if(S>=0){J.src=L[S][0]}if(T>=0){K.src=L[T][0]}if(a.clientHeight!=P.offsetHeight){E.resize.start({height:P.offsetHeight});break}G++;case 3:if(a.clientWidth!=P.offsetWidth){E.resize.start({width:P.offsetWidth,marginLeft:-P.offsetWidth/2});break}G++;case 4:Z.setStyles({top:O+a.clientHeight,marginLeft:a.style.marginLeft,visibility:"hidden",display:""});E.image.start(1);break;case 5:if(S>=0){H.style.display=""}if(T>=0){W.style.display=""}if(F.animateCaption){E.bottom.set(-I.offsetHeight).start(0)}Z.style.visibility="";G=1}}function N(){if(G){G=0;M.onload=Class.empty;for(var d in E){E[d].stop()}$$(a,Z).setStyle("display","none");E.overlay.chain(Q).start(0)}return false}})();

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage=function() {
	var links=$$("a").filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	});
	$$(links).slimbox({/* Put custom options here */}, null, function(el) {
		return (this== el) || ((this.rel.length > 8) && (this.rel== el.rel));
	});
};
window.addEvent("domready", Slimbox.scanPage);



var d=document;
function cmdata(pag,escribir,elementos,tamano){
//         alert(escribir);       
// Podríamos indicar que estamos cargando los datos.... que espere, :p, pero no lo haremos a
// d.getElementById(escribir).innerHTML='Cargando datos...';
	if (!document.getElementById(escribir)) {
				alert((escribir || "no existe")); //Evitamos que la propiedad no exista
	}

	d.getElementById(escribir).innerHTML= '';
	if(tamano!=''){
		d.getElementById(escribir).innerHTML='<div>'+tamano+'</div>';		
	}
	if(tamano=='chico'){
			d.getElementById(escribir).innerHTML='<div><img src="/imagenes/ajax-chico.gif" />Cargando...</div>';
	}
	if(tamano=='grande'){
			d.getElementById(escribir).innerHTML='<div align="center" ><img src="/imagenes/ajax-grande.gif" width="66" height="66" /><br />Cargando contenido...</div>';;
	}
	

// Compatibilidad con firefox, opera y cualquier otro BUEN navegador
		if(typeof(XMLHttpRequest)!='undefined'){
				try
				{
						var pet=new XMLHttpRequest();
				} catch(e) {}
		}    else    {
// Compatibilidad para el navegador más asqueroso del planeta [ IE ]
				try
				{
						var pet=new ActiveXObject('Microsoft.XMLHTTP'); } catch(e){
						var pet=new ActiveXObject('Msxml2.XMLHTTP');
				}
		}
// una vez incializado el objeto y definido en el contexto de nuestro script
// Intentaremos abrir la conexión a la dirección indicada por la variable 'pag'
		
try
{
// esto bien podría cambiar a "pet.open('GET',pag,true);" si se desea pasar los datos mediante método GET
		pet.open('POST',pag,true);
}
catch(e)
{
		//return false;
}
		// Esta variable envía una cabecera indicando que enviaremos los datos método 'post' en forma urlencoded
		// ejemplo ("mi_variable=cosa&otra_variable=otra_cosa");
		pet.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		// Enviamos los datos 'elementos'
		pet.send(elementos);
try {
		// Justo cuando el estatus de la petición cambia esperamos a que sea igual a 4 que es igual a OK.
						pet.onreadystatechange=function (){
										if(pet.readyState== 4){
		// ¡¡¡ Listo !!!, ahora ya tenemos el resultado y podemos acceder a él desde 'pet.responseText'
		// El resultado lo vamos a escribir en el elemento 'escribir' ...
				d.getElementById(escribir).innerHTML=pet.responseText;
				init_ibox();
										}
						}
		} catch(e) {
				//return false;
		}
				//return;
								}
		// Con esta función crearemos algo como un 'bucle' de tiempo
		// Esto para que se ejecute cada 'ptimer' segundos.
		function setTimer(cad,ptimer){
						eval(cad);
						setTimeout("setTimer('"+cad+"',"+ptimer+")",ptimer);
		}

//<-------------// JavaScript Document