﻿// JavaScript Document

function zoom(a_id_nb){
	var id_nb = a_id_nb;
	var cheminImg = document.getElementById('image'+id_nb).src;	
	var cheminImgLen = cheminImg.length;	
	var cheminImgFull = cheminImg.substring(0,cheminImgLen-4)+'_full.jpg';	
	window.open(cheminImgFull,'zoom','width=520,height=396')
}
function imprimer(a_racine){
	window.open(a_racine,'print','width=650,height=396,scrollbars=yes')
}
function envoyerAmi(a_racine){
	window.open(a_racine,'ami','width=650,height=396,scrollbars=yes')
}

var devisesAffichees = false;
function afficheDevises(){
	document.getElementById('listeDevises').style.display = (devisesAffichees)? 'none':'block';
	devisesAffichees = !devisesAffichees;
}

var optionAttente = '';
function ajouteOption(nb,id_obj, id)
{	
	optionAttente = id;
	var tableau = document.getElementById('options');
	var cheveux_array = tableau.getElementsByTagName('a');
	var len = cheveux_array.length;
	for(var i=0; i<len; i++)
	{
		if(cheveux_array[i].firstChild.className == 'option')
		cheveux_array[i].firstChild.style.border = '1px #FFFFFF solid';
	}
	id_obj.firstChild.style.border = '1px #CC0000 solid';
	//alert(id);
}
function validOption(nb,id_obj, id)
{	
	var nb = parseInt(optionAttente.value,10);
	nb++;
	optionAttente.value = nb.toString();
}
	

function afficheMenu(){
	var menu = document.getElementById('menuCollec').style
	if(menu.display == '' || menu.display == 'none')
	menu.display = 'block';	
	else
	menu.display = 'none';	
}
function afficheCGV(session){
	window.open(session+'&modele=cgv','cgv','width=620,height=450,scrollbars=yes');	
}


function ajouteItem(id_str,stock_nb) 
{
	var idValue = document.formProd['champ'+id_str].value;
	if(isNaN(parseInt(idValue))) idValue = 0;
	idValue = parseInt(idValue,10) +1;
	document.formProd['champ'+id_str].value = idValue;
	document.formProd['q'+id_str].value = idValue;
	//testStock(document.formProd['champ'+id_str], stock_nb);
}
function retireItem(id_str,stock_nb) 
{
	var idValue = document.formProd['champ'+id_str].value;
	if(isNaN(idValue)) idValue = 0;
	if(idValue > 0) 
	{
		idValue = parseInt(idValue,10) -1;
		document.formProd['champ'+id_str].value = idValue;
		document.formProd['q'+id_str].value = idValue;
		//testStock(document.formProd['champ'+id_str], stock_nb);
	}
}
function changeQT(id_str) 
{
	var idValue = document.formProd['champ'+id_str].value;
	if(isNaN(parseInt(idValue))) idValue = 0;
	document.formProd['champ'+id_str].value = idValue;
	document.formProd['q'+id_str].value = idValue;
	//testStock(document.formProd['champ'+id_str], stock_nb);
}
var error_nb = 0;
function testStock(id_obj, stock2_nb)
{
	
	var qt_nb = id_obj.value;
	if(qt_nb > stock2_nb)
	{	
		id_obj.style.color = '#FFFFFF';
		id_obj.style.backgroundColor = '#CC0000';	
		error_nb ++;
	}
	else
	{
		id_obj.style.color = '#d43d74';
		id_obj.style.backgroundColor = '#FFFFFF';	
		error_nb --;
	}
	if(error_nb == 0)
	document.getElementById('infoStock').style.display = 'none';
	else
	document.getElementById('infoStock').style.display = 'block';
}

function selectChev(id_obj)
{
	var tableau = document.getElementById('choixCheveux');
	var cheveux_array = tableau.getElementsByTagName('a');
	var len = cheveux_array.length;
	for(var i=0; i<len; i++)
	{
	cheveux_array[i].firstChild.style.border =  '1px #FFFFFF solid';
	}
	id_obj.firstChild.style.border = '1px #CC0000 solid';
}

function VerifFormfr(formu)
{
adresse = formu.from.value;
var place = adresse.indexOf("@",1);
var point = adresse.indexOf(".",place+1);
if ((place > -1)&&(adresse.length >2)&&(point > 1))
{
}
else
{
alert('Entrez une adresse e-mail valide');
return(false);
}
if (formu.manuel_perso.value == '')
{
alert('Veuillez nous indiquer si vous êtes un professionnel, un distributeur ou une personne appartenant au grand public');
return(false);
}
if (formu.manuel_contact.value == '')
{
alert('Veuillez nous indiquer votre contact Coklat');
return(false);
}
} 

function VerifFormes(formu)
{
adresse = formu.from.value;
var place = adresse.indexOf("@",1);
var point = adresse.indexOf(".",place+1);
if ((place > -1)&&(adresse.length >2)&&(point > 1))
{
}
else
{
alert('Entre una dirección e-mail válido');
return(false);
}
if (formu.manuel_perso.value == '')
{
alert('Por favor, señálenos si usted es un profesional, un distribuidor o una persona que pertenece al gran público');
return(false);
}
if (formu.manuel_contact.value == '')
{
alert('Por favor, señálenos su contacto Coklat');
return(false);
}
} 

function VerifFormus(formu)
{
adresse = formu.from.value;
var place = adresse.indexOf("@",1);
var point = adresse.indexOf(".",place+1);
if ((place > -1)&&(adresse.length >2)&&(point > 1))
{
}
else
{
alert('Enter a valid e-mail');
return(false);
}
if (formu.manuel_perso.value == '')
{
alert('Please indicate to us if you are a professional, a distributor or a person belonging to the general public');
return(false);
}
if (formu.manuel_contact.value == '')
{
alert('Please indicate us your Coklat contact');
return(false);
}
} 
function redirectBoutique(stnt1,session,cgibin){
	var cat = stnt1.substring(6,stnt1.length);
	var lien = ''+cgibin+"modele.pl?session="+session+"&modele=presentation&cat="+cat+"&action=set_session_tnt&stnt1="+stnt1
	document.location.href=lien;
}