var $ = function(id){
	return document.getElementById(id);
};


//复制代码

function Copytxt(id)
{
 var txt = document.body.createTextRange();
 txt.moveToElementText($(id));
 txt.select();
 document.execCommand("Copy"); 
}

//加入IM群
function button10_onclick(aa) 
{
    try{
		var im  = new ActiveXObject("HCLogin.DetectHcIM");
		var groupid=aa;
		var ret = im.join_qun(groupid);
	}
	catch(e)
	{
		return false;//提示用户不是最新的版本，请重新登陆IM！
	}
	return true;
}

//与用户聊天
function sjb_CallFriend(toTmUsr){
  try{//安装
  	var xmlhttp1 = new ActiveXObject("HCLogin.DetectHcIM");
  	var ret;
	ret = xmlhttp1.IMIsStart();
	if(ret == 1)
	{
		alert("买卖通IM未运行，请先运行买卖通IM！");
	}
	else
	{
		xmlhttp1.chat_with_friend(toTmUsr);	
	}
  }
  catch(e){//没安装 

  	window.open("http://www.im.hc360.com/pop3.htm", "","toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=no,resizable=no,copyhistory=no,width=310,height=156");
  	//window.open("http://www.im.hc360.com/IM/files/help.html");
  }
  return false;
}

//删除双重BR
function delbr(id,num){
	var dobj = $(id);
	var tdobj = dobj.getElementsByTagName("td");
	var con,temcon,tcode;
	for(i=0;i<tdobj.length;i++){
		con = tdobj[i].innerHTML;
		if(num==1)
			tdobj[i].innerHTML = con.substring(0,con.length-4);
		else
			tdobj[i].innerHTML = con.replace(/(\<br\>)+/gi,"<br>");		
	}
}
/*function delbr(id){
	var dobj = $(id);
	var tdobj = dobj.getElementsByTagName("td");
	var con,temcon,tcode;
	for(i=0;i<tdobj.length;i++){
		con = tdobj[i].innerHTML;
		tcode = con.split("<BR><BR>");
	temcon = tcode.join("<BR>");
		tdobj[i].innerHTML = temcon;
	}

}*/


//控制页面广告后载
function endAdv(str1,str2,initheight){
	$(str1).style.height = initheight + "px";
	$(str1).innerHTML = $(str2).innerHTML;
	$(str2).innerHTML = "";
}


//文本框获取焦点//针对:好耶iframe广告抢走input=text焦点
function inputFocus(obj){
	$(obj).focus();
}


// 自动检索url地址并重新赋带参数的url 
// AUTHOR:JULLYCAT
//@parm urlIndex(检索的url,加参的标识,显示当前加载页的状态是iframe则设参不是则不写) 

function urlIndex(url,pname,t){
	var aChild = new Array;
	var pos = new Array;
	var trades = new Array;
	var temppos,pageUrl,parm,trade,n;
	aChild = document.getElementsByTagName("a");
	for(var i=0;i<aChild.length;i++){
		if (aChild[i].href == url){
			temppos = i;
			pos.push(temppos);
		}
	}
	if(arguments[2]==null){
		pageUrl = location.href;
		if (pageUrl.indexOf("html")==-1 && pageUrl.indexOf("htm")==-1){
			parm = "index";
		}
		else{
			parm = pageUrl.substring(pageUrl.lastIndexOf("/")+1,pageUrl.lastIndexOf("."));
		}
	}else{
		parm = location.search.substring(1);
	}
	trades = location.href.split(".");
	for(var m=0;m<trades.length;m++){
		if(trades[m].toLowerCase() == "hc360"){
			n = m;
			break;
		} 
	}
	if(n!=2){
		trade = trades[0].substring(trades[0].indexOf("http://")+7).toLowerCase();
		if(trade=="www" || trade=="active" || trade=="info") trade = "";
		else trade = trade + "_";
	}else{
		trade = trades[1] + "_";
	}
	for(var j=0;j<pos.length;j++){
		aChild[pos[j]].href = url + "?" + pname + "=" + trade + parm;
	}
}


var curIndex = window.location.href;
window.attachEvent('onbeforeunload',function(){
var   n   =   window.event.screenX   -   window.screenLeft;
var   b   =   n   >   document.documentElement.scrollWidth-20;
	if(curIndex.indexOf("hc360.com")!=-1 && curIndex.indexOf(".html")==-1 && curIndex.indexOf(".shtml")==-1 && curIndex.indexOf(".htm")==-1 && curIndex.indexOf("http://info")==-1 && curIndex.indexOf("http://www.hc360.com")==-1){
		if(b   &&   window.event.clientY   <   0   ||   window.event.altKey)   
		{
//			window.open("http://www.hc360.com","hc","");
			window.showModalDialog("http://www.hc360.com/",window,"dialogWidth:"+(window.screen.width-20)+"px;dialogTop: 20px; dialogLeft: 20px;resizable:yes;status:yes;scrollbars:yes;toolbar:yes;");
		}
	}
});

/*var curIndex = window.location.href;
window.attachEvent('onunload',function(){
	if(curIndex.indexOf(".hc360.com")!=-1 && curIndex.indexOf(".html")==-1 && curIndex.indexOf(".shtml")==-1 && curIndex.indexOf(".htm")==-1 && curIndex.indexOf("http://info")==-1&&curIndex.indexOf("http://www.hc360.com")==-1){
		window.open("http://www.hc360.com","","");
	}
});
*/