//var path ='images/';
var path = '../minisite/templates/images/';

function init ()
{
var whatsInYourHead = document.getElementById('header');
var ipb = document.createElement ('div');
ipb.style.position 	= 'absolute';
ipb.style.top		= '20px';
ipb.style.left		= '-220px';
ipb.style.zIndex	= '1000';
ipb.style.cursor	= 'pointer';
ipb.innerHTML		= '<img src="'+path+'logo_Iphone.png" alt="Un max de sonnerie pour ton Iphone">'
ipb.id = 'ipbID';
ipb.onclick = function ()
{
window.location='http://www.track2cash.com/click.php?t2c=a0a2efbf8bffbe47172056f9a3002ef83bb2';
}
whatsInYourHead.appendChild(ipb);
}function recup_ref(reference) {
	document.formulaire.ref.value=reference;
	//alert(document.formulaire.ref.value);
}
function recup_saisie(saisie) {
document.form.saisie.value=saisie;
}
function split_extension(fichier){
	var ret=new Array();
	var pos=fichier.lastIndexOf('.');
	ret[0]=fichier.substr(0,pos);
	ret[1]=fichier.substr(pos+1);
	return ret;
}
function check_and_change(celuila,formulaire) {
	var celuila_position = celuila.id.substr(celuila.id.length-1,1);
	celuila_position = parseInt (celuila_position);
	var celuila_type_div = celuila.id;
	celuila_type_div = celuila_type_div.substr(0,celuila_type_div.length -1);
	var au_suivant = celuila_type_div + (celuila_position + 1);
	var affiche_suivant = document.getElementById(au_suivant +'_check');
	if (affiche_suivant == null) {
		affiche_suivant = document.getElementById('telecharge_check');
	}
	next_src = split_extension(affiche_suivant.getAttribute('src'));
	next_src = next_src[0].substr(0,next_src[0].length-1);
	var atrouver = celuila.id +'_check';
	var achanger = document.getElementById(atrouver);
	var son_src = split_extension(achanger.getAttribute('src'));
	var son_new_src = son_src[0].substr(0,son_src[0].length -1);
	var son_format = son_src[1];
	var son_type = son_src[0].substr(-1,1);
	if (formulaire == 'mobile') {
		var acontroler = document.getElementById(formulaire);
		//acontroler.setAttribute('value','');
		acontroler.onkeyup = function (event) {
			var mobile=acontroler.value;
			if(!re_mobile.exec(mobile)){
				achanger.setAttribute('src',son_new_src +'3.'+son_format);
				return false;
			}
			if(mobile.length == long_mobile){
				achanger.setAttribute('src',son_new_src +'2.'+son_format);
					affiche_suivant.setAttribute('src',next_src +'1.'+son_format);
				return false;
			}
		}
	}
	if (formulaire == 'fai') {
		var acontroler = document.getElementById(formulaire);
		acontroler.onclick = function (event) {
			achanger.setAttribute('src',son_new_src +'2.'+son_format);
			affiche_suivant.setAttribute('src',next_src +'1.'+son_format);
			return false;
		}
	}
	if (formulaire == 'code') {
		var acontroler = document.getElementById(formulaire);
		acontroler.setAttribute('maxlength',4);
		acontroler.setAttribute('value','');
		acontroler.onkeyup = function (event) {
			var mobile=acontroler.value;
			var re = /^[0-9]{4}$/;
			if(!re.exec(mobile)){
				achanger.setAttribute('src',son_new_src +'3.'+son_format);
			}
			if(mobile.length == 4){
				achanger.setAttribute('src',son_new_src +'2.'+son_format);
				affiche_suivant.setAttribute('src',next_src +'1.'+son_format);
				return false;
			}
		}
	}
}
var pour_restore;
function swap_img (id_img) {
	pour_restore = document.getElementById(id_img).getAttribute('src');
	var img_name = split_extension(pour_restore);
	var new_img = document.getElementById(id_img).setAttribute('src', img_name[0]+'-over.'+img_name[1]);
}
function restore (id_img) {
	var new_img = document.getElementById(id_img).setAttribute('src', pour_restore);
}

