var move = 0;
var currentPos = 0;
var x = 0;
var counter = 1;	
var curTimer = "";
var nbBoxes = 5;

function moveScrollerBar(i){
	move = i;
	clearTimeout(curTimer);
	x=0;
	counter=0;
	currentPos = document.getElementById('scrollerBar').scrollLeft;
	setTimeout("moveUp()",1);
}
function moveUp(){
	tomax = nbBoxes*122;
	x = x + move;
	document.getElementById('scrollerBar').scrollLeft=currentPos+x;
	counter++;
	if ((x<tomax)&&(x>(0-(tomax)))){
		curTimer = setTimeout("moveUp()",1);
	}
}

function getForfaits09(ido,idp,idfg,idfgt){
	if(window.XMLHttpRequest){
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	}

	xhr_object.open("GET", "/action/getForfaits09.cfm?uuid="+Math.random()+"&idp="+idp+"&ido="+ido+"&idfg="+idfg+"&idfgt="+idfgt, true);
	xhr_object.send(null);
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4) {
			document.getElementById('showAbo').innerHTML=xhr_object.responseText;
		}
	}

}

function switchTitle(id,obj){
	for(i=1;i<=5;i++){
		if(document.getElementById('t'+i)){
			document.getElementById('t'+i).style.visibility = 'hidden';
			document.getElementById('t'+i).style.position = 'absolute';
			document.getElementById('t'+i).style.display = 'none';
		}
		if ((i!=id)&&(document.getElementById('m'+i))) {
			document.getElementById('m'+i).className = 'subMenu';
		} else if(document.getElementById('m'+i)) {
			obj.className = 'subMenu_a';
		}

	}
	curMenu = document.getElementById('t'+id);
	if(curMenu){
		curMenu.style.visibility = 'visible';
		curMenu.style.float = 'left';
		curMenu.style.display = 'block';
		curMenu.style.position = 'relative';
	}
}

function showInfoRenew() {
	myId = document.getElementById('infoRenew');
	if (myId.style.display =="none") {
		myId.style.display ='block';
		myId.style.visibility ='visible';
	} else {
		myId.style.display ='none';
		myId.style.visibility ='hidden';
	}
}

function getRenew(idp,ido,points,num_tel,duree){
	if(window.XMLHttpRequest){
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	}

	xhr_object.open("GET", "/action/getRenew09.cfm?uuid="+Math.random()+"&idp="+idp+"&ido="+7+"&points="+points+"&num_tel="+num_tel+"&duree="+duree, true);
	xhr_object.send(null);
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4) {
			document.getElementById('showRenew').innerHTML=xhr_object.responseText;
		}
	}
}
	
function showComment(e,p,idp){
	if(window.XMLHttpRequest){
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	}
	xhr_object.open("GET", "/action/comment.cfm?uuid="+Math.random()+"&idp="+idp+"&e="+e+"&p="+p, true);
	xhr_object.send(null);
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4) {
			document.getElementById('showForm').innerHTML=xhr_object.responseText;
		}
	}
}

function addToCompare(idp,s){
	if(window.XMLHttpRequest){
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	}

	xhr_object.open("GET", "/mobiles/mods/action/addToCompare.cfm?uuid="+Math.random()+"&id="+idp+"&s="+s, true);
	xhr_object.send(null);
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4) {
			document.getElementById('compare').innerHTML=xhr_object.responseText;
		}
	}
}


function postComment(idp,iduser,title,comment,note){
	var reg=new RegExp('\n', "g");
	myCmt = comment.replace(reg,"<br>");
	
	if(window.XMLHttpRequest){
		xhr_object = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	}
	xhr_object.open("GET", "/mobiles/mods/addComment.cfm?uuid="+Math.random()+"&idp="+idp+"&iduser="+iduser+"&title="+title+"&comment="+myCmt+"&note="+note, true);
	xhr_object.send(null);
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4) {
			document.getElementById('showForm').innerHTML=xhr_object.responseText;
		}
	}
}


function addAccessoryToCart(id) {
	document.getElementById('showActionCart'+id).innerHTML='<img src="/images/loading.gif" alt="" >';
		if(window.XMLHttpRequest){
			res_object = new XMLHttpRequest();
		}else if(window.ActiveXObject){ 
			res_object = new ActiveXObject("Microsoft.XMLHTTP");   
		}else{
		   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");   
		}

	res_object.open("GET", '/?addToCart=1&idp='+id+'&quantity=1&'+Math.random(), true); 
	res_object.send(null); 
	res_object.onreadystatechange = function(){
		if(res_object.readyState == 4) {
			document.getElementById('showActionCart'+id).innerHTML='<span class="marron11bold">produit ajout&eacute;</span><br>';
			document.getElementById('showActionCart'+id).innerHTML+='<a href="/cart/" class="red11bold">voir mon panier</a>';
		}
	}
}	
	