// fonction random entre 0 et X-1 ex: si limite=5, cela génère un chiffre entre 0 et 4
function get_random(limite){
    var ranNum= Math.floor(Math.random()*limite);
	return ranNum;
}

function Popup(page1,nom1,option1) {
	if(!page1 == ''){
		window.open(page1,nom1,option1);
	}
}

function Popup_centre(page,nom,top,left,largeur,hauteur,resizable,location,menubar,status,scrollbars,menubar) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;

  if(!page == ''){
		window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+",resizable="+resizable+",location="+location+",menubar="+menubar+",status="+status+",scrollbars="+scrollbars+",menubar="+menubar);
	}
}

function envoyer(method,formname,formaction){
	document.forms[formname].method = method;
	document.forms[formname].enctype = "multipart/form-data";
	document.forms[formname].action = formaction;
	document.forms[formname].submit();
}

function confirmation(temp_url) {
	if (confirm('Voulez vous vraiment supprimer cet élément ?')) {
		location.href = temp_url;
	}else{
		alert("Vous avez annulé l'action");
	}
}

function GoURL(categoryMenu){
	if(categoryMenu.options[categoryMenu.selectedIndex].value==""){
		alert('Veuillez selectionner une gamme d\'articles dans le menu.');
	}else{
		window.location.href = categoryMenu.options[categoryMenu.selectedIndex].value;
		categoryMenu.selectedIndex=0;
	}
}


// Fonctions date
function disp(txt){
	document.write(txt);
	}

function don_date_maj(){
	var date_maj=new Date(document.lastModified);
	date_maj=don_date_format(date_maj);
	return date_maj;
	}

function don_date_jour(){
	var date_jour=new Date();
	date_jour=don_date_format(date_jour);
	return date_jour;
	}

function don_date_format(d1){
	var m=new Array(13);
	m[1]="Janvier"; m[2]="Février";	m[3]="Mars"; m[4]="Avril"; m[5]="Mai"; m[6]="Juin";
 	m[7]="Juillet";	m[8]="Aout"; m[9]="Septembre"; m[10]="Octobre";	m[11]="Novembre"; m[12]="Décembre";
	var d=new Array(8);
	d[1]="Dimanche"; d[2]="Lundi"; d[3]="Mardi"; d[4]="Mercredi"; d[5]="Jeudi"; d[6]="Vendredi"; d[7]="Samedi";
	var mois=m[d1.getMonth()+1];
	var jour=d[d1.getDay()+1];
	var date=d1.getDate();
	var an=d1.getYear();
	if (an<200) an=1900+an;
	date=jour+" "+date+" "+mois+" "+an;
	return date;
	}
	
// Fonctions heure
function don_heure(){
	var date_jour=new Date();
	var heure=date_jour.getHours();
	var min=date_jour.getMinutes();
	var sec=date_jour.getSeconds();
	if (heure<10) heure="0"+heure;
	if (min<10) min="0"+min;
	if (sec<10) sec="0"+sec;
	heure=heure+":"+min;
	return heure;
	}

// Fonctions rollover image
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

// Fonctions menu deroulant
var delay_nav_hori = 600;
var timeout_nav_hori;

function affiche_nav_hori(id){
	arrete_masque_nav_hori();
	for (var i = 1; i<=26; i++){
		var id2 = "nav_hori_smenu"+i;
		if(id != id2){
			if (document.getElementById(id2)){
				document.getElementById(id2).style.display='none';
			}
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer") 	
	{
		// Pour ie suppression de l'iframe qui a été ajouté pour que le menu passe sur les tag select 
		if (document.getElementById("iframeSelect") != null)
		{
			document.getElementById("iframeSelect").removeNode(true);
		}
	}
	if (document.getElementById(id)){
		document.getElementById(id).style.display='block';
		
		
		
		// Pour passer sur les champs select Pour ie
		if (navigator.appName == "Microsoft Internet Explorer") 	
		{
		iframe =document.createElement('iframe');
		iframe.id = "iframeSelect";
		iframe.frameBorder="0";
		iframe.style.position='absolute';
		iframe.scrolling="no";
						
		nav_bas= document.getElementById(id);
		nav_bas.parentNode.insertBefore(iframe, nav_bas );
		
		iframe.style.top=document.getElementById(id).offsetTop;
		iframe.style.width=document.getElementById(id).offsetWidth;
		iframe.style.height=document.getElementById(id).offsetHeight;
		iframe.style.left=document.getElementById(id).offsetLeft;
		
		}	
		
		
	}
}

function masque_nav_hori(){
	for (var i = 1; i<=26; i++){
		if (document.getElementById('nav_hori_smenu'+i)){
			document.getElementById('nav_hori_smenu'+i).style.display='none';
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer") 	
	{		
	// Pour ie suppression de l'iframe qui a été ajouté pour que le menu passe sur les tag select 
	if (document.getElementById("iframeSelect") != null)
	{
		document.getElementById("iframeSelect").removeNode(true);
	}
	}    
}

function lance_masque_nav_hori(){
	timeout_nav_hori = setTimeout('masque_nav_hori()', delay_nav_hori);
}
function arrete_masque_nav_hori(){
	if(timeout_nav_hori)
		clearTimeout(timeout_nav_hori);
}


function AfficheBlock(baliseId){
	for(var i=1; i<10; i++){
		var HideBlock = "contenu" + i ;
		if (document.getElementById && document.getElementById(HideBlock) != null){
		document.getElementById(HideBlock).style.visibility='hidden';
    	document.getElementById(HideBlock).style.display='none';
		}
	}
	
	if (document.getElementById && document.getElementById(baliseId) != null){
    	document.getElementById(baliseId).style.visibility='visible';
    	document.getElementById(baliseId).style.display='block';
	}
}

function Get_Url_Var (nomVariable){
	var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&";
	if (infos.indexOf("#")!=-1)
		infos = infos.substring(0,infos.indexOf("#"))+"&"
	var variable=0
	{
		nomVariable = nomVariable + "="
		var taille = nomVariable.length
		if (infos.indexOf(nomVariable)!=-1)
			variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
	}
	return variable
}


function Get_Url(){
	url = document.location;
	return url;
}

function Send_Fiche(){
	tmp_lg = Get_Url_Var('code_lg');
	
	if(tmp_lg == "lg_fr"){
		tmp_email = "";
		tmp_subject = "Ce site m'a plu, peut-être te plaira t-il...";
		tmp_body = "Cliquez sur le lien suivant : "+Get_Url()+"";
	}else if(tmp_lg == "lg_us"){
		tmp_email = "";
		tmp_subject = "Ce site m'a plu, peut-être te plaira t-il...";
		tmp_body = "Cliquez sur le lien suivant : "+Get_Url()+"";
	}
	
	w1=window.open('mailto:'+tmp_email+'?subject='+tmp_subject+'&body='+tmp_body+'');
	
}

function Send_Recommander(){
	tmp_lg = Get_Url_Var('code_lg');
	tmp_link_fr = "http://www.fashionvictime.fr/boutique/liste_rayons.cfm";
	tmp_link_us = "http://www.fashionvictime.fr/boutique_us/liste_rayons.cfm?code_lg=lg_us";
	
	if(tmp_lg == "lg_fr"){
		tmp_email = "";
		tmp_subject = "Changez d’idée, pas de bijou…fashionvictime";
		tmp_body = "Bonjour, Un bijou qui n’est ni tout à fait le même, ni tout à fait un autre… Fashionvictime : bijoux modulables aimantés. Le même modèle peut être porté en bracelet, collier, sautoir, ras de cou… "+tmp_link_fr+"";
	}else if(tmp_lg == "lg_us"){
		tmp_email = "";
		tmp_subject = "Change your mind, not your jewelry .... Fashionvictime.";
		tmp_body = "Hello, Jewelry is neither so much the same, nor so much another. Fashionvictime: magnetic convertible jewelry. One model can be worn as bracelet, necklace, collar, choker. "+tmp_link_us+"";
	}else{
		tmp_email = "";
		tmp_subject = "Changez d’idée, pas de bijou…fashionvictime";
		tmp_body = "Bonjour, Un bijou qui n’est ni tout à fait le même, ni tout à fait un autre… Fashionvictime : bijoux modulables aimantés. Le même modèle peut être porté en bracelet, collier, sautoir, ras de cou… "+tmp_link_fr+"";
	}
	
	w1=window.open('mailto:'+tmp_email+'?subject='+tmp_subject+'&body='+tmp_body+'');
}


function Send_Recommander_concept(){
	tmp_lg = Get_Url_Var('code_lg');
	tmp_link_fr = "http://www.fashionvictime.fr/site/fashionvictime-concept-fr.html";
	tmp_link_us = "http://www.fashionvictime.fr/site/fashionvictime-concept-us.html";
	
	if(tmp_lg == "lg_fr"){
		tmp_email = "";
		tmp_subject = "Changez d’idée, pas de bijou…fashionvictime";
		tmp_body = "Bonjour, Un bijou qui n’est ni tout à fait le même, ni tout à fait un autre… Fashionvictime : bijoux modulables aimantés. Le même modèle peut être porté en bracelet, collier, sautoir, ras de cou… "+tmp_link_fr+"";
	}else if(tmp_lg == "lg_us"){
		tmp_email = "";
		tmp_subject = "Changez d’idée, pas de bijou…fashionvictime";
		tmp_body = "Bonjour, Un bijou qui n’est ni tout à fait le même, ni tout à fait un autre… Fashionvictime : bijoux modulables aimantés. Le même modèle peut être porté en bracelet, collier, sautoir, ras de cou… "+tmp_link_us+"";
	}else{
		tmp_email = "";
		tmp_subject = "Changez d’idée, pas de bijou…fashionvictime";
		tmp_body = "Bonjour, Un bijou qui n’est ni tout à fait le même, ni tout à fait un autre… Fashionvictime : bijoux modulables aimantés. Le même modèle peut être porté en bracelet, collier, sautoir, ras de cou… "+tmp_link_fr+"";
	}
	
	w1=window.open('mailto:'+tmp_email+'?subject='+tmp_subject+'&body='+tmp_body+'');
	
}

function coupeambiance(){
	if (document.getElementById && document.getElementById('ambiance1') != null){
	document.getElementById('ambiance1').GotoFrame(34);
	return false;
	}
}

function videoboxpub1(vid_url,vid_title,vid_rel){
	coupeambiance();
	Videobox.open(vid_url,vid_title,vid_rel);
}

function verif()
{ var stop=0;
var str='';
var adresse = document.form_mailing.mail.value;
var place = adresse.indexOf("@",1);
var point = adresse.indexOf(".",place+1);
if ((document.form_mailing.mail.value == '') || (document.form_mailing.mail.value == 'Votre E-mail'))
{	str=str+'\n - Votre E-mail';
stop=1;
}
else
{	if ((place > -1)&&(adresse.length >2)&&(point > 1)&&(adresse.length > point+2))
{
}
else
{	if (stop == 0)
{	stop=1;
alert('Veuillez saisir une adresse E-mail valide.');
document.form_mailing.mail.focus();
}
}
}
if (stop==0) document.form_mailing.submit();
else if (str != '') alert('Nom '+str);
}



/* COMPTER LES ENTREES D'UN TABLEAU */
Array.prototype.count = function() {
	return this.length;
};


function favoris(nom,lien) {
      if ( navigator.appName != 'Microsoft Internet Explorer' ){
          window.sidebar.addPanel(nom,lien,"");
      }
      else {
          window.external.AddFavorite(lien,nom);
      }
}




function QueryString(param){
	var strParam = new String(param);
	var position = window.location.search.indexOf('&' + strParam + '=');
	if (position==-1) 
	position = window.location.search.indexOf('?' + strParam + '=');
	if (position==-1) 
	return '';
	return (window.location.search.indexOf('&', position + strParam.length + 2)==-1) ? window.location.search.substr(position + strParam.length + 2) : window.location.search.substr(position + strParam.length + 2, window.location.search.indexOf('&', position + strParam.length + 2) - (position + strParam.length + 2));
}


/***********************************************
* Ajax Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//To include a page, invoke ajaxinclude("afile.htm") in the BODY of page
//Included file MUST be from the same domain as the page displaying it.

var rootdomain="http://"+window.location.hostname

function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}