

//check that browser can use xmlhttp
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {			
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");			
} catch (e) {
	try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
		xmlhttp = false;
	}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}




function showDivAvi(MyObj){
//debugger

if (window.innerWidth || window.innerHeight){ 
docwidth = window.innerWidth; 
docheight = window.innerHeight; 
} 
//IE Mozilla 
if (document.body.clientWidth || document.body.clientHeight){ 
docwidth = document.body.clientWidth; 
docheight = document.body.clientHeight; 
} 


ElelementWidth = document.getElementById(MyObj).style.width
ElelementWidth  = ElelementWidth.replace('px','')


//alert("docwidth = " + docwidth )
//alert("docheight = " + docheight )
//alert("ElelementWidth = " + ElelementWidth )

destX = parseInt((docwidth-ElelementWidth) /2)
if(destX<0){destX=0;}


	//try{
	//destY = event.clientY +  document.body.scrollTop-200;
	//if(destY <0){destY =0;}
	//document.getElementById(MyObj).style.top = destY;
	//}
	//catch(err){}

	document.getElementById(MyObj).style.left = destX;
	document.getElementById(MyObj).style.display = 'block';


	
}	


function MakeXmlhttp(){

var xmlhttp=false;


if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

return xmlhttp
}









function MakeURL(MyFrom)
{
var MyParams = ''
var MyComma = ''
var AllURL=''

if (MyFrom!='undefined')
{

for(i=0;i<MyFrom.length;i++)
	{
	if(MyFrom[i].name!='' && MyFrom[i].value!='' )
		{
	if((MyFrom[i].type=='checkbox' && MyFrom[i].checked) || MyFrom[i].type!='checkbox')
	MyParams = MyParams + MyComma+ MyFrom[i].name + '=' + escape(MyFrom[i].value)
		MyComma='&'
		}
	}

//alert(MyParams)


if(MyParams!='')
	AllURL =  '?' + MyParams 

	}

return AllURL


}




function LoadFileAjax(RunScriptAfter, URL, MyDiv, MyMethod){
//document.getElementById(MyDiv).innerHTML='<CENTER>Loading DATA...</CENTER>';
document.getElementById(MyDiv).innerHTML='<CENTER>ومُْ...</CENTER>';

var MyXmlhttp= new MakeXmlhttp()


 MyXmlhttp.open(MyMethod, URL,true);
MyXmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 

 MyXmlhttp.onreadystatechange=function() {
  if (MyXmlhttp.readyState==4) 
	{
	Response = MyXmlhttp.responseText
	document.getElementById(MyDiv).innerHTML=Response
	if (RunScriptAfter)
		{
		RunScripts(MyDiv)
		}
	//alert(Response + MyDiv)
	return;
	  }
 }
 MyXmlhttp.send(null)



}


function MakeURL1(MyFrom)
{
var MyParams = ''
var MyComma = ''
var AllURL=''
if (MyFrom!='undefined')
	{
	for(i=0;i<MyFrom.length;i++)
		{
switch (MyFrom[i].type){
			case "checkbox":{
				if(MyFrom[i].checked)
					{
					MyParams = MyParams + MyComma+ MyFrom[i].name + '=' + escape(MyFrom[i].value)
					MyComma='&'
					}
			break;
			}
			


			case "select-multiple":{
			for(x=0;x<MyFrom[i].options.length;x++)
				{
				if (MyFrom[i].options[x].selected)

					{

					MyParams = MyParams + MyComma+ MyFrom[i].name + '=' + escape(MyFrom[i].options[x].value)
					MyComma='&'

					}
				}

			break;
			}
			
			case "radio":{
				if(MyFrom[i].checked)
					{
					MyParams = MyParams + MyComma+ MyFrom[i].name + '=' + escape(MyFrom[i].value)
					MyComma='&'
					}
			break;
			}
			


			case "hidden":{
					MyParams = MyParams + MyComma+ MyFrom[i].name + '=' + escape(MyFrom[i].value)
					MyComma='&'
					break;
			}
			

			default:{
			if(MyFrom[i].name!='' && MyFrom[i].value!='' )
				{
				MyParams = MyParams + MyComma+ MyFrom[i].name + '=' + escape(MyFrom[i].value)
				MyComma='&'
				}
		
			break;
			}	


		
		}
		}


	}
return MyParams
}


function LoadFileAjax1(RunScriptAfter,URL, MyDiv, MyMethod,MyForm){

MyData = MakeURL1(MyForm)

//document.getElementById(MyDiv).innerHTML='<CENTER>Loading DATA...</CENTER>';
document.getElementById(MyDiv).innerHTML='<CENTER>ومُْ...</CENTER>';

var MyXmlhttp= new MakeXmlhttp()

 MyXmlhttp.open(MyMethod, URL,true);
MyXmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 

 MyXmlhttp.onreadystatechange=function() {
  if (MyXmlhttp.readyState==4) 
	{
	Response = MyXmlhttp.responseText
	//alert(Response + MyDiv)
	document.getElementById(MyDiv).innerHTML=Response
	if (RunScriptAfter)
		{
		RunScripts(MyDiv)
		}


	return;
	  }
 }
 MyXmlhttp.send(MyData)



}


function RunScripts(MyDiv){
var AllScripts = ''
	 	var MyScripts = document.getElementById(MyDiv).getElementsByTagName("script");
		for(yyy=0; yyy<MyScripts.length; yyy++)
			{
			AllScripts = AllScripts + MyScripts[yyy].text + '\r\n'
			//alert(MyScripts[yyy].text)
			//if(MyScripts[yyy].text.length>0) eval(MyScripts[yyy].text);
			}
		//alert(AllScripts)
		eval(AllScripts)
}




























// this is a helper function
// method: get/post
// url: the url to make the request
// callbackfunction: create in the calling code with ccFunction = function {}
// data: the data sent, if its a get this variable will be added to url with a ? mark
// asyncCall: true - make the request async, false - make a synchronous request
function sendXmlHttpRequest(method, url, callbackFunction, data, asyncCall) {

	if (method.toLowerCase() == "post") {
		xmlhttp.open("POST", url, asyncCall);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');		 
		xmlhttp.onreadystatechange = callbackFunction;
		xmlhttp.send(data);
	} else if (method.toLowerCase() == "get") {
		xmlhttp.open("GET", url + "?" + data, asyncCall);
		xmlhttp.onreadystatechange = callbackFunction;
		xmlhttp.send(null);
	}

}

function sendXmlHttpRequestNoCallback(method, url, data, asyncCall) {

	if (method.toLowerCase() == "post") {
		xmlhttp.open("POST", url, asyncCall);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');		 		
		xmlhttp.send(data);
	} else if (method.toLowerCase() == "get") {
		xmlhttp.open("GET", url + "?" + data, asyncCall);		
		xmlhttp.send(null);
	}

}