var xmlHttp=createXMLHttpRequest();
function createXMLHttpRequest(){
	var xmlHttp ; 
	try {
		xmlHttp=new XMLHttpRequest() ;
	}catch(e){
	try{
		xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
		
	}catch(e){}
	}
		if (!xmlHttp)
		alert("Couldn't Create XmlHttpRequest Object") ;    	
		else
		return xmlHttp ; 

}


function insert_comment(fid){
	var alert_area_=document.getElementById('alert_area');
	var name_=document.getElementById('name');
	var email_=document.getElementById('email');
	var comment_title_=document.getElementById('comment_title');
	var comment_=document.getElementById('comment_text');
	var country_=document.getElementById('country');
	var verification_=document.getElementById('verification');
	var params='action=insert_comment&name='+name_.value+'&email='+email_.value+'&comment_title='+comment_title_.value+'&comment='+comment_.value+'&country='+country_.value+'&verification='+verification_+'&fileid='+fid ;
	if (xmlHttp){
	xmlHttp.open("POST","comments.php",true) ; 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	
	xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==1){
			alert_area_.innerHTML='<img src="images/loading.gif" alt="loading" align="center" class="icon" style="margin-bottom:10px;"/>';
		}else if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){
			var response_=xmlHttp.responseText; 
			alert_area_.innerHTML=response_;
			if (response_=='تمت إضافة التعليق'){
				document.getElementById('send_button').disabled='disabled';
				name_.disabled='disabled';
				email_.disabled='disabled';
				comment_title_.disabled='disabled';
				comment_.disabled='disabled';
				country_.disabled='disabled';
			}
			}
		
		}
	}
	   
   }

	xmlHttp.send(params);
	
}

function send_file(theid){
	var alert_area_=document.getElementById('alert_area');
	var your_name_=document.getElementById('your_name');
	var your_email_=document.getElementById('your_email');
	var friend_name_=document.getElementById('friend_name');
	var friend_email_=document.getElementById('friend_email');
	var comment_=document.getElementById('comment_text');
	var params='action=send_file&your_name='+your_name_.value+'&your_email='+your_email_.value+'&friend_name='+friend_name_.value+'&friend_email='+friend_email_.value+'&comment='+comment_.value ;
	
	if (xmlHttp){
	xmlHttp.open("POST","send.php?id="+theid,true) ; 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	
	xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==1){
			alert_area_.innerHTML='<img src="images/loading.gif" alt="loading" align="center" class="icon" style="margin-bottom:10px;"/>';
		}else if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){
			var response_=xmlHttp.responseText; 
			alert_area_.innerHTML=response_;	
			if (response_=='تم إرسال المقال إلي صديقك'){
				document.getElementById('send_button').disabled='disabled';
				your_name_.disabled='disabled';
				your_email_.disabled='disabled';
				friend_name_.disabled='disabled';
				comment_.disabled='disabled';
			}
			}
		
		}
	}
	   
   }

	xmlHttp.send(params);
	
}

function contact(){
	var alert_area_=document.getElementById('alert_area');
	var name_=document.getElementById('name');
	var email_=document.getElementById('email');
	var subject_=document.getElementById('subject');
	var messege_=document.getElementById('messege');
	var params='action=contact&name='+name_.value+'&email='+email_.value+'&subject='+subject_.value+'&messege='+messege_.value;
	if (xmlHttp){
	xmlHttp.open("POST","components/misc/contact.php",true) ; 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	
	xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==1){
			alert_area_.innerHTML='<img src="images/loading.gif" alt="loading" align="center" class="icon"  style="margin-bottom:10px;"/>';
		}else if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){
			var response_=xmlHttp.responseText; 
			alert_area_.innerHTML=response_;
			if (response_=='تم الإرسال وسيتم الرد عليك قريبا'){
				document.getElementById('send_button').disabled='disabled';
				name_.disabled='disabled';
				email_.disabled='disabled';
				subject_.disabled='disabled';
				messege_.disabled='disabled';
			}
			}
		
		}
	}
	   
   }

	xmlHttp.send(params);
	
}

function report(){
	var alert_area_=document.getElementById('alert_area');
	var name_=document.getElementById('name');
	var email_=document.getElementById('email');
	var messege_=document.getElementById('messege');
	var params='do=report&name='+name_.value+'&email='+email_.value+'&messege='+messege_.value;
	if (xmlHttp){
	xmlHttp.open("POST","support.php?action=report",true) ; 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	
	xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==1){
			alert_area_.innerHTML='<img src="images/loading.gif" alt="loading" align="center" class="icon"  style="margin-bottom:10px;"/>';
		}else if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){
			var response_=xmlHttp.responseText; 
			alert_area_.innerHTML=response_;
			if (response_=='تم التبليغ عن المشكلة وسيتم الرد عليك قريبا'){
				document.getElementById('send_button').disabled='disabled';
				name_.disabled='disabled';
				email_.disabled='disabled';
				messege_.disabled='disabled';
			}
			}
		
		}
	}
	   
   }

	xmlHttp.send(params);
	
}

function send_request(theid){
	var alert_area_=document.getElementById('alert_area');
	var name_=document.getElementById('name');
	var company_=document.getElementById('company');
	var email_=document.getElementById('email');
	var phone_=document.getElementById('phone');
	var request_type_=document.getElementById('request_type');
	var properties_=document.getElementById('properties');
	var notes_=document.getElementById('notes');
	var params='action=send_request&name='+name_.value+'&company='+company_.value+'&email='+email_.value+'&phone='+phone_.value+'&request_type='+request_type_.value+'&notes='+notes_.value+'&properties='+properties_.value ;
	
	if (xmlHttp){
	xmlHttp.open("POST","request.php?id="+theid,true) ; 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	
	xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==1){
			alert_area_.innerHTML='<img src="images/loading.gif" alt="loading" align="center" class="icon" style="margin-bottom:10px;"/>';
		}else if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){
			var response_=xmlHttp.responseText; 
			alert_area_.innerHTML=response_;	
			if (response_=='تم إرسال الطلب وسيتم الرد عليك قريباً'){
				document.getElementById('send_button').disabled='disabled';
				name_.disabled='disabled';
				company_.disabled='disabled';
				email_.disabled='disabled';
				phone_.disabled='disabled';
				request_type_.disabled='disabled';
				properties_.disabled='disabled';
				phone_.disabled='disabled';
				notes_.disabled='disabled';
			}
			}
		
		}
	}
	   
   }
	xmlHttp.send(params);
}

function move(dir,theid,prefix,order){
	var params='action=move&dir='+dir+'&id='+theid;
	if (xmlHttp){
	xmlHttp.open("POST","test.php",true) ; 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	
	xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==1){
		//	alert_area_.innerHTML='<img src="images/loading.gif" alt="loading" align="center" class="icon" style="margin-bottom:10px;"/>';
		}else if (xmlHttp.readyState==4){
			if (xmlHttp.status==200){
				var response=xmlHttp=responseText;
				alert(response);
				if(dir=="up"){
					moveUp(prefix,order);
				}else{
					moveDown(prefix,order);
				}
			
			}
		
		}
	}
	   
   }
	xmlHttp.send(params);
}

function moveUp(prefix,theid){
	var higherId=prefix+(theid-1);
	var thisId=prefix+theid;
	try{
		higherContents=document.getElementById(higherId).innerHTML;
		thisContents  =document.getElementById(thisId).innerHTML;
		document.getElementById(higherId).innerHTML=thisContents;
		document.getElementById(thisId).innerHTML=higherContents;
	}catch(e){}
}
function moveDown(prefix,theid){
	var lowerId=prefix+(theid+1);
	var thisId=prefix+theid;
	try{
		lowerContents=document.getElementById(lowerId).innerHTML;
		thisContents  =document.getElementById(thisId).innerHTML;
		document.getElementById(lowerId).innerHTML=thisContents;
		document.getElementById(thisId).innerHTML=lowerContents;
	}catch(e){}
}



//*/**//**//**//*
function golink(page,divID) {
createXMLHttpRequest();
xmlHttp.onreadystatechange = function()
{

if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
//alert("The server replied with: " + xmlHttp.responseText);
       var text= xmlHttp.responseText;
	 //document.getElementById("content").innerHTML="<img src='../images/loading.gif'>";
	document.getElementById(divID).innerHTML=text  ;
}
}

};
//document.getElementById(divID).innerHTML="<center><img src='images/loading.gif'></center>";    
xmlHttp.open("GET", page , true);
xmlHttp.send(null);
}
////////////////****//*//**

function poll(id) {
xmlHttp.onreadystatechange = function()
{

if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {

       var text= xmlHttp.responseText;
	 
	document.getElementById("poll_alert").innerHTML="<img src='images/loading.gif'>";  
	document.getElementById("poll_content").innerHTML=text ;
}
}

}; 
answer_n="";
for (var i = 0; i < document.vote_form.answer.length; i++) 
{
		if (document.vote_form.answer[i].checked) {
		    answer_n = document.vote_form.answer[i].value ;
		}
}
     if(answer_n==""){
		   document.getElementById("poll_alert").innerHTML = "<div class='alert'> يجب الضغط علي أحد الخيارات </alert>"  ;
		   return false; 
	 }
var params="answers="  + answer_n   +"&"+
		   "vote_id="  + document.getElementById("vote_id").value  +"&"+
		   "op="       + document.getElementById("op").value ;           
					
		   
xmlHttp.open("POST", id ,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
	
xmlHttp.send(params);
}


function emails_add(id,divId) {
xmlHttp.onreadystatechange = function()
{

if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {

       var text= xmlHttp.responseText;
	 
	document.getElementById(divId).innerHTML="<img src='images/loading.gif'>";  
	document.getElementById(divId).innerHTML=text ;
}
}

}; 
var params="name="  + document.getElementById("name").value  +"&"+
		   "email="  + document.getElementById("email").value  +"&"+
		   "tele="  + document.getElementById("tele").value  +"&"+
		   "view="  + document.getElementById("view").value  +"&"+
		   "number="       + document.getElementById("number").value ;           
					
		   
xmlHttp.open("POST", id ,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
	
xmlHttp.send(params);
}

