/* copyright by nece001@163.com */
//屏蔽错误JS
function ResumeError() { 
return true; 
} 
//window.onerror = ResumeError;
	
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openchat()
{
   window.setTimeout("KF_openBrWindow()",5000);
}

function GetCookie(sName)
{
	var aCookie = document.cookie.split("; ");
    var re="";
	for (var i=0; i < aCookie.length; i++)
	{
	  
	  var aCrumb = aCookie[i].split("=");
	  if (sName == aCrumb[0])  
	    return unescape(aCrumb[1]);
	}
	return re;
}

var win;
function KF_openBrWindow()
{ //v2.0
   try
   {
	  if(win && win.name==id)
	  {
		  alert('您已經打開一個聊天室視窗，請先關掉或重新整理本網頁！');
		  win.focus();
		  return false;
	  }
	  
	  var fsn="";
	  var froomid="";
	  if(GetCookie('MemberSN').length>0)//访客sn MemberSN DoubleCheckUid HalfYearUid2
	  {
	    fsn=GetCookie('MemberSN');
	  }
	  if(GetCookie('DoubleCheckUid').length>0)//访客昵称
	  {
	    froomid= GetCookie('DoubleCheckUid');
	  }
	
	  if(document.all)
	  { 
		 win=window.open('http://match.ek21.com/chat/chat2.php?fsn='+fsn,fsn,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=435,left=100,top=100');
	  }
	  else
	  { 
	     win = window.open('http://match.ek21.com/chat/chat2.php?fsn='+fsn,fsn,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=435,left=100,top=100');
	  }
	 win.focus();
	
   }
   catch(e)
   {alert(e);}
}

var __js_file_common = true;

String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}
String.prototype.ltrim = function(){return this.replace(/(^\s*)/g, "");}
String.prototype.rtrim = function(){return this.replace(/(\s*$)/g, "");}
String.prototype.empty = function(){return this.length == 0;}
String.prototype.bytes = function(){return this.replace(/[^\x00-\xff]/g, "**").length;}

if(typeof(HTMLElement) != "undefined") // for firefox
{  
	HTMLElement.prototype.contains = function(obj)
	{  
		while(obj != null && typeof(obj.tagName) != "undefind")
		{
	　　　　if(obj==this) return true;
	　　　　obj=obj.parentNode;
	　　}
		return false;
	};
}

function $(id)
{
	return document.getElementById(id);
}

function hide(id)
{
	var o=document.getElementById(id);
	o.style.display="none";
}

function show(id)
{
	var o=document.getElementById(id);
	o.style.display="";
}

function addEvent(obj,evtname,fun)
{
	if (obj.addEventListener){
		obj.addEventListener(evtname, fun, false);
	} else if (obj.attachEvent){
		obj.attachEvent('on' + evtname, fun);
	}else {
		obj['on' + evtname] = func;
	}
}

function getAbsPos(obj)
{
	var pos = new Object();
	pos.x = pos.y = 0;
	pos.w = obj.offsetWidth;
	pos.h = obj.offsetHeight;
	while(obj != (document.body ? document.body : document.documentElement))
	{
		pos['y'] += obj.offsetTop;
		pos['x'] += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return pos;
}

function addBookMark(title,url)
{
    var nome_sito = title;
    var url_sito = url;
	try{
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt
    (navigator.appVersion) >= 4))
    window.external.AddFavorite(url_sito, nome_sito);
    else if (navigator.appName == "Netscape")
    window.sidebar.addPanel(nome_sito, url_sito, '');
    }catch(e){
    alert("Sorry!Cann't Add this site to your favorite!.");
	}
}

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("err:\r\n" + e.message);
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',url);
         }
    }
}

function queryParams()
{
	var search = location.search.substr(1).split('&');
    var params = new Array();
	var dict;
	for(var i=0;i<search.length;i++)
    {
		dict = search[i].split('=');
		params[dict[0]] = dict[1];
    }
	return params;
}
var $_get = queryParams();


function orderLink(colno)
{
	var request = $_get;
	var search = '';
	var text = '▲';
	for(a in request)
	{
		if(a != 'colno' && a != 'asc')
		search += a+'='+request[a]+'&';
	}

	search += 'colno='+colno;
	if(request['colno'] == colno)
	{
		if(request['asc'] == 1)
		{
			text = '▲';
		}else
		{
			search += '&asc=1';
			text = '▼';
		}
	}

	document.write('<a href="?'+ search +'">'+ text +'</a>');
}

// CheckBox Element Control Show Or Hidden For Block By BlockId
function checkSH(checkbox,blockId)
{
    var block = $(blockId);
    if(checkbox.checked)
    {
		block.style.display = "";
    }
    else
    {
		block.style.display = "none";
    }
}

// Check All || Not Check All CheckBox
function selectAllCheckBox(name,all)
{
	var eles = document.getElementsByName(name);
	for(var i=0;i<eles.length;i++)
	{
		/*if(all==false)
		{*/
			eles[i].checked = !eles[i].checked;
	/*	}else
		{
			eles[i].checked = true;
		}*/
	}
}

function timeHref(url,timeout)
{
	timeout *= 1000;
	var t = setTimeout(function(){
		clearTimeout(t);
		location.href=url;
	},timeout);
}

function getSelectText(id)
{
    var sel = $(id);
    return sel.options[sel.selectedIndex].text;
}

function eoomImg(obj,size)
{
    var w = parseInt(obj.width);
    var h = parseInt(obj.height);

    if(w <= h)
    {
        obj.style.width = size+'px';
        obj.style.height = 'auto';
    }else
    {
        obj.style.width = 'auto';
        obj.style.height = size+'px';
    }
}