﻿var MIN = MIN ||{}; MIN.HOME = MIN.HOME ||{}; MIN.HOME.BG = MIN.HOME.BG ||{}; MIN.HOME.VA = MIN.HOME.VA ||{}; 
var doc = document, win = window;

MIN.HOME.BG = {	
	IMG:[	
			{id:1, desCN:"中国 北京 世贸天阶 2011", desEN:"The Place, Beijing, China", locT:"100"},
			{id:2, desCN:"印度尼西亚 巴厘岛 圣泉寺", desEN:"Pura Tirta Empul, Bali, Indonesia", locT:"100"},
			{id:3, desCN:"印度尼西亚 巴厘岛 海神庙", desEN:"Tanah Lot, Bali, Indonesia", locT:"100"},
			{id:4, desCN:"印度尼西亚 巴厘岛 京打马尼 巴都尔火山", desEN:"Gunung Batur, Kintamani, Bali, Indonesia", locT:"100"},
			{id:5, desCN:"印度尼西亚 巴厘岛 海神庙", desEN:"Tanah Lot, Bali, Indonesia", locT:"100"},
			{id:6, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},
			{id:7, desCN:"中国 北京 颐和园 2011", desEN:"The Summer Palace, Beijing, China", locT:"100"},
			{id:8, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},	
			{id:9, desCN:"印度尼西亚 巴厘岛 努沙杜瓦", desEN:"Nusa Dua, Bali, Indonesia", locT:"100"},
			{id:10, desCN:"印度尼西亚 巴厘岛 登巴萨机场", desEN:"Denpasar Airport, Bali, Indonesia", locT:"100"},
			{id:11, desCN:"印度尼西亚 巴厘岛 蓝点", desEN:"Blue Point, Bali, Indonesia", locT:"100"},
			{id:12, desCN:"印度尼西亚 巴厘岛 蓝点", desEN:"Blue Point, Bali, Indonesia", locT:"100"},
			{id:13, desCN:"中国 西安 秦始皇陵兵马俑 2011", desEN:"The Terra-cotta Warriors and Horses, Xi'an, China", locT:"100"},
			{id:14, desCN:"中国 西安 秦始皇陵兵马俑 2011", desEN:"The Terra-cotta Warriors and Horses, Xi'an, China", locT:"100"},
			{id:15, desCN:"印度尼西亚 巴厘岛 乌布", desEN:"Ubud, Bali, Indonesia", locT:"100"},
			{id:16, desCN:"印度尼西亚 巴厘岛 蓝点", desEN:"Blue Point, Bali, Indonesia", locT:"100"},
			{id:17, desCN:"印度尼西亚 巴厘岛 乌鲁瓦图 情人崖", desEN:"Uluwatu Tempel, Bali, Indonesia", locT:"100"},
			{id:18, desCN:"印度尼西亚 巴厘岛 乌鲁瓦图 情人崖", desEN:"Uluwatu Tempel, Bali, Indonesia", locT:"100"},
			{id:19, desCN:"印度尼西亚 巴厘岛 蓝点", desEN:"Blue Point, Bali, Indonesia", locT:"100"},
			{id:20, desCN:"印度尼西亚 巴厘岛 旧圣泉寺", desEN:"Gunung Kawi, Bali, Indonesia", locT:"100"},
			{id:21, desCN:"印度尼西亚 巴厘岛 乌鲁瓦图北", desEN:"North Uluwatu, Bali, Indonesia", locT:"100"},
			{id:22, desCN:"印度尼西亚 巴厘岛 金巴兰", desEN:"Jimbaran, Bali, Indonesia", locT:"100"},
			{id:23, desCN:"印度尼西亚 巴厘岛 金巴兰", desEN:"Jimbaran, Bali, Indonesia", locT:"100"},
			{id:24, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},
			{id:25, desCN:"印度尼西亚 巴厘岛 努沙杜瓦", desEN:"Nusa Dua, Bali, Indonesia", locT:"100"},
			{id:26, desCN:"印度尼西亚 巴厘岛 乌鲁瓦图 情人崖", desEN:"Uluwatu Tempel, Bali, Indonesia", locT:"100"},
			{id:27, desCN:"印度尼西亚 巴厘岛 圣泉寺", desEN:"Pura Tirta Empul, Bali, Indonesia", locT:"100"},
			{id:28, desCN:"印度尼西亚 巴厘岛 海神庙", desEN:"Tanah Lot, Bali, Indonesia", locT:"100"},
			{id:29, desCN:"中国 广西 南宁", desEN:"Nanning, Guangxi, China", locT:"100"},
			{id:30, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},
			{id:31, desCN:"中国 西安 秦始皇陵兵马俑 2011", desEN:"The Terra-cotta Warriors and Horses, Xi'an, China", locT:"100"},
			{id:32, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},
			{id:33, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:34, desCN:"中国 西安 秦始皇陵兵马俑 2011", desEN:"The Terra-cotta Warriors and Horses, Xi'an, China", locT:"100"},
			{id:35, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:36, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:37, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:38, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:39, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:40, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:41, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:42, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:43, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:44, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:45, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:46, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:47, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:48, desCN:"中国 广西 北海 涠洲岛", desEN:"Weizhou Island, Beihai, Guangxi, China", locT:"100"},
			{id:49, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},
			{id:50, desCN:"中国 广西 北海", desEN:"Beihai, Guangxi, China", locT:"100"},
			{id:51, desCN:"俄罗斯 西西伯利亚 2008", desEN:"West Siberia, Russia", locT:"100"},
			{id:52, desCN:"挪威 奥斯陆 诺贝尔和平中心 2008", desEN:"Nobel Peace Center, Oslo, Norway", locT:"100"},
			{id:53, desCN:"挪威 奥斯陆 市政厅 2008", desEN:"Oslo, Norway", locT:"100"},
			{id:54, desCN:"挪威 奥斯陆 2008", desEN:"Oslo, Norway", locT:"100"},
			{id:55, desCN:"瑞典 哈姆斯塔德 2009", desEN:"Halmstad, Sweden", locT:"100"},
			{id:56, desCN:"瑞典 马尔默 2009", desEN:"Malmo, Sweden", locT:"100"},
			{id:57, desCN:"德国 法兰克福 机场 2009", desEN:"Airport, Frankfurt, Germany", locT:"100"},
			{id:58, desCN:"瑞典 哈姆斯塔德 2009", desEN:"Halmstad, Sweden", locT:"100"},
			{id:59, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:60, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:61, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:62, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:63, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:64, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:65, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:66, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:67, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
			{id:68, desCN:"中国 陕西 华山 2011", desEN:"Mountain Hua, Shaanxi, China", locT:"100"},
		]
};

(function(){
		
		function rdBG(b,e){
		    if(!b && b!=0 || !e){return "?";}
		    return Math.floor( ( Math.random() * e ) + b );
		}
		
		function toggleBG() {		
				var eBody = doc.body;
				var iii = rdBG(1,68); 
				var path;
				//alert(doc.documentElement.clientHeight);
				if(doc.documentElement.clientHeight>860) {
					path = "1024/";
				} else if(doc.documentElement.clientHeight>600 && doc.documentElement.clientHeight <= 860){
					path = "800/";
				} else if(doc.documentElement.clientHeight>480 && doc.documentElement.clientHeight <= 600){
					path = "600/";
				} else {
					path = "480/";
				}
				var bgStr = "background:transparent url('images/home/bg/"+path+iii+".jpg') repeat fixed right bottom";
				eBody.setAttribute("style",bgStr);
				eBody.style.cssText = bgStr;
				bgInfo(iii);
		}
		
		function noIE() {
				var oUA = navigator.userAgent.toLowerCase();
				if(oUA.indexOf('msie') != -1) {
					if(oUA.indexOf('msie 9.0') != -1) { ; }
					else {
						var oBGD = doc.getElementById("bgdes");
						var divE = doc.createElement("div");
						divE.innerHTML = "您当前使用的 Internet Explorer 浏览器对本站支持较差, 请升级至 <a href='http://windows.microsoft.com/zh-CN/internet-explorer/products/ie-9/HOME'>IE9</a> 版本或者使用其他浏览器.";
						divE.style.cssText = "position:absolute; top:72px; left:100px; width: 640px; color: #39f; font-size: 14px; margin: 90px 0px 0px 0px;  text-align:left;";
						oBGD.parentNode.appendChild(divE);
						//doc.documentElement.insertBefore(divE,oBGD.parentNode);
					}
				}
		}
		
		function bgInfo(iId){
			var oBGD = doc.getElementById("bgdes");
			$("#bgdes > div").remove();
			var sBGD = "top:"+ MIN.HOME.BG.IMG[iId-1].locT +"px";
			oBGD.setAttribute("style", sBGD);
			oBGD.style.cssText = sBGD;

			var divECN = doc.createElement("div");
			var sSLECN = "font-size: 14px; padding: 6px 0px 0px 4px; text-align:left;";
			cnTXT=doc.createTextNode(MIN.HOME.BG.IMG[iId-1].desCN);
			divECN.appendChild(cnTXT);
			divECN.setAttribute("style", sSLECN);
			divECN.style.cssText = sSLECN;
			oBGD.appendChild(divECN);
			
			var divEEN = doc.createElement("div");
			var sSLEEN = "font-size: 9px; padding: 0px 0px 0px 4px; text-align:left;";
			enTXT=doc.createTextNode(MIN.HOME.BG.IMG[iId-1].desEN);
			divEEN.appendChild(enTXT);
			divEEN.setAttribute("style", sSLEEN);
			divEEN.style.cssText = sSLEEN;
			oBGD.appendChild(divEEN);
		}

		function init() {
			noIE();
			toggleBG();
			$("#bgdes").delay(2000).fadeIn("slow");
			$("#eheader").delay(4000).slideDown("slow");
			$("#efooter").delay(4100).slideDown("slow");
			$("#lazy").delay(4400).slideDown("slow");			
		}
				
		function addEventHandler(oNode, sEvt, sFunc, bCaptures) { 
			if(typeof(window.event) != "undefined") 
				oNode.attachEvent("on" + sEvt, sFunc); 
			else oNode.addEventListener(sEvt, sFunc, bCaptures); 
		}
		
		addEventHandler(win, "load", init, false);
		addEventHandler(win,'resize', init, false);
				
		$("#leaveMSG").click(function () {
        	$("#wbshow").fadeOut("fast");
        	$("#msgpub").fadeIn("fast"); 
        	$("#lMSG").fadeOut("slow");
      	});
      	
      	
		$("#msglink").click(function () {
			$("#infoboard").toggle("fast");
			$("#wbshow").toggle("slow");
			$("#msgshow").toggle("slow");
		});    

      	$(document).ready(function(event) {
	      	var t = rdBG(1,10);
	      	$('#ivar').val(t);
	      	$('#ival').val(MIN.HOME.VA[t-1]);
	 
			$('#msgpub input, #msgpub textarea').bind('blur keyup',function() {
			
			if($('#iname').val()) {
				$('#live-preview-display').removeClass('livenone').addClass('liveblock');
			
				var oDate=new Date();
				var oT = oDate.getFullYear()+"-"+oDate.getMonth()+"-"+oDate.getDate()+" "+oDate.getHours()+":"+oDate.getMinutes()+":"+oDate.getSeconds();
				if($('#iurl').val() && /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{2}/.test($('#iurl').val())) {
					$('#lp-fooinfo').html('<span class="iBy">by</span> <a href="' + $('#iurl').val() + '" title="' + $('#iname').val() + '"><span class="iBy" style="text-decoration:underline;">' + $('#iname').val() + '</span></a> <span class="iBy">' + oT + '</span>');
				}
				else {
					$('#lp-fooinfo').html('<span class="iBy">by ' + $('#iname').val() + ' ' + oT + '</span>');
				}	
				
				$('#lp-comment').text($('#imessage').val());
				$('#lp-comment').text($('#lp-comment').html().replace(/\n/g,'<br />'));
			}
			else {
				$('#live-preview-display').removeClass('liveblock').addClass('livenone');
			}
		});
});

 

})();


