/* Ajax - content */

/*switch (xhr_object.status){
  case 100 : ct.innerHTML ="100";break; // continue
  case 101 : ct.innerHTML ="101";break; // switching protocols
  case 200 : // complete
//ct.innerHTML = xhr_object.responseText;
content(ct,'cart');
break; 
case 201 : ct.innerHTML ="201";break; // created
case 202 : ct.innerHTML ="202";break; // accepted
case 203 : ct.innerHTML ="203";break; //Non-Authoritative Information 
case 204 : ct.innerHTML ="204";break; //No Content 
case 205 : ct.innerHTML ="205";break; //Reset Content 
case 206 : ct.innerHTML ="206";break; //Partial Content 
// Redirection 
case 300 : ct.innerHTML ="300";break; //Multiple Choices 
case 301 : ct.innerHTML ="301";break; //Moved Permanently 
case 302 : ct.innerHTML ="302";break; //Found 
case 303 : ct.innerHTML ="303";break; //See Other 
case 304 : ct.innerHTML ="304";break; //Not Modified 
case 305 : ct.innerHTML ="305";break; //Use Proxy 
case 306 : ct.innerHTML ="306";break; //(Unused) 
case 307 : ct.innerHTML ="307";break; //Temporary Redirect 
//Client Error
case 400 : ct.innerHTML ="400";break; //Bad Request 
case 401 : ct.innerHTML ="401";break; //Unauthorized
case 402 : ct.innerHTML ="402";break; //Payment Required
case 403 : ct.innerHTML ="403";break; //Forbidden 
case 404 : ct.innerHTML ="404";break; //Not Found 
case 405 : ct.innerHTML ="405";break; //Method Not Allowed 
case 406 : ct.innerHTML ="406";break; //Not Acceptable 
case 407 : ct.innerHTML ="407";break; //Proxy Authentication Required 
case 408 : ct.innerHTML ="408";break; //Request Timeout 
case 409 : ct.innerHTML ="409";break; //Conflict  
case 410 : ct.innerHTML ="410";break; //Gone  
case 411 : ct.innerHTML ="411";break; //Length Required  
case 412 : ct.innerHTML ="412";break; //Precondition Failed  
case 413 : ct.innerHTML ="413";break; //Request Entity Too Large  
case 414 : ct.innerHTML ="414";break; //Request-URI Too Long  
case 415 : ct.innerHTML ="415";break; //Unsupported Media Type  
case 416 : ct.innerHTML ="416";break; //Requested Range Not Satisfiable  
case 417 : ct.innerHTML ="417";break; //Expectation Failed  
//Server Error
case 500 : ct.innerHTML ="500";break; //Internal Server Error 
case 501 : ct.innerHTML ="501";break; //Not Implemented 
case 502 : ct.innerHTML ="502";break; //Bad Gateway 
case 503 : ct.innerHTML ="503";break; //Service Unavailable 
case 504 : ct.innerHTML ="504";break; //Gateway Timeout 
case 505 : ct.innerHTML ="505";break; //HTTP Version Not Supported 

default:
// bad connection : reload content
//content(ct,'cart'); // refresh bug fixed : SA, IE, FF
break;
}*/

function xhr(){
	if(window.XMLHttpRequest) return new XMLHttpRequest(); // FF
	else if(window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); // IE
	else {alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");return;}
}


var xhr_loadPage_object = xhr();

function abortLoadPageRequest(){
	if (xhr_loadPage_object.readyState!=4){
		xhr_loadPage_object.onreadystatechange=null;
			xhr_loadPage_object.abort();
	}
}

function $(id){
	return document.getElementById(id);
}
function exist(id){return ($(id)!=null);}
function clearDiv(out){$(out).innerHTML="";}

/*function evalJS(texte){
// launch all javascript found in the page
var allscript = texte.getElementsByTagName('script');
for(var i=0;i< allscript.length;i++){eval(allscript[i].text);}
}*/
function evalJS(o){
	// launch all javascript found in the page
	var allscript = o.getElementsByTagName('script');
		for(var i=0;i<allscript.length;i++){eval(allscript[i].innerHTML);}
}

function content_arg(out,p,arg,whatIfOk,whatIfKo){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			
				var pg = "content/ct_" + p + ".php";
				var method="POST";
				var asynchrone=true;
				var data=arg;
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					switch (xhr_object.readyState){
						case 0 : window.status = "loading";break;
						case 1 : window.status = "loading.";break;
						case 2 : window.status = "loading..";break;
						case 3 : window.status = "loading...";break;
						case 4 : out.innerHTML= xhr_object.responseText;
							 evalJS(out);
								 window.status = "";
								 eval(whatIfOk);
								 break;
						default: break;
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		xhr_object.send(data);
}


function content(out,p,id,sort,asc,limit){
	abortLoadPageRequest();
		//var xhr_object = xhr();
		if(xhr_loadPage_object ==null){return;}
			
				var pg = "content/ct_" + p + ".php";
				var method="POST";
				var asynchrone=true;
				var data="id="+id;
				if(sort!='undefined' || sort!=''){data+="&sort="+sort;}
					if(asc!='undefined' || asc!=''){data+="&asc="+asc;}
						if(limit!='undefined' || limit!=''){data+="&limit="+limit;}
							xhr_loadPage_object.open(method, pg , asynchrone);
								xhr_loadPage_object.onreadystatechange = function() {   
									switch (xhr_loadPage_object.readyState){
										case 0 : window.status = "loading...";
											 //loadingStatus.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
											 break; 
												 // uninitialized...
										case 1 : window.status = "loading...";
											 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
											 break; 
												 // loading...
										case 2 : window.status = "loading...";
											 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
											 break; 
												 // loaded...
										case 3 : window.status = "loading...";
											 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
											 break; 
												 // interactive...
										case 4 : //if (xhr_loadPage_object.status == 200) {
												 texte = xhr_loadPage_object.responseText;
													 out.style.display='none';
													 out.innerHTML= texte;evalJS(out);
													 var id=new Effect.Appear(out);
													 
													 online();
													 
													 initLightbox();// scan lightbox image
												 /*}
												   else if (xhr_loadPage_object.status == 404) {
												   out.innerHTML='<h1>Error</h1><p>Sorry this page does not exist.</p>';
												   }*/
												 window.status = "";
													 displayNavigation();
													 //evalJS(xhr_object.responseText);
													 evalJS(out);
													 break; // complete
										default: break;
									}
								}
	xhr_loadPage_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		xhr_loadPage_object.send(data);  
}

function direct_content(out,p,id){
	var xhr_object = xhr();
		if(xhr_object==null){return;}
			var pg = "content/ct_" + p + ".php";
				var method="POST";
				var asynchrone=true;
				var data="id="+id;;
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if(xhr_object.readyState==4){
						out.innerHTML = xhr_object.responseText; 
							online();
					}
				}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function updateCurrentPage(page,id){
	var xhr_object = xhr();
		if(xhr_object==null){return;}
			var pg = "functions/php/updateCurrentPage_process.php";
				var method="POST";
				var asynchrone=true;
				var data="page="+page+"&id="+id;
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if(xhr_object.readyState==4){
						online();
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function displayRandomSpec(){
	direct_content($('ct_random'),'random');
}
// use this function to load a page
// historic page
function loadPage(p,id){
	abortLoadPageRequest();
		iniDocument();
		//	var xhr_object = xhr();
		if(xhr_loadPage_object ==null){return;}
			var pg = "content/ct_" + p + ".php";
				var method="POST";
				var asynchrone=true;
				var data="id="+id;
				
				xhr_loadPage_object.open(method, pg , asynchrone);
				$('ct').innerHTML= "";
				xhr_loadPage_object.onreadystatechange = function() {   
					switch (xhr_loadPage_object.readyState){
						case 0 : window.status = "loading...";
							 //loadingStatus.innerHTML= "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // uninitialized...
						case 1 : window.status = "loading...";
							 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // loading...
						case 2 : window.status = "loading...";
							 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // loaded...
						case 3 : window.status = "loading...";
							 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // interactive...
						case 4 : 
							 //if (xhr_loadPage_object.status == 200) {
							 texte = xhr_loadPage_object.responseText;
								 //$('ct').innerHTML= texte;
								 $('ct').style.display='none';
								 $('ct').innerHTML= texte;evalJS($('ct'));
								 var id=new Effect.Appear($('ct'));
								 
								 evalJS($('ct'));
								 displayRandomSpec();
								 historyPage(p,id);// save in history page navigation
							 online();
								 initLightbox(); // scan lightbox image
							 /*	}
								else if (xhr_loadPage_object.status == 404) {
								out.innerHTML='<h1>Error</h1><p>Sorry this page does not exist.</p>';
								}*/
							 window.status = "";
								 displayNavigation();
								 break; // complete
						default: break;
					}
				}
	
		xhr_loadPage_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		xhr_loadPage_object.send(data);  
}

// use this function to load a page
// historic page
function loadLongPage(p,id,deb,limit){
	//	var xhr_object = xhr();
	abortLoadPageRequest();
		if(xhr_loadPage_object ==null){return;}
			var pg = "content/ct_" + p + ".php";
				var method="POST";
				var asynchrone=true;
				var data="id="+id+"&deb="+deb;
				$('ct').innerHTML= '';
				xhr_loadPage_object.open(method, pg , asynchrone);
				xhr_loadPage_object.onreadystatechange = function() {   
					switch (xhr_loadPage_object.readyState){
						case 0 : window.status = "loading...";
							 //loadingStatus.innerHTML= "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // uninitialized...
						case 1 : window.status = "loading...";
							 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // loading...
						case 2 : window.status = "loading...";
							 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // loaded...
						case 3 : window.status = "loading...";
							 //$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; 
							 break; // interactive...
						case 4 : if (xhr_loadPage_object.status == 200) {
								 texte = xhr_loadPage_object.responseText;
									 
									 $('ct').style.display='none';
									 $('ct').innerHTML= texte;evalJS($('ct'));
									 var id=new Effect.Appear($('ct'));
									 
									 displayRandomSpec();
									 historyPage(p,id);// save in history page navigation
								 online();
									 initLightbox(); // scan lightbox image
							 }
							 else if (xhr_loadPage_object.status == 404) {
								 out.innerHTML='<h1>Error</h1><p>Sorry this page does not exist.</p>';
							 }
							 window.status = "";
								 displayNavigation();
								 break; // complete
						default: break;
					}
				}
	
		xhr_loadPage_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		xhr_loadPage_object.send(data); 
}


function ini_defilTop(msg,speed){
	x = 150;
		msg_public=msg;
		msg_defil_public = msg_public;
		
		msg_defil_public = msg_defil_public.substring( 1, msg_defil_public.length);
		while( msg_defil_public.length < x ){msg_defil_public += " - " + msg_public;}
			$('defilTop').value = msg_defil_public;
				tempo = setTimeout("ini_defilTop('"+msg_defil_public+"','"+speed+"')", speed);
}		
function ini_defilBottom(msg,speed){
	x = 150;
		msg_staff=msg;
		msg_defil_staff = msg_staff;
		
		msg_defil_staff = msg_defil_staff.substring( 1, msg_defil_staff.length);
		while( msg_defil_staff.length < x ){msg_defil_staff += " - " + msg_staff;}
			$('defilBottom').value = msg_defil_staff;
				tempo = setTimeout("ini_defilBottom('"+msg_defil_staff+"','"+speed+"')", speed);
}	

// save new history page navigation
function historyPage(p,id){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/historyPage_process.php";
				var method="POST";
				var asynchrone=true;
				var data="page="+p+"&id="+id;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {if(xhr_object.readyState==4){displayNavigation();}}
				xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xhr_object.send(data);  
}
function updateOrderStatus(OrderID,StatusID){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/updateOrderStatus_process.php";
				var method="POST";
				var asynchrone=true;
				var data="OrderID="+OrderID+"&StatusID="+StatusID;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xhr_object.send(data);  
}

function updateDevisStatus(DevisID,StatusID){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/updateDevisStatus_process.php";
				var method="POST";
				var asynchrone=true;
				var data="DevisID="+DevisID+"&StatusID="+StatusID;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xhr_object.send(data);  
}

function updateCommissionPercent(MemberID,Val){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/updateCommissionPercent_process.php";
				var method="POST";
				var asynchrone=true;
				var data="MemberID="+MemberID+"&Val="+Val;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xhr_object.send(data);  
}
function updateCommission(MemberID,Val){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/updateCommission_process.php";
				var method="POST";
				var asynchrone=true;
				var data="MemberID="+MemberID+"&Val="+Val;
				xhr_object.onreadystatechange = function() {   
					if(xhr_object.readyState==4){content(stats_content,'member_commissions');}
				};
	
		xhr_object.open(method, pg , asynchrone);
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}

function resetCommission(MemberID){updateCommission(MemberID,0);}

function addCart(ViewID,quantity){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/addCart_process.php";
				var method="POST";
				var asynchrone=true;
				var data="ViewID="+ViewID+"&quantity="+quantity.value;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					switch (xhr_object.readyState){
						case 0 : break; // uninitialized...
						case 1 : break; // loading...
						case 2 : break; // loaded...
						case 3 : break; // interactive...			
						case 4 : loadPage('specification_content',ViewID);
							 //direct_content($('cartNbItem'),'cart_nbItem');
							 break;
						default: break;
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
		
}
function removeCart(CartID){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/removeCart_process.php";
				var method="POST";
				var data="CartID="+CartID;
				
				var asynchrone=true;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					switch (xhr_object.readyState){
						case 0 : window.status = "loading...";loadingStatus.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // uninitialized...
						case 1 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loading...
						case 2 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loaded...
						case 3 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // interactive...
						case 4 : window.status = "";
							 direct_content($('ct'),'cart');
								 direct_content($('cartNbItem'),'cart_nbItem');
								 online();
								 displayNavigation();
								 break; // complete
						default: break;
					}
				}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function removeAllCart(){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/removeAllCart_process.php";
				var method="POST";
				var data="";
				var asynchrone=true;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					switch (xhr_object.readyState){
						case 0 : window.status = "loading...";loadingStatus.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // uninitialized...
						case 1 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loading...
						case 2 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loaded...
						case 3 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // interactive...
						case 4 : window.status = "";
							 direct_content($('ct'),'cart');
								 direct_content($('cartNbItem'),'cart_nbItem');
								 online();
								 displayNavigation();
								 break; // complete
						default: break;
					}
				}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}

function resetBillingDelivery(){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/resetBillingDelivery_process.php";
				var method="POST";
				var data="";
				var asynchrone=false;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xhr_object.send(data);  
}
function forgot(what,email){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = null;
				switch(what){
					case 'account': pg = "functions/php/forgot_account_process.php"; break;
					case 'activationCode': pg = "functions/php/forgot_activationCode_process.php"; break;
					default:break;
				}
	
		var method="POST";
		var data="email="+email.value;
		var asynchrone=true;
		
		xhr_object.open(method, pg , asynchrone);
		xhr_object.onreadystatechange = function() {   
			switch (xhr_object.readyState){
				case 0 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // uninitialized...
				case 1 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loading...
				case 2 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loaded...
				case 3 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // interactive...			
				case 4 : content($('ct'),'result_notification');break;
				default: break;
			}
		}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data); 
}
//function quickCreateAccount(email,phone,fullName,pass,confirmPass,billingAddress,billingCountryID,deliveryAddress,deliveryCountryID,flag_newsletter,flag_tac,checkCode,checkCode2){
function quickCreateAccount(email,firstName,lastName,company,ProfilID,flag_newsletter,flag_tac,checkCode,checkCode2,flag_accountActivation){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/member_add_process.php";
				var method="POST";
				
				var tac=0;
				var accountActivation=0;	
				if (flag_tac.checked){tac=1;}
					if (flag_accountActivation.checked){accountActivation=1;}
						var data="email="+email.value+"&firstName="+firstName.value+"&lastName="+lastName.value+"&company="+company.value+"&ProfilID="+ProfilID.value+"&flag_newsletter="+flag_newsletter.value+"&flag_tac="+tac+"&checkCode="+checkCode.value+"&checkCode2="+checkCode2.value+"&flag_accountActivation="+accountActivation;
							
							var asynchrone=true;
							
							xhr_object.open(method, pg , asynchrone);
							xhr_object.onreadystatechange = function() {   
								switch (xhr_object.readyState){
									case 0 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // uninitialized...
									case 1 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loading...
									case 2 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loaded...
									case 3 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // interactive...			
									case 4 : content($('ct'),'result_notification');break; // complete
									default: break;
								}
							}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data); 
}
function quickAddCustomer(email){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/quickCustomer_add_process.php";
				var method="POST";
				var data="new_email="+email.value;
				
				var asynchrone=true;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {if(xhr_object.readyState==4){
					$('scriptJS_container').innerHTML= xhr_object.responseText;
						evalJS($('scriptJS_container'));
				}}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data); 
}
function search(out,keysearch){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "content/ct_search.php";
				var method="POST";
				var asynchrone=true;
				var data="keysearch="+keysearch.value;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					switch (xhr_object.readyState){
						case 0 : out.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // uninitialized...
						case 1 : out.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loading...
						case 2 : out.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loaded...
						case 3 : out.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // interactive...			
						case 4 : out.innerHTML = xhr_object.responseText; break; // complete
						default: break;
					}
				}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function checkField(out, field, val){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = null;
				switch (field){
					case 'email' : pg = "functions/php/check_email.php";break;
					case 'new_email' : pg = "functions/php/check_new_email.php";break;
					case 'login' : pg = "functions/php/check_login.php";break;
					default:break;
				}
	
		var method="POST";
		var data="field="+val;
		var asynchrone=true;
		
		xhr_object.open(method, pg , asynchrone);
		xhr_object.onreadystatechange = function() {if (xhr_object.readyState==4){out.innerHTML = xhr_object.responseText; }}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
		
}
function check(type, val1,val2){
	switch(type){
		case "fullName": 
			if (val1.length>=3){check_fullName.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			else {check_fullName.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				break;
					case "firstName": 
					if (val1.length>=3){check_firstName.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
					else {check_firstName.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
						break;
		case 'lastName':
				if (val1.length>=3){check_lastName.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
				else {check_lastName.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
					break;
		case 'company':
			       if (val1.length>=3){check_company.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			       else {check_company.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				       break;		
		case 'address':
			       if (val1.length>=3){check_address.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			       else {check_address.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				       break;					
		case 'city':
			    if (val1.length>=3){check_city.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			    else {check_city.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				    break;					
		case 'postcode':
				if (val1.length>=3){check_postcode.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
				else {check_postcode.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
					break;					
		case 'billingAddress':
				      if (val1.length>=3){check_billingAddress.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
				      else {check_billingAddress.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
					      break;		
		case 'billingCountryID':
					if (val1.length>=3){check_billingCountry.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
					else {check_billingCountry.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
						break;		
		case 'deliveryAddress':
				       if (val1.length>=3){check_deliveryAddress.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
				       else {check_deliveryAddress.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
					       break;		
		case 'deliveryCountryID': 
					  if (val1.length>=3){check_deliveryCountry.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
					  else {check_deliveryCountry.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
						  break;	
		case 'phone': 
			      if (val1.length>=3){check_phone.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			      else {check_phone.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				      break;		
		case 'fax': 
			    if (val1.length>=3){check_fax.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			    else {check_fax.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				    break;		
		case 'email': 
			      if (val1.length>=3){check_email.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			      else {check_email.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				      break;		
		case 'login': 
			      if (val1.length>=3){check_login.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			      else {check_login.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				      break;		
		case 'pass': 
			     if (val1.length>=4){check_pass.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			     else {check_pass.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				     break;
		case 'confirmPass': 
				    if ((val1==val2) && (val2!='')){check_confirmPass.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
				    else {check_confirmPass.innerHTML="<img src='design/img/ico_ko.gif' alt='confirmed password error' align='absmiddle'>";}
					    break;
		case 'url': 
			    if (val1.length>=3){check_url.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
			    else {check_url.innerHTML="<img src='design/img/ico_ko.gif' alt='too short' align='absmiddle'>";}
				    break;		
		case 'checkCode': 
				  if (val1==val2){check_checkCode.innerHTML="<img src='design/img/ico_ok.gif' alt='correct' align='absmiddle'>";}
				  else {check_checkCode.innerHTML="<img src='design/img/ico_ko.gif' alt='error' align='absmiddle'>";}
					  break;		
		default: break;
	}
}

function updateNoRandomView(ViewID){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/updateNoRandomView.php";
				var method="POST";
				var data="id="+ViewID;
				var asynchrone=true;
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					switch (xhr_object.readyState){
						case 0 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // uninitialized...
						case 1 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loading...
						case 2 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loaded...
						case 3 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // interactive...			
						case 4 : ct.innerHTML = xhr_object.responseText; content($('ct'),'view_edit',ViewID);break; // complete
						default: break;
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
// remove an object by its ID
function remove(o, oID){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var method="POST";
				var data="id="+oID;
				var asynchrone=true;
				var pg ="";
				switch (o){
					case 'terms_and_conditions' : pg = "functions/php/terms_and_conditions_del_process.php";break;
					case 'shopping_help' : pg = "functions/php/shopping_help_del_process.php";break;
					case 'article' : pg = "functions/php/article_del_process.php";break;
					case 'category': pg = "functions/php/category_del_process.php";break;
					case 'specification' : pg = "functions/php/specification_del_process.php";break;
					case 'order' : pg = "functions/php/order_del_process.php";break;
					case 'orderContent' : pg = "functions/php/orderContent_del_process.php";break;
					case 'profil' : pg = "functions/php/profil_del_process.php";break;
					case 'checkList' : pg = "functions/php/checkList_del_process.php";break;		
					case 'newsletterEmail' : pg = "functions/php/newsletterEmail_del_process.php";break;
					case 'view' : pg = "functions/php/view_del_process.php";break;
					case 'member' : pg = "functions/php/member_del_process.php";break;
					case 'country' : pg = "functions/php/country_del_process.php";break;
					case 'logs' : pg = "functions/php/history_reset_process.php";break;		
					case 'shoutbox' : pg = "functions/php/shoutbox_del_process.php";break;				
					case 'productType' : pg = "functions/php/productType_del_process.php";break;
					default:break;
				}
	if (pg!=""){
		xhr_object.open(method, pg , asynchrone);
			xhr_object.onreadystatechange = function() {   
				if (xhr_object.readyState==4){
					switch (o){
						case 'terms_and_conditions' : content($('ct'),'terms_and_conditions');break;
						case 'shopping_help' : content($('ct'),'shopping_help');break;		
						case 'article' : loadPage('accueil');content($('menu'),'displayMenu');content($('ct_random'),'random');break;
						case 'category': reloadPage();break;
						case 'specification' : loadPage('accueil');content($('ct_random'),'random');break;
						case 'order' : reloadPage();break;
						case 'orderContent' : content($('ct'),'result_notification');break;
						case 'profil' : reloadPage();break;
						case 'checkList' : showCheckList();break;
						case 'newsletterEmail' :content($('bo_content'),'newsletter');break;
						case 'view' : content($('ct'),'result_notification');break;
						case 'member' : reloadPage();break;
						case 'country' : content($('treeCountry'),'treeCountry','','nameUK',1,'');break;
						case 'logs' : reloadPage();break;
						case 'shoutbox' : showShoutBox(); break;							
						default:break;
					}
					//reloadPage();
				}
			}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xhr_object.send(data);
	}
}

function move(way,CategoryID){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			if(way=='next'){var pg="functions/php/moveToNext.php";}
			else if(way=='previous'){var pg="functions/php/moveToPrevious.php";}
				var method="POST";
					var data="id="+CategoryID;
					var asynchrone=true;
					
					xhr_object.open(method, pg , asynchrone);
					xhr_object.onreadystatechange = function() {   
						switch (xhr_object.readyState){
							case 0 : window.status = "loading...";out.innerHTML ="";loadingStatus.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // uninitialized...
							case 1 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loading...
							case 2 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loaded...
							case 3 : window.status = "loading...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // interactive...
							case 4 : window.status = "";displayNavigation();direct_content(menu,'menu'); break;
							default: break;
						}
					}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function payNow(paymentMethod){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = null;
				switch(paymentMethod){
					case 'cash' : pg="functions/php/payCash_process.php";break;
					case 'chk' : pg="functions/php/payChk_process.php";break;		
					case 'paypal' : pg="functions/php/payPayPal_process.php";break;
					case 'payread' : pg="functions/php/payPayRead_process.php";break;
					default:break;
				}
	var method="POST";
		var asynchrone=true;
		var data="";
		
		xhr_object.open(method, pg , asynchrone);
		xhr_object.onreadystatechange = function() {   
			switch (xhr_object.readyState){
				case 0 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // uninitialized...
				case 1 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loading...
				case 2 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // loaded...
				case 3 : ct.innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait'></div>"; break; // interactive...			
				case 4 : content(ct,'result_notification'); break; // complete
				default: break;
			}
		}
	
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data); 
}
function quickAddVendor(vendor,VendorID){
	if (vendor.value!=''){return;}
		
			var xhr_object = xhr();
			if(xhr_object ==null){return;}
				
					var pg = "functions/php/quickVendor_add_process.php";
					var method="POST";
					var asynchrone=true;
					var data="vendor="+vendor.value;
					
					xhr_object.open(method, pg , asynchrone);
					xhr_object.onreadystatechange = function() {   
						if (xhr_object.readyState ==4){
							document.frm_article.VendorID.options[document.frm_article.VendorID.length] = new Option('['+vendor.value+']',VendorID);
								document.frm_article.vendor.value='';
								document.frm_article.VendorID.selectedIndex=document.frm_article.VendorID.length-1;
						}
					}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function quickAddProductType(productType,ProductTypeID){
	
		if (productType.value==''){return;}
			
				var xhr_object = xhr();
				if(xhr_object ==null){return;}
					
						var pg = "functions/php/quickProductType_add_process.php";
						var method="POST";
						var asynchrone=true;
						var data="productType="+productType.value;
						
						xhr_object.open(method, pg , asynchrone);
						xhr_object.onreadystatechange = function() {   		
							if (xhr_object.readyState ==4){
								$('scriptJS_container').innerHTML= xhr_object.responseText;
									evalJS($('scriptJS_container'));
							}
						}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function updateProductType(ProductTypeID,productType){
	
		if (ProductTypeID==''){return;}
			if (productType.value==''){return;}
				
					var xhr_object = xhr();
					if(xhr_object ==null){return;}
						
							var pg = "functions/php/productType_edit_process.php";
							var method="POST";
							var asynchrone=true;
							var data="ProductTypeID="+ProductTypeID+"&productType="+productType.value;
							
							xhr_object.open(method, pg , asynchrone);
							xhr_object.onreadystatechange = function() {   		
								if (xhr_object.readyState ==4){
									$('scriptJS_container').innerHTML= xhr_object.responseText;
										evalJS($('scriptJS_container'));
								}
							}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}


function iniDocument(){
	document.body.scrollTop=0;
		document.body.scrollLeft=0;
}
function onResize(){
	if(exist('bgBox')){
		$('bgBox').style.width=parseInt(document.body.scrollWidth);
			$('bgBox').style.height=parseInt(document.body.scrollHeight);
	}
}

window.onresize=function(){onResize();}
function openBox(ct,bgColor,frontColor,arg){
	//iniDocument();
	var maxWidth =parseInt(document.body.scrollWidth);
		var maxHeight =document.body.scrollHeight;
		
		
		if(!exist('bgBox')){
			// CREATE BOX DIV
			var bgBox = document.createElement('div');
				bgBox.setAttribute('id', 'bgBox');
				bgBox.style.position ='absolute';
				bgBox.style.top=0;
				bgBox.style.left=0;
				bgBox.className='bgBoxOpacity';	
				bgBox.style.width=maxWidth;
				bgBox.style.height=maxHeight;
				bgBox.style.cursor='pointer';
				bgBox.style.background=bgColor;
				bgBox.style.zIndex=9;
				bgBox.onclick=function(){closeBox();}
				document.body.appendChild(bgBox);
		}
	if(!exist('box')){
		// CREATE BOX DIV
		var box = document.createElement('div');
			box.setAttribute('id', 'box');
			box.style.position ='absolute';
			box.style.top=document.body.scrollTop;
			box.style.left=document.body.scrollLeft;
			box.style.zIndex=10;//10
		box.style.padding=0;
			box.style.background='';
			document.body.appendChild(box);
	}
	
		content_arg($('box'),ct,arg,'','');
		//fadeInBox();
		//ok();
}

function closeBox(){
	if(exist('box')){window.document.body.removeChild($('box'));}
		if(exist('bgBox')){window.document.body.removeChild($('bgBox'));}
}

function updateQty(CartID, qty){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/cart_qty_edit_process.php";
				var method="POST";
				var asynchrone=true;
				var data="CartID="+CartID+"&qty="+qty;
				//var subtotal = eval('subtotal' + CartID);
				var subtotal = 'subtotal' + CartID;
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if (xhr_object.readyState==4){
						direct_content($(subtotal),'cart_subtotal',CartID);
							direct_content($('total'),'cart_total');
							direct_content($('totalTaxe'),'cart_totalTaxe');							
							direct_content($('totalToPay'),'cart_totalToPay');
							direct_content($('cartNbItem'),'cart_nbItem');
							//direct_content($('payForm'),'cart_payMethod');
							direct_content($('showPayment'),'cart_payment');
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}
function updateDiscount(CartID, discount){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/cart_discount_edit_process.php";
				var method="POST";
				var asynchrone=true;
				var data="CartID="+CartID+"&discount="+discount;
				var price = eval('price' + CartID);
				var subtotal = eval('subtotal' + CartID);
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if (xhr_object.readyState==4){
						direct_content(price,'cart_price',CartID);
							direct_content(subtotal,'cart_subtotal',CartID);
							direct_content(total,'cart_total');
							direct_content(totalTaxe,'cart_totalTaxe');
							direct_content(totalToPay,'cart_totalToPay');
							direct_content(showPayment,'cart_payment');
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(data);  
}

function showOrders(){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "content/ct_order.php";
				var method="POST";
				var asynchrone = true;
				var data="";
				xhr_object.open(method, pg , asynchrone);  // "true" -> mode asynchrone
	xhr_object.onreadystatechange = function() {   
		switch (xhr_object.readyState){
			case 0 : bo_content.innerHTML = "loading..."; break;
			case 1 : bo_content.innerHTML = "loading..."; break;
			case 2 : bo_content.innerHTML = "loading..."; break;
			case 3 : bo_content.innerHTML = "loading..."; break;
			case 4 : bo_content.innerHTML = xhr_object.responseText; break;
			default: break;
		}
	}
	/*xhr_object.setRequestHeader("Content-type:text/html; charset=utf-8");*/
		xhr_object.send(null);  
}
function showShoutBox(){content(bo_content,'shoutBox');}
function sendToShoutBox(message){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/shoutBox_ajout_process.php";
				var s=escape(message.value);
				var asynchrone = true;
				var data = "message="+s;
				var method = "POST";
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if (xhr_object.readyState==4){showShoutBox();}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		xhr_object.send(data);
}
// check list
function showCheckList(){content($('checkList_content'),'checkList_list');}
function sendToCheckList(subject,todo,expiredDate){
	var xhr_object = xhr();	if(xhr_object ==null){return;}
		var pg = "functions/php/checkList_add_process.php";
		//var s=escape(subject.value);
		var s=subject.value;
		var t=todo.value;
		var asynchrone = true;
		var data = "subject="+s+"&todo="+t+"&expiredDate="+expiredDate;
		var method = "POST";
		
		xhr_object.open(method, pg , asynchrone);
		xhr_object.onreadystatechange = function() {   
			switch (xhr_object.readyState){
				case 0 : window.status = "adding..."; break;
				case 1 : window.status = "adding..."; break;
				case 2 : window.status = "adding..."; break;
				case 3 : window.status = "adding..."; break;
				case 4 : window.status = "";showCheckList();break;
				default: break;
			}
		}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		xhr_object.send(data);
}
// this function check/uncheck all checkbox with "field" name
// status for b(oolean) : true=check, false=uncheck
function checkAll(subBox,b){
	if (subBox.length>0){
		// several subBox
		for (i=0;i<subBox.length;i++){subBox[i].checked=b;}
	}
	else {
		// one subBox
		subBox.checked=b;
	}
}

function removeSelectedNewsletterEmail(){
	if (confirm('Attention, do you really wish to remove selected e-mail(s) ?')){
		if (document.frm_newsletterEmail.selectNewsletterEmail.length>0){
			// several subBox
			for (i=0;i<document.frm_newsletterEmail.selectNewsletterEmail.length;i++){
				if (document.frm_newsletterEmail.selectNewsletterEmail[i].checked){
					remove('newsletterEmail',document.frm_newsletterEmail.selectNewsletterEmail[i].value);
				}
			}
		}
		else {
			// one subBox
			if (document.frm_newsletterEmail.selectNewsletterEmail.checked){remove('newsletterEmail',document.frm_newsletterEmail.selectNewsletterEmail.value);}
		}
		content(system_content,'newsletter');
	}
}

function removeSelectedProfils(){
	if (confirm('Attention, do you really wish to remove selected profil(s) ?')){
		if (document.frm_profil.selectProfil.length>0){
			// several subBox
			for (i=0;i<document.frm_profil.selectProfil.length;i++){
				if (document.frm_profil.selectProfil[i].checked){
					remove('profil',document.frm_profil.selectProfil[i].value);
				}
			}
		}
		else {
			// one subBox
			if (document.frm_profil.selectProfil.checked){remove('profil',document.frm_profil.selectProfil.value);}
		}
		content(system_content,'system_profils');
	}
}
function removeSelectedCountry(){
	if (confirm('Attention, do you really wish to remove selected countri(es) ?')){
		if (document.frm_country.selectCountry.length>0){
			// several subBox
			for (i=0;i<document.frm_country.selectCountry.length;i++){
				if (document.frm_country.selectCountry[i].checked){
					remove('country',document.frm_country.selectCountry[i].value);
				}
			}
		}
		else {
			// one subBox
			if (document.frm_country.selectCountry.checked){remove('country',document.frm_country.selectCountry.value);}
		}
		content(system_content,'system_country','','nameUK',1,50);
	}
}
function removeSelectedCheckList(){
	if (confirm('Attention, do you really wish to remove selected check list(s) ?')){
		if (document.frm_checkList.selectCheckList.length>0){
			// several subBox
			for (i=0;i<document.frm_checkList.selectCheckList.length;i++){
				if (document.frm_checkList.selectCheckList[i].checked){
					remove('checkList',document.frm_checkList.selectCheckList[i].value);
				}
			}
		}
		else {
			// one subBox
			if (document.frm_checkList.selectCheckList.checked){remove('checkList',document.frm_checkList.selectCheckList.value);}
		}
	}
}

function removeSelectedOrder(MemberID){
	if (confirm('Attention, do you really wish to remove selected order(s) ?')){
		if (document.frm_order.selectOrder.length>0){
			// several subBox
			for (i=0;i<document.frm_order.selectOrder.length;i++){
				if (document.frm_order.selectOrder[i].checked){
					remove('order',document.frm_order.selectOrder[i].value);
				}
			}
		}
		else {
			// one subBox
			if (document.frm_order.selectOrder.checked){remove('order',document.frm_order.selectOrder.value);}
		}
		content(bo_content,'order',MemberID);
	}
}
function removeSelectedMember(){
	if (confirm('Attention, do you really wish to remove selected member(s) ?')){
		if (document.frm_member.selectMember.length>0){
			// several subBox
			for (i=0;i<document.frm_member.selectMember.length;i++){
				if (document.frm_member.selectMember[i].checked){
					remove('member',document.frm_member.selectMember[i].value);
				}
			}
		}
		else {
			// one subBox
			if (document.frm_member.selectMember.checked){remove('member',document.frm_member.selectMember.value);}
		}
		content(bo_content,'people');
	}
}
function updateSelectedCheckListStatus(status){
	var s = escape(status);
		if (confirm('Attention, do you really wish to change the status of the selected check list(s) ?')){
			if (document.frm_checkList.selectCheckList.length>0){
				
					// several subBox
					for (i=0;i<document.frm_checkList.selectCheckList.length;i++){
						
							if (document.frm_checkList.selectCheckList[i].checked){
								updateCheckListStatus(s,document.frm_checkList.selectCheckList[i].value);
							}
					}
			}
			else {
				// one subBox
				if (document.frm_checkList.selectCheckList.checked){updateCheckListStatus(s,document.frm_checkList.selectCheckList.value);}
			}
		}
}
function updateCheckListStatus(status,id){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/updateCheckListStatus_process.php";
				var method="POST";
				var asynchrone=true;
				var data="status="+status+"&id="+id;
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if (xhr_object.readyState==4){	content(bo_content,'checkList'); }
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		xhr_object.send(data);
		
}
// this function check/uncheck Master check box
// Master check box is the checkbox which can (un)check all sub-checkbox
// status for b(oolean) : true=check, false=uncheck
function checkMasterBox(masterBox,subBox){
	masterBox.checked=true; // initialize
	if (subBox.length>0){
		// several subBox
		for (i=0;i<subBox.length;i++){
			if (!subBox[i].checked){
				masterBox.checked=false;
					return true;
			}
		}
	}
	else {
		// one subBox
		masterBox.checked=subBox.checked;
	}
}
function displayNavigation(){
	//direct_content($('navigation'),'navigation');
}

function previousPage(p,id){
	if (p!=null){
		var xhr_object = xhr();
			if(xhr_object ==null){return;}
				var pg = "functions/php/previousPage.php";
					var method="POST";
					var asynchrone=true;
					var data="";
					
					xhr_object.open(method, pg , asynchrone);
					xhr_object.onreadystatechange = function() {   
						switch (xhr_object.readyState){
							case 0 : window.status = "loading previous page...";ct.innerHTML="";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // uninitialized...
							case 1 : window.status = "loading previous page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loading...
							case 2 : window.status = "loading previous page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loaded...
							case 3 : window.status = "loading previous page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // interactive...
							case 4 : window.status = "";content($('ct'),p,id);displayNavigation();break; // complete
							default: break;
						}
					}
		
			xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
			xhr_object.send(data);  
	}
}
function nextPage(p,id){
	if (p!=null){
		var xhr_object = xhr();
			if(xhr_object ==null){return;}
				var pg = "functions/php/nextPage.php";
					var method="POST";
					var asynchrone=true;
					var data="";
					
					xhr_object.open(method, pg , asynchrone);
					xhr_object.onreadystatechange = function() {   
						switch (xhr_object.readyState){
							case 0 : window.status = "loading next page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // uninitialized...
							case 1 : window.status = "loading next page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loading...
							case 2 : window.status = "loading next page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // loaded...
							case 3 : window.status = "loading next page...";$('navigation').innerHTML = "<div align='center'><img src='design/img/loading.gif' alt='please wait' style='border:0;'></div>"; break; // interactive...
							case 4 : window.status = "";content($('ct'),p,id);displayNavigation();break; // complete
							default: break;
						}
					}
		
			xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
			xhr_object.send(data);  
	}
}
// update online member
function online(){
	var xhr_object = xhr();
		if(xhr_object ==null){return;}
			var pg = "functions/php/online_process.php";
				var method="POST";
				var asynchrone=true;
				var data="";
				
				xhr_object.open(method, pg , asynchrone);
				xhr_object.onreadystatechange = function() {   
					if(xhr_object.readyState==4){
						if(exist('online')){$('online').innerHTML =xhr_object.responseText;}
					}
				}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		xhr_object.send(data);  
}

function selectTab(liid,ulid){
	//	var ulid=liid.parentNode.parentNode.id //id of UL element
	//var ullist=$(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
	var ullist=ulid.getElementsByTagName("li") //get list of LIs corresponding to the tab contents
		for (var i=0; i<ullist.length; i++){
			ullist[i].className=""  //deselect all tabs 
		}
	liid.className="active"  //highlight currently clicked on tab
		window.focus();
}

var timerDoc_id;

function scrollingAllDocumentUp(){
	if(parseInt(document.body.scrollTop)>0){
		document.body.scrollTop=parseInt(document.body.scrollTop)-100;
			timerDoc_id = setTimeout("scrollingAllDocumentUp()", 30);
	}
	else {stopScroll(timerDoc_id);}
}

function stopScroll(TimerID) { if (TimerID) clearTimeout(TimerID); }
function scrollingAllDocumentUp(){
	stopScroll(timerDoc_id);
		if(parseInt(document.body.scrollTop)>0){
			document.body.scrollTop=parseInt(document.body.scrollTop)-100;
				timerDoc_id = setTimeout("scrollingAllDocumentUp()", 30);
		}
		else {stopScroll(timerDoc_id);}
}

function scrollingAllDocumentDown(){
	var clientHeight =document.body.clientHeight;
		var maxHeight =document.body.scrollHeight;
		
		stopScroll(timerDoc_id);
		window.status=parseInt(document.body.scrollTop) + " - " + parseInt(maxHeight)+ " - " + parseInt(document.body.offsetHeight);
		if(parseInt(document.body.scrollTop)+parseInt(clientHeight)<parseInt(maxHeight)){
			document.body.scrollTop=parseInt(document.body.scrollTop)+100;
				timerDoc_id = setTimeout("scrollingAllDocumentDown()", 30);
		}
		else {stopScroll(timerDoc_id);}
}
window.onscroll=function(){
	//stopScroll(timerDoc_id);onResize();
}
function noRightClick(){
	
		var message="";
		///////////////////////////////////
		function clickIE() {if (document.all) {(message);return false;}}
		function clickNS(e) {if 
			(document.layers||($&&!document.all)) {
				if (e.which==2||e.which==3) {(message);return false;}}}
					if (document.layers) 
					{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
					else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
						
							document.oncontextmenu=new Function("return false")
							
}




// DETECTION DU NAVIGATEUR
function isBrowser(nav){
	agent = navigator.userAgent.toLowerCase();
		var mac = (agent.indexOf("macintosh") != -1);
		var safari = (agent.indexOf("safari") != -1);
		var ie = 
		(
		 (agent.indexOf("msie") != -1) &&
		 (agent.indexOf("opera") == -1)
		);
		var ff=(agent.indexOf("firefox") != -1);
		var ns = 
		(
		 (agent.indexOf("mozilla") != -1) && 
		 (agent.indexOf("spoofer") == -1) &&
		 (agent.indexOf("compatible") == -1) &&
		 (agent.indexOf("opera") == -1) &&
		 (agent.indexOf("webtv") == -1) &&
		 (agent.indexOf("hotjava") == -1)
		);
		var opera = 
		(
		 (window.opera == 1) || 
		 (agent.indexOf('opera') != -1)
		);
		
		switch(nav){
			case 'ie' : return ie;
			case 'ff' : return ff;
			case 'safari' : return safari;
			case 'mac' : return mac;
			case 'opera' : return opera;
			case 'ms' : return ns;
			default : return false;
		}
}

//
// FORMULAIRE
//
function frmOnFocus(field,type){
	switch(type){
		case "text" : field.className='textFocus';break;
			case "textarea" : field.className='textareaFocus';break;
			case "select" : field.className='selectFocus';break;
	}
}

function frmOnBlur(field,type){
	switch(type){
		case "text" : field.className='textBlur';break;
			case "textarea" : field.className='textareaBlur';break;
			case "select" : field.className='selectBlur';break;
	}
	
}


function waitingBox(text){
	
		var maxWidth =document.body.scrollWidth;
		var maxHeight =document.body.scrollHeight;
		
		
		// CREATE BOX DIV
		var waitingBox = document.createElement('div');
		waitingBox.setAttribute('id', 'waitingBox');
		waitingBox.style.position ='absolute';
		waitingBox.style.top=0;
		waitingBox.style.left=0;
		waitingBox.className='';	
		waitingBox.style.width=document.body.clientWidth;
		waitingBox.style.height=document.body.clientHeight;
		//waitingBox.style.cursor='pointer';
		waitingBox.style.background='#000000';
		waitingBox.style.color='#FFFFFF';
		waitingBox.style.textAlign='center';
		waitingBox.style.padding=50;
		waitingBox.innerHTML=text+"<p><a href='' onclick='javascript:reloadPage();'>Click here to Cancel</a></p>"
		waitingBox.style.zIndex=100000;
		//pleaseWaitPublishBox.onclick=function(){closeWaitingBox();}
		document.body.appendChild(waitingBox);
		iniDocument();
		
}

function pleaseWaitBox(){waitingBox('Uploading, please wait...');}
function pleaseWaitPublishBox(){waitingBox('Updating item status, please wait...');}

function closeWaitingBox(){if(exist('waitingBox')){window.document.body.removeChild($('waitingBox'));}}
function closePleaseWaitPublishBox(){closeWaitingBox();}
function closePleaseWaitBox(){closeWaitingBox();}


function round(x){return Math.round(x*100)/100;}
function updateVendorTTC(){$('vendorTTCPrice').value=round($('vendorHTPrice').value*(1+$('vendorVAT').value/100));}
function updateVendorHT(){$('vendorHTPrice').value=round($('vendorTTCPrice').value/(1+$('vendorVAT').value/100));}
function updatePublicTTC(){$('publicTTCPrice').value=round($('publicHTPrice').value*(1+$('publicVAT').value/100));}
function updatePublicHT(){$('publicHTPrice').value=round($('publicTTCPrice').value/(1+$('publicVAT').value/100));}

function reloadPage(){document.location="/";}
function hidestatus(){
	window.status='';
		return true;
}
//noRightClick();
document.onmouseover=hidestatus;
document.onmouseout=hidestatus;
