$(function(){
	
	content_he();
	 function content_he(){
			var body_height = $('body').height(),
			header_height = $('#header').height(),
			footer_height = $('#footer').height(),
			content_height = body_height - (header_height + footer_height);
			$('#content').height(content_height);
		}
		
		$(window).resize(function() {
			content_he();
		});
	
	
	
	
	$(".jieru>a").click(function() {
		$(this).next().slideToggle();
		$(this).parent().siblings().find("ul").slideUp();
	});
/*	$(".nav>ul>li").click(function() {
		$(this).addClass('bg');
		$(this).find('div').css({
			display: 'block'
		});
		$(this).siblings().removeClass('bg');
		$(this).siblings().find('div').css({
			display: 'none'
		});
	});*/
	$(function(){
		$('#nav>ul>li').hover(function() {
			$(this).find('.second_list').css({
				display: 'block'
			});
		}, function() {
			$(this).find('.second_list').css({
				display: 'none'
			})
		});
	});
	
	$('#content .left>ul>li').click(function(){
		$(this).find('a').addClass('bg');
		$('.jieru>ul>li>a').removeClass('clor');
	});
	$('.jieru>ul>li>a').click(function(){
		$(this).addClass('clor').parent().siblings().find('a').removeClass('clor');
		$('#content .left>ul>li>a').removeClass('bg');
	});
	var i=1;
	$(".but").click(function() {
		if (i==1) {
			$('#content .left').css('width','3%');
			$('#content .right').css('width','97%');
			$('.jieru>a').css("textIndent","-9999px");
			$('.jieru>ul>li>a').css("textIndent","-9999px");
			$('#content .left>ul>li>a').css("textIndent","-9999px");
			$('.jieru>a>span').css("display","none");
			$('#content .left>ul>li>a span').css("display","none");
			$(this).addClass('butbg')
			i=2;
		}else if (i==2) {
			$('#content .left').css('width','18%');
			$('#content .right').css('width','82%');
			$('.jieru>a').css("textIndent","40px");
			$('.jieru>ul>li>a').css("textIndent","50px");
			$('#content .left>ul>li>a').css("textIndent","40px");
			$('.jieru>a>span').css("display","inline-block");
			$('#content .left>ul>li>a span').css("display","inline-block");
			$(this).removeClass('butbg')
			i=1;
		};
	});

	var j = 1;
	$('.news_button').click(function() {
		if (j==1) 
		{
			$(this).find('.ck_but').addClass('ck_but_bg');
			$(this).prev('.news_warp').slideUp();
			j=2;
		}else if (j==2) 
		{
			$(this).find('.ck_but').removeClass('ck_but_bg');
			$(this).prev('.news_warp').slideDown();
			j=1;
		};
	});
	var k = 1;
	$('.table_but_warp').click(function() {
		if (k==1) {
			$(this).find('.table_but').addClass('bg_pos');
			$("#table1").animate({right:"-100%"});

			k=2;
		}else if (k==2) {
			$(this).find('.table_but').removeClass('bg_pos');
			$("#table1").animate({right:"0"});
			k=1;
		};
	});
	
});











//绘制线条
function drawLine(style) {
	var lines = [];
	if (arguments && arguments.length) {
		for ( var i = 1; i < arguments.length; i++) {
			lines.push(arguments[i]);
		}
	}
	//console.log(lines.length);
	if (lines.length == 0) {
		return;
	}
	var polyline = new BMap.Polyline(lines, style);
	window.map.addOverlay(polyline);
}
function newp(x, y) {
	return new BMap.Point(x, y);
}
function jctc() {
	// 青年路
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.135992, 33.36097), newp(120.157982, 33.371825), newp(
			120.161719, 33.373875), newp(120.167181, 33.377131), newp(
			120.179542, 33.385331), newp(120.194633, 33.390516), newp(
			120.198226, 33.391842), newp(120.217342, 33.403417));
	// 范公路
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.225535, 33.325441), newp(120.215088, 33.34288), newp(
			120.209446, 33.354928), newp(120.200005, 33.36575), newp(
			120.191507, 33.373302), newp(120.179613, 33.385361), newp(
			120.173038, 33.397298), newp(120.169229, 33.40408), newp(
			120.163911, 33.409565), newp(120.155683, 33.42183), newp(
			120.152161, 33.424783), newp(120.146771, 33.427796), newp(
			120.133908, 33.435027), newp(120.122553, 33.440932), newp(
			120.116229, 33.44292), newp(120.103365, 33.453313));
	// 盐兴路
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.091499, 33.373366), newp(120.097895, 33.374482), newp(
			120.100913, 33.375748), newp(120.102422, 33.377267), newp(
			120.104758, 33.380282), newp(120.105584, 33.380764), newp(
			120.113525, 33.388832));
	// 世纪大道
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.108117, 33.324978), newp(120.110112, 33.325125), newp(
			120.11331, 33.32609), newp(120.122293, 33.329046), newp(120.136261,
			33.336406), newp(120.150284, 33.344972));
	// 城西干道
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.18256, 33.30648), newp(120.188345, 33.298785), newp(120.197005,
			33.284269));
	// 南环路
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.264413, 33.347777), newp(120.304298, 33.371418));
	// 青年东路
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.217342, 33.403914), newp(120.234877, 33.414583), newp(
			120.246663, 33.420429), newp(120.257083, 33.42519), newp(
			120.261395, 33.428564), newp(120.263336, 33.432481), newp(
			120.263264, 33.435735), newp(120.261898, 33.439471), newp(
			120.259742, 33.443809));
	// 环路
	drawLine({
		strokeColor : "#68AF2F",
		strokeWeight : 2,
		strokeOpacity : 1
	}, newp(120.182632, 33.306631), newp(120.206634, 33.317492), newp(
			120.234949, 33.329559), newp(120.264247, 33.347777), newp(
			120.250005, 33.363835), newp(120.241309, 33.374207), newp(
			120.232182, 33.385301), newp(120.225211, 33.393983), newp(
			120.208323, 33.414839), newp(120.203724, 33.415984), newp(
			120.198262, 33.416888), newp(120.191435, 33.421589), newp(
			120.175912, 33.432617), newp(120.16887, 33.435208), newp(
			120.160282, 33.434334), newp(120.139585, 33.42421), newp(
			120.129955, 33.419329), newp(120.121475, 33.413603), newp(
			120.112205, 33.407094), newp(120.109833, 33.403417), newp(
			120.109617, 33.394254), newp(120.113516, 33.388858), newp(
			120.115834, 33.38711), newp(120.118636, 33.384367), newp(
			120.124206, 33.378186), newp(120.127602, 33.37181), newp(120.1361,
			33.36094), newp(120.182632, 33.306631));
}

var BMapLib = window.BMapLib = BMapLib || {};

(function() {
	var AreaRestriction =
	BMapLib.AreaRestriction = function() {
	}
	var _isRestricted = false;
	var _map = null;
	var _bounds = null;
	AreaRestriction.setBounds = function(map, bounds) {
		if (!map || !bounds || !(bounds instanceof BMap.Bounds)) {
			throw "请检查传入参数值的合法性";
			return false;
		}
		if (_isRestricted) {
			this.clearBounds();
		}
		_map = map;
		_bounds = bounds;
		_map.addEventListener("moveend", this._mapMoveendEvent);
		_isRestricted = true;
		return true;
	};
	AreaRestriction._mapMoveendEvent = function(e) {
		if (_bounds.containsBounds(_map.getBounds())) {
			return;
		}
		var curBounds = _map.getBounds(), curBoundsSW = curBounds
				.getSouthWest(), curBoundsNE = curBounds.getNorthEast(), _boundsSW = _bounds
				.getSouthWest(), _boundsNE = _bounds.getNorthEast();
		var boundary = {
			n : 0,
			e : 0,
			s : 0,
			w : 0
		};
		boundary.n = (curBoundsNE.lat < _boundsNE.lat) ? curBoundsNE.lat
				: _boundsNE.lat;
		boundary.e = (curBoundsNE.lng < _boundsNE.lng) ? curBoundsNE.lng
				: _boundsNE.lng;
		boundary.s = (curBoundsSW.lat < _boundsSW.lat) ? _boundsSW.lat
				: curBoundsSW.lat;
		boundary.w = (curBoundsSW.lng < _boundsSW.lng) ? _boundsSW.lng
				: curBoundsSW.lng;
		var center = new BMap.Point(boundary.w + (boundary.e - boundary.w) / 2,
				boundary.s + (boundary.n - boundary.s) / 2);
		setTimeout(function() {
			_map.panTo(center, {
				noAnimation : "no"
			});
		}, 1);
	};
	AreaRestriction.clearBounds = function() {
		if (!_isRestricted) {
			return;
		}
		_map.removeEventListener("moveend", this._mapMoveendEvent);
		_isRestricted = false;
	};
})();
