/*//显示表情菜单
function showFace(showid, target) {
	var div = $('face_bg');
	if(div) {
		div.parentNode.removeChild(div);
	}
	div = document.createElement('div');
	div.id = 'face_bg';
	div.style.position = 'absolute';
	div.style.left = div.style.top = '0px';
	div.style.width = '100%';
	div.style.height = document.body.scrollHeight + 'px';
	div.style.backgroundColor = '#000';
	div.style.zIndex = 10000;
	div.style.display = 'none';
	div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0,finishOpacity=100,style=0)';
	div.style.opacity = 0;
	div.onclick = function() {
		$(showid+'_menu').style.display = 'none';
		$('face_bg').style.display = 'none';
	}
	$('append_parent').appendChild(div);
	
	if($(showid + '_menu') != null) {
		$(showid+'_menu').style.display = '';
	} else {
		var faceDiv = document.createElement("div");
		faceDiv.id = showid+'_menu';
		faceDiv.className = 'facebox';
		faceDiv.style.position = 'absolute';
		var faceul = document.createElement("ul");
		for(i=1; i<11; i++) {
			var faceli = document.createElement("li");
			faceli.innerHTML = '<img src="image/face/'+i+'.gif" onclick="insertFace(\''+showid+'\','+i+', \''+ target +'\')" style="cursor:pointer; position:relative;" />';
			faceul.appendChild(faceli);
		}
		faceDiv.appendChild(faceul);
		$('append_parent').appendChild(faceDiv)
	}
	//定位菜单
	setMenuPosition(showid, 0);
	div.style.display = '';
}
//插入表情
function insertFace(showid, id, target) {
	var faceText = '[em:'+id+':]';
	if($(target) != null) {
		insertContent(target, faceText);
	}
	$(showid+'_menu').style.display = 'none';
	$('face_bg').style.display = 'none';
}

function textCounter(obj, showid, maxlimit) {
	var len = strLen(obj.value);
	var showobj = $(showid);
	if(len > maxlimit) {
		obj.value = getStrbylen(obj.value, maxlimit);
		showobj.innerHTML = '0';
	} else {
		showobj.innerHTML = maxlimit - len;
	}
	if(maxlimit - len > 0) {
		showobj.parentNode.style.color = "";
	} else {
		showobj.parentNode.style.color = "red";
	}
	
}
function getStrbylen(str, len) {
	var num = 0;
	var strlen = 0;
	var newstr = "";
	var obj_value_arr = str.split("");
	for(var i = 0; i < obj_value_arr.length; i ++) {
		if(i < len && num + byteLength(obj_value_arr[i]) <= len) {
			num += byteLength(obj_value_arr[i]);
			strlen = i + 1;
		}
	}
	if(str.length > strlen) {
		newstr = str.substr(0, strlen);
	} else {
		newstr = str;
	}
	return newstr;
}
function byteLength (sStr) {
	aMatch = sStr.match(/[^\x00-\x80]/g);
	return (sStr.length + (! aMatch ? 0 : aMatch.length));
}
function strLen(str) {
	var charset = document.charset; 
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == "utf-8" ? 3 : 2) : 1;
	}
	return len;
}*/

//Menu 菜单
function $id(id)
{
	return document.getElementById(id);
}

function getPara()
{
	if (location.search)
	{
		var Para = (location.search).substring(1);
		var sourceArr = [];
		sourceArr = Para.split("&");
		var paraArr = []
		for (var i = 0; i < sourceArr.length; i++)
		{
			paraArr[i] = sourceArr[i].split("=");
		}
		$id("p" + paraArr[0][1]).className = "navOpen";
		$id("menu" + paraArr[0][1]).style.display = "block";
		$id("c" + paraArr[0][1] + "_" + paraArr[1][1]).className = "active";
	}
}


function Status(obj,menu)
{
	if (obj.className == "navClose")
	{
		obj.className = "navOpen";
		$id(menu).style.display = "block";
	}
	else
	{
		obj.className = "navClose";
		$id(menu).style.display = "none";
	}
}


//Focus
var rollCoun;
var rollPeriod = 3000;
var isStart = true;
var nn = 1;
var tt = false;
function change_img() {
  if (isStart) {
    if (nn > rollCount) {
	  nn = 1;
	}
    setFocus(nn);
  }else{
    tt = setTimeout('change_img()', 2000);
  } 
}
function setFocus(i){
  if (tt) {
	clearTimeout(tt);
  }
  selectLayer1(i);
  nn=parseInt(i)+1;
  tt=setTimeout('change_img()', rollPeriod);
}
function selectLayer1(i){
  for (var j = 1; j <= rollCount; j++) {
	if (j == i)	{
	  document.getElementById("focus" + j).className = "";
	  document.getElementById("change" + j).className="current";
	} else {
	  document.getElementById("focus" + j).className = "hidden";
	  document.getElementById("change" + j).className="";
	}
  }
}


//导航nav
var srh = {};
srh.__init__ = function() {
	srh.initSearch();
}

srh.search = function(text, type) {
	text = encodeURIComponent(text);
	var searchUrl;
	if (type == 'search_blog') {
		searchUrl = "space.php?do=blog&searchkey=" + text + "&searchmode=1&view=all&orderby=dateline";
	} else if (type == 'search_all') {
		searchUrl = "cp.php?ac=friend&username=" + text + "&searchmode=1&op=search";
	} else if (type == 'search_name') {
		searchUrl = "cp.php?ac=friend&name=" + text + "&searchmode=1&op=search";
	} else if (type == 'search_thread') {
		searchUrl = "space.php?do=thread&searchkey=" + text + "&searchmode=1&view=all";
	}
	window.open(searchUrl);
}

srh.initSearch = function() {
	srh._initSearchBox();
	jQuery("#opt, #searchoption").bind('mouseenter', function(event) {
		if (jQuery("#searchoption").is(':hidden')) {
			var offset = jQuery("#opt").offset();
			var left = offset.left - 6 + 'px';
			var top = offset.top - 44 + 'px';
			jQuery("#searchoption").css('top', -40).css('left', 180).show();
		}
	});

	jQuery("#searchoption").bind('mouseleave', function() {
		jQuery("#searchoption").hide();
	});
}

srh._initSearchBox = function() {
	jQuery("#search_keywords").toggleVal( {
		focusClass :"input_sb2",
		populateFrom :"alt"
	}).keypress( function(e) {
		if (e.which == 13) {
			srh.search(jQuery("#search_keywords").val(), "search_all");
			jQuery("#search_keywords").blur();
		}
	});
	
	jQuery("#searchoption").click( function(e) {
		var text = jQuery("#search_keywords").val();
		var type = e.target.className;
		srh.search(text, type);
	});
}

srh.initSecondaryNavigation = function() {
	srh._initSearchBox();
	jQuery("#brandopt span").css({cursor:"pointer",fontSize:"12px"});
	jQuery("#brandopt span, #brandopt a:first").click( function(e) {
		var text = jQuery("#search_keywords").val();
		if (text == "请输入关键词") {
			alert("请输入关键词");
			return ;
		}
		srh.search(text, "search_all");
	});
	
	jQuery("#brandopt, #searchoption").bind('mouseenter', function(){
		jQuery("#brandopt").children(":first").addClass("mouseover");
		jQuery("#searchoption").show();
	});
	
	jQuery("#brandopt, #searchoption").bind('mouseleave', function(){
		jQuery(this).prev().removeClass("mouseover");
		jQuery("#searchoption").hide();
	});
		
}