
function showBox(idbox){
	var idbtn = idbox+'_show_hide';

	var box = (navigator.appName=='Netscape') ? document.getElementById(idbox) : document.all[idbox];
	var btn = (navigator.appName=='Netscape') ? document.getElementById(idbtn) : document.all[idbtn];

	box.className = (btn.innerHTML=='Mostrar') ? 'box_content_show' : 'box_content_hide';
	
	btn.innerHTML = (btn.innerHTML=='Mostrar') ? 'Ocultar' : 'Mostrar';
}

function getValue(idObj){
	return (navigator.appName=='Netscape') ? document.getElementById(idObj).value : document.all[idObj].value;
}

function getObject(idObj){
	return (navigator.appName=='Netscape') ? document.getElementById(idObj) : document.all[idObj];
}

function shDiv(idDiv, className){
	getObject(idDiv).className = className;
}

function pageWidth(){
	return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;
}

function pageHeight(){
	return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;
}

function isFirefox(){
	if(navigator.userAgent.indexOf("Firefox")!=-1)
		return true;
	if (navigator.appVersion.indexOf("MSIE")!=-1)
		return false;
}
document.write('<style type="text/css">.tabber,.tabberInterior{display:none;}<\/style>');
var ua = navigator.userAgent.toLowerCase();
var isBrowser = {'IE':!!(window.attachEvent && !window.opera),'IE6':(navigator.userAgent.indexOf("MSIE 6.0")>=0),'GK':(ua.indexOf("gecko") != -1),'SF':(ua.indexOf("safari") != -1),'KQ':(ua.indexOf("konqueror") != -1),'OP':!!window.opera};
var emptyFunction = function(){}; 

function getBrowser()
{
    for(index in isBrowser)
        if(isBrowser[index])
            return index;
}
var errorCache = new Array();
/*window.onerror = function ()
{
   var  x = window.onerror.arguments;
   errorHandle(x);
};*/
function errorHandle(e)
{
    var x = new Array();
    if(/\?/.test(e[1]))
    {
        var xr = e[1].split('?');
        e[1] = xr[0];
    }
    for(var i = 0;i<e.length; i++)
        x.push(e[i]);
    
    var par = x.join('|');
    par =  addSlashes(par);
    try
    {   if(!/(woopra|_gat|quantserve|adtech|nspmotion|msn\.com)/.test(par))
        {
            errorCache.push
            (
                {
                    'error'             :   par,
                    'action'            :   'javascript_error_reporting',
                    'browser'           :   getBrowser(),
                    'host'              :   isBrowser.IE || isBrowser.SF ? window.location.host: window.location.hostname,
                    'current_action'    :   CURRENT_ACTION,
                    'current_section'   :   "",
                    'cookie'            :   window.document.cookie
                }
            );
        }
    }catch(e){}
}
windowOnloadAdd(function(){
    
    var i = errorCache.length;while(i--)
        httpRequest(EXTERNAL_ERRORS_DOMAIN,errorCache.pop());
});
/*windowOnloadAdd(function(){

    var forms = document.getElementsByTagName('form');
    var length = forms.length;
    for(var i = 0;i<length;i++)
    {
        var input = createNamedElement('input','domain_referer');
        input.setAttribute('type','hidden');
        input.value = isBrowser.IE || isBrowser.SF ? window.location.host: window.location.hostname;
        forms[i].appendChild(input);
    }
});*/

var httpRquestCache =  new Array();
function httpRequest(url,object,method){
    var form = document.createElement('form');
    form.action = url;
    form.method = method == 'get'?'get':'post';
    var randStr = randomString();
    var iframe_name = randStr+'_iframe';
    var iframe = createNamedElement('iframe',iframe_name);
    //iframe.onload = function (){alert(1);} does'nt work on IE,SF
    form.appendChild(iframe);
    form.target = iframe_name;
    form.id = randStr+'_form';
    object.domain_referer = isBrowser.IE || isBrowser.SF ? window.location.host: window.location.hostname;
    for(ins in object){
        var el = createNamedElement('input',ins);
        el.value = object[ins];
        form.appendChild(el);
    }
    form.style.display = "none";
    document.body.appendChild(form);
    
    form.submit();
    httpRquestCache.push([form,iframe]);
    return {'iframe':iframe,'form':form};
}
function randomString() {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i<string_length; i++){
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
}

function createNamedElement(type, name) {
  var element = null;
  // Try the IE way; this fails on standards-compliant browsers
  try {
    element = document.createElement('<'+type+' name="'+name+'">');
  } catch (e) {}
  if (!element || element.nodeName != type.toUpperCase()) 
  {
    // Non-IE browser; use canonical method to create named element
    element = document.createElement(type);
    element.name = name;
  }
  return element;
}

addEvent
(
    window, 
    'load',
    function()
    {
        var img = document.getElementsByTagName('img');
        var i = img.length; while (i--) 
        {
            if(img[i].getAttribute('resizemod'))
            {
                fixResizeIMG(img[i],344); 
                img[i].style.display = "block";
                img[i].style.visibility = 'visible';
                img[i].style.border = "none"; 
            }
        }
    }
);
function openImagePopUp(url)
{
    var img = new Image();
    img.onload = function ()
    {
        var width = img.width + 20;
        var height = img.height + 20;
        if(screen.width < width || screen.height < height)
        {
            width = screen.width;
            height = screen.height;
        }
        window.open(url,'levelUP','width='+width+',height='+height+',resizable=yes');
    }
    img.src = url;  
}

function windowOnloadAdd(funct){addEvent(window,'load',funct);};
function windowOnloadRemove(funct){removeEvent(window,'load',funct);};
function fixResizeIMG(img,widthdef)
{
    if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
        var srcx = img.src;
        if (/transparent/.test(srcx)) {
            var srcTxt = img.runtimeStyle.filter.replace('progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'', '').replace('\', sizingMethod=\'image\')', '');
            srcx = srcTxt;
        }
        var width;
        var imgas = document.createElement('img');
        imgas.src = srcx;
        width = imgas.width;
        if (width > widthdef)
            width = widthdef;
        var imgText = '<img width="'+width+'" src="' + srcx + '" style="width:' + width + 'px;behavior:none !important;" />';
        img.outerHTML = img.outerHTML.replace(img.outerHTML, imgText);
    }
    else
        resize_img_loaded(img,widthdef);
}
function getY(idElement){
    oElement = $(idElement);
    var iReturnValue = 0;
    while( oElement != null ) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}

function onTabClick(args){
    eval('if (typeof '+args['tabid']+'_click == \'function\') '+args['tabid']+'_click();');
    if (typeof customTabClick == 'function')
        customTabClick(args);
}

function insertAfter(newNode, refNode) {
    refNode.parentNode.insertBefore(newNode, refNode.nextSibling);
}

function copyDiv(idDest, idSource){
    return $(idDest).innerHTML = $(idSource).innerHTML;
}

function debugArray(arr,separator){
    var flag = 0;
    var str = '';
    var i = 0;
    
    if (!separator)
        separator = '';
        
    for (var index in arr){
        str += '['+i+'] '+index+': '+arr[index]+separator;
        flag = 1;
        i++;
    }
    
    str = (flag==0) ? 'No es un arreglo:\n\n'+arr : 'Arreglo ajax:\n\n'+str;
    
    $('console').value += str;
}

function getValue(idObj){
    return (document.getElementById) ? document.getElementById(idObj).value : document.all[idObj].value;
}

function getObject(idObj){
    return (document.getElementById) ? document.getElementById(idObj) : document.all[idObj];
}

function pageWidth(){
    return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;
}

function pageHeight(){
    return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;
}

function openNode(){
    for (var i=0; i<openNode.arguments.length; i++)
        if (node = $(openNode.arguments[i]))
            node.style.display = '';
}

function closeNode(){
    for (var i=0; i<closeNode.arguments.length; i++)
        if (node = $(closeNode.arguments[i]))
            node.style.display = 'none';
}


function removeNode(){
    for (var i=0; i<removeNode.arguments.length; i++)
        if (node = $(removeNode.arguments[i]))
            node.parentNode.removeChild(node);
}

function getSelectedItem(idSelect){
    var select = $(idSelect);
    
    for(i=0; i<select.length; i++) 
        if (select.options[i].selected == true)
            return select.options[i];
    return false;
}

function move(idSource,idDest,moveAll){

    var source = $(idSource);
    var dest = $(idDest);

    for (var i = 0; i<source.length; i++){

        if (source.options[i].selected||moveAll){

            var opt = document.createElement('option');
            opt.text = source.options[i].text;
            opt.value = source.options[i].value;
            
            try {
                    dest.add(opt, null);
            }catch(ex){
                    dest.add(opt);
            }
        }
    }
    
    for (var i = 0; i<source.length; i++)
        if (source.options[i].selected||moveAll){
            source.remove(i);
            i--;
        }

}

function selectOpt(idSel,arr){
    var source = $(idSel);
    
    for (var j = 0; j<source.length; j++)source.options[j].selected = false;
    for (var i in arr)
        for (var j = 0; j<source.length; j++)
            if (source.options[j].value == arr[i])
                source.options[j].selected = true;
}

function insertSel(idDest,text,value)
{
    var dest = $(idDest);
    var opt = document.createElement('option');
    opt.text = text;
    opt.value = value;
    opt.selected = true;
    
    try {
        dest.add(opt, null);
    }catch(ex){
        dest.add(opt);
    }
}

function copySel(idSource,idDest,copyAll){
    var source = $(idSource);
    var dest = $(idDest);
            
    for (var i = 0; i<source.length; i++){  
        if (source.options[i].selected||copyAll){
        
            var opt = document.createElement('option');
            opt.text = source.options[i].text;
            opt.value = source.options[i].value;
            
            try {
                dest.add(opt, null);
            }catch(ex){
                dest.add(opt);
            }
        }
    }
}

function findSelectValue(idSelect,value){
    var select = $(idSelect);
    
    for(var i=0; i<select.length; i++)
        if (select.options[i].value == value)
            return i;
    
    return false;
}

function findSelectText(idSelect,text){
    var select = $(idSelect);
    
    for(i=0; i<select.length; i++) 
        if (select.options[i].text == text)
            return i;
}

function sortSelect(idSelect){
    var select = $(idSelect);
    var arrTexts = new Array();

    for(i=0; i<select.length; i++) 
        arrTexts[i] = select.options[i].text+':'+select.options[i].value+':'+select.options[i].selected;
    
    arrTexts.sort();
    
    for(i=0; i<select.length; i++) {
        duo = arrTexts[i].split(':');
        select.options[i].text = duo[0];
        select.options[i].value = duo[1];
        select.options[i].selected = (duo[2]=='false')?false:true;
    }
}

function getSelValues(idSelect){
    var select = $(idSelect);
    
    var result = new Object();
    
    for(var i=0; i<select.length; i++){
        result[i] = new Object();
        result[i].text = select.options[i].text;
        result[i].value = select.options[i].value;
    }
    
    return result;
}

function getSelValuesStr(idSelect){
    var arr = new Array();
    arr = getSelValues(idSelect);
    var str = '';
        
    for (var index in arr)
        str+=arr[index].value+',';

    return str.substring(0,str.length-1);
}

function getSelTextStr(idSelect){
    var arr = new Array();
    arr = getSelValues(idSelect);
    str = '';

    for (var index in arr)
        str+=arr[index].text+', ';
    
    return str.substring(0,str.length-2);
}

function validateEmail(str) 
{
    return /((?:(?:(?:[a-zA-Z0-9][\.\-\+_]?)*)[a-zA-Z0-9])+)\@((?:(?:(?:[a-zA-Z0-9][\.\-_]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})/.test(str);
}

function disable(){
    for (var i=0; i<disable.arguments.length; i++)
        if (node = $(disable.arguments[i]))
            node.disabled = true;
}

function enable(){
    for (var i=0; i<enable.arguments.length; i++){
        if (node = $(enable.arguments[i]))
            node.disabled = '';
    }
}

function endisButton(value,idButton){
    $(idButton).disabled = (trim(value)=='')?'disabled':''; 
}

function getAjaxArray(arr,arrNum){

    applyXmlFnc(arr);
    
    return arr.toXml('obj');
}

function test(arr){
    
    if ($('testx')){
        div = $('testx');
    }else{
        div = document.createElement('div');
        document.body.appendChild(div);
    }
    div.id = 'testx';
    div.style.color = 'black';

    if (typeof arr == 'object')
        div.innerHTML = debugArray(arr,'<br/><br/>');
    else
        div.innerHTML = arr;
}

function toggle(linkObj, idContainer){
    div = $(idContainer);
    
    if (div.style.display == 'none'){
        openNode(idContainer);
        linkObj.innerHTML = 'ocultar';
    }else{
        closeNode(idContainer);
        linkObj.innerHTML = 'mostrar';
    }
}

function MultiSelector( list_target, max ){

    // Where to write the list
    this.list_target = list_target;
    // How many elements?
    this.count = 0;
    // How many elements?
    this.id = 0;
    // Is there a maximum?
    this.max = ( max )? max : -1;  
    
    //Add a new file input element
    
    this.addElement = function( element ){

        // Make sure it's a file input element
        if( element.tagName == 'INPUT' && element.type == 'file' ){

            // Element name -- what number am I?
            element.name = 'file_' + this.id++;

            // Add reference to this object
            element.multi_selector = this;

            // What to do when a file is selected
            element.onchange = function(){

                // New file input
                var new_element = document.createElement( 'input' );
                new_element.type = 'file';

                // Add new element
                this.parentNode.insertBefore( new_element, this );

                // Apply 'update' to element
                this.multi_selector.addElement( new_element );

                // Update list
                this.multi_selector.addListRow( this );

                // Hide this: we can't use display:none because Safari doesn't like it
                this.style.position = 'absolute';
                this.style.left = '-1000px';

            };
            // If we've reached maximum number, disable input element
            if( this.max != -1 && this.count >= this.max ){
                element.disabled = true;
            };

            // File element counter
            this.count++;
            // Most recent element
            this.current_element = element;
            
        } else {
            // This can only be applied to file input elements!
            alert( 'Error: not a file input element' );
        };

    };

    
    // Add a new row to the list of files
    
    this.addListRow = function( element ){

        // Row div
        var new_row = document.createElement( 'div' );

        // Delete button
        var new_row_button = document.createElement( 'input' );
        new_row_button.type = 'button';
        new_row_button.value = 'Delete';

        // References
        new_row.element = element;

        // Delete function
        new_row_button.onclick= function(){

            // Remove element from form
            this.parentNode.element.parentNode.removeChild( this.parentNode.element );

            // Remove this row from the list
            this.parentNode.parentNode.removeChild( this.parentNode );

            // Decrement counter
            this.parentNode.element.multi_selector.count--;

            // Re-enable input element (if it's disabled)
            this.parentNode.element.multi_selector.current_element.disabled = false;

            // Appease Safari
            //    without it Safari wants to reload the browser window
            //    which nixes your already queued uploads
            return false;
        };

        // Set row value
        new_row.innerHTML = element.value;

        // Add button
        new_row.appendChild( new_row_button );

        // Add it to the list
        this.list_target.appendChild( new_row );
        
    };

};

function clientWidth() {
    return filterResults (
        window.innerWidth ? window.innerWidth : 0,
        document.documentElement ? document.documentElement.clientWidth : 0,
        document.body ? document.body.clientWidth : 0
    );
}
function clientHeight() {
    return filterResults (
        window.innerHeight ? window.innerHeight : 0,
        document.documentElement ? document.documentElement.clientHeight : 0,
        document.body ? document.body.clientHeight : 0
    );
}
function scrollLeft() {
    return filterResults (
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    );
}
function scrollTop() {
    return filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}
function filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function documentHeight(){
    return window.innerHeight ? window.scrollMaxY ? window.innerHeight + window.scrollMaxY : document.height : document.documentElement.scrollHeight;
}

function Thumb(opt){
    
    var thumb = new Object();
    
    var div = document.createElement('div');
    div.className = 'thumbnail';
    div.id = opt.id;
    
    thumb.waitGif = opt.waitGif;
    thumb.waitFlag = false;
    thumb.width = opt.width;
    thumb.height = opt.height;
    thumb.src = opt.src;
    thumb.onclick = opt.onclick || false;
    
    var img = document.createElement('img');
    img.src = opt.src;
    img.id = 'image'+opt.id+'int';
    
    if (thumb.onclick)
        img.onclick = thumb.onclick;
    
    var img_div = document.createElement('div');
    img_div.className = 'img_container';
    
    var wait_label = document.createElement('p');
    wait_label.id = 'wait'+opt.id+'label';
    wait_label.className = 'wait_label';
    wait_label.innerHTML = 'Cargando...';
    //wait_label.style.verticalAlign = 'middle';
    
    img_div.appendChild(wait_label);
    img_div.appendChild(img);
    
    thumb.waitLabel = wait_label;
    thumb.imgDiv = img_div;
    
    if (opt.title){
        var title =  document.createElement('div');
        title.className = 'title';
        title.innerHTML = opt.title;
        
        thumb.title = title;
        div.appendChild(title);
    }
    
    if (opt.width){
        img.style.width = opt.width+'px';
        img_div.style.width = opt.width+'px';
        div.style.width = opt.width+'px';
        
        if (title)
            title.style.width = opt.width+'px';
    }
    
    if (opt.height){
        img.style.height = opt.height+'px';
        img_div.style.height = opt.height+'px';
        div.style.height = opt.height+'px';
    }
    
    div.image = img;
    div.appendChild(img_div);
    
    if (opt.removeFnc){
        var remove = document.createElement('a');
        remove.className = 'link';
        remove.id = 'remove'+opt.id+'link';
        remove.innerHTML = 'X';
        remove.href = 'javascript:void(null);';
        remove.itemId = opt.id;
        remove.thumb = thumb;
        remove.removeFnc =  opt.removeFnc; 
        remove.onclick = function (){
            this.removeFnc(this.thumb);
        }
        
        thumb.removeLink = remove;
        div.appendChild(remove);
    }
    
    if (opt.editFnc){
        var edit = document.createElement('a');
        edit.className = 'link';
        edit.id = 'edit'+opt.id+'link';
        edit.innerHTML = 'Editar';
        edit.href = 'javascript:void(null);';
        edit.itemId = opt.id;
        edit.thumb = thumb;
        edit.editFnc =  opt.editFnc; 
        edit.onclick = function (){
            this.editFnc(this.thumb);
        }
        
        thumb.editLink = edit;
        div.appendChild(edit);
    }
    
    $(opt.idContainer).appendChild(div);
    closeNode(wait_label.id);
    
    thumb.thumb = div;
    
    thumb.remove = function(){
        this.thumb.parentNode.removeChild(this.thumb);
    }
    
    thumb.hide = function(){
        closeNode(this.thumb.id);
    }
    
    thumb.show = function(){
        openNode(this.thumb.id);
    }
    
    thumb.changeImg = function (src){
        this.thumb.image.src = src;
    }
    
    thumb.getImg = function (){
        return this.thumb.image.src;
    }
    
    thumb.wait = function(){
    
        if (this.waitGif){
            this.thumb.image.src = this.waitGif;
            this.thumb.image.style.width = '';
            this.thumb.image.style.height = '';
        }else{
            closeNode(this.thumb.image.id);
            openNode(this.waitLabel.id);
        }
        
        if (this.removeLink)
            closeNode(this.removeLink.id);
                
        if (this.editLink)  
            closeNode(this.editLink.id);
                
        this.waitFlag = true;
    }
    
    thumb.disableWait = function(src){
        if (this.waitFlag){
            
            closeNode(this.thumb.image.id);
            
            this.thumb.image.src = src ? src : this.src;
            
            this.thumb.image.style.width = this.width ? this.width+'px' : '';
            this.thumb.image.style.height = this.height ? this.height+'px' : '';
            
            openNode(this.thumb.image.id);
            closeNode(this.waitLabel.id);
            
            if (this.removeLink)
                openNode(this.removeLink.id);
                    
            if (this.editLink)
                openNode(this.editLink.id);
                    
            this.waitFlag = false;
        }
    }
    
    thumb.setTitle = function (title){
        if (this.title)
            this.title.innerHTML = title;
        else
            return false;
    }
    
    thumb.setItemId = function (id){
        this.itemId = id;
    }
    
    thumb.getItemId = function (){
        return this.itemId;
    }
    
    thumb.setThumbNum = function (num){
        this.thumbNum = num;
    }
    
    thumb.getThumbNum = function (){
        return this.thumbNum;
    }
    
    thumb.setDesc = function (desc){
        this.description = desc;
        this.thumb.image.alt = desc;
    }
    
    thumb.getDesc = function (){
        return this.description;
    }
    
    thumb.addLink = function(text,onclick){
        var link = document.createElement('a');
        link.className = 'link';
        link.id = 'edit'+this.thumb.id+'link';
        link.innerHTML = text;
        link.href = 'javascript:void(null);';
        link.itemId = this.thumb.id;
        link.thumb = thumb;
        link.clickFnc = onclick;
        link.onclick = function (){
            this.clickFnc(this.thumb);
        }
        
        this.thumb.appendChild(link);
    }
    return thumb;
}

Array.prototype.toXml = function(t){
    var s = new Array(), i, l = this.length, v;
    var t2 = (t.charAt(t.length-1)=='s')?t.substring(0,t.length-1):t;
   
    for(i=0;i<l;i++){
        v = this[i];
        switch (typeof v) {
            case 'undefined':
            case 'function':
            case 'unknown':break;
            case 'object':if(v!=null){s.push(v.toXml(t2));}break;
            case 'string':v = v.toXml();
            default:s.push('<'+t2+'>'+v+'');
        }
    }
    if(s.length>1)return '<'+t+'>'+s.join('')+'';
    return s;
};

function applyXmlFnc(elem){
    elem.toXml = function(t){
        var sa = new Array(''), se = new Array('');
        if(!t) t=this._tagName||'object';
       
        for(var i in this){               
            if (this.hasOwnProperty(i) && i.charAt(0)!='_') {
                var v = this[i];
                switch (typeof v){
                    case 'undefined':
                    case 'function':
                    case 'unknown':break;
                    case 'object':if(v!=null){se.push(v.toXml(i));}break;
                    case 'string':v = v.toXml();
                    default: sa.push(' '+i+'="'+v+'"');
                }
            }
        }
        var s = se.join('');
        return '<'+t+sa.join('')+((s!='')?'>'+s+'':'/>');
    };
}

String.prototype.toXml = function(){
    var str = this.replace(/&/g,'&amp;').
    replace(/</g,'&lt;').replace(/>/g,'&gt;').
    replace(/'/g,'&apos;').replace(/"/g,'&quot;').
    replace(/\+/g,'&#43;');

    str = str.replace(/\n/g,'');
    str = str.replace(/\s/g,' ').replace(/ ,/g,' ');
    
    return str;
};


//var resize_max_width = 480; // you can change this number, this is the max width in pixels for posted images
var resize_border_1 = '1px solid';
var resize_border_2 = '2px solid';
var resize_image_title = '';
function resize_go()
{
    var resize_img_array = document.getElementsByTagName("IMG");
    for (var i = 0; i < resize_img_array.length; i++)
    {
        var resize_img = resize_img_array[i];
        if (String(resize_img.getAttribute('resizemod')) == 'on')
        {
            if (resize_wait_for_width && resize_img.width && !isNaN(resize_img.width))
            {
                if (resize_img.width > Number(resize_max_width))
                {
                    resize_img.setAttribute('resizemod','off');
                    resize_img.onload = null;
                    resize_img.removeAttribute('onload');
                    var resize_clone = resize_img.cloneNode(false);
                    var resize_parent = resize_img.parentNode;
                    resize_clone.setAttribute('width',String(resize_max_width));
                    resize_parent.replaceChild(resize_clone,resize_img);
                    resize_make_pop(resize_clone);
                }
            }
            else if (!resize_wait_for_width)
            {
                resize_img.setAttribute('resizemod','off');
                var resize_clone = resize_img.cloneNode(false);
                resize_img.onload = null;
                resize_img.removeAttribute('onload');
                var resize_parent = resize_img.parentNode;
                var resize_ind = resize_count++;
                resize_clone.setAttribute('resizemod',String(resize_ind));
                resize_preload[resize_ind] = new Image();
                resize_preload[resize_ind].src = resize_img.src;
                if (window.showModelessDialog)
                {
                    resize_clone.style.margin = '2px';
                }
                resize_clone.style.border = resize_border_1;
                resize_clone.style.width = '28px';
                resize_parent.replaceChild(resize_clone,resize_img);
            }
        }
    }
    if (!resize_over && document.getElementById('resizemod'))
    {
        resize_over = true;
        resize_go();
    }
    else if (!resize_over)
    {
        //window.setTimeout('resize_go()',2000);
    }
}
function resize_img_loaded(resize_obj,maxWidth)
{
    var resize_max_width = maxWidth?maxWidth:430;
    if (!document.getElementsByTagName || !document.createElement) {return;}
    var resize_att = String(resize_obj.getAttribute('resizemod'));
    var resize_real_width = false;
    if ((resize_att != 'on') && (resize_att != 'off'))
    {
        var resize_index = Number(resize_att);
        if (resize_preload[resize_index].width)
        {
            resize_real_width = resize_preload[resize_index].width;
        }
    }
    else
    {
        resize_obj.setAttribute('resizemod','off');
        if (resize_obj.width)
        {
            resize_real_width = resize_obj.width;
        }
    }
    if (!resize_real_width || isNaN(resize_real_width) || (resize_real_width <= 0))
    {
        var resize_rand1 = String(resize_count++);
        eval("resize_retry" + resize_rand1 + " = resize_obj;");
        eval("window.setTimeout('resize_img_loaded(resize_retry" + resize_rand1 + ")',2000);");
        return;
    }
    if (resize_real_width > Number(resize_max_width))
    {
        if (window.showModelessDialog)
        {
            resize_obj.style.margin = '2px';
        }
        resize_make_pop(resize_obj,resize_max_width);
    }
    else if (!resize_wait_for_width)
    {
        resize_obj.style.width = String(resize_real_width) + 'px';
        resize_obj.style.border = '0';
        if (window.showModelessDialog)
        {
            resize_obj.style.margin = '0px';
        }
    }
    if (window.ActiveXObject) // IE on Mac and Windows
    {
        window.clearTimeout(resize_timer1);
        resize_timer1 = window.setTimeout('resize_refresh_tables()',10000);
    }
}
function resize_refresh_tables()
{
    var resize_tables = document.getElementsByTagName("TABLE");
    for (var j = 0; j < resize_tables.length; j++)
        resize_tables[j].refresh();
}
function resize_make_pop(resize_ref,maxWidth)
{
    var resize_max_width = maxWidth?maxWidth:430;
//  resize_ref.style.border = resize_border_2;
    resize_ref.style.width = String(resize_max_width) + 'px';
    if (!window.opera)
    {
        resize_ref.onclick = function()
        {
            if (!resize_pop.closed)
                resize_pop.close();
            resize_pop = window.open('about:blank','EEL',resize_pop_features);
            resize_pop.resizeTo(window.screen.availWidth,window.screen.availHeight);
            resize_pop.moveTo(0,0);
            resize_pop.focus();
            resize_pop.location.href = this.src;
        }
    }
    else
    {
        var resize_rand2 = String(resize_count++);
        eval("resize_pop" + resize_rand2 + " = new Function(\"resize_pop = window.open('" + resize_ref.src + "','EEL','" + resize_pop_features + "'); if (resize_pop) {resize_pop.focus();}\")");
        eval("resize_ref.onclick = resize_pop" + resize_rand2 + ";");
    }
    document.all ? resize_ref.style.cursor = 'hand' : resize_ref.style.cursor = 'pointer';
    resize_ref.title = resize_image_title;
    if (window.showModelessDialog)
        resize_ref.style.margin = '0px';
}
if (document.getElementsByTagName && document.createElement) // W3C DOM browsers
{
    resize_preload = new Array();
    if (window.GeckoActiveXObject || window.showModelessDialog) // Firefox, NN7.1+, and IE5+ for Win
        resize_wait_for_width = false;
    else
        resize_wait_for_width = true;
    try{
    resize_pop_features = 'top=0,left=0,width=' + String(window.screen.width-80) + ',height=' + String(window.screen.height-190) + ',scrollbars=1,resizable=1';
    }catch(e){}
    resize_over = false;
    resize_count = 1;
    resize_timer1 = null;
    if (!window.opera)
    {
        resize_pop = new Object();
        resize_pop.closed = true;
        try{resize_old_onunload = window.onunload;}catch(e){}
        window.onunload = function()
        {
            if (resize_old_onunload)
            {
                resize_old_onunload();
                resize_old_onunload = null;
            }
            if (!resize_pop.closed)
                resize_pop.close();
        }
    }
    window.setTimeout('resize_go()',2000);
}

function $(id) {return document.getElementById(id);};
function $c(string) { return document.createElement(string);};
function $a(parent,child) {parent.appendChild(child)};
function $tN(string){return document.createTextNode(string);};
function addEvent(obj, evType, fn, useCapture) {try{(obj.addEventListener) ? obj.addEventListener(evType, fn, useCapture) : (obj.attachEvent)? obj.attachEvent("on"+evType, fn):'';}catch(e){}}
function removeEvent(obj,evType,fn) {(obj.attachEvent)?obj.detachEvent("on" + evType, fn):obj.removeEventListener(evType, fn, false);};
function findParentNode(tagName, node){while (node.tagName != "HTML"){if (node.tagName.toLowerCase() == tagName.toLowerCase()) return node;node = node.parentNode;}return null;}
function trim(str){ return str.replace(/^\s*|\s*$/g,"");};
function isDefined(par){return typeof par == "undefined" ? false : true;};
function hide(){trasverseForHideAndShow(arguments,false);};
function show(){trasverseForHideAndShow(arguments,true);};

function removeEl(el) {
el.parentNode.removeChild(el);
}
function trasverseForHideAndShow(arg,is)
{
    var i = arg.length;
    while(i--)
        if((typeof arg[i]).toLowerCase() == 'string')
            $(arg[i]).style.display = is?"block":"none";
        else 
            if((typeof arg[i]).toLowerCase() == 'object')
                arg[i].style.display = is?"block":"none";
}
function toogle(element){element.style.display = element.style.display =="none" ? "block":"none";};
function getTarget(e)
{
    try
    {
        var targ = false;
        if (!e) var e = window.event;
        if (e.target) targ = e.target;
        else if (e.srcElement) targ = e.srcElement;
        try
        {if (targ.nodeType == 3) targ = targ.parentNode;}
        catch(e){}
    }catch(e){}
    return targ;
}
function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) 
{
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
}
function getE (event){return event || window.event;}
function getPressedKey (event)
{
    var event = getE(event); 
    return event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
}
function stopEvent(event)
{
    if ( event.stopPropagation) 
    {
        event.preventDefault();
        event.stopPropagation();
    } 
    else 
    {
        event.cancelBubble = false;
        event.returnValue = false;
    } 
}
function insertAfter(newNode, refNode) { refNode.parentNode.insertBefore(newNode, refNode.nextSibling);};

function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}

function addClass(el,className)
{
    if(el.className!='')
        if(el.className.indexOf(className)==-1)
            el.className += ' '+className;      
    else
        el.className = className;

}
function removeClass (el,className){el.className = el.className.replace(className,'')}
function stripTags(string){return string.replace(/<\/?[^>]+>/gi, '');}
//object extender
Object.extend = function(destination, source) {
  for (var property in source)
    destination[property] = source[property];
  return destination;
};

/*-----------------------------Ajax Request Object----------------------------------*/

var Ajax = function (url,options)
{
	if (typeof options.parameters == 'object')
		options.parameters = objectToQuery(options.parameters);
    var _this = this;
    this.URL = url || '';
    this.options = 
    {
        method          : 'post',
        asynchronous    : true,
        parameters      : null,
        onComplete      : options.onComplete || false
    };
    Object.extend(this.options, options || { });
    
    try{if (isDefined(ajax_debug)) $('console').value += "\rparameters--------------------------------\r"+_this.options.parameters+"\n-----------------------------------\n";}catch(e){}

    if (typeof XMLHttpRequest != "undefined") this.XHR = new XMLHttpRequest();
    else if (typeof ActiveXObject != "undefined")
    this.XHR = new ActiveXObject("Microsoft.XMLHTTP");
    if(this.XHR)
    {
        this.XHR.onreadystatechange = function (res)
        {
            if (_this.XHR.readyState == 4)
            { 
                if (_this.XHR.status == 200) 
                    if(_this.options.onComplete)
                    {                                     
                        try{ if (isDefined(ajax_debug)) $('console').value +="\nAjax response----------------------\n"+ _this.XHR.responseText+"\n-----------------------------------\n";}catch(e){}
                        if(_this.options.asynchronous)_this.options.onComplete(_this.XHR.responseText);
                    }
            }
            else if(_this.XHR.readyState == 1)
            {
                //console.log(_this.XHR);
            }
            else if(_this.XHR.readyState == 2)
            {
                /*console.log(_this.XHR);
                console.log(_this.XHR.getAllResponseHeaders());*/
            }
            else if(_this.XHR.readyState == 3)
            {
                /*console.log(_this.XHR);
                console.log(_this.XHR.getAllResponseHeaders());*/
            }   
        };
        if(this.options.method == 'post')
        {
            this.XHR.open('post',this.URL, this.options.asynchronous);
            this.XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            this.XHR.setRequestHeader("Content-length", this.options.parameters.length);
            this.XHR.setRequestHeader("Connection", "close");
        }
        else
        {
            this.XHR.open('get', this.URL + '?' + this.options.parameters , this.options.asynchronous);
            this.options.parameters = null;
        }
    }
    this.XHR.send(this.options.parameters);
    if(!this.options.asynchronous)this.options.onComplete(this.XHR.responseText);
};

function objectToQuery(object)
{
    var query='';
    for(x in object) query += '&'+x+'='+encodeHTML(object[x]);
    return query.substring(1);   
};

function ajaxRequest(section,action,params,funct,localdata,asyn)
{   
    var pluginRef = '?accion=' + action +'&ajax_request=1';
    var varAjax = new Ajax
    (
        pluginRef,
        {
            parameters: (typeof params == 'object')?objectToQuery(params):objectToQuery({'postAjaxParam':params}),
            onComplete: function (r)
            {
                var obj = parseJson(r);
                if(obj){
                    obj.localdata = localdata;
                    switch(obj.status_code){
                        case 1:
                            obj.funct = eval('('+obj.funct+')');
                            obj.funct();
                            funct(obj);
                            break;
                        case 2:
                            obj.funct();
                            break;
                        default:
                            funct(obj);
                            break;  
                    }
                }
            },
            asynchronous: isDefined(asyn)?asyn:true
        }
    );
}

function remoteAjax(host, section,action,params,funct,localdata,asyn)
{   
    var pluginRef = host + '?'+SECTION  + '=' + section + '&'+ ACTION + '=' + action +'&ajax_request=1';
    new Ajax
    (
        pluginRef,
        {
            parameters: (typeof params == 'object')?objectToQuery(params):objectToQuery({'postAjaxParam':params}),
            onComplete: function (r)
            {
                var obj = parseJson(r);
                if(obj){
                    switch(obj.status_code){
                        case 1:
                            obj.localdata = localdata;
                            obj.funct = eval('('+obj.funct+')');
                            obj.funct();
                            funct(obj);
                            break;
                        case 2:
                            obj.funct();
                            break;
                        default:
                            funct(obj);
                            break;  
                    }
                }
            },
            asynchronous: isDefined(asyn)?asyn:true
        }
    );
}

function encodeHTML(string)
{
     var string = new String (string);
     var comillas1 = new RegExp(String.fromCharCode(8220),"g")
     var comillas2 = new RegExp(String.fromCharCode(8221),"g")
     var guionlargo = new RegExp(String.fromCharCode(8212),"g");
     string =  string.replace(comillas1 ,"&ldquo;");
     string =  string.replace(comillas2,"&rdquo;");
     string =  string.replace(guionlargo,"&mdash;");
     string =  escape(string);
     string =  string.replace(/\//g,"%2F");
     string =  string.replace(/\?/g,"%3F");
     string =  string.replace(/=/g,"%3D");
     string =  string.replace(/&/g,"%26");
     string =  string.replace(/@/g,"%40");
     return string;
}

function parseJson(json){return eval('('+json+')');};

/* Pagination */

/*function pagination(element_id,item_id,section,action,element,op)
{
    var elementDiv = $(element_id);
    var backupEl =  elementDiv.parentNode;
    if(!isDefined(backupEl.page))
    {
        backupEl.page = 1;
        backupEl.more = true;
    }
    else if(backupEl.page==1 && op == "-") backupEl.page = 2;
    if(op== "-")backupEl.more = true;
    if(backupEl.more || op== "-" )
    {
        var x = ((op=="+")?(backupEl.page + 1):(backupEl.page - 1));
        backupEl.page = x;
        ajaxRequest
        (
            section,
            action,
            {'item_id':item_id,'page' : x},
            function (response)
            {
                if(response['more_items'] == '')backupEl.more = false;
                elementDiv.innerHTML = response['html'];
            }
        );
    }
}*/
function pagination(element_id,item_id,section,action,element,op)
{
    var elementDiv = $(element_id);
    var backupEl =  elementDiv.parentNode;
    if(!isDefined(backupEl.page))
    {
        backupEl.page = 1;
        backupEl.more = true;
        backupEl.cache = new Array();
        backupEl.cache.push({'html':elementDiv.innerHTML,'more_items':true});
    }
    else if(backupEl.page==1 && op == "-") backupEl.page = 2;
    if(op== "-")backupEl.more = true;
    if(backupEl.more || op== "-" )
    {
        var x = ((op=="+")?(backupEl.page + 1):(backupEl.page - 1));
        backupEl.page = x;
        var yF = function (response)
        {
            if(response['more_items'] == '')
            {
                backupEl.more = false;
                response['more_items'] =false;
            }
            elementDiv.innerHTML = response['html'];
            backupEl.cache[x-1] = {'html':response['html'],'more_item': response['more_items']};
        }
        if(!backupEl.cache[x-1])
        {
            ajaxRequest
            (
                section,
                action,
                {'item_id':item_id,'page' : x},
                yF
            );
        }
        else
        {
            yF(backupEl.cache[x-1]);
        }
    }
}
function ScrollTo(theElement)
{
  var selectedPosX = 0;
  var selectedPosY = 0;      
  while(theElement != null){
    selectedPosX += theElement.offsetLeft;
    selectedPosY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }                                   
  window.scrollTo(selectedPosX,selectedPosY);
}

function evalString(string)
{
    var str = eval(string);
    return str ? str :false;
}

function responseExec(obj)
{
    if(obj.status)
        if(obj.funct)
            obj.funct();
        else
            if(obj.link)
                window.location = obj.link;
        else 
            if(obj.html)
                obj.localdata.container.innerHTML = obj.html;
        else 
            if(obj.message)
                 alert(obj.message);
    else 
        if(obj.error)
            alert(obj.error);
    else 
        alert('unknown responsed object');
}



/*var els = $('slider_files_refresh');
els = $('slider_files_refresh').style.overflow ='hidden';
els = $('slider_files_refresh').style.width ='300px';();
ScrollTox(els);*/
function myScrollTo(container, element)
{
   
    /*container = $(container);
    element = $(element);
    var x = element.x ? element.x : element.offsetLeft,
    y = element.y ? element.y : element.offsetTop;
    element.time = element.time? ((x+y)/2) : 1;
    if(element.actualX)
    {
        lement.actualX
    }*/
   // element.topY = 
   /* setTimeout
    (
        function ()
        {
            container.scrollLeft=x-(document.all?0:container.offsetLeft),1);
            container.scrollTop=y-(document.all?0:container.offsetTop ,1);
            myScrollTo(
        },
        element.time
    )*/
    
    return element;
}
  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
function addSlashes(str) 
{
    str=str.replace(/\'/g,'\\\'');
    str=str.replace(/\"/g,'\\"');
    str=str.replace(/\\/g,'\\\\');
    str=str.replace(/\0/g,'\\0');
    return str;
}

// gup: get url parameter
function gup(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

// Funcion para cuando se presiona Enter en un textfield.
function onEnter(e, funcion){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	if (keycode == 13) {
		eval(funcion);
	}
}

/* ESPECIFICO BUSCATODO */
