

var isIE = (document.all) ? true : false;

function trim(str){
	return str.replace(/(^\s*)|(\s*$)|(　*)/g , "");
}

function getEvent(){
	if(document.all){
		return window.event;
	}
	func=getEvent.caller;
	while(func!=null){
		var arg0=func.arguments[0]; 
		if(arg0){ 
			if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){  
				return arg0; 
			} 
		} 
		func=func.caller; 
	} 
	return null; 
}

function Get_mouse_position(loc){
	var event=getEvent();
	if(navigator.appName=='Microsoft Internet Explorer'){
		if(loc=="loc"){
			return [event.x+document.documentElement.scrollLeft,event.y+document.documentElement.scrollTop];
		}else if(loc=="frame"){
			return [event.x+window.screenLeft-120,event.y+window.screenTop-120];
		}else{
			return [frame_content.event.x+frame_content.screenLeft-window.screenLeft,frame_content.event.y+frame_content.screenTop-window.screenTop];
		}
	}else if(navigator.appName=='Netscape'){
			if(loc=="loc"){
				return [event.pageX,event.pageY];
			}else{
				return [event.pageX,event.pageY+30];
			}
	}
}

function InitXMLDOM(){
  if(window.ActiveXObject){
		var oXmlDom = new ActiveXObject("Microsoft.XMLDOM");
	}else{
		var oXmlDom = document.implementation.createDocument("","",null);
	}
	return oXmlDom;
}

var $ = function (id) {
	return "string" == typeof id ? document.getElementById(id) : id;
};

function nTabs(tabObj,obj){
var tabList = $(tabObj).getElementsByTagName("a");
for(i=0; i <5; i++)
{
   if (tabList[i].id == obj.id)
   {
   	   $(tabObj+"_Title"+i).className = "active"; 
   }else{
    $(tabObj+"_Title"+i).className = "normal"; 
   }
}
}
///////////
function toggle(targetid,type_id,mod_id){
       var  target=$(targetid+"_"+type_id+"_"+mod_id);
             if (target.style.display==""){
				 $("openreply_"+type_id+"_"+mod_id).innerHTML = "回复";
                 target.style.display="none";
             } else {
				 $("openreply_"+type_id+"_"+mod_id).innerHTML = "收起回复";
                 target.style.display="";
             }
}
var settimeouti = '';
var togglestatu = true;
function toggle2(targetid){
	var target=$(targetid+'_2');
	var target2=$(targetid+'_1');
	var input2=$(targetid+'_input');

	if (target.style.display=="none"){
		target.style.display="";
		target2.style.display="none";
		input2.focus();
	} else {
		if(input2.value=='') {
			togglestatu = true;
			settimeouti = setTimeout("toggleshow_1('"+targetid+"')",500);
		}
	}
}

function toggleshow_1(targetid) {
	if(togglestatu) {
		var target=$(targetid+'_2');
		var target2=$(targetid+'_1');
		var input2=$(targetid+'_input');
		target.style.display="none";
		target2.style.display="";
		$('face_list_menu').style.display = 'none';
	}
}

function showim() {
	togglestatu = false;
	// 显示表情操作。。。
}
//侧边栏
function showDiv (){
	$('sidebar').style.display = 'none';
	$('bigpart').style.width = 773 + 'px';
	$('bar').style.display = '';
	$('img').style.display = 'none';
	if(frame_content.document.getElementById('secNav')){
	frame_content.document.getElementById('secNav').style.width = 84.6 + '%';
	}
  	if(frame_content.document.getElementById('mood_txt')){
	frame_content.document.getElementById('mood_txt').style.width = 83 + '%';
	}
	
}
function hiddenDiv (){
	$('bar').style.display = 'none';
	$('img').style.display = '';
	$('bigpart').style.width = 593 + 'px';
	$('sidebar').style.display = '';
	if(frame_content.document.getElementById('secNav')){
	frame_content.document.getElementById('secNav').style.width = 80 + '%';
	}
	if(frame_content.document.getElementById('mood_txt')){
	frame_content.document.getElementById('mood_txt').style.width = 78 + '%';
	}  	
}
function showDiv2 (){
	$('sidebar').style.display = 'none';
	$('bigpart').style.width = 736 + 'px';
	$('bar').style.display = '';
	$('img').style.display = 'none';
}
function hiddenDiv2 (){
	$('bar').style.display = 'none';
	$('img').style.display = '';
	$('bigpart').style.width = 553 + 'px';
	$('sidebar').style.display = '';
}


//feed按钮
function feed_menu(feedid, show) {
	var obj = $('a_feed_menu_'+feedid);
	if(obj) {
		if(show) {
			obj.style.display='block';
		} else {
			obj.style.display='none';
		}
	}
}

//feed菜单
function ajaxmenu(obj,ctrlid,uid,type_id) {
	var div = $(ctrlid + '_menu');
	var parentnode = $('append_parent');
	var divs = parentnode.childNodes;
	var t = obj.offsetTop;   
    var l = obj.offsetLeft;
	var height=obj.offsetHeight;   
    var width=obj.offsetWidth;   
    while(obj=obj.offsetParent) {   
        t+=obj.offsetTop;   
        l+=obj.offsetLeft;   
    } 
	for(i=0;i<divs.length;i++){
		if(divs[i].nodeType == 1){
			parentnode.childNodes[i].style.display = 'none';
		}
	}
	if(!div) {
		div = document.createElement('div');
		div.id = ctrlid + '_menu';
		div.className = 'popupmenu_popup';
		div.style.top = (t + 20) + 'px';
		div.style.left = (l - 170) + 'px';
		div.style.zIndex = 100;
		div.innerHTML = "<h1>屏蔽动态</h1><div class=\'popupmenu_inner\' id=\'content_hidden\'><p>在下次浏览时不再显示此类动态</p><p class=\'btn_line\'><input type=\'radio\' checked=\'\' name=\'hidden_type\' value="+uid+" /><label>仅屏蔽该好友信息</label><br/><input type=\'radio\' value="+type_id+" name=\'hidden_type\' /><label>屏蔽该类别信息</label><br/><br/><button class=\'top_button\' value=\'true\' type=\'button\' onclick=hidden_affair();>确定</button><button id="+ctrlid+"_del class=\'top_button\' value=\'true\' type=\'button\' onclick=hidden_affair();>取消</button></p></div>";
		$('append_parent').appendChild(div);
	}
	div.style.display = '';
	var del_bt = $(ctrlid+'_del');
	if(del_bt){
		del_bt.onclick = function(){div.style.display = 'none';}
	}
}
//屏蔽动态
function hidden_affair(){
obj=document.getElementsByName("hidden_type");
if(obj[0].checked){
	var hidden_value=obj[0].value;
	var t_hidden=0;
}else{
	var hidden_value=obj[1].value;
	var t_hidden=1;
}
var xmlhttp=InitAjax();
xmlhttp.open("GET","do.php?act=pr_affair&type="+t_hidden+"&hidden_value="+hidden_value+"&is_del=0");
xmlhttp.onreadystatechange=function(){
	if(xmlhttp.readyState==4&&xmlhttp.status==200){
		var xmlhttp_text=trim(xmlhttp.responseText);
		if(xmlhttp_text=='success'){
			parent.Dialog.alert('设置成功');
			window.location.reload();
		}else{
			parent.Dialog.alert(xmlhttp_text);
		}
	}
}
xmlhttp.send(null);
}
//change class
var oldclassname = '';
function addClass (obj,newClass){
	oldclassname = obj.className;
	obj.className = obj.className + ' ' +newClass;
}
function removeClass(obj,newclass){
	obj.className = oldclassname;
}
//createAge
function createAge(){
	$('select_age_b').innerHTML = '';
	$('select_age_e').innerHTML = '';
	$('age_begin').value = $('select_age_b').value;
	$('age_end').value = $('select_age_e').value;
	for(i=18;i<100;i++){
		$('select_age_b').options[$('select_age_b').options.length] = new Option(i,i);
		$('select_age_e').options[$('select_age_e').options.length] = new Option(i,i);
	}
}
function createAge2(){
	$('select_age_e').innerHTML = '';
	var j = parseInt($('select_age_b').value);
	for(i=j;i<100;i++){
		$('select_age_e').options[$('select_age_e').options.length] = new Option(i,i);
	}
}
//search
function showBox(id){
	for(i=0;i<3;i++){
		if(i!=id){
			$('showssBox_'+i).style.display = 'none';
		}
		$('showssBox_'+id).style.display = ($('showssBox_'+id).style.display == 'none')?'block':'none';
	}
}
//setArea
function setArea(){
	if($('q_city').value == ''){
		if($('q_province').value == ''){
			$('area').innerHTML = '不限';
		}else{
			$('area').innerHTML = $('q_province').value;
		}	
	}else if($('q_city').value == '不限'){
		$('area').innerHTML = $('q_province').value;
	}else{
		$('area').innerHTML = $('q_city').value;
	}
	$('showssBox_0').style.display = 'none';
}
//setAge
function setAge(){
	$('age_begin').value = $('select_age_b').value;
	$('age_end').value = $('select_age_e').value;
	if($('age_begin').value == $('age_end').value){
		$('age').innerHTML = $('age_begin').value;
	}else{
		$('age').innerHTML = $('age_begin').value + '-' + $('age_end').value;
	}
	$('showssBox_1').style.display = 'none';
}
//setgender
function setGender(obj){
	$('gender').innerHTML = obj.innerHTML;
	$('showssBox_2').style.display = 'none';
}
//showFace
function showFace(obj,name,target){
	$(name).style.display = 'none';	
	var t=obj.offsetTop;
    var l=obj.offsetLeft;
	var height=obj.offsetHeight;   
    var width=obj.offsetWidth;   
    while(obj=obj.offsetParent) {
        t+=obj.offsetTop;
        l+=obj.offsetLeft;   
    }
	if(target == 'mood_txt' || target == 'mood'){
		$(name).style.top = (t+34) + 'px';
		$(name).style.left = (l) + 'px';
		$(target).focus();
		togglestatu = true;
	}else{
		$(name).style.top = (t+25) + 'px';
		$(name).style.left = (l-197) + 'px';
		$(target).focus();
		togglestatu = false;
	}
		$(name).style.display = '';
	$(name).innerHTML = "<div class=\'emItem\' onmouseover=addClass(this,\'emAct\') onmouseout=removeClass(this,\'emAct\') onclick=insertFace(\'"+name+"\',1,\'"+target+"\') title=\'微笑\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',2,\'"+target+"\') title=\'呲牙笑\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',3,\'"+target+"\') title=\'偷笑\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',4,\'"+target+"\') title=\'吐舌\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',5,\'"+target+"\') title=\'色迷迷\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',6,\'"+target+"\') title=\'害羞\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',7,\'"+target+"\') title=\'耍酷\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',8,\'"+target+"\') title=\'晕\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',9,\'"+target+"\') title=\'疑惑\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',10,\'"+target+"\') title=\'-_-|||\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',11,\'"+target+"\') title=\':(\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',12,\'"+target+"\') title=\'不满\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',13,\'"+target+"\') title=\'吃惊\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',14,\'"+target+"\') title=\'不明白\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',15,\'"+target+"\') title=\'生气\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',16,\'"+target+"\') title=\'暴怒\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',17,\'"+target+"\') title=\'睡觉\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',18,\'"+target+"\') title=\'闭嘴\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',19,\'"+target+"\') title=\'衰\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',20,\'"+target+"\') title=\'猪头\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',21,\'"+target+"\') title=\'红心\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',22,\'"+target+"\') title=\'心碎\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',23,\'"+target+"\') title=\'鲜花\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',24,\'"+target+"\') title=\'花谢\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',25,\'"+target+"\') title=\'晚安\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',26,\'"+target+"\') title=\'拍砖\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',27,\'"+target+"\') title=\'钱\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',28,\'"+target+"\') title=\'便便\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',29,\'"+target+"\') title=\'呕吐\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',30,\'"+target+"\') title=\'扁你\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',31,\'"+target+"\') title=\'好\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',32,\'"+target+"\') title=\'鼓掌\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',33,\'"+target+"\') title=\'支持你\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',34,\'"+target+"\') title=\'鄙视你\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',35,\'"+target+"\') title=\'服了\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',36,\'"+target+"\') title=\'服了\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',37,\'"+target+"\') title=\'ok\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',38,\'"+target+"\') title=\'握手\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',39,\'"+target+"\') title=\'抱抱\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',40,\'"+target+"\') title=\'抽你\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',41,\'"+target+"\') title=\'亲一个\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',42,\'"+target+"\') title=\'委屈\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',43,\'"+target+"\') title=\'痛哭\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',44,\'"+target+"\') title=\'惊叫\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',45,\'"+target+"\') title=\'抓狂\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',46,\'"+target+"\') title=\'烧香\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',47,\'"+target+"\') title=\'期待\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',48,\'"+target+"\') title=\'喊话\'></div><div class=\'emItem\' onmouseover=addClass(this,'emAct') onmouseout=removeClass(this,'emAct') onclick=insertFace(\'"+name+"\',49,\'"+target+"\') title=\'爽歪歪\'></div>"	;	
}																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																												
//add、remove Class
var oldclassname = '';
function addClass (obj,newClass){
	oldclassname = obj.className;
	obj.className = obj.className + ' ' +newClass;
}
function removeClass(obj,newclass){
	obj.className = oldclassname;
}
//insertFace
var timeout;
function insertFace (name,id,target){
	togglestatu = false;
	if(target == 'mood_txt'){
		$(name).style.display = '';
		clearTimeout(timeout);
	}else{
		$(name).style.display = 'none';
	}
	$(target).style.display = '';
	$(target).focus();
	var faceText = '[em_'+id+']';
	if($(target) != null) {
		$(target).value += faceText;
	}
}
function setHidden(obj){
	//$(obj).style.display = ($(obj).style.display == 'none')?'block':'none'
	$(obj).style.display = 'none';
}
function show(obj,t_time){
	//$(obj).style.display = 'none';
	timeout = setTimeout("setHidden('"+obj+"')",t_time);
}
/* 1128*/

function reSetIframeHeight(){
	var iObj=parent.document.getElementById('frame_content');
	iObj.height='100px';
	parent.reinitIframe();
}

//最大字符量限制
function isMaxLen(o){
  var nMaxLen=o.getAttribute? parseInt(o.getAttribute("maxlength")):"";  
  if(o.getAttribute && o.value.length>nMaxLen){  
  	o.value=o.value.substring(0,nMaxLen)  
  }  
}

//批量选择
	function select_attach(type_value){
		var mail_array=document.getElementsByName('attach[]');
		var num=mail_array.length;
		is_checked='checked';
		if(type_value==0){
			is_checked='';
		}
		for(array_length=0;array_length<num;array_length++){
				mail_array[array_length].checked=is_checked;
		}
	}