var listAjaxPage="newslist.asp";

$(document).ready(function()
{
	getday();
	gettime();
	gethello();
	document.getElementById("nongyear").innerHTML=getnongliYear();
	document.getElementById("nongdaymonth").innerHTML=getnongliMonthDay();
	activateMenu('MenuTr');
	tooltip();
});

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


this.tooltipClick = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.ding").click(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    });			
};


activateMenu = function(nav) {

    /* currentStyle restricts the Javascript to IE only */

		
        var navroot = document.getElementById(nav);
		//alert(navroot.tagName);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("TD");  
        for (i=0; i<lis.length; i++) {
      	  //
           /* If the LI has another menu level */
		   		j=i
		  
            if(lis[i].firstChild.tagName=="DIV"){
           		 // alert(lis[i].lastChild.tagName);
                /* assign the function to the LI */
				//alert(j);
				eval("temp"+j+"=lis[i].lastChild");
             	lis[i].onmouseover=function() {	
                
					//alert(this.tagName);
                   /* display the inner menu */
            			this.firstChild.style.display='inline';
						
                }
                lis[i].onmouseout=function() {                       
                    this.firstChild.style.display='none';
				  // temp.style.display="none";
                }
            }
        }
}


function getday()
{
	var now = new Date();
	var SY = now.getYear(); 
	var SM = now.getMonth()+1;
	var SD = now.getDate();
	var ww = now.getDay();
	if(SM<10) SM="0"+SM.toString();
	if(SD<10) SD="0"+SD.toString();
	if(ww==0)  ww="星期日";
	if (ww==1) ww="星期一";
	if (ww==2) ww="星期二";
	if (ww==3) ww="星期三";
	if (ww==4) ww="星期四";
	if (ww==5) ww="星期五";
	if (ww==6) ww="星期六";
	document.getElementById("mm").src="images/yue_"+SM+".jpg";
	document.getElementById("dd").src="images/ri_"+SD+".jpg";
	//document.getElementById("nongyear").innerHTML=ww.toString();
	
	
	
}
function gethello()
{
	var Digital=new Date()
	var hours=Digital.getHours()
	var hellostr="";
	if(hours<6)  {hello="凌晨"} 
	else if (hours < 9){hellostr="早上"} 
	else if (hours < 12){hellostr="上午"} 
	else if (hours < 14){hellostr="中午"} 
	else if (hours < 17){hellostr="下午"} 
	else if (hours < 19){hellostr="傍晚"} 
	else if (hours < 22){hellostr="晚上"} 
	else {hello="夜里"} ;
	document.getElementById("hello").innerHTML=hellostr;
}
function gettime()
{
	var Digital=new Date()
	var hours=Digital.getHours()
	var minutes=Digital.getMinutes()
	var seconds=Digital.getSeconds()
	if(minutes<=9)	{minutes="0"+minutes;};
	document.getElementById("timer").innerHTML=hours+":"+minutes;
	//setTimeout("gettime()",1000)	
}

//加入收藏
function AddFavorite(sURL, sTitle)
{
	if (document.all)
		window.external.AddFavorite(sURL, sTitle);
	else if (window.sidebar)
		window.sidebar.addPanel(sTitle, sURL, "") 
}

//设为首页
function SetHome(obj,url){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
                        }  
                        catch (e)  { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");  
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',url);
                 }
        }
}
function ding(ID)
{
	alert("成功！感谢您的参与！")
	
}
function copyToClipboard(txt) {       
     if(window.clipboardData) {       
              window.clipboardData.clearData();       
              window.clipboardData.setData("Text", txt);       
      } else if(navigator.userAgent.indexOf("Opera") != -1) {       
           window.location = txt;       
      } else if (window.netscape) {       
          try {       
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");       
           } catch (e) {       
                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");       
           }       
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);       
          if (!clip)       
               return;       
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);       
          if (!trans)       
               return;       
           trans.addDataFlavor('text/unicode');       
          var str = new Object();       
          var len = new Object();       
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);       
          var copytext = txt;       
           str.data = copytext;       
           trans.setTransferData("text/unicode",str,copytext.length*2);       
          var clipid = Components.interfaces.nsIClipboard;       
          if (!clip)       
               return false;       
           clip.setData(trans,null,clipid.kGlobalClipboard);       
           alert("复制成功！")       
      }       
} 