/**********************************************/
/*               VOTE SYSTEM                  */
/**********************************************/

function store_rating (id_sys, id_store, vote) {

	/*alert(id_sys+' '+vote);*/
	$("#"+id_store).val(vote);
	avgwidth = vote * 10;
	$("#"+id_sys).width(avgwidth);
}


/**********************************************/
/*                   JQUERY                   */
/**********************************************/

$(document).ready(function() {
	$(".thickbox").css("visibility", "visible");
	//$("#mpu").html($("#mpuload").html());
	
	jQuery.browser.msie6 = jQuery.browser.msie &&
	parseInt(jQuery.browser.version) == 6 &&
	!window["XMLHttpRequest"];
   
	$("#connect").click(function () {
		$("#uloginform").toggle();
	});

	$("#uloginform").toggle();
    
	$(".columncontainer").each(function(i) {
		//pour chaque columncontainer

		var left = $(".leftcolumn", this);
		var right = $(".rightcolumn", this);

	 	if(left != null){
 			if(left.height() > right.height()) {
				//vu les pages si y a un left y a un right
		 		left.css("border-right", "1px solid #B7B7B7");
				right.css("border-left", "none");
			}
		}
	});


	$("#submitReview").submit( function() {

		var res = true;
		var summary = jQuery.trim($("#opinion-summary").val());
		var oppros = jQuery.trim($("#opinion-pros").val());
		var opcons = jQuery.trim($("#opinion-cons").val());

		if (summary == "" || summary == "résumé de votre avis") {
			res = false;
			alert("Veuillez saisir un résumé et éventuellement des arguments pour et contre, merci");
		}

		if (oppros == "Les points forts de ce logiciel" || opcons == "Les points faibles de ce logiciel") {
			res = false;
			alert("Veuillez saisir des arguments pour et contre, merci");
		}

		return res;
	});


	$toggle_wizard = function() {

 		//le link de search et de changement de mobile
	      	//$("#wizard-search-shortcut").slideToggle();

		if ($("#wizard-expanded").is(":hidden")) {	
			//si on est minimisé on veut etre expande
			$("#wizard-search-shortcut").hide("slow");
   			$("#select-mobile-link").css("visibility", "visible"); 

	   		//on montre expanded cache mobile reduced et reduced
   			$("#wizard-mobile-reduced").fadeOut();	
   			$("#wizard-expanded").show("slow");
	   		$("#wizard-reduced").slideUp();
   		
   			//reaffiche la sizebar
   			$("#wizard-sizebar").css("padding-bottom", "0");   
	   		$("#wizard-sizebar").slideUp("fast");
   			$("#wizard-sizebar").slideDown("fast");
       		
       		
       			//bouton de resize de expand -> minimize
	       		$("#wizard-size-button").removeClass("expand");
      			$("#wizard-size-button").addClass("minimize");
      		
      			//affiche mobile expanded
	      		//$("#wizard-mobile-reduced").slideDown();
        			$("#wizard-mobile-expanded").slideDown("slow");
      			$("#wizard-size-link > a").text("réduire le menu");

			$.cookie('Wizard-menu', 'expanded', 3600, "/", ".businessmobile.fr");

		} else {
			//si on est expandé on veut etre minimise
			$("#wizard-search-shortcut").show("fast");
      			$("#select-mobile-link").css("visibility", "hidden"); 
      		
	      		//on affiche/cache les bonnes zones du widget
      			$("#wizard-mobile-expanded").fadeOut();	
	        		$("#wizard-expanded").slideUp();
			$("#wizard-reduced").show("slow");
		
			//reaffiche la sizebar
        			$("#wizard-sizebar").css("padding-bottom", "20px");
		        	$("#wizard-sizebar").slideUp("fast");
        			$("#wizard-sizebar").slideDown("fast");
        	
	        		//le bouton de resize
	        		$("#wizard-size-button").removeClass("minimize");
      			$("#wizard-size-button").addClass("expand");
      		
      			//le link de resize
	      		$("#wizard-size-link > a").text("agrandir le menu");
      		
      			//affiche mobile reduced
	        		$("#wizard-mobile-reduced").fadeIn("slow");

			$.cookie('Wizard-menu', 'collapsed', 3600, "/", ".businessmobile.fr");

		}

		$("#wizard").show("slow");      	

	}


	// COOKIES
	// Header State
	var showWizardMenu = $.cookie('Wizard-menu');
	//alert(showWizardMenu);
	
	// Set the user's selection for the WizardMenu State
	if (showWizardMenu == 'expanded' && $("#wizard-expanded").is(":hidden")) {
		//si on est minimisé on veut etre expande
		$("#wizard-search-shortcut").hide("slow");
   		$("#select-mobile-link").css("visibility", "visible"); 

	   	//on montre expanded cache mobile reduced et reduced
   		$("#wizard-mobile-reduced").fadeOut();	
   		$("#wizard-expanded").show("slow");
	   	$("#wizard-reduced").slideUp();
   		
   		//reaffiche la sizebar
   		$("#wizard-sizebar").css("padding-bottom", "0");   
	   	$("#wizard-sizebar").slideUp("fast");
   		$("#wizard-sizebar").slideDown("fast");
       		       		
       		//bouton de resize de expand -> minimize
		$("#wizard-size-button").removeClass("expand");
      		$("#wizard-size-button").addClass("minimize");
      		
      		//affiche mobile expanded
	      	//$("#wizard-mobile-reduced").slideDown();
        		$("#wizard-mobile-expanded").slideDown("slow");
      		$("#wizard-size-link > a").text("réduire le menu");

		//$toggle_wizard();

	} else if (showWizardMenu == 'collapsed' && $("#wizard-expanded").is(":visible")) {

		//si on est expandé on veut etre minimise
		$("#wizard-search-shortcut").show("fast");
      		$("#select-mobile-link").css("visibility", "hidden"); 
      		
	      	//on affiche/cache les bonnes zones du widget
      		$("#wizard-mobile-expanded").fadeOut();	
	        	$("#wizard-expanded").slideUp();
		$("#wizard-reduced").show("slow");
		
		//reaffiche la sizebar
        		$("#wizard-sizebar").css("padding-bottom", "20px");
		$("#wizard-sizebar").slideUp("fast");
        		$("#wizard-sizebar").slideDown("fast");
        	
	        	//le bouton de resize
	        	$("#wizard-size-button").removeClass("minimize");
      		$("#wizard-size-button").addClass("expand");
      		
      		//le link de resize
	      	$("#wizard-size-link > a").text("agrandir le menu");
      		
      		//affiche mobile reduced
	        	$("#wizard-mobile-reduced").fadeIn("slow");

		//$toggle_wizard();
	}

 
	/*
	$(".checkbox").click(function () {
		if(($(this).hasClass("checkboxactive"))|($(this).hasClass("checkboxinactive"))) {
			$(this).toggleClass("checkboxactive");
			$(this).toggleClass("checkboxinactive");
		}
	});
	*/

	$("#wizard-size-button").click($toggle_wizard);
	$("#wizard-size-link").click($toggle_wizard);

	$("#wizard-search-shortcut").click(function () {
		$toggle_wizard();
		$("#wizardsearch").focus();
	});
	$("#submitReview .disabled").click(function () {
		alert("cliquez sur \"se connecter\" pour laisser un commentaire");
	});


});