function BeforeSlideChanged(index) {
	$(".trigger").each(function() {
		$(this).removeClass("activethumb");
		$(this).addClass("thumb");
	});
	$(".sel" + (index * 1 + 1)).addClass("activethumb");
	$(".sel" + (index * 1 + 1)).removeClass("thumb");
}
var passes = false;
function SlideChanged(index, label) {
	$(".slide-title").html(label);
}
$(document).ready(function() {
	$(".next").click(function() {
		$('#slider')[0].stop();
	});
	$(".next").mouseout(function() {

		// $('#slider')[0].play();

		});

	$(".next").click(function() {

		$('#slider')[0].stop();

		$('#slider')[0].next();

	});



	$(".prev").click(function() {

		$('#slider')[0].stop();

	});

	$(".prev").mouseout(function() {

		// $('#slider')[0].play();

		});

	$(".prev").click(function() {

		$('#slider')[0].stop();

		$('#slider')[0].prev();



	});

	

	$(".playstop").click(function() {

		$('#slider')[0].stop();

		if($(".playstop").hasClass("play")){

			$('#slider')[0].play();

			$(".playstop > img").attr("src", "http://www.amafashion.ro/pages/tpl/front/images/adbox/stop_arr.gif");

			$(".playstop").removeClass("play");

			$(".playstop").addClass("stop");

			return;

		}

		

		if($(".playstop").hasClass("stop")){

			$('#slider')[0].stop();

			$(".playstop > img").attr("src", "http://www.amafashion.ro/pages/tpl/front/images/adbox/play_arr.gif");

			$(".playstop").removeClass("stop");

			$(".playstop").addClass("play");

			return;

		}

	});



	var config = 

		{    

		     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    

		     interval: 100, // number = milliseconds for onMouseOver polling interval    

		     over: function(){

					$('#slider')[0].stop();

					$(".trigger").each(function() {

						$(this).removeClass("activethumb");

						$(this).addClass("thumb");

					});

					$(this).addClass("activethumb");

					$('#slider')[0].stop();

					$('#slider')[0].goToSlide($(this).attr("rel") - 1);

				},

		     timeout: 500, // number = milliseconds delay before onMouseOut    

		     out: function() { } // function = onMouseOut callback (REQUIRED)    

		};

	$(".trigger").hoverIntent(config);



	$('#slider').slideshow( {

		width : 745,

		height : 400,

		time : 3000,

		effecttime : 300,

		effect : 'fade',

		beforeslidechange : BeforeSlideChanged,

		callback : SlideChanged,

		playframe : false,

		playhoverr : true,

		title : false,

		titleshow : false,

		panel : false,

		imgresize : true, // resize image to slideshow window

		imgzoom : true, // zoom image to slideshow window (for smaller side)

		imgcenter : true // set image to center

	});

});





/**

* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+

* <http://cherne.net/brian/resources/jquery.hoverIntent.html>

* 

* @param  f  onMouseOver function || An object with configuration options

* @param  g  onMouseOut function  || Nothing (use configuration options object)

* @author    Brian Cherne <brian@cherne.net>

*/

(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
