document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
//  Main VARS  
var xmlHttp = "";
var browser =	this.name = navigator.appName; //Browser Information 
var	oldTop = 0;
var newLeft   = 0;
var newHeight = "";

///*************   Create AJAX Object ***************/
	function AJAX()
			{
				 document.cookie.length=0;
				 this.time = new Date();
				 try{ this.xmlHttp=new XMLHttpRequest();}
				 catch (e){  try{this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
							 catch (e){	try{this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
										catch (e){
										 alert("Your browser does not support AJAX!");
												   return false;   
												}
										}
						  }
		
			}
		function myAjax()
			{
				 document.cookie.length=0;
				 this.time = new Date();
				 try{ this.xmlHttp=new XMLHttpRequest();}
				 catch (e){  try{this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
							 catch (e){	try{this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
										catch (e){
										 alert("Your browser does not support AJAX!");
												   return false;   
												}
										}
						  }
		
			}	
/////**********   ESSENTAIL FUNCTIONS  **************************/
function checkTextField(textObj)
		{ 
				if(textObj.value == ""){textObj.focus();return false;}
				else if(textObj.value == " "){textObj.focus();return false;}
				else if(textObj.value.length ==0){textObj.focus();return false;}
				return true;
		}
function checkemail(x)
	{
			if(x.value == ""){x.focus();return false;}
			if(x.value.indexOf("@") == -1){x.focus();return false;}
			if(x.value.indexOf(".") == -1){x.focus(); return false;}
			if(x.value.indexOf("@") == 0) {x.focus();return false;}
			if(x.value.indexOf(".") == 0){x.focus(); return false;}
			return true;
	}

function  CHKFILE(file)
	{
		 imgRe = /^.+\.(jpg|jpeg|gif|png)$/i;
		 if(file.search(imgRe) == -1)return false;
		 else return true;
	}

function CHKNUM(x)
		{

		var code ;
		if(!e) var e = window.event;
		if(e.keyCode) code= e.keyCode;
		else if(e.which) code = e.which;
		var character =  String.fromCharCode(code);
		if( (code >= 48 && code <= 57) || (code == 46) || (code == 45) )return true;
		else return false;
		}
function chkIfPhoneNumber(x)
		{

		var code ;
		if(!e) var e = window.event;
		if(e.keyCode) code= e.keyCode;
		else if(e.which) code = e.which;
		var character =  String.fromCharCode(code);		
		if( (code >= 48 && code <= 57) || (code == 46) || (code == 45) || (code == 40) || (code == 41) || (code == 43))return true;
		else return false;
		}


function getTableName(idName){

			TBL = "";
			if(browser=="Netscape")
							  { 
								mainTable = document.getElementsByTagName("table");
								for(i=0 ; i < mainTable.length ; i++){
										if(mainTable[i].id == idName){ TBL = mainTable[i];}
									}
					}else{if(document.getElementById(idName))TBL = document.getElementById(idName);}
			return TBL;
	}
function getBrowserHeightWidth(){

						clientWidth  = document.body.clientWidth ;			
						clientHeight = document.body.clientHeight;			
						clientWidth  = clientWidth / 2;
						newLeft      = clientWidth -150;
						newHeight    = eval(clientHeight - 420);	
		}
function showLoadingTblProcess(){

								
								wTbl = getTableName("WAITTBL");
								wTbl.style.display = 'block';
								//newHeight = newHeight + 200;
								wTbl.style.left    = newLeft + "px" ;
								wTbl.style.top     = newHeight + "px";	
	}
	function showLoadingTblProcess2(){

								
								wTbl = getTableName("WAITTBL2");
								wTbl.style.display = 'block';
								//newHeight = newHeight + 200;
								wTbl.style.left    = newLeft + "px" ;
								wTbl.style.top     = newHeight + "px";	
	}

function hideLoadingTblProcess(){

								
								wTbl = getTableName("WAITTBL");
								wTbl.style.display = 'none';
		}
		function hideLoadingTblProcess2(){

								
								wTbl = getTableName("WAITTBL2");
								wTbl.style.display = 'none';
		}

function loginErrorBlock(blockId , msg ){
		    document.getElementById(blockId).style.display = 'block';
		    document.getElementById(blockId).innerHTML = msg;
		}
		
function SHOWHEADER(){
		 val = document.getElementById("grid").scrollTop-1;
		 document.getElementById("header").style.top=val + "px" ;
	}
function SHOWHEADER2(){
		 val = document.getElementById("grid2").scrollTop-1;
		 document.getElementById("header2").style.top=val + "px" ;
	}

function chkAllBoxs(frmName , chk , chkName){

		FORM = document.getElementById(frmName);
		for( i = 0; i < FORM.elements.length ; i++){if(FORM.elements[i].name == chkName)FORM.elements[i].checked = chk; }
	}
function changeTextBgColor(obj){
			obj.style.backgroundColor = "#FFFFFF";
	}
function retrieveTextBgColor(obj , oldColor){
			obj.style.backgroundColor = oldColor;
	}
function chkLoginchar()
	{
		var code ;
		if(!e) var e = window.event;
		if(e.keyCode) code= e.keyCode;
		else if(e.which) code = e.which;
		var character =  String.fromCharCode(code);
		if(code==13)ChkLoginForm();
   }

// ---------------------------------------------------------------------------------------------------------

///***********  CAHNGE PASSWORD FUNCTIONS *****************/

function chkform2()
	{
		  if(document.getElementById("oldpass").value=="")
			{
			 document.getElementById("err").style.display='block';
			 document.getElementById("err").innerHTML='kindly check the old password field';
			document.getElementById("oldpass").focus();
			 return false;
			}
		  if(document.getElementById("npass").value=="")
			{
			 document.getElementById("err").style.display='block';
			 document.getElementById("err").innerHTML='kindly check the new password field';
			document.getElementById("npass").focus();
			 return false;
			}
		  if(document.getElementById("conpass").value != document.getElementById("npass").value)
			{
			 document.getElementById("err").style.display='block';
			 document.getElementById("err").innerHTML='kindly confirm password ';
			document.getElementById("conpass").focus();
			 return false;
			}	 
	 return true
	}


function chkoldpass()
		{
	
				if(chkform2() == true)
					{
										
							FRM = document.getElementById("chpass");
							obj = new AJAX();
							obj.xmlHttp.onreadystatechange=function()
							  {
									if (obj.xmlHttp.readyState==1)
									 { 
										 document.getElementById("goBt").disabled = true;
										 document.getElementById("err").style.backgroundColor="#F0EFE8";
										 document.getElementById("err").style.color="#000000";
										 document.getElementById("err").innerHTML = "Please wait..."; 
									 }
									if (obj.xmlHttp.readyState==4)
									 {  
										 if(obj.xmlHttp.responseText==1){ FRM.submit();}
										 else{
												 document.getElementById("err").style.backgroundColor="#FF0000";
												 document.getElementById("err").style.color="#FFFFFF";
												 document.getElementById("err").style.fontSize ="11px";
												 document.getElementById("err").style.display="block";
												 document.getElementById("err").innerHTML = "wrong old password";
												 document.getElementById("goBt").disabled = false; 
											 }
									 } 
								}
							url="admin_pass/chkoldpass.php?pass="+document.getElementById("oldpass").value+"&time="+obj.time.getTime();
							obj.xmlHttp.open("GET",url,true);
							obj.xmlHttp.send(null);
				   }
	}




function SHOWSUBTBL(){

								if(navigator.appName=="Netscape"){
														mainTable = document.getElementsByTagName("table").length;
														mainTableObj = document.getElementsByTagName("table");
														for(i = 0 ; i < mainTable ; i++)
																{ 
																	if(mainTableObj[i].id == "SUBTBL")
																			{
																				phTable = document.getElementById(mainTableObj[i].id);
																			}
																}
										}else { phTable = document.getElementById("SUBTBL");}
									phTable.style.display = 'block';


					}
function SHOWSUB_users_TBL(){

								if(navigator.appName=="Netscape"){
														mainTable = document.getElementsByTagName("table").length;
														mainTableObj = document.getElementsByTagName("table");
														for(i = 0 ; i < mainTable ; i++)
																{ 
																	if(mainTableObj[i].id == "SUB_users_TBL")
																			{
																				phTable = document.getElementById(mainTableObj[i].id);
																			}
																}
										}else { phTable = document.getElementById("SUB_users_TBL");}
									phTable.style.display = 'block';


}
function DROP_SHADOW(id){

document.getElementById(id).style.filter="shadow(color:gray, strenght:10, direction:135)";
document.getElementById(id).style.padding= "10px";
document.getElementById(id).style.width = "70%";
}
function REMOVE_SHADOW(id){
document.getElementById(id).style.filter="";
document.getElementById(id).style.padding= "0px";
document.getElementById(id).style.width = "";
}
function moveItRight(){
//if(document.getElementById("items").scrollLeft == 300)document.getElementById("items").scrollLeft=0;
		scrollValue = document.getElementById("items").scrollLeft;
		scrollValue = scrollValue + 10;
		document.getElementById("items").scrollLeft = scrollValue;
		scrollTimeOut = setTimeout("moveItRight()", 100);
}
function StopScrolling(){
clearTimeout(scrollTimeOut);
}
function moveItLeft(){
		scrollValue = document.getElementById("items").scrollLeft;
		scrollValue = scrollValue - 10;
		document.getElementById("items").scrollLeft = scrollValue;
		scrollTimeOut = setTimeout("moveItLeft()", 100);
}
function LogOut(lan){
	
			FRM = document.getElementById("loginFrm");
			FRM.action = "?pid=logOut&lan="+lan;
			FRM.submit();
		}
		function fadOut(obj){
				if(document.all){obj.style.filter='Alpha(opacity="100")';}
				else obj.style.opacity = '1';
			}
	function fadIn(obj){
				if(document.all){obj.style.filter='Alpha(opacity="70")';}
				else obj.style.opacity = '0.5';
			}
			
	function ajaxFadOut(obj){
				if(document.all){obj.style.filter='Alpha(opacity="100")';}
				else obj.style.opacity = '1';
			}
	function ajaxFadIn(obj){
				if(document.all){obj.style.filter='Alpha(opacity="40")';}
				else obj.style.opacity = '0.4';
			}
function chkWord(txtObj){
			
			txtObj.style.color = "#000000";

			if(  txtObj.value == "  البحث  ")txtObj.value = "";
			if(txtObj.value == " Search "  )txtObj.value = "";
			}
	function chkWordBlur(txtObj){
			txtObj.style.color = "#999999";			
			if( document.getElementById("lan") ){
					if(txtObj.value == "")txtObj.value = "  Search ";
			}else{
			if(txtObj.value == "")txtObj.value = " البحث ";
			}
			}
//------------------------------------------

function chkParentImg(liObj , picOver , normalPic){
				if(document.getElementById(liObj) )document.getElementById(liObj).src = picOver;
				}
function chkParentImgOut(liObj , picOver , normalPic){
				if(document.getElementById(liObj) )document.getElementById(liObj).src = normalPic;
				}				

