// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};


var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
        
        //ddmenuitem = $(this).find('ul').eq(0).animate({height: '100%'},{queue: false, duration: 600, easing: 'easeOutBounce'});
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function(){
      var count = 1;
            // JQuery way
            $('#increase').click(function (e) {
                count++;
                $('.dispqty').text(count);
                $('#article-qty').val(count);
            });

            $('#decrease').click(function (e) {
                if(count>1){
                    count--;
                    $('.dispqty').text(count);
                    $('#article-qty').val(count);
                }
            });
            
            
       	$('#slideshow').serialScroll({
		items:'li',
		prev:'#screen2 a.prev',
		next:'#screen2 a.next',
		offset:-130, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:1, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: true //click on the images to scroll to them
	});
        
        // Animation vignette fiche article
        $("img.vignette").mouseover(
        function()
        {
            //$('#bigimg').html("<img id='bigimg2' width='304' height='304' border='0' src='" + $('#' + this.id).attr("src") + "' />");
            $("#bigimg img").attr("src",$('#' + this.id).attr("src"));

        }
        );
            
        //add a link on the span 'view full size' and on the big image
	$('div#bigimg img').click(function(){
		$('#slideshow li a.shown').click();
	});
        
        //Jquery selectbox
        //$("select#IDmarque").dropdownReplacement();
        
        $('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);


});

document.onclick = jsddm_close;

function load_model(){  

    $.post("model_request.php", { mark: $('#IDmarque').val() }, function(data){
            $('#IDmodele').html(data);
    });

 } // load_model()
 
 function load_result(){  

    $.post("resultats.php", { model: $('#IDmodele').val() });

 } // Charge la page resultats
 
