var contenedor_anterior="";

var globalCallbacks = {
                onCreate: function(){
                        $("cargando").show();
                },
 
                onComplete: function() {
                        if(Ajax.activeRequestCount == 0){
                                $("cargando").hide();
                        }
                }
        };
/* Se registran los callbacks en Ajax.Responders */
Ajax.Responders.register( globalCallbacks );

//-----------------------------------------------------------------------------------------------------------
function Grabar(url){
var valid_pub = new Validation('formName', {useTitles:true, immediate : true});
var result=valid_pub.validate();
if(result){
new Ajax.Request(url,   {     
								method:'post',
								//parameters: {dsc_login: dsc_login, dsc_clave: dsc_clave} ,		
								parameters: $('formName').serialize(),
								onSuccess: GrabaronSuccess,     
								onFailure: ResultonFailure 
								}
				 ); 
}
}
//-----------------------------------------------------------------------------------------------------------
function Grabar2(url,frmName,contenedor){
var valid_pub = new Validation(frmName, {useTitles:true, immediate : true});
var result=valid_pub.validate();
if(result){
new Ajax.Request(url,   {     
								method:'post',
								//parameters: {dsc_login: dsc_login, dsc_clave: dsc_clave} ,		
								parameters: $(frmName).serialize(),
								onSuccess: function(resp){$(contenedor).innerHTML = resp.responseText;},     
								onFailure: ResultonFailure 
								}
				 ); 
}
}
//-----------------------------------------------------------------------------------------------------------
function AddContFck(cont_fck,cont_frm){
var oEditor2 = FCKeditorAPI.GetInstance(cont_fck);
document.getElementById(cont_frm).value=oEditor2.GetXHTML();
}
//-----------------------------------------------------------------------------------------------------------
function GrabaronSuccess2(resp){
$("general_busca2").innerHTML = resp.responseText;
}
//-----------------------------------------------------------------------------------------------------------
function GrabaronSuccess(resp){
$("general_busca").innerHTML = resp.responseText;
}
//-----------------------------------------------------------------------------------------------------------
function Cargar(url,contenedor){
new Ajax.Updater(contenedor, url);
}
//-----------------------------------------------------------------------------------------------------------
function Eliminar(url,contenedor) {
	if (confirm("ESTA SEGURO QUE DESEA ELIMINAR?")){
	Cargar(url,contenedor);
	}
}
//-----------------------------------------------------------------------------------------------------------
function Enviar(url,contenedor) {
	if (confirm("AL ENVIAR UNA EXPERIENCIA, USTED NO LA PODRA VOLVER A EDITAR NI ELIMINAR\nESTA SEGURO QUE DESEA ENVIAR ESTA EXPERIENCIA?")){
	Cargar(url,contenedor);
	}
}
//-----------------------------------------------------------------------------------------------------------
function Devolver(url,contenedor) {
	if (confirm("AL DEVOLVER UNA EXPERIENCIA, ESTA REGRESA AL USUARIO QUE LA CREO\nESTA SEGURO QUE DESEA DEVOLVER ESTA EXPERIENCIA?")){
	Cargar(url,contenedor);
	}
}
//-----------------------------------------------------------------------------------------------------------
function Publicar(url,contenedor) {
	if (confirm("ESTA SEGURO QUE DESEA PUBLICAR ESTA EXPERIENCIA?")){
	Cargar(url,contenedor);
	}
}
//-----------------------------------------------------------------------------------------------------------
function Editar(url,contenedor) {
	GetContenedorAnterior();
	Cargar(url,contenedor);
}
//-----------------------------------------------------------------------------------------------------------
function GetContenedorAnterior(){
	contenedor_anterior=$("general").innerHTML;
}
//-----------------------------------------------------------------------------------------------------------
function Regresar(){
	$("general").innerHTML=contenedor_anterior;
}
//-----------------------------------------------------------------------------------------------------------
function Editar2(url,contenedor) {
	GetContenedorAnterior2();
	Cargar(url,contenedor);
}
//-----------------------------------------------------------------------------------------------------------
function GetContenedorAnterior2(){
	contenedor_anterior=$("general2").innerHTML;
}
//-----------------------------------------------------------------------------------------------------------
function Regresar2(){
	$("general2").innerHTML=contenedor_anterior;
}
//-----------------------------------------------------------------------------------------------------------
function Login() {
var valid= new Validation('formLogin', {useTitles:true, immediate : true});
var result=valid.validate();
if(result){
new Ajax.Request('controller/Auth.php',   {     
								method:'post',
								//parameters: {dsc_login: dsc_login, dsc_clave: dsc_clave} ,		
								parameters: $('formLogin').serialize(),
								onSuccess: LoginonSuccess,     
								onFailure: ResultonFailure 
								}
				 ); 
}
}
//-----------------------------------------------------------------------------------------------------------
function CargaronSuccess(resp){
var band=resp.responseText;
if(band=="-1"){
location.href="index.php?m=2"
}else{
$("contenido_seccion").innerHTML = resp.responseText;
}
}
//-----------------------------------------------------------------------------------------------------------
function LoginonSuccess(resp){
var band=resp.responseText;
if(band==1){
location.href="index1.php"
}else{
$("resultado").innerHTML="<font color=red><b>Accesos incorrectos ..... vuelva a intentarlo</b></font>"
}
//$("resultado").innerHTML = resp.responseText;
}
//-----------------------------------------------------------------------------------------------------------
function ResultonFailure(){
$("resultado").innerHTML = 'error en la transaccion .... intente nuevamente';
}
//-----------------------------------------------------------------------------------------------------------
function EliminarFile(field,conte) {
        $(field).value='';	
	$(conte).innerHTML = '';
}
//-----------------------------------------------------------------------------------------------------------
function AbreFicha(theURL,winName) { //v2.0
window.open(theURL,winName,"width=700,height=500,resizable=yes,scrollbars=yes");
}
//-----------------------------------------------------------------------------------------------------------
function AbreFicha2(theURL,winName) { //v2.0
window.open(theURL,winName,"width=400,height=200,resizable=yes,scrollbars=yes");
}
//-----------------------------------------------------------------------------------------------------------
function CambiarEstilo(id1,id2,id3) { 
document.getElementById(id1).className = "titulo_act"; 
document.getElementById(id2).className = "titulo_des"; 
document.getElementById(id3).className = "titulo_des"; 
}
//-----------------------------------------------------------------------------------------------------------
function Asignar(hp_id,reg_id) { 
opener.document.getElementById('hp_enlaceoff_'+hp_id).value=reg_id;	
opener.document.getElementById('hp_enlace_'+hp_id).value=reg_id;	
self.close();
}
//-----------------------------------------------------------------------------------------------------------
function Desasignar(hp_id) { 
if (confirm("ESTA SEGURO QUE DESEA DESASIGNAR?")){
document.getElementById('hp_enlaceoff_'+hp_id).value='0';	
document.getElementById('hp_enlace_'+hp_id).value='0';	
}
}
//-----------------------------------------------------------------------------------------------------------
function SerValorRecu(value) {
    $('rec_tipo').value=value;	
	
	if(value=='IM'  || value=='DO'){
		$('div_url').style.display='none';
		$('arch').style.display='block';
	}else{
		$('div_url').style.display='block';
		$('arch').style.display='none';
	}

}
//-----------------------------------------------------------------------------------------------------------