/*
author	: licx
email	: 56766706@qq.com
*/
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function (elt /*, from*/) {
		var len = this.length >>> 0;
		var from = Number(arguments[1]) || 0;
		from = (from < 0)
			 ? Math.ceil(from)
			 : Math.floor(from);
		if (from < 0)
			from += len;
		for (; from < len; from++) {
			if (from in this &&
				this[from] === elt)
				return from;
		}
		return -1;
	};
}
//设为首页
function SetHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(vrl);
	}catch(e){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch (e){
				alert("抱歉！您的浏览器不支持直接设为首页。");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}else{
			alert('抱歉，您的浏览器不支持自动设置首页, 请使用浏览器菜单手动设置!');
		}
	}
}
function fill_news(list){
	var news = "";
	for(var i=0;i<list.length;i++){
		news+=list[i];
	}
	$("#city-news").append(news);
}
//删除左右两端的空格
function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g, "");
}
function openwin(url) {
	var a = document.createElement("a");
	a.setAttribute("href", url);
	a.setAttribute("target", "_blank");
	a.setAttribute("id", "openwin");
	document.body.appendChild(a);
	a.click();
}
function getCacheDate(){
	var tt = new Date();
	var str = ""+tt.getFullYear()+tt.getMonth()+tt.getDate()+tt.getHours()+tt.getMinutes()/5;
	return str;
}
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
	var Days = 30; //此 cookie 将被保存 30 天
	var exp   = new Date(); //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + Days*24*60*60*1000);
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数
{
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)//删除cookie
{
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function pv(url, w, h , id,auto){
	if(url==''||url.indexOf('//')<0)
		 return false;
	var play = 0;
	if(typeof(auto) != 'undefined'){
		 play = auto;
	}
	var flashvars={
		f:url,
		c:0,
		b:1,
		p:play,
		i:''
	};
	var video=[url+'->video/mp4'];
	CKobject.embed('https://w.dzwww.com/zt/dzplayer/ckplayer/ckplayer.swf',id,'ckplayer_'+id,w,h,false,flashvars,video)	;
}
/*
jquery.taber
*/
(function($){
	$.fn.taber = function(options){
		var opts = $.extend({},defaults,options);
		return $(this).each(function(index,elementP){
			var tarT = $(this).find(opts.title);
			var tarC = $(this).find(opts.content);
			tarT.each(function(index,element){
				$(element).mouseover(function(e){
					tarT.removeClass(opts.activeClass);
					tarC.hide();
					$(this).addClass(opts.activeClass);
					tarC.eq(index).show();
					opts.onActionEnd(index,element,elementP);
				});
			});
		});
	};
	var defaults = {
		title:'span',
		content:'ul',
		activeClass:'current',
		onActionEnd:function(index,obj,container){
			//index 序号
			//obj 当前标题
			//container 父类容器
		}
	};
})(jQuery);
/*
$(".taber").taber({title:'div.title span',content:'div.text1'});
$(".taberHref").taber({title:'div.title span',content:'ul.list1',onActionEnd(index,obj,container){
	var href= $(obj).find('a').attr('href');
	$(container).find('a.more').attr('href',href)
}});
*/

var IPCtl = {
	ipInfo : function(){
		if(!window.remote_ip_info){
			return {
				city:'\u6d4e\u5357'
			};
		}else{
			var citys="\u6d4e\u5357,\u9752\u5c9b,\u67a3\u5e84,\u5a01\u6d77,\u70df\u53f0,\u6f4d\u574a,\u6d4e\u5b81,\u804a\u57ce,\u65e5\u7167,\u6ee8\u5dde,\u5fb7\u5dde,\u4e34\u6c82,\u83cf\u6cfd,\u4e1c\u8425,\u6cf0\u5b89,\u6dc4\u535a,\u83b1\u829c";
			if(citys.indexOf(window.remote_ip_info.city)==-1){
				return	{
					city:'\u6d4e\u5357'
				};
			}else{
				return window.remote_ip_info;
			}
		}
	},
	getCityName:function(){
		return this.ipInfo().city;
	},
	getCityDesc:function(){
		var citys="\u6d4e\u5357,\u9752\u5c9b,\u67a3\u5e84,\u5a01\u6d77,\u70df\u53f0,\u6f4d\u574a,\u6d4e\u5b81,\u804a\u57ce,\u65e5\u7167,\u6ee8\u5dde,\u5fb7\u5dde,\u4e34\u6c82,\u83cf\u6cfd,\u4e1c\u8425,\u6cf0\u5b89,\u6dc4\u535a,\u83b1\u829c";
		var val = 0;
		var city = this.ipInfo().city;
		var cities=citys.split(',');
 	  	for(var i=0;i<cities.length;i++){
 	  		if(cities[i].indexOf(city)>=0){
 	  			val = i;
				break;
 	  		}
 	  	}
	   var cs="";
       switch(val){
        case "0": cs="jn";break;
    	case "1":cs="qd";break;
    	case "2":cs="zz";break;
    	case "3":cs="wh";break;
    	case "4":cs="yt";break;
        case "5":cs="wf";break;
        case "6":cs="jng";break;
        case "7":cs="lc";break;
        case "8":cs="rz";break;
        case "9":cs="bz";break;
        case "10":cs="dz";break;
        case "11":cs="ly";break;
        case "12":cs="hz";break;
        case "13":cs="dy";break;
        case "14":cs="ta";break;
    	case "15":cs="zb";break;
    	
		default:cs = "jn";
       }
       return cs;
	},
	getCityURL:function(){
		var citys="\u6d4e\u5357,\u9752\u5c9b,\u67a3\u5e84,\u5a01\u6d77,\u70df\u53f0,\u6f4d\u574a,\u6d4e\u5b81,\u804a\u57ce,\u65e5\u7167,\u6ee8\u5dde,\u5fb7\u5dde,\u4e34\u6c82,\u83cf\u6cfd,\u4e1c\u8425,\u6cf0\u5b89,\u6dc4\u535a,\u83b1\u829c";
		var val = 0;
		var city = this.ipInfo().city;
		var cities=citys.split(',');
 	  	for(var i=0;i<cities.length;i++){
 	  		if(cities[i].indexOf(city)>=0){
 	  			val = i;
				break;
 	  		}
 	  	}
	   var URL="";
       switch(val){
        case "0":URL="http://jinan.dzwww.com/";;break;
    	case "1":URL="http://qingdao.dzwww.com/";break;
    	case "2":URL="http://zaozhuang.dzwww.com/";break;
    	case "3":URL="http://weihai.dzwww.com/";break;
    	case "4":URL="http://yantai.dzwww.com/";break;
        case "5":URL="http://weifang.dzwww.com/";break;
        case "6":URL="http://jining.dzwww.com/";break;
        case "7":URL="http://liaocheng.dzwww.com/";break;
        case "8":URL="http://rizhao.dzwww.com/";break;
        case "9":URL="http://binzhou.dzwww.com/";break;
        case "10":URL="http://dezhou.dzwww.com/";break;
        case "11":URL="http://linyi.dzwww.com/";break;
        case "12":URL="http://heze.dzwww.com/";break;
        case "13":URL="http://dongying.dzwww.com/";break;
        case "14":URL="http://taian.dzwww.com/";break;
    	case "15":URL="http://zibo.dzwww.com/";break;
    	
		default:URL = "http://jinan.dzwww.com/";
       }
       return URL;
	},
	cityy:function(val)    //把按钮的城市转换为汉字 在标题上列出
	{
		var city="";
		switch(val)
		{
			case "jn": city="济南";break;
			case "qd":city="青岛";break;
			case "zz":city="枣庄";break;
			case "wh":city="威海";break;
			case "yt":city="烟台";break;
			case "wf":city="潍坊";break;
			case "jng":city="济宁";break;
			case "lc":city="聊城";break;
			case "rz":city="日照";break;
			case "bz":city="滨州";break;
			case "dz":city="德州";break;
			case "ly":city="临沂";break;
			case "hz":city="菏泽";break;
			case "dy":city="东营";break;
			case "ta":city="泰安";break;
			case "zb":city="淄博";break;
			
			default:city="济南";
		}
		return city;
	}
};

var CityNewsCtl = {
	init:function(){
		var cityDesc = this.getCookie();
		var cityName = "济南";
        var cityURL='http://jinan.dzwww.com/';
		if(cityDesc){
			cityName = this.cityyy(cityDesc);
			cityURL = this.URLL(cityDesc);
		}else{
			cityDesc = window.IPCtl.getCityDesc();
			cityName = window.IPCtl.getCityName();
			cityURL = window.IPCtl.getCityURL();

		}
		this.showTargetCity(cityDesc,cityName,cityURL);
		this.addEvent();
	},
	cityyy:function (val)    //把按钮的城市转换为汉字 在标题上列出
	{
		var city="";
		switch(val)
		{
			case "jn": city="济南";break;
			case "qd":city="青岛";break;
			case "zz":city="枣庄";break;
			case "wh":city="威海";break;
			case "yt":city="烟台";break;
			case "wf":city="潍坊";break;
			case "jng":city="济宁";break;
			case "lc":city="聊城";break;
			case "rz":city="日照";break;
			case "bz":city="滨州";break;
			case "dz":city="德州";break;
			case "ly":city="临沂";break;
			case "hz":city="菏泽";break;
			case "dy":city="东营";break;
			case "ta":city="泰安";break;
			case "zb":city="淄博";break;
		
		}
		return city;
	},
	showTargetCity:function(city,name,cityURL){
		this.setCookie(city);
		$('#city-news .list').css({
			display: 'none',
		});
		$("#city-list li").removeClass('current');
		$("#city-list li[data-city='"+city+"']").addClass('current');
		$('#city-zone').html("<a href='"+cityURL+"' target='_blank' >"+name+"</a><i></i>");
		$("div[data-news='"+city+"']").css({
			display: 'block',
		});
	},
	setCookie:function(city){
		SetCookie ("dishis", city);
	},
	getCookie:function(){
		return getCookie('dishis');
	},
	URLL:function(val){
       var URL="";
       switch(val){
        case "jn":URL="http://jinan.dzwww.com/";;break;
    	case "qd":URL="http://qingdao.dzwww.com/";break;
    	case "zz":URL="http://zaozhuang.dzwww.com/";break;
    	case "wh":URL="http://weihai.dzwww.com/";break;
    	case "yt":URL="http://yantai.dzwww.com/";break;
        case "wf":URL="http://weifang.dzwww.com/";break;
        case "jng":URL="http://jining.dzwww.com/";break;
        case "lc":URL="http://liaocheng.dzwww.com/";break;
        case "rz":URL="http://rizhao.dzwww.com/";break;
        case "bz":URL="http://binzhou.dzwww.com/";break;
        case "dz":URL="http://dezhou.dzwww.com/";break;
        case "ly":URL="http://linyi.dzwww.com/";break;
        case "hz":URL="http://heze.dzwww.com/";break;
        case "dy":URL="http://dongying.dzwww.com/";break;
        case "ta":URL="http://taian.dzwww.com/";break;
    	case "zb":URL="http://zibo.dzwww.com/";break;
    	
		default:URL = "http://jinan.dzwww.com/";
       }
       return URL;
	},
	addEvent:function(){
		var _this = this;
		$('#city-zone').click(function(){
			$("#city-list").toggle();
		});
		$("#city-list li").click(function(e){// 点击按钮后，把选中城市存入cookies，获取城市链接
			e.preventDefault();
			e.stopPropagation();
			$("#city-list li").removeClass('current');
			$(e.currentTarget).addClass('current');
			var city = $(this).attr('data-city');
			var name = $(this).html();
			var cityURL=_this.URLL(city);
			$("#city-list").hide();
			_this.showTargetCity(city,name,cityURL);
		});
	}
};



var navParts=$(".drop-title");
var conParts=$(".drop-box");
var Gflag=0,Gtimer=null;
navParts.each(function(index,element){
	$(element).on('mouseover',function(){
		Gflag=1; 
		conParts.hide();
		navParts.removeClass('open');
		$(conParts).eq(index).show();
		if($(this).hasClass('arrow')){
			$(this).addClass('open')
		}
		startDetect();
	})
	$(element).on('mouseout',function(){
		Gflag=0;
	})
	$(conParts).eq(index).on('mouseover',function(){
		Gflag=1;
	})
	$(conParts).eq(index).on('mouseout',function(){
		Gflag=0;
	})
});

function startDetect(){
	if(Gtimer){
		clearInterval(Gtimer);
	}
	Gtimer=setInterval(function(){
	if(Gflag==0) {
		conParts.hide();
		navParts.removeClass('open');
		clearInterval(Gtimer);
	}
	},1000);
}
$('#video-frame').slides({
	preload: false,
	preloadImage: 'img/loading.gif',
	play: 3500,
	pause: 2500,
	paginationClass:'tab',
	generatePagination:false,
	hoverPause: true,
});
$("#video-frame .photo").each(function(index,element){
	var src = $(element).attr('data-video');
	if(src&&src.indexOf('mp4')>0){
		$(element).find('a.play').show();
		$(element).on('click','.bofang',function(e){
			e.preventDefault();
			pv(src,710,440,'frame',1);
			$("#video-container").fadeIn();
		});
	}
});
$("#video-container").on('click','.videoCloseBtn',function(e){
	$("#video-container").slideUp();
	CKobject.videoClear();
	$("#frame").empty();
});
$(".taber").taber({title:'div.title1 span',content:'div.con'});
$("#layout13").taber({title:'.tab li',content:'div.show ul'});
$(".taber-more").taber({title:'div.title1 span',content:'.con',onActionEnd(index,obj,container){
	var href= $(obj).find('a').attr('href');
	$(container).find('a.more').attr('href',href)
}});


$("#dzwbao select").on('change',function(e){
	var val = $(e.currentTarget).val();
	//console.log(val);
	openwin(val);
});

(function(){
	var script=document.createElement("script"),
		head=document.getElementsByTagName('head')[0]||document.documentElement;
	script.src="https://jinan.dzwww.com/dfxw/index_53608.js?t="+getCacheDate();
	script.charset="gb2312";
	document.body.appendChild(script);
})();




//轮播图鼠标覆盖动效Start
function focus_over()
{
	document.getElementById("video-frame").className="focus fw focus-over"
}

function focus_out()
{
	document.getElementById("video-frame").className="focus fw focus-out"
}
//轮播图鼠标覆盖动效End