$(document).ready(function(){
  CMenuClass();
  control_scroll();
}); 

function menudrop(){
	$('#menu ul').hide();
	$('#menu li a').addClass('menu_parent');
	$('#menu ul a').removeClass('menu_parent');
	$('#menu ul a').addClass('menu_child');
	$('.menu_parent').bind('mouseenter', function() {
		if (($(this).next().is('ul')) && ($(this).next().is(':visible'))) {
		return false;
		} else if (($(this).next().is('ul')) && ($(this).next().is(':hidden'))) {
		$(this).addClass('sr_on');
		$(this).next().show();
		return false;
		}
	});
	$('.menu_parent').parent().bind('mouseleave', function() {
		$('#menu li a').removeClass('sr_on');
		$('#menu ul:visible').hide();
	});
}

function control_scroll(){
	if (document.documentElement && document.documentElement.scrollTop)
		diffY = document.documentElement.scrollTop;
	else if (document.body)
		diffY = document.body.scrollTop;
	else
		{/*Netscape stuff*/}
	document.getElementById("control_pannel").style.left=(parseInt(document.body.clientWidth-335))+"px";
	document.getElementById("control_pannel").style.top=(parseInt($(window).height()+diffY)-91)+"px";
}
$(window).resize(function(){
control_scroll();
}); 
$(window).scroll(function(){
control_scroll();
}); 

function show_tab(id,obj){
		$('.sr_box_con_small ul').hide();
		$('#'+id).show();
		$('.sr_box li').removeClass('sr_select');
		$(obj).addClass('sr_select');
		//alert(obj);
	}
function hideright(obj)
{
	if($('.sr_td_right').is(':hidden')){
		$('.sr_td_right').show();
		$(obj).text("隐藏右边栏");
	}else
	{
		$('.sr_td_right').hide();
		$(obj).text("显示右边栏");
	}
}	

function CMenuClass()
{
	if(MenuNumber!="")
	{
		$('#menu .'+MenuNumber).addClass('current-cat');
	}
}

function listshow(obj){
	 switch(obj){
		case 'title':
		 {
			writeCookie("stylesheet",obj);
			$(".sr_post_entry").css("display","none"); 
			$('.sr_post_metadata').css("display","none"); 
			$('.sr_post_title').css({"padding-bottom":"5px","margin-bottom":"5px","border-bottom-color":"#ebebeb","border-bottom-style":"dashed","border-bottom-width":"1px"});
			 break;
		 }
		case 'content':
		{
			writeCookie("stylesheet",obj);
			$(".sr_post_entry").css("display",""); 
			$('.sr_post_metadata').css("display",""); 
			$('.sr_post_title').css({"padding-bottom":"0px","margin-bottom":"0px","border-bottom-color":"#ebebeb","border-bottom-style":"dashed","border-bottom-width":"0px"});
			 break;
		}
	 }
}

function setStyleSheet(obj){
	if(obj!="")
	{
		switch(obj){
		case 'title':
		 {
			$(".sr_post_entry").css("display","none"); 
			$('.sr_post_metadata').css("display","none"); 
			$('.sr_post_title').css({"padding-bottom":"5px","margin-bottom":"5px","border-bottom-color":"#ebebeb","border-bottom-style":"dashed","border-bottom-width":"1px"});
			 break;
		 }
		case 'content':
		{
			$(".sr_post_entry").css("display",""); 
			$('.sr_post_metadata').css("display","");
			$('.sr_post_title').css({"padding-bottom":"0px","margin-bottom":"0px","border-bottom-color":"#ebebeb","border-bottom-style":"dashed","border-bottom-width":"0px"});
			 break;
		}
	}
	}
}
// *** Cookies ***
function writeCookie(name, value) { //写入COOKIE
exp = new Date(); 
exp.setTime(exp.getTime() + (86400 * 1000 * 30));
document.cookie = name + "=" + escape(value) + "; expires=" + exp.toGMTString() + "; path=/"; 
} 
function readCookie(name) { //读取COOKIE
var search; 
search = name + "="; 
offset = document.cookie.indexOf(search); 
if (offset != -1) { 
  offset += search.length; 
  end = document.cookie.indexOf(";", offset); 
  if (end == -1){
   end = document.cookie.length;
  }
  return unescape(document.cookie.substring(offset, end)); 
}else{
  return "";
}
}

//alert($('#menu').html());
//document.getElementById("control_pannel").style.top=(parseInt($( window ).height()+document.documentElement.scrollTop)-100)+"px";
