

// hace transicion de fundido entre fotos
// Usa  jquery
/*
El HTML necesario:
<div id="slideshow">
	<img src="media/bidegintza_head-photo_01.jpg" alt="Bidegintza" title="Bidegintza" />
	<img src="media/bidegintza_head-photo_02.jpg" alt="Bidegintza" title="Bidegintza" />
</div>

*/
function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


// inserta div.edit para edición enlinea.
function admin_on() {

	$edit = '<div class="admin" >';
	$edit += '<img src="' + base_url + 'css/icons/12-em-pencil.png" alt="edit" title="edit" class="edit" />';
	$edit += ' <img src="' + base_url + 'css/icons/12-em-plus.png" alt="new" title="new" />';
	$edit += ' <img src="' + base_url + 'css/icons/12-em-cross.png" alt="delete" title="delete" />';
	$edit += '</div>\n';

	$("#media li").prepend($edit);

	$('.admin img.edit').click(function(e) {
		alert(e);
		$admin = $(this).parent();
		$li = $(this).parent().parent();
		slug = $li.attr('id');


		if($li.in_edit) return;
		$li.in_edit = true;
alert($li.in_edit);

		$admin.prepend('<div id="editor_'+ slug +'" />');

		$.post(base_url + "edit/editar", {slug:slug}, function(data) {
			//$('#editor_'+ slug).html(data);
			$('#editor_'+ slug).html(data);
			$('#cerrar').click(function(e) {
				//$('#editor_'+ slug).remove();
				$(this).parent().remove();
				$li.in_edit = false;
				alert($li.in_edit);
			});
		});

	});


}




		jQuery('.admin img.edit').click(function(e){
			e.preventDefault();
			var email = jQuery('#email').val();
			jQuery.post("<?php echo base_url().'welcome/editar'; ?>", {email:email}, function(data) {
				jQuery('#login .loginform').html(data);
				//alert(data);
			});
		});

