function nav_pos(vc,vm) {
  var curr = $("#m_nav ul li[c=" + vc + "]");
  if (curr.find("em").length == 0) return;
  $("#subtopnav").empty();
  curr.find("em").remove();
  $("#subtopnav").append($("<a m='0' href='"+ curr.find("a:first").attr("href") +"'>" + curr.find("a:first").text() + "</a>"));
  var b = document.createTextNode(">");
  $("#subtopnav").append($(b));
  curr.find('dl a').each(function(idx){
    $("#subtopnav").append($(this));
  });
  if (vm==undefined) vm=0;
  $('#subtopnav a[m!=' + vm + ']').addClass("bnav");
  $('#subtopnav a[m=' + vm + ']').addClass("bnav_hover");

  curr.html(curr.find("a:first").text());
  curr.addClass("nav_now");
}

$(function(){
  $("#m_nav ul li a em").each(function(idx){
    //this.click = $(this).parent().parent().find('dl').show();
    $(this).click(function(event){
      event.preventDefault();
      //event.stopPropagation();
      nav_hideall();
      $(this).parent().parent().find('dl').toggle();
      //toggleVisible($(this).parent().parent().find('dl'));
      return false;
    });
  }
  );

  $("#m_nav ul li dl").each(function(idx){
    $(this).mouseout(function(event){
      $(this).hide();
    });
    $(this).mouseover(function(event){
      $(this).show();
    });
  });
});

function nav_hideall() {
  $("#m_nav ul li dl").hide();
}

//显示CCTV6节目表
function show_cctv6_Tables(tt) {
  var daps = document.getElementById('pop').style;
  if(daps.visibility!='hidden' && daps.display!='none')
  {
    daps.display='none';
    return;
  }
  else
  {
    daps.display='';
  }
  var ttop = tt.offsetTop; //TT控件的定位点高
  var thei = tt.clientHeight; //TT控件本身的高
  var tleft = tt.offsetLeft; //TT控件的定位点宽
  var ttyp = tt.type; //TT控件的类型
  while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
  daps.top = (ttyp && ttyp=="image")? (ttop+thei)+''+'px' : (ttop+thei+6) + 'px'; //层的 Y 坐标
  daps.left = (tleft-190) + '' + 'px' ; //层的 X 坐标
  daps.visibility = "visible"; //层显示
}

//打开消息框
function show_messagebox(title,msg) {
  if($("#warn_window").length>0) {
    $("#warn_title").html(title);
    $("#warn_msg").html(msg);
    $("#warn_window").show();
    $("#dialogBG").show();
  } else {
	var dialogBGhtml = '<div style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 998; opacity: 0.6; filter:alpha(opacity=60);background-color: rgb(238, 238, 238);" id="dialogBG"></div>';
	$(dialogBGhtml).appendTo('body');
	    
    var messagehtml = '<div id="warn_window">';
    messagehtml += '<div class="warn_title white_f font14 font_w" id="warn_title">';
    messagehtml += title;
    messagehtml += '</div><div class="warn_box"><p id="warn_msg">';
    messagehtml += msg;
    messagehtml += '</p><p><a href="javascript:void(0);" onclick="close_messagebox();"><samp class="banner white_f">关闭</samp></a></p></div></div>';
    $(messagehtml).appendTo('body');
    
    //$alertContainer = $('#warn_window').css({position:'absolute',overflow:'hidden'}).hide();
    $alertContainer = $('#warn_window').css({position:'absolute',overflow:'hidden'}).hide();
    $alertContainerBG = $('#dialogBG').css({height:document.body.clientHeight}).hide();

    // 设置zIndex并显示提示DIV
    var windowWidth = document.documentElement.clientWidth;   
    var windowHeight = document.documentElement.clientHeight;   
    var popupHeight = $alertContainer.height();   
    var popupWidth = $alertContainer.width(); 

    //居中设置 
     $alertContainer.css({   
      "position": "absolute",   
      "top": windowHeight/2-popupHeight,   
      "left": windowWidth/2-popupWidth/2   
    }); 

    $alertContainerBG.css({zIndex:998}).show();
    $alertContainer.css({zIndex:999}).show();
  }
}

//隐藏消息框
function close_messagebox() {
  $("#warn_window").hide();
  $("#dialogBG").hide();
}

$(function(){
	//避免IE6重复下载图片
  if($.browser.msie)
	document.execCommand('BackgroundImageCache',false,true);
});

//新浪转帖
function share_sina(s,d,e)
{
  typeof(s)=='undefined'&&(s=screen);
  typeof(d)=='undefined'&&(d=document);
  typeof(e)=='undefined'&&(e=encodeURIComponent);
  try{}
  catch(e){}
  var f='http://v.t.sina.com.cn/share/share.php?';
  var u=d.location.href;
  var p=['url=',e(u),'&title=',e(d.title),'&appkey=2924220432'].join('');
  function a()
  {
    if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=620,height=450,left=',(s.width-620)/2,',top=',(s.height-450)/2].join('')))
      u.href=[f,p].join('');
  };
  if(/Firefox/.test(navigator.userAgent))
  {
    setTimeout(a,0);
  }
  else
  {
    a();
  }
}

//自动滚屏
function AutoScrollUILI(obj) {
    $(obj).find("ul:first").animate({
        marginTop:"-25px"
    },3000,function(){
          $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
      });
}

//鼠标位置取得
function mouseCoords(ev)
{
  if(ev.pageX || ev.pageY){
    return {x:ev.pageX, y:ev.pageY};
  }
  return {
    x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
    y:ev.clientY + document.body.scrollTop - document.body.clientTop
  };
}

