function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
	var expires = new Date();
	expires.setTime(expires.getTime() + seconds * 1000);
	domain = !domain ? cookiedomain : domain;
	path = !path ? cookiepath : path;
	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
	+ (expires ? '; expires=' + expires.toGMTString() : '')
	+ (path ? '; path=' + path : '/')
	+ (domain ? '; domain=' + domain : '')
	+ (secure ? '; secure' : '');
};
function getcookie(name) {
	var cookie_start = document.cookie.indexOf(name);
	var cookie_end = document.cookie.indexOf(";", cookie_start);
	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
};
function tishi(string){
	if(getcookie('tishi')==1)
	{
		location=string;
	}

}
function writecookie(){
	var cookietime=new Date((new Date()).getTime() + 9999 * 3600000 * 30);
	document.cookie="tishi=1;expires="+cookietime;
}
function turnto(){
	var tishi = document.getElementById("tishi");
	if(tishi.checked==true)
	{
		var cookietime=new Date((new Date()).getTime() + 9999 * 3600000 * 30);
		document.cookie="tishi=1;expires="+cookietime;
	}
	location="/space.php?do=lessons";
}
function noturn(string){
	var tishi = document.getElementById("tishi");
	if(tishi.checked==true)
	{
		var cookietime=new Date((new Date()).getTime() + 9999 * 3600000 * 30);
		document.cookie="tishi=1;expires="+cookietime;
	}
	jQuery(document).trigger('close.facebox');
	location=string;
}
function setcheck(){
	var tishi = document.getElementById("tishi");
	if(tishi.checked==true)
	{
		tishi.checked=false;
	}
	else
	{
		tishi.checked=true;
	}
}
// 加入收藏
function addfavorite()
{
	if (document.all)
	{
		window.external.addFavorite("http://www.51pigai.com","新东方批改网|欢迎您！");
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel("新东方批改网|欢迎您！","http://www.51pigai.com","");
	}
}

function setHomePage(obj){

}

/** 菜单换背景 **/
function showMenuPic(obj){
	if(obj=='index'){
		jq('.menu_index>a>img').attr("src","/image/head_button1_1.jpg");
	}else if(obj=='friend'){
		jq('.menu_friend>a>img').attr("src","/image/head_button2_1.jpg");
	}else if(obj=='bbs'){
		jq('.menu_bbs>a>img').attr("src","/image/head_button3_1.jpg");
	}
}

function hideMenuPic(obj){
	if(obj=='index'){
		jq('.menu_index>a>img').attr("src","/image/head_button1.jpg");
	}else if(obj=='friend'){
		jq('.menu_friend>a>img').attr("src","/image/head_button2.jpg");
	}else if(obj=='bbs'){
		jq('.menu_bbs>a>img').attr("src","/image/head_button3.jpg");
	}
}

// 作文工具箱
function hideTools() {
	//jq("#tools_info").slideUp(1000);
	jq("#tools_info").fadeOut('slow');
}
function showTools(){
	jq.ajax({
		type: "GET",
		url: "/composition_tool.php",
		timeout: 20000,
		data: "",
		error: function(){
			alert(error);
		},
		success: function(res){
			if(res){
				if(jq("#tools_info").queue().length<=1){
					//jq("#tools_info").slideToggle(800);
					jq("#tools_info").fadeIn('slow');
					jq("#tools_info").html(res);
				}
			}else{
				jq("#tools_info").html("<img src='image/loading.gif' border=0>");
			}
		}
	});
}



function searchW(){
	var search_word = jq('.search_word').val();
	if(!search_word){
		jq('.search_alert').html("请输入关键词!");
		jq('.search_alert').css("border","1px solid #CCCCCC");
		jq('.search_alert').css("background","#FFFFFF");
		jq(document).ready(function() {
			function jump(count) {
				window.setTimeout(function(){
					count--;
					if(count > 0) {
						jump(count);
					} else {
						jq(".search_alert").html('');
						jq('.search_alert').css("border","none");
						jq('.search_alert').css("background","none");
					}
				}, 1000);
			}
			jump(3);
		});
		return false;
	}else{
		window.open("search.php?keyword="+encodeURIComponent(search_word),"_blank");
	}
}
