$(document).ready(function() {	
	// menu
	/*$(".produits_ul").superfish({ 
		delay:       500,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'normal',                          // faster animation speed 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
	}); */
	
	// add class to inputs

	 $(":checkbox").addClass('checkbox');
	 $(":radio").addClass('radio');
	 $(":submit").addClass('submit');
	 
	//
	/*
	$('#side-nav .produits_ul li li').each(function() {
		var ul = $(this).find('> ul');
		if(ul.length == 1) {
			$(this).find('> a').click(function() {
				if(ul.css('display') == 'none') {
					ul.css('display', 'block');
				}
				else {
					ul.css('display', 'none');
				}
				return false;
			});
			ul.css('display', 'none');
		}
	});
	*/
	var loc = (document.location+'');
	if(loc.indexOf('souscategorie=') > 0) {
		loc = loc.replace(/^[^\?]+/, '');
		$('#side-nav .produits_ul li li').each(function() {
			var href = $(this).find('>a').attr('href').replace(/^[^\?]+/, '');
			if(loc.substr(0, href.length) == href) {
				$(this).find('> ul').css('display', 'block');
			}
		});
	}
	
	// clear search field on click
	
	$("#req_search").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	// animation for formSuccess & formError
	try{
		window.setTimeout(function(){
			$('.formSuccess, .formError, .panier_chronopost').animate({'opacity' : 0.75}, 1000);
		}, 1000);
	}catch(e){}
	
	// corners
	try{ $('a.button, input.button').corner("6px"); }catch(e){}
	
	//Replace "Page Suivante" and "Page Precedente" links with images
	$("#content a:contains('Page suivante')").html('<img src="/upload/design/listing/suivante.png" alt="Page Suivante" />');
	$("#content a:contains('Page précédente')").html('<img src="/upload/design/listing/precedent.png" alt="Page Pr&eacute;c&eacute;dente" />');
	$("#content a:contains('Première page')").html('<img src="/upload/design/listing/premiere.png" alt="Premi&egrave;re page" />');
	$("#content a:contains('Dernière page')").html('<img src="/upload/design/listing/derniere.png" alt="Derni&egrave;re page" />');
	
	// remove "Attente de paiement" lines in orders table in user profile
	$("table#commandes td:contains('Attente paiement')").parent().remove();
});