 

 
    $(function () {
        Date.prototype.format = function (format) {
            var o = {
                "M+": this.getMonth() + 1, //month 
                "d+": this.getDate(), //day 
                "h+": this.getHours(), //hour 
                "m+": this.getMinutes(), //minute 
                "s+": this.getSeconds(), //second 
                "q+": Math.floor((this.getMonth() + 3) / 3), //quarter 
                "S": this.getMilliseconds() //millisecond 
            }

            if (/(y+)/.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            }

            for (var k in o) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
                }
            }
            return format;
        }
       
        initDate();
        $('.m-date').DatePicker({
            format: 'Y-m-d',
            date: $('#curdate').html(),
            current: $('#curdate').html(),
            starts: 1,
            position: 'bottom',
            onBeforeShow: function () {
            },
            onChange: function (formated, dates) {
                if (initDate(formated) != false) {
                    $('#curdate').html(formated);
                }
                $('#getdate').DatePickerHide();
            }
        });


        $("#znzul li").mouseover(function () {
            $(".m-znz-con").hide();
            $("#znzul li").attr("class", "");
            $(this).attr("class", "cur");
            $("#div-" + $(this).attr("t")).show();
        });
        $(".m-nav ul li a").click(function () {
            $(".m-nav ul li").attr("class", "");
            $(this).parent().attr("class", "cur");
        });

        



    });

    
    var dataurl='zaowanbao/data1/';
    var ajaxdata=null;
    function datacallback(json){
    	$("#nocon").hide();
    	$("#list").html("");
		
    	if (json.list.length > 0) { 
    		var str = "";
    		for (var i = 0; i < json.list.length; i++) {
    		   	t=i+1; 
    		   for(var j=0;j<json.list[i].length;j++){
    			   t1=j+1;
    		   	o=$("#m"+t+'n'+t1);
    			o.find(".news_title").html(' <span class="number">'+t1+'</span>'+json.list[i][j].title);
    			o.find(".news_intro").html(json.list[i][j].content);
				 $("[stockCode1]").unbind();
   			$("[stockCode2]").unbind();
   	 		wkstock.appendTip();  
   			wkstock.stockPlugin({pid:'379'}); 	
    		  }
    		} 
    		str=null; 
    		$(".g-con").show();
    	}else{
    		 $(".g-con").hide();
    		 $("#nocon").html("今日暂无数据!").show();
    	}
    }
    
    
    function popuurl(url, w, h) {
        if (external.iWinMain)
            external.iWinMain('cmd_PopupWindow', url, w, h);
    }
    //初始化日期加载
    function initDate(sdate) {
		$(".g-con").hide(); 
   $("#nocon").html("正在加载数据...").show();
        var tdDT; //日期 
        var hrefLength = location.href.length;
        var line = location.href.lastIndexOf("/");
        var name = location.href.substr(line + 1, (hrefLength - line));
        var rq = name.replace(".html", "")
        if (sdate == undefined) {
            if (CheckDate(rq)) {
                currDT = new Date(rq.replace(/-/g, '/'));
            }
            else {
                currDT = new Date(); 
            	temptd=currDT.getDay();  
            	tempdd=currDT.getDate();
                if(temptd==0){
                	currDT.setDate(tempdd-2);      
                }else
                if(temptd==6){  
                	currDT.setDate(tempdd-1);      
                }else{
				  if(currDT.getHours()<9){
				  currDT.setDate(currDT.getDate()-0.3);
				  }
				}
            }
            var curdate = document.getElementById("curdate");
            curdate.innerHTML = currDT.getFullYear() + "-" + (currDT.getMonth() + 1) + "-" + currDT.getDate();
            dateurl = currDT.format("yyyy-MM-dd");
            wkstock.getData({url:dataurl+dateurl,callback:datacallback});
        } else {
            currDT = new Date(sdate.replace(/-/g, '/'));
            var gourl;
            var file;
            var checkurl;
            var dateurl = currDT.getFullYear() + "-" + (currDT.getMonth() + 1) + "-" + currDT.getDate();
            dateurl = new Date(dateurl.replace(/-/g, '/')).format("yyyy-MM-dd");
            //file = new Date(dateurl.replace(/-/g, '/')).format("yyyyMM");
            //checkurl = file + "/" + dateurl + ".html";
            wkstock.getData({url:dataurl+dateurl,callback:datacallback});
        }
    }

    function CheckDate(strInputDate) {
        if (strInputDate == "") return false;
        strInputDate = strInputDate.replace(/-/g, "/");
        var d = new Date(strInputDate);
        if (isNaN(d)) return false;
        var arr = strInputDate.split("/");
        return ((parseInt(arr[0], 10) == d.getFullYear()) && (parseInt(arr[1], 10) == (d.getMonth() + 1)) && (parseInt(arr[2], 10) == d.getDate()));
    }

    $('a[href*=#],area[href*=#]').click(function () {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
            if ($target.length) {
                var targetOffset = $target.offset().top - 130;
                $('html,body').animate({
                    scrollTop: targetOffset
                },
                1000);
                return false;
            }
        }
    });
 