var set_jiemu;
function addfavorite(url,text)
{
   switch(getOs())
   {
       case 1:window.external.addFavorite(url,text);break;
       case 2:window.sidebar.addPanel(text, url, "");break;
       case 0:break;
   }
}
function getOs()
{
   if(navigator.userAgent.indexOf("MSIE")>0)return 1;
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
   if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 3;   
   if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 4;
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)return 5;
   return 0;
}

function tabMouseover(ul,d){
	var dd=d.childNodes;
	for(var i=0;i<dd.length;i++){
		if(dd[i].nodeName=="#text")d.removeChild(dd[i]);;
	}

  $A(ul.getElementsByTagName("li")).each(function(item){
    if(window.attachEvent){
      item.attachEvent("onmouseover",function(){return tab_Mouseover(item,ul,d)});
    }else{
      item.addEventListener("mouseover",function(){return tab_Mouseover(item,ul,d)},false);
    }
  });
}
function tab_Mouseover(o,ul,d){
  var count=0;
  if(o.getAttribute("event")!="no"){
	  $A(ul.getElementsByTagName("li")).each(function(item){
	    item.className="";
	    //if(d.childNodes[count].nodeName=="#text")count++;
	    d.childNodes[count].style.display="none";
	    if(item==o){
	      o.className="hover";
	      d.childNodes[count].style.display="block";
	    }
	    count++;
	  });
	}
}

function imgerr(o,s){
	try{
		if(""+o.getAttribute("nopic")!="yes"){
			o.setAttribute("nopic","yes");
			if(s){
				o.src=s;
			}else{
				o.src=(""+o.src).replace('_lit.','.');
			}
		}else{
			o.src="http://www.iqilu.com/templets/img/dfpic.gif";
		}
	}catch(e){}
}


function setCookie(name,value)
{
    var Days = 30;
    var exp  = new Date();    //new Date("December 31, 9998");
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}
function delCookie(name)
{
    var exp = new Date();
        exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
        if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function show(d){
	clearTimeout(set_jiemu);
	var h=parseInt((""+d.style.height).replace("px",""));
	//alert(h);
	d.style.height=(h+1)+"px";
	h=parseInt((""+d.style.height).replace("px",""));
	if(h<20){
		set_jiemu=setTimeout(function(){
			show(d);
		},1);
	}else{
		set_jiemu=setTimeout(function(){
			hid(d);
		},5000);
	}
}

function hid(d){
	clearTimeout(set_jiemu);
	var h=parseInt((""+d.style.height).replace("px",""));
	d.style.height=(h-1)+"px";
	h=parseInt((""+d.style.height).replace("px",""));
	if(h>0){
		set_jiemu=setTimeout(function(){
			hid(d);
		},1);
	}else{
	//alert(d.nextSibling);
		if(d.nextSibling){
			show(d.nextSibling)
		}else{
			for(var j=0;j<d.parentNode.childNodes;j++){
				d.parentNode.childNodes[j].height="20";
			}
			show(d.parentNode.firstChild);
		}
	}
}

function showSearch1(o){
	var searchform=document.getElementById("searchform");
	searchform.q.value="site:iqilu.com "+o.innerHTML;
	searchform.submit();
	return false;
}

function showSearch(o){
	var searchform=document.getElementById("searchform");
	searchform.q.value=""+o.innerHTML;
	searchform.submit();
	return false;
}

function copyToClip(){
	setTimeout(copyClip,100);
}
function copyClip() {
	var t=cptxt();
	if(t.length>10){
		t+="Ô­ÎÄ("+(""+window.location).replace("news.iqilu.com","www.iqilu.com/html/news")+")";
		var flashcopier = 'flashcopier';
		var swfcopier=document.getElementById(flashcopier);
		if(swfcopier) {
			swfcopier.parentNode.removeChild(swfcopier);
		}
		var divholder = document.createElement('div');
		divholder.id = flashcopier;
		document.body.appendChild(divholder);
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="http://www.iqilu.com/images/_clip.swf" FlashVars="clipboard='+encodeURIComponent(t)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
}
function cptxt(){
	var g;
	if(document.all){
		g = document.selection.createRange().text;
	}else{
		g=document.getSelection();
	}
	return g;
}

function returnXmlValue(url,funstr) {
		var xmlreader = 'xmlreader';
		var swfreader=document.getElementById(xmlreader);
		if(swfreader) {
			swfreader.parentNode.removeChild(swfreader);
		}
		var divholder = document.createElement('div');
		divholder.id = xmlreader;
		document.body.appendChild(divholder);
		document.getElementById(xmlreader).innerHTML = '';
		var divinfo = '<embed src="http://www.iqilu.com/templets/new_root_images/xml.swf" FlashVars="xmlfile='+encodeURIComponent(url)+'&fun='+funstr+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(xmlreader).innerHTML = divinfo;
}
