/*
	Script slide de fotos tipo1 al 100
	Autor: Claudio Romano Cherņac
	Modificaciones: Mariana Moran
*/


var j = 0;
jQuery.fn.slideT1 = function(settings) {
	 settings = jQuery.extend({
     easeFunc: "expoinout",
     easeTime: 750,
     toolTip: false
  }, settings);

	return this.each(function(){
		var container = jQuery(this);
		container.removeClass("cswT1").addClass("stripViewerT1");
		var timer = null;
		var cnt = 1;
		var isFade = false;

			loopSlide = function(){
				timer = setTimeout("loopSlide()", 6000);
				cantidad = jQuery('.panel', container).size();
				jQuery('.panel', container).fadeOut("fast", function(){active=cnt;});
				jQuery(".panel:eq("+cnt+")", container).fadeIn("fast", function(){cnt=(cnt==(cantidad-1))?0:cnt+1;});
				jQuery("a.current").removeClass('current').parent().parent().find("a:eq("+cnt+")").addClass('current');
				//jQuery(".stripNav ul li a:eq("+cnt+")", container).addClass('current');
			}
			timer = setTimeout("loopSlide()", 6000);

			/*
			stop = function (){
				if(timer!=null){clearTimeout(timer);}
			}
			*/

			timer = setTimeout("start()", 6000);

			// Create the Tabs
			jQuery(this).before("<div class='stripNav' id='stripNav" + j + "'><ul><\/ul><\/div>");
			jQuery(this).find("div.panel").each(function(n) {
						jQuery("div#stripNav" + j + " ul").append("<li class='tab" + (n+1) + "'><a href='#' onclick='return false;' class='pos" + (n+1) + "' title='"+ jQuery(this).attr("title") +"'>&nbsp;<\/a><\/li>");
			});
			jQuery("div#stripNav" + j + " ul li:eq(0) a").addClass('current');

			jQuery("div#stripNav" + j + " a").each(function(index) {

				jQuery(this).bind("click", function() {
					if(jQuery('div.panelContainerT1').children(".panel:eq("+index+")").attr("class")!='panel showing' && !isFade){
						isFade = true;
						jQuery('div.panelContainerT1').children(".panel").fadeOut("fast", function(){
							//jQuery(this).attr("class","destacada hide");
							jQuery(this).removeClass("showing");
							jQuery(this).addClass("hide");
							isFade = false;
						});
						jQuery('div.panelContainerT1').children(".panel:eq("+index+")").fadeIn("fast", function(){
							//jQuery(this).attr("class","destacada showing");
							jQuery(this).removeClass("hide");
							jQuery(this).addClass("showing");
							isFade = false;
						});
						jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
					}
					if(timer!=null){clearTimeout(timer);}
					timer = setTimeout("loopSlide()", 6000);
				});
			});
		j++;
  });
};


jQuery.timer = function (interval, callback){
	var interval = interval || 100;

	if (!callback)
		return false;
	
	_timer = function (interval, callback) {
		this.stop = function () {
			clearInterval(self.id);
		};
		
		this.internalCallback = function () {
			callback(self);
		};
		
		this.reset = function (val) {
			if (self.id)
				clearInterval(self.id);
			
			var val = val || 100;
			this.id = setInterval(this.internalCallback, val);
		};
		
		this.interval = interval;
		this.id = setInterval(this.internalCallback, this.interval);
		
		var self = this;
	};
	
	return new _timer(interval, callback);
};

/*
jQuery(window).bind("load", function() {
	jQuery("div#slider1").slide()
});
*/




