function cargarEditor() {
		crearEditor('Comentario', 200);
}
	
function crearEditor(Nombre, alto) {

	var oFCKeditor = new FCKeditor( Nombre ) ;	
	oFCKeditor.BasePath	= BASE + 'js/fckeditor/fckeditor/';
	oFCKeditor.Height = alto;
	oFCKeditor.Width = 600; // ancho del editor
	oFCKeditor.ToolbarSet = "ToolBarPosts";
	oFCKeditor.ReplaceTextarea();
	
}		

function addOnloadEvent(fnc){
	  if ( typeof window.addEventListener != "undefined" )
		window.addEventListener( "load", fnc, false );
	  else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", fnc );
	  }
	  else {
		if ( window.onload != null ) {
		  var oldOnload = window.onload;
		  window.onload = function ( e ) {
			oldOnload( e );
			window[fnc]();
		  };
		}
		else
		  window.onload = fnc;
	  }
}	

function ltrim(s) {
   return s.replace(/^\s+/, "");
}

function rtrim(s) {
   return s.replace(/\s+$/, "");
}

function trim(s) {
   return rtrim(ltrim(s));
}



function $(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function $S(o) { return((typeof(o)=='object'?o:$(o)).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function abPos(o) { var o=(typeof(o)=='object'?o:$(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; return(z); }
function XY(e,v) { var o=agent('msie')?{'X':event.clientX+document.documentElement.scrollLeft,'Y':event.clientY+document.documentElement.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); }

star={};

star.mouse=function(e,o) { if(star.stop || isNaN(star.stop)) { star.stop=0;

    document.onmousemove=function(e) { var n=star.num;
    
        var p=abPos($('star'+n)), x=XY(e), oX=x.X-p.X, oY=x.Y-p.Y; star.num=o.id.substr(4);

        if(oX<1 || oX>84 || oY<0 || oY>19) 
			{ star.stop=1; star.revert(); }        
        else {

            $S('starCur'+n).width=oX+'px';
            $S('starUser'+n).color='#111';
            $('starUser'+n).innerHTML=Math.round(oX/84*100)+'%';
        }
    };
} };

star.update=function(e,o, IdFoto) { var n=star.num, v=parseInt($('starUser'+n).innerHTML);

    n=o.id.substr(4); $('starCur'+n).title=v;
    req=new XMLHttpRequest(); req.open('GET','http://www.cactuseros.com/VotarFotoCactus/'+IdFoto+'/Calificacion/'+(v/100),false); req.send(null);    
	
	// voto... apago el rater
	star.desactivar(o);
	$('cantVotos'+n).innerHTML = '&nbsp;-&nbsp;Voto enviado!';

};

star.revert=function() { var n=star.num, v=parseInt($('starCur'+n).title);

    $S('starCur'+n).width=Math.round(v*84/100)+'px';
    $('starUser'+n).innerHTML=(v>0?Math.round(v)+'%':'0%');
    $('starUser'+n).style.color='#888';
    
    document.onmousemove='';

};

star.desactivar=function(o) { 

	n=o.id.substr(4); 
	v=parseInt($('starCur'+n).title);
    $S('starCur'+n).width=Math.round(v*84/100)+'px';
    $('starUser'+n).innerHTML=(v>0?Math.round(v)+'%':'');
    $('starUser'+n).style.color='#888';
	o.onmousedown = function() {
						  alert('Ya ha votado esta foto.');
						};
	o.onmousemove = '';
    
    //document.onmousemove='';

};

star.inicializar=function(n) { 

	var v=parseInt($('starCur'+n).title);

    $S('starCur'+n).width=Math.round(v*84/100)+'px';
    $('starUser'+n).innerHTML=(v>0?Math.round(v)+'%':'0%');
    $('starUser'+n).style.color='#888';

};

star.num=0;