// JavaScript Document
jQuery(document).ready(function() {

	//标题下方点击分享
	jQuery('.tag_share').hover(function() {
		jQuery(this).find('.w-share-trigger').addClass('w-share-trigger-on').end().find('.w-share-list').show();
	}, function() {
		jQuery(this).find('.w-share-trigger').removeClass('w-share-trigger-on').end().find('.w-share-list').hide();
	});


	//右侧本周热点
	/*$("#hot_news li").mouseover(function(){
		$("#hot_news .hot_show").eq($(this).index()).show();
	})

	$("#hot_news li").mouseout(function(){
		$("#hot_news .hot_show").eq($(this).index()).hide();
	})*/
	
	jQuery("#text").focus(function() { 
		var text_value = jQuery(this).val(); 
		if (text_value == this.defaultValue) { 
		jQuery("#text").hide(); 
		jQuery("#password").show().focus(); 
		} 
		}); 
		jQuery("#text").blur(function() { 
		var text_value = jQuery(this).val(); 
		if (text_value == "") { 
		jQuery("#text").show(); 
		jQuery("#password").hide(); 
		} 
	}); 

	
	// 返回顶部
    var scrolltotop = jQuery('<a id="scrolltotop"></a>').appendTo("body");
    scrolltotop.click(function() {
      jQuery("html, body").animate({ scrollTop: 0 }, 300);
      return false;
    });
    jQuery(window).on('scroll', scrollToTop).triggerHandler('scroll');

    function scrollToTop() {
      var st = jQuery(document).scrollTop(), wh = jQuery(window).height();
      scrolltotop[st > wh ? 'show' : 'hide']();
      // IE6 下的定位
      /*if (!window.XMLHttpRequest) {
        $scrolltotop.css('top', st + wh - 166);
      }*/
    }
    
    
    
  //列表页摘要控制两行的js代码
	//var $ = jQuery.noConflict();
    try{
    	$(".main_left .list_model p,.con-details .tuwen p ").each(function(i) {
    		
    		var divH = $(this).height();
    		var $p = $("span", $(this)).eq(0);
    		while ($p.outerHeight() > divH) {
    			$p.text($p.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."));
    		};
    	});
    }catch (e) {
	}
	
	jQuery.jqtab = function(tabtit,tab_conbox,shijian) {
		//var $ = jQuery.noConflict();
		$(tab_conbox).find(".tab_con").hide();
		$(tabtit).children(":first").addClass("on").show(); 
		$(tab_conbox).find(".tab_con:first").show();

		$(tabtit).children().bind(shijian,function(){
		  $(this).addClass("on").siblings().removeClass("on"); 
			var activeindex = $(tabtit).children().index(this);
			$(tab_conbox).children().eq(activeindex).show().siblings().hide();
			return false;
		});
	};
	
	//var $ = jQuery.noConflict();
//	jQuery.jqtab("#tabs3","#tab_conbox3","mouseenter");
//	jQuery.jqtab("#tabs1","#tab_conbox1","mouseenter");
//	jQuery.jqtab("#tabs2","#tab_conbox2","mouseenter");
	if($.jqtab != undefined){
		$.jqtab("#tabs3","#tab_conbox3","mouseenter");
		$.jqtab("#tabs1","#tab_conbox1","mouseenter");
		$.jqtab("#tabs2","#tab_conbox2","mouseenter");
	}else{
		jQuery.jqtab("#tabs3","#tab_conbox3","mouseenter");
		jQuery.jqtab("#tabs1","#tab_conbox1","mouseenter");
		jQuery.jqtab("#tabs2","#tab_conbox2","mouseenter");
	}

  
//     $(function(){
//    		var $ = jQuery.noConflict();
//		   var rtop=$(".ofweek_con_hr").offset().top;
//		   var adH=$("#ad-5").offset().top-385;
//		   var leftH=$(".article_left").height();
//		    var rightH=$(".main_right").height();
//			
//		   $(window).scroll(function(){
//			  var scroTop=$(this).scrollTop();
//			  if((scroTop>rtop) && (scroTop<adH) && (rightH<leftH)){
//				     $(".ofweek_con_hr").addClass("fix");
//				  }else{
//					 $(".ofweek_con_hr").removeClass("fix");
//					   
//				    }
//			   });
//		   
//		   });
//   
 });
jQuery(document).ready(function($){
    if($("#goto_phone").length){
        var _img = '<img id="two-bar-codes"  class="hide" src="http://www.ofweek.com/images/weibo_a.png"/>';
        $("#goto_phone").after(_img); 
            $("#goto_phone").mouseover(function(){  
            $("#two-bar-codes").animate({right:'122px',opacity:'1',},"fast");
            $("#two-bar-codes").addClass("show");           
        });
        $("#goto_phone ").mouseout(function(){ 
            $("#two-bar-codes").animate({right:'137px',opacity:'0',},"slow");});

    }

});	

/**
 * 特殊字符处理
 */
function dealSpecialWords(htmlstr){
	htmlstr=htmlstr.replace(/&amp;trade;/g,'™')
				   .replace(/&amp;reg;/g,'®')
				   .replace(/&amp;copy;/g,'©');
	return htmlstr;
}
$(function(){
	if(document.getElementById('articleC')){
		var c=document.getElementById('articleC').innerHTML;
		document.getElementById('articleC').innerHTML=dealSpecialWords(c);
	}
})









