var fr_id ;
function showMsgDiv(obj, title, pos, module, param, effect){
  $("div.show_msg_content").html($("#"+module).html());
  $("div.show_msg_content > *").show();
  
  var widthTemp = $("#showMsgDiv").outerWidth();
  var heightTemp = $("#showMsgDiv").outerHeight();
  var objTop = $(obj).offset().top;
  var objLeft = $(obj).offset().left;
  var objWidth = $(obj).width();
  var objHeight = $(obj).height();
  var leftTemp = parseInt(objLeft)+parseInt(objWidth)-parseInt(widthTemp);
  if(pos=='up'){
  	var topTemp = parseInt(objTop)-parseInt(heightTemp);
  }else{
	var topTemp = parseInt(objTop)+parseInt(objHeight);
  }
  $(".show_msg_name").html(title);

  if( 'undefined' != typeof(effect)){
	$("#showMsgDiv").css({"zIndex":2,position:"absolute",top:topTemp + "px",left:leftTemp+"px"}).fadeIn();
  }else{
  	$("#showMsgDiv").css({"zIndex":2,position:"absolute",top:topTemp + "px",left:leftTemp+"px"}).show();
  }
  fr_id = param;
  $("input[type='text']:first", "div.show_msg_content" ).focus();

}

function hideMsgDiv(){
  $("#showMsgDiv").hide();
}

//取得瀏覽器視窗高度
function getBrowserHeight() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight :
                 document.body.clientHeight;
    } else {
        return self.innerHeight;
    }
}

//取得瀏覽器視窗寬度
function getBrowserWidth() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth :
                 document.body.clientWidth;
    } else {
        return self.innerWidth;
    }
} 
//518討論區聲明
function showPopWin(){
	var scroll_top = $(this).scrollTop();
	var widthTemp = $("#showPopWin").outerWidth();
	var heightTemp = $("#showPopWin").outerHeight();
	var browserHeight = getBrowserHeight();
	var browserWidth = getBrowserWidth();
	var leftTemp = parseInt(browserWidth)/2-parseInt(widthTemp)/2;
	var topTemp = parseInt(browserHeight)/2-parseInt(heightTemp)/2 + scroll_top ;

	$(".show_msg_name").html("518討論區聲明");
	$("#showPopWin").css({"zIndex":1000,position:"absolute",top:topTemp + "px",left:leftTemp+"px"}).show();
}
function hidePopWin(){
  $("#showPopWin").hide();
}
function TB_switch(mode)
{
	if(mode==1)
	{
		document.getElementById("TB_overlay").style.display='block';
		document.getElementById("TB_load").style.display='block';
	}else if(mode==2)
	{
		document.getElementById("TB_overlay").style.display='none';
		document.getElementById("TB_load").style.display='none';
	}
}
function setCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)
	+ ";expires="+expire.toGMTString();
} 
function getCookie(c_name)
{
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
        { 
        c_start=c_start + c_name.length+1 ;
        c_end=document.cookie.indexOf("&",c_start);
        if (c_end==-1) c_end=document.cookie.length
        return unescape(document.cookie.substring(c_start,c_end));
        } 
      }
    return ""
}
function fbs_click() 
{
	u=location.href;t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	location.reload();
	return false;
}
