blocolor = true;
function hexa(couleur,test,form)
{
	if(test=='0')
	{
		document.getElementById(form).value = couleur; // On inscrit dans le champs TEXT la valeur HEX de la couleur
		document.getElementById(form+'2').style.display = 'none';	
	}
	document.getElementById(form).style.color = couleur;
}

function mise_ajour_prix_liste(idchlo)
{
	//alert(idchlo);
	choixa=idchlo.split('-');
	document.getElementById("prixadmin_produit").value =choixa[1];
	document.getElementById("promoadmin_produit").value =choixa[2];
	
}

function palette_couleurs(form) 
{ 
if(document.getElementById(form+'2').style.display == 'block')
{
			document.getElementById(form+'2').style.display = 'none';	
			document.getElementById(form+'1').innerHTML = '<img src="../images/accordion_open.png" width="16" height="17" onclick="palette_couleurs(\''+form+'\');">';
			
			
}
else
{
	document.getElementById(form+'2').style.display = 'block';	
	document.getElementById(form+'1').innerHTML = '<img src="../images/accordion_close.png" width="16" height="17" onclick="palette_couleurs(\''+form+'\');">';

}
	// Ouverture du tableau
	txtdiv="<TABLE border='0' cellpadding='0' cellspacing='0' ><TR>";
	
	// Déclaration des variables
	var tabk = new Array('FF','CC','99','66','33','00'); // Tableau principal de couleur
	var tabj = tabk;
	var tabi = new Array('CC', '66', '00'); // Petit tableau principal (colonne de 6 couleurs)
	var tabi2 = new Array('00','33','66','99','CC','FF'); // Tableau principal inversé pour la colone du milieu (colonne de 6 couleurs)
	var color=""; // initialisation de color a vide
	var cmp = 0; // initialisation du compteur a 0
	
	// Début prog
	for(var k=0;k<6;k++) // Boucle pour les lignes de couleurs
	{
		for(var i=0;i<3;i++) // Boucle pour les colonnes (colonnes de 6 couleurs)
		{
			if (i == 1) // Si on attaque la 2 eme colonne de 6 couleurs
			{
				tabj = tabi2; // on inverse le tableau principale de couleurs
			}
			else // sinon
			{
				tabj = Array('FF','CC','99','66','33','00'); // On remet le tableau par default
			}
			
			for(var j=0;j<6;j++) // Boucle pour l'affichage couleur par couleur
			{
				color="#"+tabi[i]+tabk[k]+tabj[j]; // concaténation des chaines pour la valeur de la couleur
				// et on affiche la couleur
				txtdiv = txtdiv + "<TD width='15' height='15' style='border: 1px solid #000000;' bgcolor='"+color+"' onMouseOver=\"hexa('"+color+"','1','"+form+"')\" onClick=\"hexa('"+color+"','0','"+form+"')\"></TD>"; 
			} 
		} 
		txtdiv = txtdiv + "</tr>";
		
		cmp = cmp + 1; // On compte le nombre de ligne faite
		if (cmp == 6) // si on a fait les 6 lignes
		{
			var tabi = new Array('FF', '99', '33'); // on redéfini le nouveau tableau principal (colonne de 6 couleurs)
			var tabk = tabi2; // on re initialise le tableau des lignes
			k = -1; // on défini k à -1 car on a déja fait un passage
		}
	}
	// Fin prog
	txtdiv = txtdiv + "</TABLE><BR>"; // On ferme le tableau + saut de ligne
document.getElementById(form+'2').innerHTML = txtdiv;
} 


function bloc_menutype(txt)
{
	if(txt=='2'){
document.getElementById('typebloc').style.display = 'none';	
	}else
	{
		document.getElementById('typebloc').style.display = 'block';	

	}
}


function afficher_numerocolis()
{
numcol=document.getElementById('numero_colis').value;


choix=document.getElementById('etat_delacomunede').value;
choixa=choix.split('*');
choixb=choixa[0];

test=document.getElementById(choixb).value;

a=test.split('<var2>numero_colis</var2>');

if(a[1]){
newtxt=a[0] + " " + numcol + " " +a[1];
document.getElementById('mailetat').value=newtxt;
}

}
function ch_txt_comande(txt)
{
a=txt.split('*');
txt=a[0];
idtxt=a[1];


document.getElementById('mailetat').value = document.getElementById(txt).value;
document.getElementById('idpiuerpm').value = idtxt;

document.getElementById('mailsujet').value = document.getElementById(txt+'wwwww').value;

}

function soumettre_ordre(choix)
{
document.getElementById('choixordr').value = choix;
document.form_page_admin.submit();
}

function affichage_popup(nom_de_la_page, nom_interne_de_la_fenetre)
{
window.open (nom_de_la_page, 'Pass', config='height=220, width=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}


var ds_i_date = new Date();
ds_c_month = ds_i_date.getMonth() + 1;
ds_c_year = ds_i_date.getFullYear();

// Get Element By Id
function ds_getel(id) {
	return document.getElementById(id);
}

// Get the left and the top of the element.
function ds_getleft(el) {
	var tmp = el.offsetLeft;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetLeft;
		el = el.offsetParent;
	}
	return tmp;
}
function ds_gettop(el) {
	var tmp = el.offsetTop;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetTop;
		el = el.offsetParent;
	}
	return tmp;
}

// Output Element

var ds_oe = ds_getel('ds_calclass');
// Container
var ds_ce = ds_getel('ds_conclass');

// Output Buffering
var ds_ob = ''; 
function ds_ob_clean() {
	ds_ob = '';
}
function ds_ob_flush() {
	ds_oe.innerHTML = ds_ob;
	ds_ob_clean();
}
function ds_echo(t) {
	ds_ob += t;
}

var ds_element; // Text Element...

var ds_monthnames = [
'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin',
'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Décembre'
]; // You can translate it for your language.

var ds_daynames = [
'Dim', 'Lun', 'Mar', 'Me', 'Jeu', 'Ven', 'Sam'
]; // You can translate it for your language.

// Calendar template
function ds_template_main_above(t) {
	return '<table cellpadding="3" cellspacing="1" class="ds_tbl">'
	     + '<tr>'
		 + '<td class="ds_head" style="cursor: pointer" onclick="ds_py();">&lt;&lt;</td>'
		 + '<td class="ds_head" style="cursor: pointer" onclick="ds_pm();">&lt;</td>'
		 + '<td class="ds_head" style="cursor: pointer" onclick="ds_hi();" colspan="3">[Fermer]</td>'
		 + '<td class="ds_head" style="cursor: pointer" onclick="ds_nm();">&gt;</td>'
		 + '<td class="ds_head" style="cursor: pointer" onclick="ds_ny();">&gt;&gt;</td>'
		 + '</tr>'
	     + '<tr>'
		 + '<td colspan="7" class="ds_head">' + t + '</td>'
		 + '</tr>'
		 + '<tr>';
}

function ds_template_day_row(t) {
	return '<td class="ds_subhead">' + t + '</td>';
	// Define width in CSS, XHTML 1.0 Strict doesn't have width property for it.
}

function ds_template_new_week() {
	return '</tr><tr>';
}

function ds_template_blank_cell(colspan) {
	return '<td colspan="' + colspan + '"></td>'
}

function ds_template_day(d, m, y) {
	return '<td class="ds_cell" onclick="ds_onclick(' + d + ',' + m + ',' + y + ')">' + d + '</td>';
	// Define width the day row.
}

function ds_template_main_below() {
	return '</tr>'
	     + '</table>';
}

// This one draws calendar...
function ds_draw_calendar(m, y) {
	// First clean the output buffer.
	ds_ob_clean();
	// Here we go, do the header
	ds_echo (ds_template_main_above(ds_monthnames[m - 1] + ' ' + y));
	for (i = 0; i < 7; i ++) {
		ds_echo (ds_template_day_row(ds_daynames[i]));
	}
	// Make a date object.
	var ds_dc_date = new Date();
	ds_dc_date.setMonth(m - 1);
	ds_dc_date.setFullYear(y);
	ds_dc_date.setDate(1);
	if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
		days = 31;
	} else if (m == 4 || m == 6 || m == 9 || m == 11) {
		days = 30;
	} else {
		days = (y % 4 == 0) ? 29 : 28;
	}
	var first_day = ds_dc_date.getDay();
	var first_loop = 1;
	// Start the first week
	ds_echo (ds_template_new_week());
	// If sunday is not the first day of the month, make a blank cell...
	if (first_day != 0) {
		ds_echo (ds_template_blank_cell(first_day));
	}
	var j = first_day;
	for (i = 0; i < days; i ++) {
		// Today is sunday, make a new week.
		// If this sunday is the first day of the month,
		// we've made a new row for you already.
		if (j == 0 && !first_loop) {
			// New week!!
			ds_echo (ds_template_new_week());
		}
		// Make a row of that day!
		ds_echo (ds_template_day(i + 1, m, y));
		// This is not first loop anymore...
		first_loop = 0;
		// What is the next day?
		j ++;
		j %= 7;
	}
	// Do the footer
	ds_echo (ds_template_main_below());
	// And let's display..
	ds_ob_flush();
	// Scroll it into view.
	ds_ce.scrollIntoView();
}

// A function to show the calendar.
// When user click on the date, it will set the content of t.
function ds_sh(t) {
	// Set the element to set...
	ds_element = t;
	// Make a new date, and set the current month and year.
	var ds_sh_date = new Date();
	ds_c_month = ds_sh_date.getMonth() + 1;
	ds_c_year = ds_sh_date.getFullYear();
	// Draw the calendar
	ds_draw_calendar(ds_c_month, ds_c_year);
	// To change the position properly, we must show it first.
	ds_ce.style.display = '';
	// Move the calendar container!
	the_left = ds_getleft(t);
	the_top = ds_gettop(t) + t.offsetHeight;
	ds_ce.style.left = the_left + 'px';
	ds_ce.style.top = the_top + 'px';
	// Scroll it into view.
	ds_ce.scrollIntoView();
}

// Hide the calendar.
function ds_hi() {
	ds_ce.style.display = 'none';
}

// Moves to the next month...
function ds_nm() {
	// Increase the current month.
	ds_c_month ++;
	// We have passed December, let's go to the next year.
	// Increase the current year, and set the current month to January.
	if (ds_c_month > 12) {
		ds_c_month = 1; 
		ds_c_year++;
	}
	// Redraw the calendar.
	ds_draw_calendar(ds_c_month, ds_c_year);
}

// Moves to the previous month...
function ds_pm() {
	ds_c_month = ds_c_month - 1; // Can't use dash-dash here, it will make the page invalid.
	// We have passed January, let's go back to the previous year.
	// Decrease the current year, and set the current month to December.
	if (ds_c_month < 1) {
		ds_c_month = 12; 
		ds_c_year = ds_c_year - 1; // Can't use dash-dash here, it will make the page invalid.
	}
	// Redraw the calendar.
	ds_draw_calendar(ds_c_month, ds_c_year);
}

// Moves to the next year...
function ds_ny() {
	// Increase the current year.
	ds_c_year++;
	// Redraw the calendar.
	ds_draw_calendar(ds_c_month, ds_c_year);
}

// Moves to the previous year...
function ds_py() {
	// Decrease the current year.
	ds_c_year = ds_c_year - 1; // Can't use dash-dash here, it will make the page invalid.
	// Redraw the calendar.
	ds_draw_calendar(ds_c_month, ds_c_year);
}

// Format the date to output.
function ds_format_date(d, m, y) {
	// 2 digits month.
	m2 = '00' + m;
	m2 = m2.substr(m2.length - 2);
	// 2 digits day.
	d2 = '00' + d;
	d2 = d2.substr(d2.length - 2);
	// YYYY-MM-DD
//	return y + '-' + m2 + '-' + d2;


return y + '-' + m2 + '-' + d2;
}

// When the user clicks the day.
function ds_onclick(d, m, y) {
	// Hide the calendar.
	ds_hi();
	// Set the value of it, if we can.
	if (typeof(ds_element.value) != 'undefined') {
		ds_element.value = ds_format_date(d, m, y);
		//alert(ds_element.id);
		document.getElementById(ds_element.id+"a").value=d2 + ' ' + m2 + ' ' + y;

		
	// Maybe we want to set the HTML in it.
	} else if (typeof(ds_element.innerHTML) != 'undefined') {
		ds_element.innerHTML = ds_format_date(d, m, y);
	// I don't know how should we display it, just alert it to user.
	} else {
		alert (ds_format_date(d, m, y));
	}
}
function cacher(champ) 
{ 
document.getElementById(champ).style.display = 'none';
}


function montrer(champ,champ_txt,txt,tabsql,chtxt,ch,ch2,ch3) 
{ 
document.getElementById(champ).style.display = 'block';
document.getElementById(champ_txt).innerHTML = txt;

document.getElementById(champ+'a').contentWindow.document.getElementById('champ_en_coursse').value=ch3;

document.getElementById(champ+'a').contentWindow.document.getElementById(chtxt).value=tabsql;
document.getElementById(champ+'a').contentWindow.document.getElementById(ch2).value=ch;





}



function augmenter_ch(champ,nbr_pag) 
{
minch = parseInt(document.getElementById(champ).value)+parseInt(1);
if(minch <= nbr_pag){
document.getElementById(champ).value = minch;
document.form_page_admina.submit(); 
}
}

function diminuer_ch(champ) 
{
minch = parseInt(document.getElementById(champ).value)-parseInt(1);
if(minch>0){
document.getElementById(champ).value = minch;
document.form_page_admina.submit(); 
}
}

function modifier_page_admin(id_page_admin) 
{
window.parent.document.getElementById("id_page_admin").value = id_page_admin;
window.parent.document.getElementById("test_parent_page_admin").value = '0';
window.parent.document.form_page_admin.submit(); 

}

function modifier_page_adminw(id_page_admin) 
{
window.parent.document.getElementById("id_page_admina").value = id_page_admin;
window.parent.document.getElementById("test_parent_page_admina").value = '0';
window.parent.document.form_page_admina.submit(); 

}


function supprimer_page_adminw(id_page_admin) 
{
	if (confirm('Confirmez vous la suppression ?'))
	{
	window.parent.document.getElementById("id_page_admina").value = id_page_admin;
	window.parent.document.getElementById("test_parent_page_admina").value = '3';
	window.parent.document.form_page_admina.submit()	
	}
	else
	{
	return false;	
	}
	
	
; 

}

function supprimer_page_admin(id_page_admin) 
{
	if (confirm('Confirmez vous la suppression ?'))
	{
	window.parent.document.getElementById("id_page_admin").value = id_page_admin;
	window.parent.document.getElementById("test_parent_page_admin").value = '3';
	window.parent.document.form_page_admin.submit()	
	}
	else
	{
	return false;	
	}
	
	
; 

}
function remplir_champ_page_admin(val_champ,nom_champ,nbr_champ,type) 
{
	
for(t=val_champ;t<nbr_champ;t++)
{	
nom_du_champ = nom_champ + t;

if(type=="1")
{
val_du_champ =document.getElementById(nom_champ+val_champ).value
document.getElementById(nom_du_champ).value = val_du_champ;
}
else if (type=="2")
{
val_du_champ = document.getElementById(nom_champ+val_champ).selectedIndex;

document.getElementById(nom_du_champ).selectedIndex = val_du_champ;

}

else if (type=="3")
{
	if(document.getElementById(nom_champ+val_champ).checked){testchec="1";}else{testchec="0";}
	
if(testchec=="1")
{
document.getElementById(nom_du_champ).checked=true;
}
else
{
document.getElementById(nom_du_champ).checked=false;

}


}
}

}

function changement_image(nomimg,taillelar) {
	document.getElementById("image").innerHTML = "<a rel=\"lightbox[roadtrip2]\" href=\"administration/catalogue/images/"+nomimg+"\" target=\"_blank\"><img src=\"administration/catalogue/images/"+nomimg+"\" "+taillelar+"=\"200\" class=\"bloc_produit_bordure\" /></a>";
}
function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox

function voir_panier()
{ 

vu = document.getElementById('valu').value;



document.forms["fiche_prod"+vu].testajout.value="2";

document.forms["fiche_prod"+vu].submit();

}
function continuer_achat()
{ 

vu = document.getElementById('valu').value;
//alert(vu);
document.forms["fiche_prod"+vu].submit();

}


function openbox(formtitle, fadin)
{ 
window.scrollTo('0','0');
var box = document.getElementById('box'); 
  document.getElementById('valu').value=fadin;
  
  document.getElementById('filter').style.display='block';

  var btitle = document.getElementById('boxtitle');
  btitle.innerHTML = "";
  
  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }  return false;
}


// Close the lightbox

function verif_conditions(texte)
{
  if(document.getElementById('verifmention').checked==false){
alert(texte);return false;}

  if(document.getElementById('code_reduction').value!=""){
alert("Vous avez oublié de valider votre code promotion");
return false;}


}

function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
}
function box_alert(txt)
{
alert(txt);
}
function blocspecial_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
 
var divz = document.getElementById("blocspecial" )

var currentLocation =  document.location.href;

a=currentLocation.split('/');


if (a[3]!='administration') { 
 
jQuery(document).ready(function() {
    jQuery('#blocspecial').carousel({
        vertical: true,
		auto: 2,
        scroll: 1,
		wrap: 'last',
		buttonNextHTML: null,
		buttonPrevHTML: null,
        initCallback:blocspecial_initCallback
    });
});
						   }
function vider_password()
{
document.getElementById('divpass').innerHTML = '<input type="password" id="pass" value="" class="champ_texte_mini_compte" name="pass"/>';

setTimeout("focus_champ_txt('pass')",10); 

}

function vider_mail()
{
document.getElementById('divmail').innerHTML = '<input type="text" id="mail" value="" class="champ_texte_mini_compte" name="mail"/>';

setTimeout("focus_champ_txt('mail')",10); 

}

function focus_champ_txt(idch)
{document.getElementById(idch).focus();

}

