﻿
var ua = 'msie';
var W=navigator.userAgent.toLowerCase();
if(W.indexOf("opera")!=-1){ua='opera';}else if(W.indexOf("msie")!=-1){ua='msie';} else if(W.indexOf("mozilla")!=-1){ua='gecko';}
if(W.indexOf("opera")!=-1){ua='opera';}else if(W.indexOf("msie")!=-1){ua='msie';} else if(W.indexOf("mozilla")!=-1){ua='gecko';}

if(window.innerWidth){
    bodyWidth=function(win){if(!win)win=window;return parseInt(win.innerWidth)}
	bodyHeight=function(win){if(!win)win=window;return parseInt(win.innerHeight)}
	scrollTop=function(win){if(!win)win=window;return win.pageYOffset}
	scrollLeft=function(win){if(!win)win=window;return win.pageXOffset}
	
	  
}
else
{
    bodyWidth=function(win){if(!win)win=window;return parseInt(win.document.body.clientWidth)}
	bodyHeight=function(win){if(!win)win=window;return parseInt(win.document.body.clientHeight)}
	scrollTop=function(win){if(!win)win=window;return win.document.body.scrollTop}
	scrollLeft=function(win){if(!win)win=window;return win.document.body.scrollLeft}	
} 


function addListener(obj, event, listener){
    if(ua == 'gecko' || ua == 'opera'){
        obj.addEventListener(event, listener, false);
    } else if (ua == 'msie') {
        obj.attachEvent("on"+event,listener);
    }
};

function removeListener(obj, event, listener){
    if(ua == 'gecko' || ua == 'opera'){
        obj.removeEventListener(event, listener, false);
    } else if (ua == 'msie') {
        obj.detachEvent("on"+event,listener);
    }
};





function $(id)
{
var item;
if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;

}








function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");

}

function hs(obj,value,TF)
{

try{

if (! TF)
 $(obj).style.display=value;
else
{
  if ($(obj).style.display=='block')
  $(obj).style.display='none';
else
  $(obj).style.display='block';
}
}

catch (e){}
}

 








function $ES(txt)
{
 
  return escape(txt)

}

function $css(obj,cn)
{
  $(obj).className=cn;
  
}
 function $FR(obj)
 {
 
   return $(obj).contentWindow;
 
 }
 
 














	function $MC(msg,msgcancel)
{
 if (confirm(msg))
  {
         
         return true;
       }
       else {
          alert (msgcancel);
          return false;
       } 
  
}
















      function popup(strURL,intWinW,intWinH)
{	
	
		var strProperties = "menubar=no, resizable=yes,  "; 


		var intScreenW = parseInt(screen.width, 10); 
		var intScreenH = parseInt(screen.Height, 10); 
		var intWinT = (intScreenH - intWinH)/2; 
		var intWinL = (intScreenW - intWinW)/2;
		strProperties += 'height=' + intWinH + ', width=' + intWinW + ', top=' + intWinT + ', left=' + intWinL + ', status=no,scrollbars=yes,toolbar=no,location=no'; 
		var winObject = window.open(strURL, 'PageServices', strProperties, false); 
//		var winObject=window.open("../services/postFeedbackAction.aspx","","height="+intWinH+",width="+intWinW+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
		winObject.focus(); 
	
}

 



function showdim(btn,X,Y,obj,display)
		{
		 
		 btn=$(btn)
		 
	    var x = btn.offsetLeft;
        var y = btn.offsetTop + btn.offsetHeight ;

  // deal with elements inside tables and such
  var parent = btn;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    x += parent.offsetLeft;
    y += parent.offsetTop ;
		}
	
x=x+X
y=y+Y

	 $(obj).style.left=(x)+'px';
	 $(obj).style.top=(y)+'px'; 
	 $(obj).style.display=display;
		}



function ckbox(TF,nameck) {
var ck=document.body.getElementsByTagName("input")
for(var i=0;i<ck.length;i++)
{
  if (ck[i].type=='checkbox' && ck[i].name.match(nameck)==nameck)
  ck[i].checked=TF;

}


	}  
	
	
	
	
	
	
	
		function viewmeDiv(objshow,obj)
		{
	      var div = $("maindiv").getElementsByTagName("div");
	      var table=$("mainTB").getElementsByTagName("td");
	
	if ($(objshow).style.display=='none')
	{
	
	for (var i=0; i<div.length; i++)
	{
	
	div[i].style.display="none";
	
	
	}
	
	
	for (var i=0; i<table.length; i++)
	{
	  if (i%2 !=0)
{
  table[i].className='tabs';


}
	
	
	}
	
	
	$(objshow).style.display='block';
	$(obj).className='tab_choosed';
	
	
	}
    		
    	}
    	
    	
    	
    	
    	function viewmeDivsector(objshow,obj)
		{
	      var div = $("MainIndex").getElementsByTagName("div");
	      var table=$("mainTB").getElementsByTagName("td");
	
	if ($(objshow).style.display=='none')
	{
	
	for (var i=0; i<div.length; i++)
	{
	name=String(div[i].name)
	if (name=='sector')
	{
	div[i].style.display="none";
	
	}
	}
	
	
	for (var i=0; i<table.length; i++)
	{

  table[i].className='sectortaboff';



	
	
	}
	
	
	$(objshow).style.display='block';
	$(obj).className='sectortabon';
	
	
	}
    		
    	}
    	
    	function deletedata(url)
{
if ($MC('هل تريد فعلا بأن تتأخد هذا الإجراء','تم إلغاء الإجراء'))
{

go_to(url)

}

}

function go_to(url)
{

document.location.href=url;

}

function centerpage(obj)
{
$('tdanalysis').innerHTML=$('analysis'+obj).innerHTML

$('tdchart').innerHTML=$('chart'+obj).innerHTML
try{
$('tddetails').innerHTML=$('details'+obj).innerHTML
}
catch(e){$('tddetails').innerHTML=''}

 $('showdetails').style.left=document.body.clientWidth/2-$('showdetails').offsetWidth/2;
 $('showdetails').style.top='0'//document.body.clientHeight/2-$('showdetails').offsetHeight/2;
document.recalc(true);

}
