var ModeAjax = false;
var Page = new Object();
Page.width;
Page.height;
Page.top;

var haut = (document.documentElement.clientHeight);
var larg = (document.documentElement.clientWidth);
function redim(){
	document.getElementById('resultats').style.height = haut - 210 + "px";
}

function MonoSearch(Type) {
								Page.getPageCenterX();
								var parms;
								var resultats = document.getElementById('resultats');
								if(Type == 'NUM') {
													var NumLot = document.getElementById('NumLot').value;
													document.getElementById('RefLot').value = "";
													document.getElementById('CouleurLot').value = "";
													params = '&NumLot='+ NumLot;
													}
								else if (Type == 'REF'){
										var RefLot = document.getElementById('RefLot').value;
										document.getElementById('NumLot').value = "";
										document.getElementById('CouleurLot').value = "";
										params = '&RefLot='+ RefLot;
										}
								else if (Type == 'Col'){
										var CouleurLot = document.getElementById('CouleurLot').value;
										document.getElementById('NumLot').value = "";
										document.getElementById('RefLot').value = "";
										params = '&CouleurLot='+ CouleurLot;
										}
							
								var url = 'AjaxMonoSearch/MonoSearch.php?Type='+Type+params;
								CreerRequet(Wnredirect(url),"",ModeAjax, TraitementStock);
								
								if (ResultatAjax) { 
													resultats.innerHTML = ResultatAjax;
													document.getElementById('loading').innerHTML = "";
													Slimbox.scanPage(); 
													}
								}
								
Page.getPageCenterX = function () {
										var fWidth;
										var fHeight;
										//For old IE browsers
										if(document.all) {
															fWidth = document.body.clientWidth;
															fHeight = document.body.clientHeight;
														   }
										//For DOM1 browsers
										else if(document.getElementById && !document.all) {
																							fWidth = innerWidth;
																							fHeight = innerHeight;
																						  }
										else if(document.getElementById) {
																			fWidth = innerWidth;
																			fHeight = innerHeight;
																			}
										//For Opera
										else if (is.op) {
															fWidth = innerWidth;
															fHeight = innerHeight;
															}
										//For old Netscape
										else if (document.layers) {
																	fWidth = window.innerWidth;
																	fHeight = window.innerHeight;
																	}
										Page.width = fWidth;
										Page.height = fHeight;
										Page.top = window.document.body.scrollTop;
									  }								
function CreerRequet(url,parametre,mode,methode){
										var httpRequest = false;
										if (window.XMLHttpRequest) { 
													httpRequest = new XMLHttpRequest();
													if (httpRequest.overrideMimeType) {
														httpRequest.overrideMimeType("text/xml");
													}
												} else if (window.ActiveXObject) { // IE
													try {
														httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
													} catch (e) {
														try {
															httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
														} catch (e) {
																		//alert(httpRequest);
																		}
													}
												}
										
										 if (!httpRequest) {
															//alert("Abandon : Impossible de créer une instance XMLHTTP");
															return false;
																	}
										 if(mode == true) httpRequest.onreadystatechange = function() { methode(httpRequest); };
										 httpRequest.open("POST", url, false);
										 httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
										 httpRequest.send(parametre);
										 if(mode == false){
																methode(httpRequest);
																	}
											}	
function Wnredirect(url) {
								var myRandom = parseInt(Math.random()*99999999);  // cache buster
								return  url+"&myRandom="+myRandom;
							  }	
function TraitementStock(httpRequest){
										  try {
												if (httpRequest.readyState < 4) {
																					document.getElementById('loading').style.top = (Page.top + Page.height/2);
																					document.getElementById('loading').style.left = Page.width/2-75;
																					document.getElementById('loading').style.position = "absolute";
																					document.getElementById('loading').innerHTML = "<table border=0 cellpadding=0 cellspacing=1 width=160 bgcolor=gray><tr><td align=center class=loading height=45 bgcolor=#FFFF66><img src='../images/snake_transparent.gif'/>&nbsp;&nbsp;Loading..</td></tr></table>";
																					}
												if (httpRequest.readyState == 4) {
														if (httpRequest.status == 200) {
																						// alert(httpRequest.responseText);
																						 //resultats.innerHTML = httpRequest.responseText;
																						 ResultatAjax = httpRequest.responseText;
																						 //alert(ResultatAjax);
																						 setTimeout('Page.loadOut()',20);
																						 return true;
																							} 
														else {
																//alert('Un problème est survenu au cours de la requête.');
																	}
														}
													}
											catch( e ) {
															//alert("Une exception s'est produite : " + e.description);
															}
												}							  
Page.loadOut = function () {
								document.getElementById('loading').innerHTML = "";
								}						
