jQuery.fn.exists = function(){return ($(this).length > 0);}

$(document).ready(function() {
	
	
	// PARA EL CODA SLIDER DEL FOOTER ADMIN
	if ($("#coda-slider-admin").exists()) { 
		$("#coda-slider-admin").codaSlider({dynamicArrows: false});
	}
	
/************ 19-10-2010 *************************************
*  
*   	COLORBOX
*
*****************************************/
	if(jQuery().colorbox) {
	$(".colorboxIngreso").colorbox({height:'500px', width:'700px'});
	$(".colorboxRegistro").colorbox({height:'700px', width:'750px'});
	
	
	$(".no_disponible").colorbox({width:"50%", inline:true, href:"#no_disponible"});

	
	}
	
	
        
        
/************ 19-10-2010 *************************************
*  
*   Muestra areas de secciones. Expose.
*
*****************************************/       
	 
  	if(jQuery().mostrar_areas) {$(".mostrar_areas").mostrar_areas({});}
	
	$('.quita_mask').live('click', function(eve) {
    	eve.preventDefault();
		$('.area_mask').remove();
	});


/*
	$('.baja_comprimido').live('submit', function(eve){
    eve.preventDefault();
          
    //console.log( $(this).serialize() );
		$.post(base_url + 'download/zip_files' , $(this).serialize() , function(html){
				
		});
    });
*/

	if(jQuery().ckeditor) {$('.jquery_ckeditor').ckeditor();}
	
	$('.jquery_ckeditor_notas').live('click', function(eve) {
		var new_html = '<textarea class="jquery_ckeditor" name="notas" rows="35" cols="70">' + $(this).html() + '</textarea>';
		$(this).html(new_html);
		$(this).removeClass('jquery_ckeditor_notas')
		$('.jquery_ckeditor').ckeditor();
	});
	
	$('.jquery_ckeditor_notas_estefi').live('click', function(eve) {
		var new_html = '<textarea class="jquery_ckeditor" name="notas_estefi" rows="35" cols="70">' + $(this).html() + '</textarea>';
		$(this).html(new_html);
		$(this).removeClass('jquery_ckeditor_notas_estefi')
		$('.jquery_ckeditor').ckeditor();
	});
	
	$('.jquery_ckeditor_notas_generales').live('click', function(eve) {
		var new_html = '<textarea class="jquery_ckeditor" name="notas_generales" rows="35" cols="70">' + $(this).html() + '</textarea>';
		$(this).html(new_html);
		$(this).removeClass('jquery_ckeditor_notas_generales')
		$('.jquery_ckeditor').ckeditor();
	});
	
		$('.jquery_ckeditor_notas a, .jquery_ckeditor_notas_generales a, .jquery_ckeditor_notas_estefi a').click(function(event){
      		event.stopPropagation(); // stop click event from bubbling to parents
		});


});	//$(document).ready(function() {

/* ABRIR ENLACE EN NUEVA PAGINA SIN USAR TARGET*/
document.onclick = function(e)
{
  var target = e ? e.target : window.event.srcElement;    

 while (target && !/^(a|body)$/i.test(target.nodeName))
  {
    target = target.parentNode;
  }

  if (target && target.getAttribute('rel') && target.rel == 'external')
  {
    var external = window.open(target.href);

    return external.closed;
  }
}


