$(document).ready(function(){

	
    $('#quicksearch').submit(function(){
        if($('#search').val() == 'Entrez votre recherche' || $('#search').val() == '')
            return false;
    });


    $('#notification_close').click(function(){
        $('#notification_box').hide();
    });


 $('#produit_composition_close').click(function(){
        $('#produit_composition').hide();
    });

    $('#search').click(function(){
        $(this).val('')
    });

    

    if(typeof(max) != 'undefined')
    {
        $('#pdt_prev').animate({ 'opacity': 0.5,
			msfilter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)',
			filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)' });

        if(max < 5)
            $('#pdt_prev').animate({ 'opacity': 0.5,
    			msfilter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)',
    			filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)' });

        $('#pdt_prev').click(function(){
            if(current > 0)
            {
                $('#produit_cat_pano').animate({
                    left: '+=154'
                }, 1000)
                current--;
                if(current == 0)
                    $('#pdt_prev').animate({ 'opacity': 0.5,
            			msfilter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)',
            			filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)' });
                if(current < (max - 4))
                    $('#pdt_next').animate({ 'opacity': 1,
            			msfilter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)',
            			filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)' });
            }
            return false;
        });


        $('#pdt_next').click(function(){
            if(current < (max - 4))
            {
                $('#produit_cat_pano').animate({
                    left: '-=154'
                }, 1000);
                current++;
                if(current == (max - 4))
                    $('#pdt_next').animate({ 'opacity': 0.5,
            			msfilter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)',
            			filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)' });
                if(current > 0)
                    $('#pdt_prev').animate({ 'opacity': 1,
            			msfilter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)',
            			filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)' });
            }
            return false;

        });

        $('.produit_cat_linkbox a').each(function(){
            if($(this).height() < 16)
                $(this).css('padding-top', '15px');
            if($(this).height() <= 30 && $(this).height() >= 16)
                $(this).css('padding-top', '8px');
            if($(this).height() > 30)
            {
                $(this).css('padding-top', '5px');
                $(this).css('line-height', '12px');
            }
            
        });


        

    }





    /*** PRODUITS ***/

   

		$('#print_btn_pdt').click(function(){
			//$('#produit_composition').css('display', 'block');
		});

    if($('#pdt_fch_prev').attr('href') == '') {
        $('#pdt_fch_prev').animate({
            'opacity': 0.5
        }, 400);
        $('#pdt_fch_prev').click(function(){
            return false;
        })
    }

    if($('#pdt_fch_next').attr('href') == '') {
        $('#pdt_fch_next').animate({
            'opacity': 0.5
        }, 400);
        $('#pdt_fch_next').click(function(){
            return false;
        })
    }


    $('#lightbox').click(function(){
        $('#produit_composition').hide();
        $(this).hide();
        $('body').css('overflow', 'visible');
    });

    

    var IE6 = false

    var strChUserAgent = navigator.userAgent;
    var intSplitStart = strChUserAgent.indexOf("(",0);
    var intSplitEnd = strChUserAgent.indexOf(")",0);
    var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);

    if(strChMid.indexOf("MSIE 6") != -1) IE6 = true;





    $('#produit_show_composition a').click(function(){

        sizeW = $(document).width() * 0.80;
        sizeH = $(document).height() * 0.80;

        posW = ($(document).width() - 470) / 2;
        posH = ($(document).height() - $('#produit_composition').height()) /2;


        $("#lightbox").animate({
            opacity: 0.95
        });
        $("#lightbox").css('width', ($(document).width() + 100)+'px');
        $("#lightbox").css('height', $(document).height()+'px');
        
        
        $("#lightbox").css('background', '#fcc601');


        $("#produit_composition").css('top', '0px');
        $("#produit_composition").css('margin', 'auto');


        $('body').css('overflow', 'hidden');

        

        $("#lightbox").fadeIn(300, function() {

            $('#lightbox').html('<div style="margin-left: ' + posW + 'px;margin-top:70px;z-index:1000; opacity:1;font-size:11px">' + $("#produit_composition").html() + '</div>');



            
        });

        
        return false;
    });

    /*** RECETTE ***/

    if($('#rct_fch_prev').attr('href') == '') {
        $('#rct_fch_prev').animate({
            'opacity': 0.5
        }, 400);
        $('#rct_fch_prev').click(function(){
            return false;
        })
    }

    if($('#rct_fch_next').attr('href') == '') {
        $('#rct_fch_next').animate({
            'opacity': 0.5
        }, 400);
        $('#rct_fch_next').click(function(){
            return false;
        })
    }



$('#atelier_home_visuel a').click(function(){
           

            if($(this).attr('href').indexOf('http://') == 0)
            {
                window.open($(this).attr('href'));
                return false;
            }
                
        });


        $('.innerBoxFooter a').click(function(){


            /*if($(this).attr('href').indexOf('http://') == 0)
            {
                window.open($(this).attr('href'));
                return false;
            }*/
            if($(this).attr('href').indexOf('http://') == 0)
            {
                window.location.href=$(this).attr('href');
                return false;
            }
        });


});



function recherche_photo(){
  $(location).attr('href',"/recherche/FiltrePhoto");
}

function addToFavorites(anchor)
{
    if (window.external)
    {
        window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
    }
   
}

function favoris(element) {
    if ( navigator.appName != 'Microsoft Internet Explorer' )
    {
        window.sidebar.addPanel("Vahiné","http://www.vahine.fr","");
    }
    else {
        window.external.AddFavorite("http://www.vahine.com","Vahiné");
    }
}

/*
$('#produit_visuel_inner img').ready(function(){
    hauteurVisuel = ($('#produit_visuel').height() - $('#produit_visuel_inner img').height()) / 2;
    $('#produit_visuel_inner').css('margin-top', Math.round(hauteurVisuel) +'px')


    });
*/

