function GEI(id){
	return document.getElementById(id);
}
window.onload=function(){
	/*if(GEI('cnt')){
		var offset=165;
		var bodyHeight=GEI('body').offsetHeight;
		var sideHeight=GEI('side').offsetHeight;
		var contHeight=GEI('cnt').offsetHeight;
		if(sideHeight>=(contHeight+offset)){
		}else if(sideHeight>=contHeight){
			GEI('body').style.height=(bodyHeight+(offset-(sideHeight-contHeight)))+'px';
		}else if(contHeight>sideHeight){
			GEI('body').style.height=(bodyHeight+offset)+'px';
		}
	}*/
	/*if(GEI('prods')){
		getprodinfo(GEI('q').value);
	}*/
	if(GEI('prods')){
		GEI('prods').innerHTML='<iframe frameborder="0" id="prodframe" onload="prodframeonload();" src="http://aspirateursgatineau.tzo.com:81/produits.php'+GEI('q').value+'"></iframe>';
		/*GEI('prodframe').onload=function(){
			prodframeonload();
		}*/
		bcsbckup=GEI('bcs').innerHTML;
		prodframeonload();
	}
}
var bcsbckup='';
function prodframeonload(){
	var AJAX=createAJAX();
	if(AJAX){
		status=AJAX.onreadystatechange=function(){
			if(AJAX.readyState==4){
				var infs=AJAX.responseText.split("||");
				if(/^\d+px$/.test(infs[0])){
					GEI('prodframe').style.height=infs[0];
				}
				var newbcs='';
				if(infs[1]!=''&&infs!=undefined){
					newbcs='<img src="../int/breadcrumb.gif" width="10" height="10" alt="" title="" /><a href="?c='+infs[2]+'">'+infs[1]+'</a>';
					if(infs[3]!=''&&infs!=undefined){
						newbcs+='<img src="../int/breadcrumb.gif" width="10" height="10" alt="" title="" /><a href="?c='+infs[2]+'&i='+infs[4]+'">'+infs[3]+'</a>';
					}
				}
				GEI('bcs').innerHTML=bcsbckup+newbcs;
			}
		}
		var url="../php/getheight.php?i="+GEI('ip').value+"&r="+Math.floor(Math.random()*10001);
		AJAX.open("GET", url, true);
		AJAX.send(null);
	}
}
function createAJAX(){
	try{
		/*Opera 8.0+, Firefox, Safari*/
		AJAX=new XMLHttpRequest();
	}catch(e){
		/*Internet Explorer Browsers*/
		try{
			AJAX=new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				AJAX=new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				return false;
			}
		}
	}
	return AJAX;
}
function getprodinfo(query){
	var AJAX=createAJAX();
	if(AJAX){
		status=AJAX.onreadystatechange=function(){
			if(AJAX.readyState==4){
				GEI('prods').innerHTML=AJAX.responseText;
			}
		}
		var url="http://aspirateursgatineau.tzo.com/temp.php"+query;
		AJAX.open("GET", url, true);
		AJAX.send(null);
	}
}
function gonext(Obj){
	if(Obj.value.length==3){
		if(Obj.id=="tel1"){
			GEI("tel2").focus();
		}else if(Obj.id=="tel2"){
			GEI("tel3").focus();
		}
	}
}
function popup(Caller){
	window.open(
		Caller.href,
		'popup',
		""
		  /*+"channelmode=0,"
		  +"fullscreen=0,"
		  +"height=100,"*/
		  +"left=35,"
		  /*+"location=1,"
		  +"menubar=1,"
		  +"resizable=1,"*/
		  +"scrollbars=1,"
		  +"status=1,"
		  /*+"titlebar=1,"
		  +"toolbar=1,"*/
		  +"top=35,"
		  +"width=500",
		true
	);
}
function popdown(){
	window.close();
}
function validate(Obj){
	err=0;
	for(i=0;i<Obj.length;i++){
		with(Obj[i]){
			if(id=="name"||id=="fname"||id=="ref"){
				if(value&&!(/^\s$/.test(value))){
					className="";
					if(id=="ref"){
						className="w348";
					}
				}else{
					err++;
					className="fred";
					if(id=="ref"){
						className="w348 fred";
					}
				}
			}else if(id=="mail"){
				if((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value))){
					className="";
				}else{
					err++;
					className="fred";
				}
			}else if(id=="remail"){
				if((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value))&&value==GEI('mail').value){
					className="";
				}else{
					err++;
					className="fred";
				}
			}else if(id=="tel1"||id=="tel2"||id=="tel3"){
				if((/^\d{3}$/.test(value)&&id!="tel3")||(/^\d{4}$/.test(value)&&id=="tel3")){
					className="w35";
					if(id=="tel3"){
						className="w50";
					}
				}else{
					err++;
					className="w35 fred";
					if(id=="tel3"){
						className="w50 fred";
					}
				}
			}else if(id=="ctel"){
				if(GEI('ctel').checked||GEI('cmail').checked){
					GEI('contopt').className="";
				}else{
					err++;
					GEI('contopt').className="mandatory";
				}
			}
		}
	}
	if(err>0){
		return false;
	}
	return true;
}
