﻿// JavaScript Document
$(function(){ 
	message_list();	//信息发布下拉列表框
	waytab_change();	//行业下拉菜单
	pinyin_change();	//拼音切换
	$(".scoll_content").Scroll({line:4,speed:500,timer:4000});
	ScrollBusinessCon(); //商机滚动
	loginStatusVerify();//登陆状态
})


/*-----信息发布列表------*/
function message_list() {
	$("#head dl").hover( 
		function(){
			$(this).addClass("s"); 
			$("#head dd").show();
		}, 
		function(){
			$(this).removeClass("s");
			$("#head dd").hide()
		} 
	) 
}

function loginStatusVerify(){
	var loginStatusEM = $("#loginStatus");
	$.ajax({
		url:"/loginVerify.ashx",
		timeout:15000,
		dataType:"html",
		success:function(_html)
		{
			if (_html!="") {
				loginStatusEM.html(_html);
			}
		}
	})
}

/*-----行业类别切换------*/
/*function way_change (){
	
	  
	var Tab_style =$('#way .menu ul');
	Tab_style.children('li:first').addClass('s');
	Tab_style.parents('.menu').parents('.titlenav').parents('#way').next('div').css('display','block');
	
	Tab_style.children('li').click(
		function(){
			Tab_style.children('li').removeClass("s");
			$("#main .contentnav").hide();
			$('.'+this.id).show();
			$(this).addClass("s");
			$(this).attr("title","点击查看该类别相关网站");
		}
	)
}
*/
	
/*-----行业类别下拉菜单切换------*/
function waytab_change (){
	
	/* 初始值*/   
	var Tabs =$('#way .menu ul li');
	var TabSeaver =$('#way .menu ul .ss');
	var con_mask = $('#way .mask');

	/*鼠标经过的变化*/
	Tabs.hover(
		function(){
			Tabs.removeClass("s");
			con_mask.hide();
			$('.'+this.id).show();
			$(this).not('.ss').addClass("s");
		},
		function(){
		    $('.'+this.id).hide();
			$(this).not('.ss').removeClass("s");
		}
	)
	
	TabSeaver.hover(
		function(){
			$(this).addClass("seaver");
		},
		function(){
		    $('.'+this.id).hide();
		    $(this).removeClass("seaver");
		}
	)
}


/*-----拼音下拉菜单切换------*/
function pinyin_change (){
	
	var Tabs =$('#way .pinyin dl dt');
	var con_py = $('#way .con_pinyin');
	var content_py = $('#way .con_pinyin ul');
	
	
	/*鼠标经过的变化*/
	Tabs.hover(
		function(){
			Tabs.removeClass("s");
			Tabs.removeClass("prevnod");
			$('#way .pinyin').addClass("py_s");
			con_py.show();
			//alert("["+$(this).text()+"]");//调试是否有空格
			
			/*数据加载前*/
			$.ajax({
		        url:"/tags/"+$(this).text().replace(" ", "")+".txt",
		        cache: false,
		        beforeSend:function(){
			        content_py.html('数据加载中<img src="/skins/66good/images/loading.gif"/>');
		        },
		        success:function(_html){
			        content_py.html(_html);
			        content_py.slideDown("10000");
		        },
		        error:function(){
			        content_py.html('数据整理中，敬请关注...');
		        }	
	        });
						
			
			//con_py.load("/tags/"+$(this).text().replace(" ", "")+".txt");//拼音类别路径
			$(this).addClass("s");
			$(this).prev("dt").addClass("prevnod")
		},
		function(){
		}
	)
	/*移动出内容框时div消失*/
	con_py.hover(
		function(){},
		function(){
			con_py.hide();
			Tabs.removeClass("s");
			$('#way .pinyin').removeClass("py_s");
			Tabs.prev("dt").removeClass("prevnod")
		}
	)
	/*移动mennu框时div消失*/
	$('#way .pinyin').hover(
		function(){},
		function(){
			con_py.hide();
			Tabs.removeClass("s");
			$('#way .pinyin').removeClass("py_s");
			Tabs.prev("dt").removeClass("prevnod")
		}
	)
}


/*-----商机滚动------*/
(function($){
$.fn.extend({
    Scroll:function(opt,callback){
        //参数初始化
        if(!opt) var opt={};
        var _this=this.eq(0).find("ul:first");
        var     lineH=_this.find("li:first").height()/2, //获取行高
                line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
                timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
        if(line==0) line=1;
        var upHeight=0-line*lineH;
        //滚动函数
        scrollUp=function(){
                _this.animate({
                        marginTop:upHeight
                },speed,function(){
                        for(i=1;i<=line;i++){
                                _this.find("li:first").appendTo(_this);
                        }
                        _this.css({marginTop:0});
                });
        }
        //鼠标事件绑定
		var timerID;
		_this.hover(function(){
			clearInterval(timerID);
		}, function(){
			timerID = setInterval("scrollUp()", timer);
		}).mouseout();
		if(timerID==undefined)
			timerID = setInterval("scrollUp()", timer);
    }        
})
})(jQuery);


/*------------商机时间滚动---------------*/
function GQSwither(){
    var thistime = new Date();
    var years = thistime.getYear();
    var days = thistime.getDay();
    var hours = thistime.getHours();
    var minutes = thistime.getMinutes();
    var seconds = thistime.getSeconds();
    var lastDate = new Date( thistime.getYear(), thistime.getMonth(), thistime.getDate(), hours, 5 * parseInt(minutes / 5));
    var timetxt = $(".scoll_time span");
    var timeMask = $(".time_mask");
    if (hours >= 18 && hours < 24) {
        timeMask.html("上次更新时间18:00<br/>下次更新时间是明日8:00");
        timetxt.addClass("select").html("上次更新时间<br/>18:00");
    }
    else if (hours >= 0 && hours < 8) {
        timeMask.html("上次更新时间是昨日18:00<br/>下次更新时间是今日8:00");
        timetxt.addClass("select").html("上次更新时间<br/>18:00");
    }
    else {
        minutes = 4 - minutes % 5;
        seconds = 59 - seconds;
        var smin = lastDate.getMinutes();
        if (smin < 10) 
            smin = "0" + smin;
            timeMask.html("8:00 -18:00 每5分钟更新一次<br/>上次更新时间" + (lastDate.getHours()) + ":" + smin);
        if (minutes == 0 && seconds == 0) {
        }
        else {
            if (minutes < 10){ 
                minutes = "0" + minutes;}
            if (seconds < 10){ 
                seconds = "0" + seconds;}
            thistime = minutes + ":" + seconds;
            timetxt.html(thistime);
        };
    };
};

//鼠标移入图层
function timeMask(){
    $(".scoll_time").hover(
        function(){
            $(".time_mask").show();
        },
        function(){
            $(".time_mask").hide();
        }
    )   
}

//商机内容载入
function BusinessLoad(){
    var scrollTime = $(".scoll_time span");
    var scrollCon =$("#suply .scoll_content ul");
    $.ajax({
        url:"/tags/roll-business.ashx",
        cache: false,
        beforeSend:function(){
            scrollCon.html('数据加载中<img src="/skins/66good/images/loading.gif"/>');
        },
        success:function(_html){
            scrollCon.html(_html);
            scrollCon.slideDown("10000");
        },
        error:function(){
            scrollCon.html('数据整理中，敬请关注...');
        }	
    });
}

//每5分钟商机内容载入
function BusinessCon(){
    var scrollTime = $(".scoll_time span");
    if (scrollTime.text()=="04:59"){
        BusinessLoad();    
    }
}


//每秒刷新一次
function updater(){
    GQSwither();
    BusinessCon();
    timerID = window.setTimeout("updater()", 1000); 
}

function ScrollBusinessCon(){
    updater();
    timeMask();
    BusinessLoad()
}