﻿// JavaScript Document
$().ready(function(){//登录框是否显示
     //alert(1)
	if($.cookie('loginUserName')){//alert(123)
		$('#wlogin').css('display','none');
		$('#ylogin').css('display','block');
		$('#uname').text($.cookie('loginUserName'));
		//alert($.cookie('loginUserName'));
		
		}
	//alert(2)  
     
})

 $().ready(function(){//右侧快速链接
					$('.quick_link>ul>li').each(function(n){
											$(this).mouseover(function(){
													if(!$(this).children('span').hasClass('on')){
														$('.quick_link>ul>li>span.on').removeClass('on');
														$(this).children('span').eq(0).addClass('on');
														$('.quick_link>div').css('display','none');
														$('.quick_link>div').eq(n).css('display','block');
														}
													})
											})
					
					})
$().ready(function(){
	
	 $('#articlelist li:nth-child(5n+2)').css('margin-top','30px');	//文章列表页列表间隔		   
     
})

$().ready(function(){
                 $('.datashowtable').each(function(){
									$(this).children('tbody').children('tr').each(function(){
											if($(this).children('td').eq(1).text()!=0&&$(this).children('td').eq(2).text()!=0){$(this).children('td').eq(3).text($(this).children('td').eq(2).text()*0.5+$(this).children('td').eq(1).text()*0.5)}
											})
									}) 
				 //报价表格滚动
				 setInterval(gundong,2000);
				 //$('.datashowtable').hover(function(){clearInterval(gundong())},function(){setInterval(gundong,2000);});

})
function gundong(){
	   $('.datashowtable').each(function(){
						   $(this).children('tbody').children('tr').eq(0).children('td').animate({height:"0px"},1900,function(){})
						   $(this).children('tbody').children('tr').eq(0).children('td').animate({'line-height':"0px"},1905,function(){
																							$(this).parent('tr').appendTo($(this).parent('tr').parent('tbody'));
																							$(this).css({'height':'30px','line-height':'30px'});										  
																							})
                            })
	}


 //.tab通用切换事件
$().ready(function(){
	 $('.tab').each(function(){
				   $(this).children('dt').children('table').children('tbody').children('tr').children('td').each(function(n){
							$(this).click(function(){
									a = $(this).children('a').eq(0);
									if(!a.hasClass('on')){
										a.css({'border-color':'#fff','background-color':'#fff','font-weight':'bold'});
										a.parent('td').siblings('td').children('a').css({'border-color':'#d3d3d3','background-color':'#f3f3f3','font-weight':'normal'})
										//隐藏之前的tab内容，显示对应的tab内容页
                                                                                
										 $(this).parent('tr').parent('tbody').parent('table').parent('dt').siblings('.contenton').removeClass('contenton');
										 $(this).parent('tr').parent('tbody').parent('table').parent('dt').siblings('.content').eq(n).addClass('contenton').css('overflow','hidden');
                                         $(this).parent('tr').parent('tbody').parent('table').siblings('.contenton').removeClass('contenton');
										 $(this).parent('tr').parent('tbody').parent('table').siblings('.content').eq(n).addClass('contenton').css('overflow','hidden');
										 return false;
										 }
								   })
							})
				   })
	})
//图片轮播
var t = n = 0, count;    
		 $(document).ready(function(){            
									count=$(".banner_list a").length;       
									$(".banner_list a:not(:first-child)").hide();        
									$(".banner_info").html($(".banner_list a:first-child").find("img").attr('alt'));        
									$(".banner_info").click(function(){window.open($(".banner_list a:first-child").attr('href'), "_blank")});        
									$(".banner li").click(function() {            
																   var i = $(this).text() - 1;//获取Li元素内的值，即1，2，3，4        
																   n = i;            
																   if (i >= count) return;            
																   $(".banner_info").html($(".banner_list a").eq(i).find("img").attr('alt'));            
																   $(".banner_info").unbind().click(function(){window.open($(".banner_list a").eq(i).attr('href'), "_blank")})            
																   $(".banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);            
																   $(this).toggleClass("on");            
																   $(this).siblings().removeAttr("class");       
																   });      
									t = setInterval("showAuto()", 4000);        
									$(".banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});    })       
		 function showAuto()    { 
		         n = n >=(count - 1) ? 0 : ++n;       
				 $(".banner li").eq(n).trigger('click');    
				 }

//宏观
/*
$().ready(function(){
				   
         $("#cjyw1 :nth-child(6n)").addClass('boldline');
         $('#cjyw1 :first').addClass('firstline');
})
*/
//点击刷新验证码
function showverify(obj){
						obj.src="/webroot.php/Public/verify/random/"+Math.random();
			}
			
document.write("<div class='QQbox' id='divQQbox' >"+
			   "<div class='Qlist' id='divOnline' onmouseout='hideMsgBox(event);' style='display : none;'>"+
			   "<div class='t'></div>"+
			   "<div class='con'>"+
			   "<h2>在线客服</h2>"+
			   "<ul>"+
			   "<li class='odd'>"+
			   "<a href='http://wpa.qq.com/msgrd?V=1&amp;uin=738527633&amp;Site=世界金属网&amp;Menu=yes' target='_blank'><img border='0' src='http://wpa.qq.com/pa?p=2:738527633:41' alt='点击这里给我发消息' title='点击这里给我发消息'></a>"+
			   "<li class='odd'>"+
			   "<a href='http://wpa.qq.com/msgrd?V=1&amp;uin=596615874&amp;Site=世界金属网&amp;Menu=yes' target='_blank'><img border='0' src='http://wpa.qq.com/pa?p=2:596615874:41' alt='点击这里给我发消息' title='点击这里给我发消息'></a>"+
			   "</li>"+
			   "<li class='odd'>"+
			   "<a href='http://wpa.qq.com/msgrd?V=1&amp;uin=63508065&amp;Site=世界金属网&amp;Menu=yes' target='_blank'><img border='0' src='http://wpa.qq.com/pa?p=2:63508065:41' alt='点击这里给我发消息' title='点击这里给我发消息'></a>"+
			   "</li>"+
			   "<li class='odd'>"+
			   "<a href='http://wpa.qq.com/msgrd?V=1&amp;uin=417388469&amp;Site=世界金属网&amp;Menu=yes' target='_blank'><img border='0' src='http://wpa.qq.com/pa?p=2:417388469:41' alt='点击这里给我发消息' title='点击这里给我发消息'></a>"+
			   "</li>"+
			   "</ul>"+
			   "<h2>电话：(0755)82908920</h2>"+
              " </div>"+
			  " <div class='b'></div>"+
			   "</div>"+
			   "<div id='divMenu' onmouseover='OnlineOver();'>"+
			   "<img src='/Public/Images/qq_1.png' class='press' alt='QQ客服热线'>"+
			   "</div>"+
			   "</div>");




var tips; var theTop = 145/*这是默认高度,越大越往下*/; var old = theTop;

function initFloatTips() {

tips = document.getElementById('divQQbox');

moveTips();

};

function moveTips() {

var tt=50;

if (window.innerHeight) {

pos = window.pageYOffset

}

else if (document.documentElement && document.documentElement.scrollTop) {

pos = document.documentElement.scrollTop

}

else if (document.body) {

pos = document.body.scrollTop;

}

pos=pos-tips.offsetTop+theTop;

pos=tips.offsetTop+pos/10;



if (pos < theTop) pos = theTop;

if (pos != old) {

tips.style.top = pos+"px";

tt=10;

//alert(tips.style.top);

}



old = pos;

setTimeout(moveTips,tt);

}


initFloatTips();







function OnlineOver(){

document.getElementById("divMenu").style.display = "none";

document.getElementById("divOnline").style.display = "block";

document.getElementById("divQQbox").style.width = "145px";

}



function OnlineOut(){

document.getElementById("divMenu").style.display = "block";

document.getElementById("divOnline").style.display = "none";



}


if(typeof(HTMLElement)!="undefined")    //给firefox定义contains()方法，ie下不起作用
{   
      HTMLElement.prototype.contains=function(obj)   
      {   
          while(obj!=null&&typeof(obj.tagName)!="undefind"){ //通过循环对比来判断是不是obj的父元素
   　　　　if(obj==this) return true;   
   　　　　obj=obj.parentNode;
   　　}   
          return false;   
      };   
}  


function hideMsgBox(theEvent){ //theEvent用来传入事件，Firefox的方式

　 if (theEvent){

　 var browser=navigator.userAgent; //取得浏览器属性

　 if (browser.indexOf("Firefox")>0){ //如果是Firefox

　　 if (document.getElementById('divOnline').contains(theEvent.relatedTarget)) { //如果是子元素

　　 return; //结束函式

} 

} 

if (browser.indexOf("MSIE")>0){ //如果是IE

if (document.getElementById('divOnline').contains(event.toElement)) { //如果是子元素

return; //结束函式

}

}

}

/*要执行的操作*/

document.getElementById("divMenu").style.display = "block";

document.getElementById("divOnline").style.display = "none";

}		
