function killErrors() {
return true;
}
window.onerror = killErrors;

function oCopy(str)
{
var clipBoardContent=str;
window.clipboardData.setData("Text",clipBoardContent);
alert("复制成功，您可以粘贴到你的 MSN/QQ/Blog/BBS 上推荐给你的好友");
}

//设定图片显示尺寸
var flag=false; 
function DrawImage(ImgD,w,h){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= w/h){ 
    if(image.width>w){ 
      ImgD.width=w; 
      ImgD.height=(image.height*w)/image.width; 
    }else{ 
      ImgD.width=image.width; 
      ImgD.height=image.height; 
    } 
  }else{ 
    if(image.height>h){ 
      ImgD.height=h; 
      ImgD.width=(image.width*h)/image.height; 
    }else{ 
      ImgD.width=image.width; 
      ImgD.height=image.height; 
    } 
  } 
} 
} 

// javascript 操作Cookies
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 365; //此 cookie 将被保存 365 天
    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)//取cookies函数        
{
    var err = "";
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return err;
}

function textLimitCheck(thisArea, maxLength){
  if (thisArea.value.length > maxLength){
    alert(maxLength + ' 个字限制. \r超出的将自动去除.');
    thisArea.value = thisArea.value.substring(0, maxLength);
    thisArea.focus();
  }
    messageCount.innerText = thisArea.value.length;
}
function tabit(btn){
  btn.className="curr";
  var idname = new String(btn.id);
  var s = idname.indexOf("_");
  var e = idname.lastIndexOf("_")+1;
  var tabName = idname.substr(0, s);
  var id = parseInt(idname.substr(e, 1));
  var tabNumber = btn.parentNode.childNodes.length;
  for(i=0;i<tabNumber;i++)
	  {
	  j=document.getElementById(tabName+"_div_"+i)
	  e=document.getElementById(tabName+"_btn_"+i)
	  if ((tabName+"_btn_"+i) != idname)
	  {e.className="";
	  j.style.display = "none";
	  }else{
	  j.style.display = "block";
	  }
	  };
};
var fodTime;
function delaytabit(btn){
clearTimeout(fodTime);
fodTime=setTimeout(function(){tabit(btn)},100);
}
function openIframeDialog(tit,url,w,h){
if ($("#IframeDialogBox").length>0){$(".ui-dialog").remove();}
$("body").append("<div id='IframeDialogBox' class='flora' />")
$("<iframe src='"+url+"' frameborder='0' width='100%' height='100%' scrolling='no' allowtransparency='true' class='flora' />").appendTo($("#IframeDialogBox"));
$("#IframeDialogBox").dialog({autoOpen:true,title:tit,width:w,height:h,resizable:false,modal:true,overlay:{opacity:0.5,background:"black"}});
}

function closeIframeDialog(){
$('#IframeDialogBox').dialog('close');
}
// 显示无模式对话框
function ShowDialog(url, width, height) {
	var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
}
//加入收藏夹代码
function addBookmark(title,url,desc)   
{
	if (window.sidebar) {  
		window.sidebar.addPanel(title, url,desc); //Mozilla browser  
	} else if( document.all ) { //IE browser  
		window.external.AddFavorite(url,title);   
	} else if( window.opera && window.print ) { //Not Support Now  
		return true;  
	}  
} 
 
//设为首页代码
function setHomepage(url)
{
	if (document.all)
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('url');
	} else if (window.sidebar) {
		if(window.netscape)
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			}
			catch (e) 
			{
				alert("Firefox暂无此功能，请手动设置。" ); 
			}
		}
	var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
	prefs.setCharPref('browser.startup.homepage','url');
	}
}
function InitAjax(){
var ajax=false; 
try { ajax = new ActiveXObject("Msxml2.XMLHTTP"); } 
catch (e) { try { ajax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { ajax = false; } }
if (!ajax && typeof XMLHttpRequest!='undefined') { ajax = new XMLHttpRequest(); } 
return ajax;}

//公用ajax
function ToAjax(url,Post){
	if (url!=""){
		var getinfo = "";
		var ajax = InitAjax();
		ajax.open("POST", url, true); 
		ajax.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded; charset=GB2312"); 
		ajax.send(Post);
	    ajax.onreadystatechange = function(){
		  if (ajax.readyState == 4){getinfo = ajax.responseText;}
	      AjaxShow.innerHTML = getinfo;
		  }
	}
}
