function isIE(done) {
	var browser = navigator.appName;
	var b_version = navigator.appVersion;
	var version = b_version.split(";");
	var trim_Version = version[1].replace(/[ ]/g, "");
	if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0") {
		if (done == 'hidden') {
			$('select:visible').css({
				'visibility': 'hidden'
			}).attr('flag', 'true');
		} else {
			$('select[flag="true"]').css({
				'visibility': 'visible'
			}).removeAttr('flag');
		}
	};
}
/*function getPos(obj) {
	var w = $(document).width() < $('body').width() ? $(document).width() : $('body').width();
	var h = $(document).height() < $('body').height() ? $(document).height() : $('body').height();
	var sl = document.body.scrollTop > document.documentElement.scrollTop ? document.body.scrollTop: document.documentElement.scrollTop;
	var t = parseInt((document.documentElement.clientHeight - obj.height()) / 2 + sl);
	var l = parseInt((document.documentElement.clientWidth - obj.width()) / 2);
	$('<div id="mask"></div>').appendTo('body').css({
		'width': w + 'px',
		'height': h + 'px'
	});
	return {
		t: t,
		l: l
	};
}*/
function AddFavorite(sURL, sTitle) {
	try {
		window.external.addFavorite(sURL, sTitle);
	} catch(e) {
		try {
			window.sidebar.addPanel(sTitle, sURL, "");
		} catch(e) {
			alert("加入收藏夹失败，请使用Ctrl+D进行添加");
		}
	}
}

var zbCookie=document.cookie.match(/loc=(\d+).(\d+),\s(\d+).(\d+)/gi);
if(zbCookie){
	zbCookie=zbCookie.toString().split('=')[1].toString().split(',');
	var lat = zbCookie[0];var lon = zbCookie[1];
}

$(function() {
	var timer;
	$(document).bind("contextmenu",
	function(e) {
		return false;
	});
	$('.nav_list').find('a').hover(function() {
		var links = $(this).parent().attr('id');
		$('.nav_more').find('.show').removeClass('show');
		$('#x' + links).addClass('show');
		$(this).addClass('on').parent().siblings().find('.on').removeClass('on');
		clearTimeout(timer);
	},
	function() {
		timer = setTimeout(function() {
			$('.nav_list').find('.flag').click();
		},
		1000);
	}).click(function() {
		var links = $(this).parent().attr('id');
		$('.nav_more').find('.show').removeClass('show');
		$('#x' + links).addClass('show');
		$(this).addClass('on').parent().siblings().find('.on').removeClass('on');
	});
	$('.nav_more').find('ul').find('a').click(function() {
		$(this).addClass('on').parent().siblings().find('.on').removeClass('on');
	}).hover(function() {
		clearTimeout(timer);
	},
	function() {
		timer = setTimeout(function() {
			$('.nav_list').find('.flag').click();
		},
		1000);
	});
	$('.list').find('a').click(function() {
		$(this).addClass('on').parent().siblings().find('.on').removeClass('on');
		var links = $(this).attr('link');
		$('#' + links).addClass('show').siblings('.show').removeClass('show');
	});
	$('.shop_btns').find('a').click(function() {
		var flag = $(this).attr('class');
		if (flag == 'on') {
			return;
		}
		var links = $(this).attr('link');
		$('#' + links).show().css({
			'top': 0,
			'left': '740px'
		}).animate({
			'left': '0px'
		},
		1000).siblings().fadeOut();
		$(this).addClass('on').parent().siblings().find('.on').removeClass('on');
	});
	$('.apps').find('.more').click(function() {
		isIE('hidden');
		var pos = getPos($('#moreApps'));
		$('#moreApps').css({
			'top': pos.t + 'px',
			'left': pos.l + 'px'
		}).fadeIn();
	});
	$('#moreApps').find('.closeApps').click(function() {
		isIE('show');
		$('#moreApps').fadeOut();
		$('#mask').remove();
	});
	$("#slider").easySlider({
		controlsShow: false,
		speed: 800,
		auto: true,
		pause: 5000,
		continuous: true,
		hoverPause: false,
		numeric: true,
		numericId: 'slider_controls'
	});
	$(".links").easySlider({
		controlsShow: false,
		speed: 800,
		auto: true,
		pause: 5000,
		continuous: true,
		hoverPause: false,
		vertical: true
	});
	$('.host_control > a').click(function() {
		var links = $(this).attr('links');
		$(this).addClass('on').siblings('.on').removeClass('on');
		$('#' + links).show().siblings('.m').hide();
	});
	$('.world').find('a').hover(function() {
		$(this).addClass('over');
	},
	function() {
		$(this).removeClass('over');
	});
	$('#memberPhoto').click(function() {
		isIE('hidden');
		var pos = getPos($('#morePhoto'));
		$('#morePhoto').css({
			'top': pos.t + 'px',
			'left': pos.l + 'px'
		}).fadeIn();
	});
	$('#morePhoto').find('.closePhoto').click(function() {
		isIE('show');
		$('#morePhoto').fadeOut();
		$('#mask').remove();
	});
	$('.contact_main').find('.map').click(function() {
		isIE('hidden');
		var links = $(this).attr('links');
		if (links == undefined) {
			var pos = getPos($('#contactMap'));
			$('#contactMap').css({
				'top': pos.t + 'px',
				'left': pos.l + 'px',
				'visibility': 'visible'
			});
		} else if (links == '2') {
			var pos = getPos($('#contactMap2'));
			$('#contactMap2').css({
				'top': pos.t + 'px',
				'left': pos.l + 'px',
				'visibility': 'visible'
			});
		} else if (links == '3') {
			var pos = getPos($('#contactMap3'));
			$('#contactMap3').css({
				'top': pos.t + 'px',
				'left': pos.l + 'px',
				'visibility': 'visible'
			});
		} else {
			var pos = getPos($('#contactMap4'));
			$('#contactMap4').css({
				'top': pos.t + 'px',
				'left': pos.l + 'px',
				'visibility': 'visible'
			});
		}
	});
	$('#pMap').click(function() {
		isIE('hidden');
		var pos = getPos($('#contactMap'));
		$('#contactMap').css({
			'top': pos.t + 'px',
			'left': pos.l + 'px'
		}).fadeIn();
	});
	$('#contactMap').find('.closeMap').click(function() {
		isIE('show');
		$('#contactMap').css({
			'top': '-1000px',
			'left': '-1000px',
			'visibility': 'hidden'
		});
		$('#mask').remove();
	});
	$('#contactMap2').find('.closeMap').click(function() {
		isIE('show');
		$('#contactMap2').css({
			'top': '-1000px',
			'left': '-1000px',
			'visibility': 'hidden'
		});
		$('#mask').remove();
	});
	$('#contactMap3').find('.closeMap').click(function() {
		isIE('show');
		$('#contactMap3').css({
			'top': '-1000px',
			'left': '-1000px',
			'visibility': 'hidden'
		});
		$('#mask').remove();
	});
	$('#contactMap4').find('.closeMap').click(function() {
		isIE('show');
		$('#contactMap4').css({
			'top': '-1000px',
			'left': '-1000px',
			'visibility': 'hidden'
		});
		$('#mask').remove();
	});
	$('.visualizePhoto').find('.preview').click(function() {
		isIE('hidden');
		$(this).parent().siblings('img').clone().css({
			'height': '500px'
		}).appendTo('#vPhoto > .vPhoto');
		var pos = getPos($('#vPhoto'));
		$('#vPhoto').css({
			'top': pos.t + 'px',
			'left': pos.l + 'px'
		}).fadeIn();
	});
	$('.closeVPhoto').click(function() {
		isIE('show');
		$('#vPhoto').fadeOut(function() {
			$(this).find('.vPhoto').empty()
		});
		$('#mask').remove();
	});
	$("#contactSlide").easySlider({
		controlsShow: false,
		speed: 800,
		auto: true,
		pause: 3000,
		continuous: true,
		hoverPause: false
	});
	$('.addressArea').find('.title').click(function() {
		$(this).siblings('p').slideToggle();
	});
	$('.partnerBox').find('li').hover(function() {
		$(this).find('div').animate({
			'top': '0px'
		},
		100);
	},
	function() {
		$(this).find('div').animate({
			'top': '120px'
		},
		100);
	});
	if(lat&&lon){
		$('.shenghuo').attr('href','./code/points.php?lon='+lon+'&lat='+lat);
		$('.shxx').attr('href','./code/points.php?lon='+lon+'&lat='+lat);
	}
})

