// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12164738-9']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

//POP UP WINDOW
//
//COMMON
function openwin(url){
    	subWin = window.open(url,"popup","scrollbars=yes,resizable=yes,menubar=yes,width=540,height=520");
}

function openwin_c(url){
    	subWin = window.open(url,"popup","scrollbars=yes,resizable=yes,menubar=yes,width=780,height=570");
}

function openwin_cd(url){
    	subWin = window.open(url,"popup","scrollbars=no,resizable=no,menubar=no,width=540,height=440");
}

function openwin_h(url){
    	subWin = window.open(url,"popup","scrollbars=no,resizable=yes,menubar=yes,width=540,height=600");
}

function openwin_v(url){
    	subWin = window.open(url,"popup","scrollbars=yes,resizable=yes,menubar=yes,width=700,height=520");
}

function openwin_we(url){
    	subWin = window.open(url,"popup","scrollbars=yes,resizable=yes,menubar=yes,width=800,height=700");
}

//FOR ARABIC
function openarabic(){
    	subWin = window.open("../english/arabic_pop.html","arabic","width=420,height=350");
}



//OPEN ENGLISH SITE ON MAIN WINDOW FROM OTHER SIDE
//
function enSite(strURL){

	if(is_opener()){
		window.opener.location.href=strURL;
	}else{
		window.open('../english/index.html') ;
	}
}

function is_opener() {

    var strUserAgent = navigator.userAgent

    if( !!window.opener )
        if( strUserAgent.indexOf('MSIE 4')!=-1 && strUserAgent.indexOf('Win')!=-1 ) 
            return !window.opener.closed
        else return typeof window.opener.document == 'object'
    else return false
}



//FOR COMMON NAVIGATION & SWAP IMAGE
//
function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function showHideLayers() { //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


//FOR COMMON NAVIGATION
//
function allOff() {
swapImage('menu1','','../script/img/btn_home.gif',1);
swapImage('menu2','','../script/img/btn_location.gif',1);
showHideLayers('Layer2','','hide');
swapImage('menu3','','../script/img/btn_courses.gif',1);
showHideLayers('Layer3','','hide');
swapImage('menu4','','../script/img/btn_accomm.gif',1);
showHideLayers('Layer4','','hide');
swapImage('menu5','','../script/img/btn_facilities.gif',1);
showHideLayers('Layer5','','hide');
swapImage('menu6','','../script/img/btn_activities.gif',1);
showHideLayers('Layer6','','hide');
swapImage('menu7','','../script/img/btn_students.gif',1);
showHideLayers('Layer7','','hide');
swapImage('menu8','','../script/img/btn_faq.gif',1);
swapImage('menu9','','../script/img/btn_contact.gif',1);
showHideLayers('Layer9','','hide');
}

// switch off the dropDown if mouse y-position is above menu strip!
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0

function getMouseXY(e) {
	  if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	  } else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	  }  
	  if (tempX < 0){tempX = 0}
	  if (tempY < 0){tempY = 0}  

	 // layer off!!!!
	 if(tempY > 281 || tempY < 45 || tempX > 770)
	 {
		allOff();	
	 }
	  return true
}