function main_contenido_load(url){
	$.historyLoad(url.substring(url.indexOf('#')+1));
}

function main_contenido_load_aux(url){
	if(url.substring(url.indexOf('#')+1)=='')
		return;
	cargar_url_id(url.substring(url.indexOf('#')+1)+'.php','main_contenido');
}


function cargar_url_id(url,id){
		$('#'+id).load(url,function(){$('#main_load').fadeOut('normal');});
		$('#main_load').remove();
		$('#main_wrapper').append('<div id="main_load"></div>');
		$('#main_load').fadeIn('normal');
	return false;
}

function cargar_url_id2(url,id){
		 $('#'+id).load(url);
	return false;
}

function empezar_carga(target){
		$('#main_upload').remove();
		$('#main_wrapper').append('<div id="main_upload" align="center"><form action="include/cancel.php" target="'+target+'" name="form_upload" id="form_upload"><a onclick="document.form_upload.submit();window.terminar_carga();"><img src="plantilla/upload.gif"><br><span style="font-size:15px;">Cancelar</span></a></form> </div>');
		$('#main_upload').fadeIn('normal');
}

function terminar_carga(){
	$('#main_upload').fadeOut('normal');
}

function cargar_url_id_efecto(url,id){
		$('#'+id).slideUp('fast',function(){loadContent(url,id);});
		$('#main_load').remove();
		$('#main_wrapper').append('<div id="main_load"></div>');
		$('#main_load').fadeIn('normal');
	return false;
}
function loadContent(url,id) {
		$('#'+id).load(url,function(){showNewContent(id);})
}
function showNewContent(id) {
			$('#'+id).slideDown('normal',hideLoader);
}
function hideLoader() {
			$('#main_load').fadeOut('normal');
}



function loadurl_sub(url){
	var pagecnx = createXMLHttpRequest();
	pagecnx.open('GET', url, true);
	pagecnx.send(null);
}



function loadurlkey(e,url,id){
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==13)
		loadurl(url,id);
}

function createXMLHttpRequest() {
	var xmlHttp=null;
	if (window.ActiveXObject) 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) 
			xmlHttp = new XMLHttpRequest();
	return xmlHttp;
}

function abrir_cerrar(id){
	if(document.getElementById(id).style.display=='none')
		$('#'+id).slideDown('fast');
	else
		$('#'+id).slideUp('fast');
}

function cerrar(id){
	if(document.getElementById(id).style.display!='none')
		$('#'+id).slideUp('fast');
}


function main_contenido_load_accion(url,url2,id){
	$('#main_contenido').load(url.substring(url.indexOf('#')+1)+'.php',function(){cargar_url_id(url2,id);});
}

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 cargar_url_dragdrop(url){
	$('#main_dragdrop_aux').load(url,function(){$('#main_dragdrop').fadeIn('normal');$('#main_dragdrop_aux').fadeIn('normal');});
}

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();

}