/* =========================================================
 * jQuery.slide 
// ========================================================= */

$(document).ready(function(){
current = 1;
width = 570;

$('#p1').animate({"left": "0px"}, 0, "swing");

$("#tooltips a").click(function() {
	button=current;
	clickButton = $(this).attr('id');
	current = parseInt(clickButton.slice(1));
	if (current > button) {animateLeft(current,button)}
	if (current < button) {animateLeft(current,button)}
});

$("#footer a").click(function() {
	button=current;
	clickButton = $(this).attr('id');
	current = parseInt(clickButton.slice(1));
	if (current < button) {animateLeft(current,button)}
});
//horaciod 
		botones_ant_sig();	

function animateLeft(current,button) {
	$('#p'+current).css("left",width +"px");
	$('#p'+current).animate({"left": "0px"}, 650, "swing");
	$('#p'+button).animate({"left": -width+"px"}, 650, "swing");
	
}


});

function botones_ant_sig(){
	var ant = jQuery('#ant').val(); 
		var sig = jQuery('#sig').val() ; 
		if (ant=='0'){
		$('.back img').hide();
		}
		else {
		$('.back img').show(); 
		$('.back img').click(anteriores); 
			}	
	if (sig=='0'){
		$('.next img').hide();
		}
		else {
		$('.next img').show(); 
		$('.next img').click(proximos); 
			}
	}

function anteriores(){
		var pag  = $('#ant').val();
		if ( pag=='undefined' && pag !='0') return false ; 
		$('#pag1').animate({"left": "520px"}, 650, "swing");
		sleep(1);
		$('#pag1').load('productos.php?pag='+pag, function (){ 
															$('#pag1').animate({"left": "0px"}, 650, "swing"); 
															botones_ant_sig();
													}); 

	}
function proximos(){
		var pag  = $('#sig').val();
				if ( pag=='undefined' && pag !='0') return false ; 
		$('#pag1').animate({"left": "520px"}, 650, "swing");
		sleep(1);
		$('#pag1').load('productos.php?pag='+pag,  function (){ 
												$('#pag1').animate({"left": "0px"}, 650, "swing");
												botones_ant_sig();
												}); 
	}
function sleep (seconds) {
    // Delay for a given number of seconds  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/sleep
    // +   original by: Christian Doebler
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // %          note: For study purposes. Current implementation could lock up the user's browser. 
    // %          note: Consider using setTimeout() instead.
    // *     example 1: sleep(1);
    // *     returns 1: 0
    
    var start = new Date().getTime();
    while (new Date() < start + seconds*1000) {}
    return 0;
}


/* =========================================================
 * jQuery.innerfade
// ========================================================= */

$(document).ready(function() {
$('#slideshow').innerfade({
	speed: 2000,
	timeout: 4000,
	type: 'sequence',
	containerheight: '110px'
});
$('#slideshow2').innerfade({
	speed: 2000,
	timeout: 4000,
	type: 'sequence',
	containerheight: '110px'
});
$('#slideshow3').innerfade({
	speed: 2000,
	timeout: 4000,
	type: 'sequence',
	containerheight: '110px'
});
$('#slideshow4').innerfade({
	speed: 2000,
	timeout: 4000,
	type: 'sequence',
	containerheight: '110px'
});
$('#slideshow5').innerfade({
	speed: 2000,
	timeout: 4000,
	type: 'sequence',
	containerheight: '110px'
});
$('#p1').innerfade({
	speed: 3000,
	timeout: 5500,
	type: 'sequence',
	containerheight: '440px'
});
$('#pavimentos').innerfade({
	speed: 3000,
	timeout: 5500,
	type: 'sequence',
	containerheight: '440px'
});
$('#cocina').innerfade({
	speed: 3000,
	timeout: 5500,
	type: 'sequence',
	containerheight: '440px'
});
$('#bano').innerfade({
	speed: 3000,
	timeout: 5500,
	type: 'sequence',
	containerheight: '440px'
});
$('#materiales').innerfade({
	speed: 3000,
	timeout: 5500,
	type: 'sequence',
	containerheight: '440px'
});
});

/* =========================================================
 * jQuery Tooltip plugin 1.3
// ========================================================= */

$(function() {
$('#tooltips a').tooltip({
	track: true,
	delay: 0,
	showURL: false,
	showBody: " - ",
	fade: 500
});
});

/* =========================================================
 * Scroller
// ========================================================= */

var scroller = null;
window.onload = function () {
	var el = document.getElementById("Scroller-1");
	scroller = new Scrolling.Scroller(el, 400, 200);
};

/* =========================================================
 * Accordion
// ========================================================= */

jQuery().ready(function(){
	jQuery('#navigation').accordion({
		header: '.head',
		navigation: true,
		animated: 'easeslide',
		autoheight: false
	});
});

