function getXhr(){
var xhr = null;
if(window.XMLHttpRequest)
xhr = new XMLHttpRequest();
else if(window.ActiveXObject){ 
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else {
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
return xhr;
}



function isASpace(b)
	{	
		//alert("hehe");
		var i=0;
		var a=b;
		var es=0;
		var c=0;
		var mess='';
		
		while (i<a.length)
			{
				if (a.charAt(i)==' ')
					es++;
				i++;
			}
		if ((a.length==es)||(a.length==0))
			{
				
				if (c=='1') 
					{
						alert(mess);						
					}
				return 1;
			}
		else
			return 0;
		
	}

function verif_email(email) {
	var arobase = email.indexOf("@"); 
	var point = email.lastIndexOf(".")
	if((arobase < 3)||(point + 2 > email.length)||(point < arobase+3)) 
	return false;
	else
	return true;
}
function test_t(){
      if(isASpace(document.frm_contact.nom.value)) {
         alert("Please enter your last name"); document.frm_contact.nom.focus(); return false
         }
	 
	  if(isASpace(document.frm_contact.company.value)) {
         alert("Please enter your company"); document.frm_contact.company.focus(); return false
         }
	 /* if(document.frm_contact.secteur.value=="0") {
         alert("Le champ 'SECTEUR D'ACTIVITE' est requis !"); document.frm_contact.secteur.focus(); return false
         }*/
		 
      if(isASpace(document.frm_contact.tel.value)) {
         alert("Please enter your telephone number"); document.frm_contact.tel.focus(); return false
         }		      
		 if(isASpace(document.frm_contact.txtemail.value)) {
         alert("Please enter your E-mail address"); document.frm_contact.txtemail.focus(); return false
         }	
	  /*if (!verif_email(document.frm_contact.txtemail.value)) {
			  alert("E-mail disabled"); document.frm_contact.txtemail.focus(); return false
      }*/
	  
	  if(isASpace(document.frm_contact.remarque.value)) {
         alert("The field 'YOUR MESSAGE' is required"); document.frm_contact.remarque.focus(); return false
		 }
	}

function test_f(){
      if(isASpace(document.frm_contact1.nom.value)) {
         alert("Please enter your last name"); document.frm_contact1.nom.focus(); return false
         }
	  
	  if(isASpace(document.frm_contact1.prenom.value)) {
         alert("Please enter your First name"); document.frm_contact1.prenom.focus(); return false
         }	 
		 
	/* if(isASpace(document.frm_contact1.domaine.value)) {
         alert("Please enter your Domain Name"); document.frm_contact1.domaine.focus(); return false
         }	 */
		 
	  if(isASpace(document.frm_contact1.company.value)) {
         alert("Please enter your company Name"); document.frm_contact1.company.focus(); return false
         }
	 /* if(document.frm_contact.secteur.value=="0") {
         alert("Le champ 'SECTEUR D'ACTIVITE' est requis !"); document.frm_contact.secteur.focus(); return false
         }*/
		 if(isASpace(document.frm_contact1.activity.value)) {
         alert("Please enter your Activity"); document.frm_contact1.activity.focus(); return false
         } 
		 
	   if(isASpace(document.frm_contact1.adresse.value)) {
         alert("Please enter your Address"); document.frm_contact1.adresse.focus(); return false
         }		 
		 
      if(isASpace(document.frm_contact1.tel.value)) {
         alert("Please enter your telephone number"); document.frm_contact1.tel.focus(); return false
         }		      
		 if(isASpace(document.frm_contact1.txtemail.value)) {
         alert("Please enter your E-mail address"); document.frm_contact1.txtemail.focus(); return false
         }	
	  /*if (!verif_email(document.frm_contact.txtemail.value)) {
			  alert("E-mail disabled"); document.frm_contact.txtemail.focus(); return false
      }*/
	  
	  if(isASpace(document.frm_contact1.remarque.value)) {
         alert("The field 'Comment' is required"); document.frm_contact1.remarque.focus(); return false
		 }
	}


function test(){
	//alert(par);
	alert(555555);
	}
	
	
	function session_true(etat){
	var xhr = getXhr();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
//document.getElementById('div_page').innerHTML =xhr.responseText;
}
}
xhr.open("GET","form/session_true.php?etat" + etat ,true);
//alert(1111);
xhr.send(null);
	}
	function arr_page11(){
		alert(1111);
		}
	
function arr_page(){
		
	
	var xhr = getXhr();
	
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
document.getElementById('arr_page').innerHTML ="<img src='templates/tpl_santis/images/arr_plan_santis.jpg'>";
}else{
	document.getElementById('arr_page').innerHTML="<center><br><br><img  src='templates/tpl_santis/images/Loading.gif'/><br><br>Loading ...</center>";//"Loading ...";
	}
}
xhr.open("GET","templates/tpl_santis/index.php",true);
//alert(1111);
xhr.send(null);
	}
	
	
	////////////////////////////////function ajax//////////////////////////
function ajax(id,itemid){
	//alert("ajax  "+id+"  "+itemid);
var xhr = getXhr();
session_true('t');
xhr.onreadystatechange = function(){

if(xhr.readyState == 4 && xhr.status == 200){
alert(xhr.responseText);
tmp=xhr.responseText;//.split("AAAAAAAAAA");


tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");
tmp[1]=tmp[1].replace("/@/","@");

//document.getElementById('show').innerHTML=tmp[1];
//document.getElementById('menu').innerHTML=tmp[1];
document.getElementById('page1').innerHTML=tmp;;
//document.getElementById('contenu1').style.display='none';
}else{
//aff();
//document.getElementById('show').innerHTML="<center><br><br><br><br><img  src='images/Loading.gif'/><br><br>Loading ...</center>";
document.getElementById('menu').innerHTML="<div class='texte' style='margin-left:420px;'><img  src='images/Loading.gif'/><br><br>Loading ...</div>";
document.getElementById('page').innerHTML="<div class='texte' style='margin-left:420px;'><br><br><br><br><br><br><br><br><br><img  src='images/Loading.gif'/><br><br>Loading ...</div>";
}
}
//alert(id + "&Itemid=" + itemid);

if(itemid==107){
	xhr.open("GET","index2.php?option=com_content&task=blogcategory&id=" + id + "&Itemid=" + itemid,true);
}else{
	xhr.open("GET","index2.php?option=com_content&task=view&id=" + id + "&Itemid=" + itemid,true);
}
if(id==0 && itemid==0){

		xhr.open("GET","index2.php?option=com_registration&task=lostPassword",true);
}
if(id==1 && itemid==0){
		xhr.open("GET","index2.php?option=com_registration&task=register",true);
}
document.location.hash="#"+id+"sep"+itemid;
xhr.send(null);
//hash_en_cours = "#" + id + "n" + itemid + "n" + id3 + "";
}
	
/////////////////////function suivant _ precedent //////////////////////////

function PromptMe() {
	//alert(window.location.href);
	var stateVar = "nothin'", displayDiv = document.getElementById("HistoryState");
	this.promtForNew = function(newVal) {
	
		
		unFocus.History.addHistory(newVal);
	};
	this.historyListener = function(historyHash) {
		stateVar = historyHash;
	
		
		p1=document.location.hash;
		/*pa2=p1.substr(1,p1.length-1);
		if(pa2<=32 && p1.length<=3){
			//alert("pa2 : " + pa2);
			chargePage(document.location.hash,false);
			}
			p2=document.location.hash;

			pa3=p2.substr(1,2);
			idd=p2.substr(3,p2.length-1);
			if(pa3=='1a'){
				//alert(1111111);
				charger3(idd);
				}*/
		//pa1=p1.substr(1,1);
			//if(p1.length>=4 && pa3!='1a'){
						//alert(2000000000);
						
						tab=p1.split("sep");
						id1=tab[0];
						id1=id1.substr(1,id1.length);
						id2=tab[1];
						//id3=tab[2];
						/*if(id3!=77){
							menu(id3);
						}*/
						
						/*if(p1==''){
							
							url=window.location.href;
							
						tab_url=url.split("id=");
						
						id1=tab_url[1];
					
						i=0;
						id3='';
						id4='';
						
							while(id4!='&'){
									//alert("id3 "+id3);
								id4=id1.substr(i,1);
								id3=id3+id4;
								i=i+1;
							}
						//alert(2222);
						id1=id3;
						id2=tab_url[2];
							
							ajax(id1,id2);
						}else{
							ajax(id1,id2);
						}*/
						//ajax(id1,id2);
						if(p1!=''){
							ajax(id1,id2);
						}
						
						//alert(id1+"   "+id2);
						/*if(((id1<24 || id1>29) &&  (id2 <43 || id2>48)) && document.logout!=null ){
							document.logout.submit();
						}*/
						//document.location.hash="#"+id1+"sep"+id2;
			//}
		////////////

displayDiv.innerHTML = "Current History: " + historyHash;
		//document.title = "unFocus History Keeper - Current History: " + historyHash;
	};
	unFocus.History.addEventListener('historyChange', this.historyListener);
	this.historyListener(unFocus.History.getCurrent());
};

var demoApp;
	
	