//////	add the capacities that were choosen to the url and resfresh the page
//	
function refPageFiltreCapacite(urlStr){
	var capaArray = document.capaForm.capa;
	var capaStr = "";
	var allCapa = true;
	for(x=0; x<capaArray.length; x++){
		if(capaArray[x].checked){
			capaStr += capaArray[x].value + ".";
		}
		else{
			allCapa = false;
		}
	}
	
	// si toutes les capacités sont checked
	if(allCapa || capaStr == ""){
		capaStr = "t.";
	}
	capaStr += "html";

	window.location.href = urlStr + "_" + capaStr;
}



////// add nom, quantité, capacité and ref to the email form
//
function addDetialsToEmailForm(nom){
	var capaE = document.getElementById('quantiteCapa');
	var capa = capaE.options[capaE.selectedIndex].text;
	var ref = document.getElementById("ref" + capa).value;
	var quant = document.getElementById('quantiteValue').value;
	
	//alert("nom-"+nom+", capa-"+capa+", ref-"+ref+", quant-"+quant);
	if (quant != "" && quant != 0) {
		var demandCount = document.getElementById('demandeCount').value;
		var newDemande = document.createElement('p');
		newDemande.innerHTML = "<span class='removeCheckbox'><input type='checkbox' width=10 height=10 onclick='removeDetialsFromEmailForm(this)' CHECKED /></span><span class='formQuantiteRefDetails' id='demande_" + demandCount +"'>" + quant + " - " + nom + " - " + capa + " - " + ref + "</span>";
		
		var formDiv = document.getElementById('formQuantiteRef');
		document.getElementById('formQuantiteMes').style.display = "none";
		formDiv.appendChild(newDemande);	
		document.getElementById('demandeCount').value = ++demandCount;
	}	
}

//////// remove a demande when clicking on one of the check boxes
//
function removeDetialsFromEmailForm(e){
	var p = e.parentNode.parentNode;
	p.parentNode.removeChild(p);
}

///// clear the quantité field 
//
function clearQauntValue(){
	document.getElementById('quantiteValue').value = "";
}




/////////// change images //////////////////////////////////
//
function changeImage(image, width, height, imageLarge){
	document.getElementById('mainImage').innerHTML = "<a href='"+ imageLarge + "' class='lightbox' rel='prodImages'><img src='" + image + "' width=" + width +" height=" + height + " /></a><a href='"+ imageLarge + "' id='zoomImg' class='lightbox' rel='prodImages'><img src='./images/zoomImg.gif' /></a>";
	$(".lightbox").lightbox();
}


///////////// show or hide the option message ////////////////////////////////////////////
//
function showHideOptionMessage(opt, nom){
	var optionStr = "\n"+ "Option - " + nom;
	if(document.getElementById(opt).style.display == "block"){
		$('#'+ opt).hide('slow');
		document.getElementById('message').value = document.getElementById('message').value.replace(optionStr, "");
	}
	else{
		$('#'+opt).show('slow');	 
		document.getElementById('message').value =  document.getElementById('message').value + optionStr;
	}
	
}


/////////// enlargePico /////////////////
//
function enlargePicto(picto){
	$(picto).animate( { width:'50px', height:'50px'}, 500 ); 
	$(picto).parent().addClass("pictoOnTop");  
}

function originatePicto(picto){
	$(picto).animate( { width:'25px', height:'25px'}, 500 );
	$(picto).parent().removeClass("pictoOnTop"); 
}





