// JavaScript Document
function UrlToDiv(divId,remoteUrl){	
	
	new Ajax.Request(remoteUrl, { 
  			method: "get", 
  			onSuccess: function(transport) {    				
  			 $(divId).innerHTML=transport.responseText;
			 } 
			 });
	}
	
function DelDiv(divId){
	$(divId).remove();
	isClickChain=false;
	}

	////////////////////////////////////////////////
Date.prototype.Format = function(fmt)
{
    //author: meizz
    var o =
     {
        "M+" : this.getMonth() , //月份
        "d+" : this.getDate(), //日
        "h+" : this.getHours(), //小时
        "m+" : this.getMinutes(), //分
        "s+" : this.getSeconds(), //秒
        "q+" : Math.floor((this.getMonth() + 3) / 3), //季度
        "S" : this.getMilliseconds() //毫秒
     };
    if (/(y+)/.test(fmt))
         fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
             fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}


Date.prototype.addDays = function(d)
{
	//alert(this.getDate());
    this.setDate(this.getDate() + d);
}


Date.prototype.addWeeks = function(w)
{
    this.addDays(w * 7);
}


Date.prototype.addMonths= function(m)
{
    var d = this.getDate();
    this.setMonth(this.getMonth() + m);

    if (this.getDate() < d)
        this.setDate(0);
}


Date.prototype.addYears = function(y)
{
    var m = this.getMonth();
    this.setFullYear(this.getFullYear() + y);

    if (m < this.getMonth())
     {
        this.setDate(0);
     }
}

function addFavHotel() {
			var url=window.location.href;
			var title=window.document.title;
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}

	
function GetIpadd(ipStr){	
	var url="/GetIp.asp?ip="+ipStr;		
		new Ajax.Request(url, { 
  		method: "get", 
		onSuccess: function(transport) { 
		var json = transport.responseText.evalJSON();
		var ipContent;
		ipContent="<ul class='ipadd'><li>IP："+json.ip+"&nbsp;&nbsp;&nbsp;&nbsp;来自："+json.address+"</li></ul>";
		new Insertion.Top('left',ipContent);
		
	
  } 
 });
	}
	
	
function GetSu(){
	$$('#GoogleSu li').each(Element.remove);
	$("GoogleSu").style.display = "block";
	if($F("word")!=""){
	var url="/GetSu.asp?k="+escape($F("word"));	
	addEventHandler(document, "mousedown", document_MouseDown);
		new Ajax.Request(url, { 
  		method: "get", 
		onSuccess: function(transport) { 
		var json = transport.responseText.evalJSON();
		//var ipContent;
		//ipContent="<ul class='ipadd'><li>IP："+json.ip+"&nbsp;&nbsp;&nbsp;&nbsp;来自："+json.address+"</li></ul>";
		//alert(json.size());
		//new Insertion.Top('left',ipContent);
		var thisLi;
		var topSu=json[1].size();
		if(json[1].size()>10){topSu=10;}
		for(var i=0;i<topSu;i++){
			thisLi="<li onclick=\"setKw('"+json[1][i][0]+"');\"  onMouseOver=\"this.className='on'\" onMouseOut=\"this.className=''\"><a href='javascript:void(0);'>"+json[1][i][0]+"</a></li>";
		new Insertion.Bottom('GoogleSu', thisLi); 
		
		}
	
  } 
 });
	
	}
	}
	
	function setKw(Kw){
		$("word").value=Kw;
		$("GoogleSu").style.display = "none";
		}
	
/////////////////////////

function addEventHandler(target, type, func) {
    if (target.addEventListener)
        target.addEventListener(type, func, false);
    else if (target.attachEvent)
        target.attachEvent("on" + type, func);
    else target["on" + type] = func;
}

function removeEventHandler(target, type, func) {
    if (target.removeEventListener)
        target.removeEventListener(type, func, false);
    else if (target.detachEvent)
        target.detachEvent("on" + type, func);
    else delete target["on" + type];
}


function document_MouseDown(e) {
    var element = typeof event != "undefined" ? event.srcElement : e.target;
    var downPanel = false;
    while (element) {
        downPanel = element == $("GoogleSu");
        if (downPanel) break;
        element = element.parentNode;
    }
    if (!downPanel) {
        removeEventHandler(document, "mousedown", document_MouseDown);
        $("GoogleSu").style.display = "none";
		//hideMe("itemsForDropdownLayer");
    }
}


/////////////////////////

function GetHanzi(zi){	
	var url="/GetHanzi.asp?zi="+escape(zi);	
	var hanziTemplete = new Template("<div id=\"hanzi\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"61\" height=\"60\" rowspan=\"2\" align=\"center\" valign=\"middle\" class=\"zi\" >#{zi}</td><td width=\"187\" height=\"29\" align=\"left\" valign=\"middle\">&nbsp;&nbsp;拼音：#{pinyin}</td><td width=\"207\">笔画：#{bihua}</td><td width=\"195\">&nbsp;</td></tr><tr><td align=\"left\" valign=\"middle\">&nbsp;&nbsp;部首：#{bushou}</td><td>五笔：#{wubi}</td><td>&nbsp;</td></tr></table></div>");
		new Ajax.Request(url, { 
  		method: "get", 
		onSuccess: function(transport) { 
		var json = transport.responseText.evalJSON();
		var hanziTemplete2=hanziTemplete.evaluate(json);
		//alert(hanziTemplete2);
		new Insertion.Before('searchultul',hanziTemplete2);
		
	
  } 
 });
	}
