function $(obj){
	return document.getElementById(obj);	
}
function kelongcode(objstr){
	var obj=$(objstr);
	code=obj.innerText;
	if(code=='') code=obj.value;
	window.clipboardData.setData("Text",code); 
	alert("成功复制以下内容：\r\n\r\n" + code); 
}

function viewqzone(url,width,height){
	var yz= /^[0-9]{4,12}$/;
	var d_obj = new Date();
	var t_obj = Math.round((d_obj.getTime()/1000)-1261900000);
	var timeint='_'+t_obj;
	var gturl=vu;
	if(gturl==null) gturl=cu;
	if(height==0 || width==0){
		w_h='fullscreen=yes';
	}else{
		w_h='width='+width+',height='+height;
	}
	if(yz.test(url)){
		window.open('http://'+url+'.qzone.qq.com','viewcode');
	}else{
		window.open(gturl+url+timeint,'viewcode',w_h+',scrollbars=yes');		
	}
} 

function viewqzone3(qid,qcode,width,height){
	if(qcode==null){
		viewqzone(qid,width,height);
	}else{
		viewqzone('/analyzer/'+qid+'/'+qcode,width,height);
	}
}

function viewqzone2(qqnum,codestr,width,height){
	if(height==0 || width==0){
		w_h='fullscreen=yes';
	}else{
		w_h='width='+width+',height='+height;
	}
	window.open(cu+'/search.php?qqid2='+qqnum+'&qzcode='+encodeURI(codestr),'viewcode',w_h+',scrollbars=yes');
} 

function doclone(job){
	var qq=$("kelong_key");
	var clonefrm=$('clonefrm');
	var d_obj = new Date();
	var t_obj = Math.round((d_obj.getTime()/1000)-1261900000);	
	if(qq.value!=''){
		var yz= /^[0-9]{4,12}$/;   
		if(yz.test(qq.value)==false) 
		{  
			alert("请输入正确的QQ号码！");
			qq.focus();
			return false;
		}
		clonefrm.action=cu+'/'+searchdir+'/'+job+'/'+qq.value+'_'+t_obj;
		clonefrm.submit();
	}else{
		alert('请输入QQ号码！');
		qq.focus();
		return false;
	}
	return false;
}
function cka(o){
	if(cu!==null) o.href=o.href.replace(/http\:\/\/[^\/]+?\//g,cu+"/");
}
function ckb(url){
	var a=document.createElement('A');
	a.href=url;
	document.body.appendChild(a);
	if(document.all){
		a.click();
	}else{
		window.location.href=url;
	}
}
function ckc(url){
	window.location.href=cu+url;
	return false;
}
function showphoto(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function encode64(input)
{
input = escape(input);
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;

do
{
   chr1 = input.charCodeAt(i++);
   chr2 = input.charCodeAt(i++);
   chr3 = input.charCodeAt(i++);
  
   enc1 = chr1 >> 2;
   enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
   enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
   enc4 = chr3 & 63;
  
   if (isNaN(chr2))
   {
    enc3 = enc4 = 64;
   }
   else if (isNaN(chr3))
   {
    enc4 = 64;
   }
  
   output = output +
   keyStr.charAt(enc1) +
   keyStr.charAt(enc2) +
   keyStr.charAt(enc3) +
   keyStr.charAt(enc4);
   chr1 = chr2 = chr3 = "";
   enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);

return output;
}

function decode64(input)
{
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
var base64test = /[^A-Za-z0-9\+\/\=]/g;
var keyStr='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

do
{
   enc1 = keyStr.indexOf(input.charAt(i++));
   enc2 = keyStr.indexOf(input.charAt(i++));
   enc3 = keyStr.indexOf(input.charAt(i++));
   enc4 = keyStr.indexOf(input.charAt(i++));
  
   chr1 = (enc1 << 2) | (enc2 >> 4);
   chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
   chr3 = ((enc3 & 3) << 6) | enc4;
  
   output = output + String.fromCharCode(chr1);
  
   if (enc3 != 64)
   {
    output = output + String.fromCharCode(chr2);
   }
   if (enc4 != 64)
   {
    output = output + String.fromCharCode(chr3);
   }
  
   chr1 = chr2 = chr3 = "";
   enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);
return unescape(output);
}

var cu=decode64(vcdurl);
var vu=decode64(vmdurl);
var iu=decode64(schurl);