﻿/////////////////////////////////////////////////////////////////////////////////////////
var isIE;
var isFirefox;

function sniffBrowserType() {
	isFirefox = ( navigator.appName == "Netscape" );
	isIE = (navigator.appName == "Microsoft Internet Explorer" ); 
}

function getElement( id ) 
{

	var result = document.all[ id ];

	if ((browseris.w3c) && (!browseris.ie)) 
	{
	    result = document.getElementById( id );
	}
	
	return result;

}

/*
function searchSuggest(event)
{
   bindAjax();

}

function hid(){var resultlist = getElement('searchList'); if(resultlist == null) return; resultlist.style.display="none";}
function show(){var resultlist = getElement('searchList');if(resultlist == null) return; resultlist.style.display="block";}
*/
var mosssearchBox;
var dhxWins;
function getDhxWins()
{
 	if(dhxWins == null)
	dhxWins = new dhtmlXWindows();
	
	return dhxWins ;
 }
setupSearchbox();
                    	 
 top1=getCookie('top1');
 
 if(top1!=null) 
 {
 	sel(top1,'top1');
 }
 else 
 {
	sel('GK|KY|ZZ','top1');
 }


function setupSearchbox()
{
    
    if(mosssearchBox == null)
        mosssearchBox = findSearchbox();
     
     mosssearchBox.style.border = "none";
       mosssearchBox.focus();
   //  mosssearchBox.onmousedown = function(){alert()};
     //mosssearchBox.onkeyup=searchSuggest;
    // mosssearchBox.onmousedown = searchSuggest;
    // mosssearchBox.onfocusout = hid;
}
var rnd = Math.random();

function bindAjax()
{
	rnd++;
	url = '/_layouts/SearchboxKeywords/GetKeywords.aspx?keywords='+encodeURIComponent(mosssearchBox.value)+'&session=' + rnd;

	req = getAjax();

	req.onreadystatechange = function(){
	
		if( req.readyState == 4 && req.status == 200 ) {
		
			getKeyWords(req.responseText)
		}
	}
	
	req.open( 'GET', url, true );
	req.send( null );
}
/*
function getKeyWords(request){

var _data="";
var _str = request.split('@');
_len=_str.length-1;
for (i=0; i< _len;i++){	
_data = _data + '<div id="k'+i+'" onmouseover="setBg('+i+') " onclick="hid();">'+_str[i]+'</div>';

}
if (_len > 0){
var list = getElement('searchList');
if(list==null) return;
list.innerHTML=_data;
show();
}else{
hid();
}

}

function setBg(id){
for (i=0;i<_len;i++){
getElement('k'+i).style.backgroundColor="#ffffff";
getElement('k'+i).style.color="#666666"
getElement('k'+i).style.cursor="pointer";
}
getElement('k'+id).style.backgroundColor="#0066cc";
getElement('k'+id).style.color="#ffffff"
mosssearchBox.value = getElement('k'+id).innerHTML;
}

*/
function findSearchbox()
{

	if (browseris.nav)
		return;


	inputElts = document.documentElement.getElementsByTagName("input");
	
	if ((browseris.w3c) && (!browseris.ie)) 
	{
		inputElts=document.getElementsByTagName("input");
	}
	numElts=inputElts.length;
	for(var i= 0 ;i<numElts;i++)
	{
	    
	    if(inputElts[i].className =="ms-sbplain")
	        return inputElts[i];
	}
  
}

function getAjax()
{
	var XmlHttp;
	
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
	return XmlHttp;
}

//////////////////////////////////////////
//var nav = findNavframe()
//if(nav != null)
// nav.style.display = "none";

//function findNavframe()
//{

//	if (browseris.nav)
//		return;

//	Elts = document.documentElement.getElementsByTagName("TABLE");
//	
//	if ((browseris.w3c) && (!browseris.ie)) 
//	{
//		Elts=document.getElementsByTagName("TABLE");
//	}
//	numElts=Elts.length;
//	for(var i= 0 ;i<numElts;i++)
//	{
//	    if(Elts[i].className =="ms-navframe")
//	        return Elts[i];
//	}
//  
//}

function hxsubNavOver(index)
 {
 //alert(index);alert( activeSubNav ); alert(hoverSubNav);
  if(index != activeSubNav && index != hoverSubNav) 
  {
   var newTab = getElement('sn_' + index);

    hoverSubNav = index;

    newTab.className = "subHover";
    }
     }
function hxsubNavOut(index)
 {
 if(index != activeSubNav) 
 {
   var newTab = getElement('sn_' + index);

    hoverSubNav = index;
    
    newTab.className = "normal";
}
 }
 
 function setwinwidth()
 {
//       alert();	    var height = 523;
//        var width = 652 ;

//        win.setDimension(width , height);
}
var isFading = false; 
var isAnimating = false;
var l2al ;
var l2op ;
var l2timer;

function subNavClickInterval() 
{ 
 	  	  if(isFading)
 	  	  { 
 	  	  	if(l2al<=0)
 	  	 	 { isFading=false; 
 	  	 	   tabbar.setTabActive('sn_' + tmpi);
 	  	 	 } 
 	  	 	 	else{ 
 	  	 	 	l2al=l2al-15; 
 	  	 	 	if(l2al<0)l2al=0; 
 	  	 	 	l2op=l2op-0.15; 
 	  	 	 	if(l2op<0)l2op=0; 
 	  	 	 	} 
 	  	 	 	} 
 	  	 	 	else{ l2al=l2al+15; l2op=l2op+0.15;
 	  	 	 	 } 
 	  	 	 	 var  mnwPanel = getElement('MNWPanel');
 	  	 	 	 mnwPanel.style.MozOpacity = ''+l2op;
 	  	 	 	  mnwPanel.style.filter = 'alpha(Opacity='+l2al+')'; 
 	  	 	 	  if(l2al>=100 && !isFading) 
 	  	 	 	  { mnwPanel.style.MozOpacity = '';
 	  	 	 	   mnwPanel.style.filter = ''; 
 	  	 	 	   clearInterval(l2timer); 
 	  	 	 	   isAnimating = false; 
 	  	 	 	   l2timer = null; 
 	  	} 
} 
var tmpi;
function hxsubNavClick(index,obj)
 {

 if(isAnimating){ return false; } 
   tmpi= index;
   var i = 0;
   while(getElement('sn_' + i) != null)
   {
     var newTab = getElement('sn_' + i);
     if(i==index) 
     {
     
        win = getDhxWins().window(id);
        
         activeSubNav = index;
         newTab.className = "subNavActive";

 	  	   isFading = true; 
 	  	   isAnimating = true; 
 	  	   l2al=100; 
 	  	   l2op=1; 
 	  	   l2timer = setInterval(subNavClickInterval, 1); 

         
         
         //tabbar.setTabActive('sn_' + i);
        
         

     }
     else
     {
        newTab.className = "normal";
     }
        i++;
   }
 } 


var id = "winMessager";	
 var win;
 var timeID;





function ShowMessageWindow()
{

	getDhxWins().enableAutoViewport(true);
	//getDhxWins().setViewport(0, 40, 800, 800); 
	
	var width = 650;
	var height = 523;
	
	var x = ( document.body.offsetWidth - width ) / 2;
    var y = 40;//( document.body.offsetHeight - height ) / 2;


    var win ;
    
    
    if(getDhxWins().window(id) == null)
    {
    	win = getDhxWins().createWindow(id, x, y, width, height);
        win.button("help").hide();
    	win.button("close").hide(); 
    	win.button("minmax1").hide();
    	win.button("park").hide();
    	win.setModal(true);
    	win.setText("学校信息");
    	win.denyMove();
    	win.denyResize();
    	win.addUserButton("tray", 0, "关闭", "tray");
    // attach event to "Tray" button
    win.button("tray").attachEvent("onClick", function(){
        win.hide();
        getDhxWins().enableAutoViewport(false);
        getDhxWins().setViewport(0, 0, 1, 1);
        //win.setModal(false);

    });
    	
    	win.attachObject('WindowForm');
    	//win.attachURL("http://www.baidu.com");
       
	}
    else
    {
    	win = getDhxWins().window(id);
    	if(win.isHidden())
    	{
    		win.show();
    		win.setModal(true);
    	}
    }

    
    getElement('WindowForm').style.display = '';

			tabbar = new dhtmlXTabBar("MNWPanel","left");
            tabbar.setImagePath("codebase/imgs/");
            tabbar.loadXML("/Schools/dhtml/tabs5.xml");
			tabbar.setSkinColors("white","white");
            //tabbar.enableAutoReSize(true);
          //  hxsubNavClick(0,null);
          
           
             
            

    }	



function     GetQueryString(name)   
{   
     var     reg     =   new   RegExp("(^|&)"+     name     +"=([^&]*)(&|$)");   
     var     r     =     window.location.search.substr(1).match(reg);   
     if     (r!=null)   return     unescape(r[2]);   return   null;   
}  

//Creating and setting the instance of appropriate XMLHTTP Request object to a 揦mlHttp?variable  
function getAjax()
{
	var XmlHttp;
	
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
	return XmlHttp;
}



