// This is a very simple demo that shows how a range of elements can
// be paginated.
// The elements that will be displayed are in a hidden DIV and are
// cloned for display. The elements are static, there are no Ajax 
// calls involved.
/**
 * Callback function that displays the content.
 *
 * Gets called every time the user clicks on a pagination link.
 *
 * @param {int} page_index New Page index
 * @param {jQuery} jq the container with the pagination links as a jQuery object
 */
function pageselectCallback(page_index, jq){
    var new_content = jQuery('#hiddenresult ul.result:eq('+page_index+')').clone();
    $('#Searchresult').empty().append(new_content);
	$(".gallery").fancybox({scrolling:false});
    return false;
}
/** 
 * Initialisation function for pagination
 */
function initPagination() {
    // count entries inside the hidden content
    var num_entries = jQuery('#hiddenresult ul.result').length;
    // Create content inside pagination element
    $(".contPage").pagination(num_entries, {
        callback: pageselectCallback,
        items_per_page:1, // Show only one item per page
		num_display_entries: 5,
		num_edge_entries: 1,
		ellipse_text: '...'
    });
 }

$(function(){

// Efecto ocultar y mostrar trabajos en menu.
    $('.showWorks').click(function(){
        $('.listWorks').slideToggle(500);
        return false;
    });
	
// Efecto ver condiciones.
    $(".showLegal").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
	
/* Google maps */
   	function setMap() {
	    var latlng = new google.maps.LatLng(39.612060, 2.686012);
    
	    var myOptions = {
			zoom: 15,
			center: latlng,
			mapTypeControl: false,
			mapTypeId: google.maps.MapTypeId.ROADMAP
	    };
		var map = new google.maps.Map(document.getElementById("map"), myOptions);
		var image = "img/map-icon.png";
		var marker = new google.maps.Marker({
			position: latlng, 
			map: map,
			icon: image,
			title:"Jardineria Alonso"
		  });
	  }

	if ($('#map').length >0) setMap();

// Paso slide imagenes
    $("#slider").easySlider({
		auto: true,
		continuous: true,
		speed: 800,
		pause: 5000
	});
	initPagination();

});

