
function pageload(url){
if(url.substring(url.indexOf('#')+1)=='' || url.indexOf('..')!=-1)
    cargar_url_id_efecto(url,'main_contenido');
else{
    url=url.substring(url.indexOf('#')+1);
    cargar_url_id_efecto(url,'main_contenido');
  }

}





function abrir_cerrar(id){
	if(document.getElementById(id).style.display=='none')
		$('#'+id).slideDown('fast');
	else
		$('#'+id).slideUp('fast');
}

function abrir_cerrar_tabla(id,largo){
 if(document.getElementById(id).style.display=='none'){
     $('#'+id).slideDown('fast');
     ordenar_tabla(id,largo);
 } else
     $('#'+id).slideUp('fast');
}

function cerrar(id){
	if(document.getElementById(id).style.display!='none')
		$('#'+id).slideUp('fast');
}

function abrir(id){
	if(document.getElementById(id).style.display =='none')
		$('#'+id).slideDown('fast');
}

function getNameValues(name){
    var temp=document.getElementsByName(name);
    j=0;
    for(i=0;i<temp.length;i++)
        if(temp[i].checked)
            j++
    var valores=new Array(j);
    for(i=0;i<temp.length;i++)
        if(temp[i].checked)
            valores[i]=temp[i].value;
    return valores;
}


function getIdValue(id){
    if(document.getElementById(id)!=undefined)
        return document.getElementById(id).value;
    else
    	return false;
}



function getIdHtml(id){
    if(document.getElementById(id)!=undefined)
        return document.getElementById(id).innerHTML;
    else
    	return false;
}

function getRadioButtonSelectedChecked(ctrl){
var temp=document.getElementsByName(ctrl);
    for(i=0;i<temp.length;i++)
        if(temp[i].checked) return true;
	return false;
}

function getRadioButtonSelectedValue(ctrl){
var temp=document.getElementsByName(ctrl);
    for(i=0;i<temp.length;i++)
        if(temp[i].checked) return temp[i].value;
}

function MarcarCheckBox(name){
    var temp=document.getElementsByName(name);
        for(i=0;i<temp.length;i++)
            temp[i].checked=1
}

function DesmarcarCheckBox(name){
    var temp=document.getElementsByName(name);
        for(i=0;i<temp.length;i++)
            temp[i].checked=0
}

function copiar_contenido(id_desde,id_para){
    $('#'+id_para).html($('#'+id_desde).html());
}

function setIdHtml(id,text){
    $('#'+id).html(text);
}

function ordenar_tabla(id,h){
	if(document.getElementById(id)==undefined) return;
	//height maximo
	if(h!=undefined){
		tableEl=document.getElementById(id);
		tableEl.style.width='97%';

	    if(document.all && document.getElementById && !window.opera){ //IE
			containerEl = tableEl.parentNode.insertBefore(document.createElement('div'), this.tableEl);
			containerEl.appendChild(tableEl);
			containerEl.style.height = h + 'px';
			containerEl.style.width = '100%';
			containerEl.style.overflow= 'auto';
		}
		if (!document.all && document.getElementById && !window.opera){//FF
			scrollWidth=17;
			thead = this.tableEl.getElementsByTagName('thead');
			thead = (thead[0]) ? thead[0] : null;
			tfoot = this.tableEl.getElementsByTagName('tfoot');
			tfoot = (tfoot[0]) ? tfoot[0] : null;
			tbody = this.tableEl.getElementsByTagName('tbody');
			tbody = (tbody[0]) ? tbody[0] : null;

			headHeight = (thead) ? thead.clientHeight : 0;
			headFoot = (tfoot) ? tfoot.clientHeight : 0;
			bodyHeight = tbody.clientHeight;

			var trs = tbody.getElementsByTagName('tr');
			tbody.style.overflow = '-moz-scrollbars-vertical';
			for (x=0; x<trs.length; x++) {
				var tds = trs[x].getElementsByTagName('td');
				tds[tds.length-1].style.paddingRight += this.scrollWidth + 'px';
			}
			cellSpacing = (tableEl.offsetHeight - (tbody.clientHeight + headHeight)) / 4;
			tbody.style.height = (h - (headHeight + cellSpacing * 2) - (headFoot+ cellSpacing * 2)) + 'px';
        }
    }

	//odd
	tbody=document.getElementById(id).getElementsByTagName('tbody');
	tbody = (tbody[0]) ? tbody[0] : null;
	var trs = tbody.getElementsByTagName('tr');
	for (x=0; x<trs.length; x++) {
		if(x%2==0)
		trs[x].className ="odd";
	}

	//ordenar tabla
	$('#'+id).tablesorter();

}


