var YJZT_ALL = new Array()
YJZT_ALL[0] = new Array ('rrw','人人网','rr_y_logo.gif')
YJZT_ALL[1] = new Array ('tjh','淘江湖','tb_y_logo.gif')
YJZT_ALL[2] = new Array ('xlwb','新浪微博','sina_y_logo.gif')
YJZT_ALL[3] = new Array ('kxw','开心网','kx001_y_logo.gif')
YJZT_ALL[4] = new Array ('itb','i贴吧','i_y_logo.gif')
YJZT_ALL[5] = new Array ('w163','网易微博','163_y_logo.gif')
YJZT_ALL[6] = new Array ('dkw','递客网','dkw_y_logo.gif')
YJZT_ALL[7] = new Array ('wsohu','搜狐微博','sohu_y_logo.png')
YJZT_ALL[8] = new Array ('qqkj','QQ空间','qz_y_logo.png')
YJZT_ALL[9] = new Array ('txwb','腾讯微博','txwb_y_logo.png')
YJZT_ALL[10] = new Array ('txpy','腾讯朋友','txpy_y_logo.png')

var u = encodeURIComponent(document.URL);
var t = encodeURIComponent(document.title);
var c = $('meta[name=description]').attr('content');

/* 打印类型,打印数量,contentid*/
var DYYJZT = {
  getcode : function(dytpye,num,template) {
	var str = '';
    if (num == 0) { cnum = YJZT_ALL.length; } else { cnum = num; }
    if (dytpye == 'icon_text') {
	  if(template == 1) { str += '<div class="news_share"><span class="fl">一键转帖：</span><div class="fl">'; }
      for(var i=0; i<cnum; i++) {
        str += '<a href="http://www.m1905.com/pubfunc/share.php?tp=' + dytpye + '&cp='+ YJZT_ALL[i][0] +'&url='+ u + '&title=' + t + '" target="_blank"><img src="http://static.m1905.com/images/shareicon/'+ YJZT_ALL[i][2] +'" alt="'+ YJZT_ALL[i][1] +'" />' + YJZT_ALL[i][1] + '</a>';
	  }
	  if(template == 1) { str += '</div></div>'; }
	  return str;
    }
	if (dytpye == 'icon') {
	  if(template == 1) { str += '<div class="news_share"><span class="fl">一键转帖：</span><div class="fl">'; }
	  for(var i=0; i<cnum; i++) {
	    str += '<a href="http://www.m1905.com/pubfunc/share.php?tp=' + dytpye + '&cp='+ YJZT_ALL[i][0] +'&url='+ u + '&title=' + t + '" target="_blank"><img src="http://static.m1905.com/images/shareicon/'+ YJZT_ALL[i][2] +'" alt="'+ YJZT_ALL[i][1] +'" /></a>';
	  }
	  if(template == 1) { str += '</div></div>'; }
	  return str;
	}
	if (dytpye == 'text') {
	  if(template == 1) { str += '<div class="news_share fl"><span class="fl">一键转帖：</span><div class="fl">'; }
	  for(var i=0; i<cnum; i++) {
        str += '<a href="http://www.m1905.com/pubfunc/share.php?tp=' + dytpye + '&cp='+ YJZT_ALL[i][0] +'&url='+ u + '&title=' + t + '" target="_blank">' + YJZT_ALL[i][1] + '</a>';
	  }
	  if(template == 1) { str += '</div></div>'; }
	  return str;
	}
  },
  writecode_news : function(obj,dytpye,num,template) {
	$(obj).before(DYYJZT.getcode(dytpye,num,template));
  },
  writecode : function(obj,dytpye,num,template) {
    $(obj).append(DYYJZT.getcode(dytpye,num,template));
  }
}

$(document).ready(function() {
  DYYJZT.writecode_news('#orther_onlick','icon_text',0,1);
});

$(function(){	 
    if ($("#left_content")== 0 || $("#new_page").size() == 0) return false;
    if (getcookie("admin_auth") != '' && getcookie("admin_auth") != null) return false;

    $("#left_content img:not('#left_content a img')") .each(function(){
        var divwidth = parseInt($(this).attr("offsetWidth"));
        if (divwidth < 250) return;
		$(this).attr("onmousemove","imgmovenav(event,this)"); 
		$(this).next("br").remove();
      	$(this).replaceWith($('<div style="width:'+ divwidth +'px;margin:0pt auto; overflow: hidden; position: relative; text-align: center;"></div>').append($(this).clone(this)));
	  });
  });
 
 function news_to_newgallery(tocid) {
   var glylink='';
   if(typeof(tocid)!= "undefined" && tocid)
   glylink = '<span><a href="/newgallery/hdpic/'+ tocid +'.shtml" target="_blank">点击浏览高清图集</a></span><br/>';
   if($("#left_content table table").size()>0) return;
   $("#left_content img:not('#left_content a img')").each(function(){
	   var divwidth = parseInt($(this).attr("offsetWidth"));
	   if (divwidth < 350) return;
	   $(this).before(glylink);
   });
 }
 
 function imgmovenav(event,img) {
  
  var curpageobj = null;
  if ($("#new_page u").size() > 0) {
    curpageobj = $("#new_page u");
  } else {
    curpageobj = $("#new_page span:eq(1)");
  }

  var prevurl = $(curpageobj).prev().attr("href");
  var nexturl = $(curpageobj).next().attr("href");
  var isfirst = false,islast = false;
  if (isNaN($(curpageobj).prev().text())) isfirst = true;
  if (isNaN($(curpageobj).next().text())) islast = true;

  var event = window.event || event;
  var Ml;
  if (event.offsetX == undefined)   //Firefox   
  {
    var evtOffsets = getOffset(event);
    Ml = evtOffsets.offsetX;
  }  else {
    Ml = event.offsetX;
  }

  var prev = (Ml < Math.floor((parseInt($(img).attr("offsetWidth")) + parseInt($(img).attr("offsetLeft"))) / 2));
  $(img).unbind('click');
  if (prev) {
      if (isfirst) {
        $(img).css("cursor","default");
        $(img).attr("title","已到达第一页");
      } else {
        $(img).css("cursor","url(" + "http://www.m1905.com/images/arr_left.cur" + "),auto");
        $(img).attr("title","上一页");
        $(img).bind('click',function(){window.location.href=prevurl});
        //$(img).attr("onclick","javascript:window.location.href='" + prevurl + "';");
      }
  } else {
    if (islast) {
      $(img).css("cursor","default");
      $(img).attr("title","已到达最后一页");
    } else {
      $(img).css("cursor","url(" + "http://www.m1905.com/images/arr_right.cur" + "),auto");
      $(img).attr("title","下一页");
      $(img).bind('click',function(){window.location.href=nexturl});
      //$(img).attr("onclick","javascript:window.location.href='" + nexturl + "';");
    }
  }
 }

 function getOffset(evt)   
{   
  var target = evt.target;   
  if (target.offsetLeft == undefined)   
  {   
    target = target.parentNode;   
  }   
  var pageCoord = getPageCoord(target);   
  var eventCoord =   
  {    
    x: window.pageXOffset + evt.clientX,   
    y: window.pageYOffset + evt.clientY   
  };   
  var offset =
  {   
    offsetX: eventCoord.x - pageCoord.x,   
    offsetY: eventCoord.y - pageCoord.y   
  };   
  return offset;   
}   
  
function getPageCoord(element)   
{   
  var coord = {x: 0, y: 0};   
  while (element)   
  {   
    coord.x += element.offsetLeft;   
    coord.y += element.offsetTop;   
    element = element.offsetParent;   
  }   
  return coord;   
}
