﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
/// <reference path="miya_validator.js" />
/// <reference path="Justgo.js" />
/*| /default.aspx |******************************************************************************************/

/* 도시 선택 레이어 보이기*/
function WeatherDIVVisible(DIVID) {
	jQuery("#"+DIVID).toggle();/*
	if (document.getElementById(DIVID).style.display == "none") {
		document.getElementById(DIVID).style.display = "";
	} else {
		document.getElementById(DIVID).style.display = "none";
	}*/
}
/*구글 날씨 관련*/
function GetGoogleWeatherLoad() {

	try {
		//alert(document.getElementById("hidden_curr").value);
		GetYahooCurr(document.getElementById("hidden_curr").value, document.getElementById("tempEMXC_BUY").value);

		var oParms = "";
		//oParms = "KeyWord=" + encodeURIComponent(strSearchWord);
		//var returnValue = jQuery.ajax({ url: "/Inc/GoogleAPI.ashx?key=TOKYO", type: 'get', data: oParms, async: false }).responseText;
		jQuery.ajax({
			type: "POST",
			url: "/Inc/GoogleAPI.ashx?key=TOKYO",
			success: function(returnValue) {
				if (returnValue.length > 0) {
					var splitArr = returnValue.split("^");
					var TableString = "<table border='0' cellspacing='0' cellpadding='0'><tr>";
					for (var i = 0; i < splitArr.length; i++) {
						var splitArr2 = splitArr[i].split(",");

						TableString += "<td width='51' valign='top' ><!--오늘날씨-->";
						TableString += "<table width='55' border='0' cellpadding='0' cellspacing='0'><tr>";
						TableString += "<td align='center'><img src='" + splitArr2[0] + "' width='35' height='28' /></td>";
						TableString += "</tr>";
						TableString += "<tr>";
						TableString += "<td height='3'></td>";
						TableString += "</tr>";
						TableString += "<tr>";
						if (i == 0) {
							TableString += "<td height='14'  valign='top' align='center'><img src='../img/ico_today.gif' width='47' height='14' /></td>";
						} else {
							TableString += "<td height='14'  align='center'><span class='mainnew_07'>" + splitArr2[1] + "</span></td>";
						}
						TableString += "</tr>";
						TableString += "<tr>";
						TableString += "<td height='11'  valign='bottom' align='center'><span class='mainnew_07'>" + splitArr2[2] + "˚C</span></td>";
						TableString += "</tr>";
						TableString += "</table>";
						TableString += "<!--//오늘날씨 끝--></td>";
						//TableString += "<td width='5'></td>";
						//TableString += "<!--//오늘날씨 끝--></td><td width='5'></td>";
					}

					TableString += "</tr></table>";

					//alert(TableString);
					var tempTable = "<table width='226' align='center'  height='69' border='0' cellspacing='0' cellpadding='0' background='../img/bg_weather2.gif'  ><tr><td align='center'>";
					tempTable += TableString;
					tempTable += "</td></tr></table>";

					document.getElementById("WeatherDIV").innerHTML = tempTable;
				}
			}
		});
	}
	catch (e) {
	}
	setInterval(SetWeatherIntervalLoad, 10000);
	
	//setInterval(GetToDayString, 1000);
	//setTimeout(SetWeatherIntervalLoad, 1000);
}


function GetGoogleWeather(code, value, DIVID, LabelID, currCD, tempcurr,timeDiff) {

	try {
		//alert(DIVID);
		//alert(value);
		WeatherDIVVisible(DIVID);
		document.getElementById(LabelID).innerText = value;
		document.getElementById("hidden_curr").value = currCD;

		GetYahooCurr(currCD, tempcurr);
	
		var oParms = "";
		//oParms = "KeyWord=" + encodeURIComponent(strSearchWord);
		var returnValue = jQuery.ajax({ url: "/Inc/GoogleAPI.ashx?key=" + code, type: 'get', data: oParms, async: false }).responseText;
;
		//document.write(returnValue);
		if (returnValue.length > 0) {
			var splitArr = returnValue.split("^");
			var TableString = "<table  border='0' cellspacing='0' cellpadding='0'><tr>";
			for (var i = 0; i < splitArr.length; i++) {
				var splitArr2 = splitArr[i].split(",");

				TableString += "<td width='51' valign='top' ><!--오늘날씨-->";
				TableString += "<table width='55' border='0' cellpadding='0' cellspacing='0'><tr>";
				TableString += "<td align='center'><img src='" + splitArr2[0] + "' width='35' height='28' /></td>";
				TableString += "</tr>";
				TableString += "<tr>";
				TableString += "<td height='3'></td>";
				TableString += "</tr>";
				TableString += "<tr>";
				if (i == 0) {
					TableString += "<td height='14'  valign='top' align='center'><img src='../img/ico_today.gif' width='47' height='14' /></td>";
				}
				else {
					TableString += "<td height='14'  align='center'><span class='mainnew_07'>" + splitArr2[1] + "</span></td>";
				}
				TableString += "</tr>";
				TableString += "<tr>";
				TableString += "<td height='11'  valign='bottom' align='center'><span class='mainnew_07'>" + splitArr2[2] + "˚C</span></td>";
				TableString += "</tr>";
				TableString += "</table>";
				TableString += "<!--//오늘날씨 끝--></td>";
			}

			TableString += "</tr></table>";

			//alert(TableString);
			var tempTable = "<table width='226' align='center'  height='69' border='0' cellspacing='0' cellpadding='0' background='../img/bg_weather2.gif'  ><tr><td align='center'>";
			tempTable += TableString;
			tempTable += "</td></tr></table>";

			document.getElementById("WeatherDIV").innerHTML = tempTable;
		}
		else {
			document.getElementById("WeatherDIV").innerHTML = "<table style='text-align:center; vertical-align:middle; height:100%;'><tr><td><br/>세계 도시의 날씨 정보를 가져오는 중 입니다.</td></tr></table>";
		}
	}
	catch (e) {
	}
}

/*yahoo환률 부분 확인*/
function GetYahooCurr(CTNM,tempcurr) {
	//alert(value);

	var oParms = "";
	//oParms = "KeyWord=" + encodeURIComponent(strSearchWord);
	//var returnValue = jQuery.ajax({ url: "/Inc/GoogleAPI.ashx?CTNM=" + encodeURIComponent(CTNM), type: 'get', data: oParms, async: false }).responseText;
	var returnValue = jQuery.ajax({ url: "/Inc/GoogleAPI.ashx?CTNM=" + encodeURIComponent(CTNM), type: 'get', data: oParms, async: false }).responseText;
	
	if (returnValue.length > 0 && returnValue.length < 30) {
		document.getElementById("currLabel").innerText = returnValue + ' 원';
	}
	else {
		document.getElementById("currLabel").innerText = "   "+CTNM +"	"+ tempcurr + ' 원';
}
//alert(document.getElementById("currLabel").innerText);
}

/*세계는 지금 부분 변경 */
function GoWorldNews(cnt) {
	var totalcnt = ((document.getElementById("WorldTotalcnt").value) * 1) - 1;
	var nowcnt = (document.getElementById("Nowcnt").value) * 1;
	//alert('현제'+nowcnt);
	var sumcnt = nowcnt + cnt;
	var lastcnt = 0;
	//alert('카운트 증가'+sumcnt);
	if (sumcnt < 0) {
		lastcnt = totalcnt;
	}
	else if (sumcnt > totalcnt) {
		lastcnt = 0;
	}
	else {
		lastcnt = sumcnt;
	}
	
	var splitArr = document.getElementById("TotalCTNM").value.split("^");
	var splitArr2 = splitArr[lastcnt].split(",");

	document.getElementById("worldName").innerText = splitArr2[0];

	var oParms = "";
	//oParms = "KeyWord=" + encodeURIComponent(strSearchWord);
	//var returnValue = jQuery.ajax({ url: "/Inc/GoogleAPI.ashx?CTCD=" + splitArr2[1], type: 'get', data: oParms, async: false }).responseText;


	jQuery.ajax({
		type: "POST",
		url: "/Inc/GoogleAPI.ashx?CTCD=" + splitArr2[1],
		success: function(returnValue) {
			if (returnValue.length > 0) {
				var resultArr = returnValue.split("§");

				var FirstTable = "";
				var ResultTable = "";
				for (var j = 0; j < resultArr.length; j++) {
					if (j == 0) {
						var resultArr2 = resultArr[j].split("♣");
						FirstTable += "<table width='226' height='71' border='0' cellspacing='0' cellpadding='0' background='../img/bg_world3.gif' >";
						FirstTable += "<tr>";
						FirstTable += "<td align='center'>";
						FirstTable += "<table width='95%' border='0' cellspacing='0' cellpadding='0' >";
						FirstTable += "<tr valign='top' align='left'>";
						FirstTable += "<td width='81'><img src='" + resultArr2[0] + "' width='73' height='59' /></td>";
						FirstTable += "<td>";
						if (resultArr2[2] == "0") {
							FirstTable += "<a href='" + resultArr2[1] + "'>";
						}
						else {
							FirstTable += "<a href='" + resultArr2[1] + "' target='_blank'>";
						}
						FirstTable += "<span>" + resultArr2[3] + "</span><br />";
						//FirstTable += "도쿄 2009 ";
						FirstTable += "</a>";
						FirstTable += "</td>";
						FirstTable += "</tr>";
						FirstTable += "</table>";
						FirstTable += "</td>";
						FirstTable += "</tr>";
						FirstTable += "</table>";
						//alert(FirstTable);
						document.getElementById("worldNewsFirst").innerHTML = FirstTable;
					}
					else if (j == resultArr.length - 1) {
						var resultArr2 = resultArr[j].split("♣");
						ResultTable += "<tr align='left'>";
						ResultTable += "<td width='8' height='18' ><img src='../img/blut_1.gif' width='8' height='1' /></td>";
						ResultTable += "<td><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='left'>";
						if (resultArr2[2] == "0") {
							ResultTable += "<a href='" + resultArr2[1] + "'>";
						}
						else {
							ResultTable += "<a href='" + resultArr2[1] + "' target='_blank'>";
						}
						//ResultTable += resultArr2[3].substring(0, 16) + "..</a></td>";
						ResultTable += resultArr2[3];
						ResultTable += "<td align='right'><a href='javascript:GoWorldNews(-1)'><img src='../img/ico_world1.gif' alt='이전' width='13' height='12' /></a><a href='javascript:GoWorldNews(1)'><img src='../img/ico_world2.gif' alt='다음' width='13' height='12' /></a></td>";
						ResultTable += "</tr></table></td></tr>";
					}
					else {
						var resultArr2 = resultArr[j].split("♣");
						ResultTable += "<tr align='left'>";
						ResultTable += "<td width='8' height='18' ><img src='../img/blut_1.gif' width='8' height='1' /></td>";
						ResultTable += "<td>";
						if (resultArr2[2] == "0") {
							ResultTable += "<a href='" + resultArr2[1] + "'>";
						}
						else {
							ResultTable += "<a href='" + resultArr2[1] + "' target='_blank'>";
						}
						//ResultTable += resultArr2[3].substring(0, 25) + "...</a></td>";
						ResultTable += resultArr2[3];
						ResultTable += "</tr>";

					}

					//worldnewsContent
				}

				//alert(ResultTable);
				document.getElementById("worldnewsContent").innerHTML = "<table width='90%' border='0' cellspacing='0' cellpadding='0'>" + ResultTable + "</table>";
				document.getElementById("Nowcnt").value = lastcnt;
			}
		}
	});
}


/* 테마스팟 */
function GoThemeSpot(cnt) {
    
    var nowcnt = (document.getElementById("Nowcnt_2").value) * 1;
    var TotCnt = (document.getElementById("ToTCnt_2").value) * 1;
    
    var sumcnt = nowcnt + (cnt);
    var currCnt = sumcnt;

    document.getElementById("Nowcnt_2").value = currCnt;

    //if (parseInt(TotCnt -1) < currCnt)
    //    document.getElementById("Nowcnt_2").value = TotCnt -1;
    
    //if (currCnt == -1)
    //    document.getElementById("Nowcnt_2").value = 0;

    if (currCnt > (TotCnt - 2)) {
        document.getElementById("Nowcnt_2").value = 0;
        currCnt = 0;
    }

    if (currCnt < 0) {
        document.getElementById("Nowcnt_2").value = TotCnt - 2;
        currCnt = TotCnt - 2;
    }

    var oParms = "";

    jQuery.ajax({
        type: "POST",
        url: "/Inc/GoogleAPI.ashx?PageCnt=" + currCnt,
        success: function(returnValue) {
            if (returnValue.length > 0) {
                var resultArr = returnValue.split("§");

                var ResultTable = "";
                var ResultTable2 = "";
                //for (var j = 0; j < resultArr.length; j++) {
                for (var j = 0; j < 2; j++) {
                    if (j == 0) {
                        var resultArr2 = resultArr[j].split("♣");
                        var target = "";
                        if (resultArr2[2] == "0")
                            target = "target='_blank'";

                        ResultTable += "<div id=\"themelist1\">";
                        ResultTable += "<ul class=\"theme1\">";
                        ResultTable += "<li>";
                        ResultTable += "<a href='" + resultArr2[1] + "&keywd=IAy9u911&logger_kw=IAy9u911&source=logger_kw' " + target + ">";
                        ResultTable += "<img src='" + resultArr2[0] + "' width='105' height='100' />";
                        ResultTable += "</a>";
                        ResultTable += "</li>";
                        ResultTable += "<li>";
                        ResultTable += "<a href='" + resultArr2[1] + "&keywd=IAy9u911&logger_kw=IAy9u911&source=logger_kw' " + target + ">";
                        //ResultTable += "<b>" + getTruncText(resultArr2[3], 8) + "</b>";
                        ResultTable += "<b>" + resultArr2[3] + "</b>";
                        ResultTable += "</a>";
                        ResultTable += "</li>";
                        ResultTable += "<li>";
                        ResultTable += "<span><a href='" + resultArr2[1] + "&keywd=IAy9u911&logger_kw=IAy9u911&source=logger_kw' " + target + ">";
                        ResultTable += getTruncText(resultArr2[4], 40);
                        //ResultTable += resultArr2[4];
                        ResultTable += "</a></span>";
                        ResultTable += "</li>";
                        ResultTable += "</ul>";
                        ResultTable += "</div>";
                    }
                    else {
                        var resultArr2 = resultArr[j].split("♣");
                        var target = "";
                        if (resultArr2[2] == "0")
                            target = "target='_blank'";

                        ResultTable += "<div id=\"themelist2\">";
                        ResultTable += "<ul class=\"theme2\">";
                        ResultTable += "<li>";
                        ResultTable += "<a href='" + resultArr2[1] + "&keywd=IAy9u911&logger_kw=IAy9u911&source=logger_kw' " + target + ">";
                        ResultTable += "<img src='" + resultArr2[0] + "' width='105' height='100' />";
                        ResultTable += "</a>";
                        ResultTable += "</li>";
                        ResultTable += "<li>";
                        ResultTable += "<a href='" + resultArr2[1] + "&keywd=IAy9u911&logger_kw=IAy9u911&source=logger_kw' " + target + ">";
                        //ResultTable += "<b>" + getTruncText(resultArr2[3], 8) + "</b>";
                        ResultTable += "<b>" + resultArr2[3] + "</b>";
                        ResultTable += "</a>";
                        ResultTable += "</li>";
                        ResultTable += "<li>";
                        ResultTable += "<span><a href='" + resultArr2[1] + "&keywd=IAy9u911&logger_kw=IAy9u911&source=logger_kw' " + target + ">";
                        ResultTable += getTruncText(resultArr2[4], 40);
                        //ResultTable += resultArr2[4];
                        ResultTable += "</a></span>";
                        ResultTable += "</li>";
                        ResultTable += "</ul>";
                        ResultTable += "</div>";

                    }
                }

                //if (currCnt < 2) {
                //    ResultTable2 += "<div class=\"info2\">";
                //    ResultTable2 += "<span class=\"img1\">";
                //    ResultTable2 += "<img src=\"img/btn_listbefor_off.gif\" width=\"16\" height=\"15\" alt=\"이전\" />";
                //    ResultTable2 += "</span>";
                //    ResultTable2 += "<span class=\"img2\">";
                //    ResultTable2 += "<a href=\"javascript:GoThemeSpot(2);\"><img src=\"img/btn_listnext.gif\" width=\"16\" height=\"15\" alt=\"다음\" /></a>";
                //    ResultTable2 += "</span>";
                //    ResultTable2 += "</div>";
                //}
                //else if (currCnt >= 4) {
                //    ResultTable2 += "<div class=\"info2\">";
                //    ResultTable2 += "<span class=\"img1\">";
                //    ResultTable2 += "<a href=\"javascript:GoThemeSpot(-2);\"><img src=\"img/btn_listbefor.gif\" width=\"16\" height=\"15\" alt=\"이전\" /></a>";
                //    ResultTable2 += "</span>";
                //    ResultTable2 += "<span class=\"img2\">";
                //    ResultTable2 += "<img src=\"img/btn_listnext_off.gif\" width=\"16\" height=\"15\" alt=\"다음\" />";
                //    ResultTable2 += "</span>";
                //    ResultTable2 += "</div>";
                //}
                //else {
                    ResultTable2 += "<div class=\"info2\">";
                    ResultTable2 += "<span class=\"img1\">";
                    ResultTable2 += "<a href=\"javascript:GoThemeSpot(-2);\"><img src=\"img/btn_listbefor.gif\" width=\"16\" height=\"15\" alt=\"이전\" /></a>";
                    ResultTable2 += "</span>";
                    ResultTable2 += "<span class=\"img2\">";
                    ResultTable2 += "<a href=\"javascript:GoThemeSpot(2);\"><img src=\"img/btn_listnext.gif\" width=\"16\" height=\"15\" alt=\"다음\" /></a>";
                    ResultTable2 += "</span>";
                    ResultTable2 += "</div>";
                //}

                //alert(ResultTable);
                document.getElementById("ThemeSpotView").innerHTML = ResultTable2;
                document.getElementById("ThemeSpotList").innerHTML = ResultTable;
                //document.getElementById("Nowcnt_2").value = lastcnt;
            }
        }
    });
}



function MakerGoogleMap() {
	//
	function TextualZoomControl() {}
	TextualZoomControl.prototype = new GControl();
	// Creates a one DIV for each of the buttons and places them in a container
	// DIV which is returned as our control element. We add the control to
	// to the map container and return the element for the map class to
	// position properly.
	TextualZoomControl.prototype.initialize = function(map) {
		var container = document.createElement("div");

		var zoomInDiv = document.createElement("div");
		this.setButtonStyle_(zoomInDiv);
		container.appendChild(zoomInDiv);
		zoomInDiv.appendChild(document.createTextNode("+"));
		GEvent.addDomListener(zoomInDiv, "click", function() {
			map.zoomIn();
			if (map.getZoom() == 3) {
				var center = map.getCenter();
				
				OverGoogleMap('0', GoogleMapAddMarker('0'), center.toString());
//				var MarkerList = GoogleMapAddMarker('0');
//				var splitArr = MarkerList.split('■');

//				//alert(map.getZoom());
//				for (var i = 0; i < splitArr.length; i++) {


//					/*TMML_OCOD□	0 : seq
//					Latitude □		1 : 좌표값 
//					Longitude □	2 : 좌표값 
//					TMML_BNER		3 : 이미지
//					TMML_CST1		4 : 가로
//					TMML_CST2		5 : 세로
//					*/
//					var splitArr2 = splitArr[i].split('□');

//					var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
//					map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5],splitArr2[6],splitArr2[7]));
//				}
			}
		});

		var zoomOutDiv = document.createElement("div");
		this.setButtonStyle_(zoomOutDiv);
		container.appendChild(zoomOutDiv);
		zoomOutDiv.appendChild(document.createTextNode("-"));
		GEvent.addDomListener(zoomOutDiv, "click", function() {
			map.zoomOut();
			if (map.getZoom() <= 2) {
				MakerGoogleMap();
			}
		});

		map.getContainer().appendChild(container);
		return container;
	}

	// By default, the control will appear in the top left corner of the
	// map with 7 pixels of padding.
	TextualZoomControl.prototype.getDefaultPosition = function() {
		return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
	}

	// Sets the proper CSS for the given button element.
	TextualZoomControl.prototype.setButtonStyle_ = function(button) {
		//button.style.textDecoration = "underline";
		button.style.color = "#0000cc";
		button.style.backgroundColor = "white";
		button.style.font = "small Arial";
		button.style.border = "1px solid black";
		button.style.padding = "1px";
		button.style.marginBottom = "1px";
		button.style.textAlign = "center";
		button.style.width = "2em";
		button.style.cursor = "pointer";
	}

	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(37.566535, 126.9779692), 1);
		map.addControl(new TextualZoomControl());
		//map.addControl(new GSmallMapControl());

		GEvent.addListener(map, "dblclick", function() {
			if (map.getZoom() >= 4) {
				
				map.zoomOut();
				//alert(map.getZoom());
				if (map.getZoom() == 3) {

					var center = map.getCenter();

					OverGoogleMap('0', GoogleMapAddMarker('0'), center.toString());
					//				var MarkerList = GoogleMapAddMarker('0');
					//				var splitArr = MarkerList.split('■');

					//				//alert(map.getZoom());
					//				for (var i = 0; i < splitArr.length; i++) {


					//					/*TMML_OCOD□	0 : seq
					//					Latitude □		1 : 좌표값 
					//					Longitude □	2 : 좌표값 
					//					TMML_BNER		3 : 이미지
					//					TMML_CST1		4 : 가로
					//					TMML_CST2		5 : 세로
					//					*/
					//					var splitArr2 = splitArr[i].split('□');

					//					var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
					//					map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5], splitArr2[6], splitArr2[7]));
					//				}
				}
			}
		});
		
		// Create a base icon for all of our markers that specifies the
		// shadow, icon dimensions, etc.
		//var baseIcon = new GIcon(G_DEFAULT_ICON);
		//baseIcon.shadow = "";
		//baseIcon.iconSize = new GSize(20, 34);
		//baseIcon.shadowSize = new GSize(37, 34);
		//baseIcon.iconAnchor = new GPoint(9, 34);
		//baseIcon.infoWindowAnchor = new GPoint(9, 2);

		// Creates a marker whose info window displays the letter corresponding
		// to the given index.
		function createMarker(point, index,img,wSize,hSize,Linked,Soon) {

			var baseIcon = new GIcon(G_DEFAULT_ICON);
			baseIcon.iconSize = new GSize(wSize, hSize);
			
			// Create a lettered icon for this point using our icon class
			var letteredIcon = new GIcon(baseIcon);
			letteredIcon.image = img;

			// Set up our GMarkerOptions object
			markerOptions = { icon: letteredIcon };
			var marker = new GMarker(point, markerOptions);

			//alert(Soon);
			if (Soon != "soon")
			{
				GEvent.addListener(marker, "click", function() {
				if (map.getZoom() >= 3) {
					
						parent.window.location.href = Linked;
					}
					else if(map.getZoom() < 3){
						OverGoogleMap_s(index, GoogleMapAddMarker(index));
					}
				}
				)
			}
			;
			return marker;
		}

		var MarkerList = GoogleMapAddMarker('');
		
		/*□ : 컬럼 구분 
		■ : 로우 구분 
		*/
		var splitArr = MarkerList.split('■');
		//alert(MarkerList);
		//alert(map.getZoom());
		for (var i = 0; i < splitArr.length; i++) {
			
			if(map.getZoom() == "0" ||  map.getZoom() == "1")
			{
				/*TMML_OCOD□	0 : seq
				Latitude □		1 : 좌표값 
				Longitude □	2 : 좌표값 
				TMML_BNER		3 : 이미지
				TMML_CST1		4 : 가로
				TMML_CST2		5 : 세로
				*/
				var splitArr2 = splitArr[i].split('□');

				var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
				map.addOverlay(createMarker(latlng, splitArr2[0],splitArr2[3], splitArr2[4],splitArr2[5],splitArr2[6],splitArr2[7]));
			}
		}
		
//		for (var i = 0; i < 10; i++) {
//			var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(),
//        southWest.lng() + lngSpan * Math.random());
//			map.addOverlay(createMarker(latlng, i));
//		}
	}
}

function OverGoogleMap_s(ClickIndex, MarkerArr) {

	function TextualZoomControl() {
	}
	TextualZoomControl.prototype = new GControl();

	// Creates a one DIV for each of the buttons and places them in a container
	// DIV which is returned as our control element. We add the control to
	// to the map container and return the element for the map class to
	// position properly.
	TextualZoomControl.prototype.initialize = function(map) {
		var container = document.createElement("div");

		var zoomInDiv = document.createElement("div");
		this.setButtonStyle_(zoomInDiv);
		container.appendChild(zoomInDiv);
		zoomInDiv.appendChild(document.createTextNode("+"));
		GEvent.addDomListener(zoomInDiv, "click", function() {
			if (map.getZoom() < 4) {
				map.zoomIn();
				if (map.getZoom() = 3) {
					var center = map.getCenter();

					OverGoogleMap('0', GoogleMapAddMarker('0'), center.toString());
					//				var MarkerList = GoogleMapAddMarker('0');
					//				var splitArr = MarkerList.split('■');

					//				//alert(map.getZoom());
					//				for (var i = 0; i < splitArr.length; i++) {


					//					/*TMML_OCOD□	0 : seq
					//					Latitude □		1 : 좌표값 
					//					Longitude □	2 : 좌표값 
					//					TMML_BNER		3 : 이미지
					//					TMML_CST1		4 : 가로
					//					TMML_CST2		5 : 세로
					//					*/
					//					var splitArr2 = splitArr[i].split('□');

					//					var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
					//					map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5],'',splitArr2[7]));
					//				}
				}
			}
		});

		var zoomOutDiv = document.createElement("div");
		this.setButtonStyle_(zoomOutDiv);
		container.appendChild(zoomOutDiv);
		zoomOutDiv.appendChild(document.createTextNode("-"));
		GEvent.addDomListener(zoomOutDiv, "click", function() {
			map.zoomOut();
			if (map.getZoom() <= 2) {
				MakerGoogleMap();
			}
		});

		map.getContainer().appendChild(container);
		return container;
	}

	// By default, the control will appear in the top left corner of the
	// map with 7 pixels of padding.
	TextualZoomControl.prototype.getDefaultPosition = function() {
		return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
	}

	// Sets the proper CSS for the given button element.
	TextualZoomControl.prototype.setButtonStyle_ = function(button) {
		//button.style.textDecoration = "underline";
		button.style.color = "#0000cc";
		button.style.backgroundColor = "white";
		button.style.font = "small Arial";
		button.style.border = "1px solid black";
		button.style.padding = "1px";
		button.style.marginBottom = "1px";
		button.style.textAlign = "center";
		button.style.width = "2em";
		button.style.cursor = "pointer";
	}


	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		
		/*□ : 컬럼 구분 
		■ : 로우 구분 
		*/
		/*TMML_OCOD□	0 : seq
		Latitude □		1 : 좌표값 
		Longitude □	2 : 좌표값 
		TMML_BNER		3 : 이미지
		TMML_CST1		4 : 가로
		TMML_CST2		5 : 세로
		*/
		var splitArr = MarkerArr.split('■');
		var tempPointArr = splitArr[0].split('□');

		map.setCenter(new GLatLng(tempPointArr[1], tempPointArr[2]), 3);
		map.addControl(new TextualZoomControl());
		
		
		function createMarker(point, index, img, wSize, hSize,Linked,Soon) 
		{

			var baseIcon = new GIcon(G_DEFAULT_ICON);
			baseIcon.iconSize = new GSize(wSize, hSize);

			// Create a lettered icon for this point using our icon class
			var letteredIcon = new GIcon(baseIcon);
			letteredIcon.image = img;

			// Set up our GMarkerOptions object
			markerOptions = { icon: letteredIcon };
			var marker = new GMarker(point, markerOptions);

			//alert(Soon);
			if (Soon != "soon") {

				GEvent.addListener(marker, "click", function() {
					//OverGoogleMap(index, GoogleMapAddMarker(index));
					//alert(index);

					//alert(map.getZoom());
					//if (confirm("이동 하시겠습니까?")) {

					if (map.getZoom() >= 3) {

						//alert(Linked);
						parent.window.location.href = Linked;
					}
					else if (map.getZoom() < 3) {
						OverGoogleMap_s(index, GoogleMapAddMarker(index));
					}
					//}

				})
			};
			return marker;
		}

		GEvent.addListener(map, "dblclick", function() {
			if (map.getZoom() >= 4) {

				map.zoomOut();
				//alert(map.getZoom());
				if (map.getZoom() == 3) {

					var center = map.getCenter();

					OverGoogleMap('0', GoogleMapAddMarker('0'), center.toString());
					//				var MarkerList = GoogleMapAddMarker('0');
					//				var splitArr = MarkerList.split('■');

					//				//alert(map.getZoom());
					//				for (var i = 0; i < splitArr.length; i++) {


					//					/*TMML_OCOD□	0 : seq
					//					Latitude □		1 : 좌표값 
					//					Longitude □	2 : 좌표값 
					//					TMML_BNER		3 : 이미지
					//					TMML_CST1		4 : 가로
					//					TMML_CST2		5 : 세로
					//					*/
					//					var splitArr2 = splitArr[i].split('□');

					//					var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
					//					map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5], splitArr2[6], splitArr2[7]));
					//				}
				}
			}
		});

		for (var i = 0; i < splitArr.length; i++) {

			
				/*TMML_OCOD□	0 : seq
				Latitude □		1 : 좌표값 
				Longitude □	2 : 좌표값 
				TMML_BNER		3 : 이미지
				TMML_CST1		4 : 가로
				TMML_CST2		5 : 세로
				*/
				var splitArr2 = splitArr[i].split('□');

				var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
				map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5], splitArr2[6],splitArr2[7]));
		}
	}

}


function OverGoogleMap(ClickIndex, MarkerArr,CenterPosition) {

	function TextualZoomControl() {
	}
	TextualZoomControl.prototype = new GControl();

	// Creates a one DIV for each of the buttons and places them in a container
	// DIV which is returned as our control element. We add the control to
	// to the map container and return the element for the map class to
	// position properly.
	TextualZoomControl.prototype.initialize = function(map) {
		var container = document.createElement("div");

		var zoomInDiv = document.createElement("div");
		this.setButtonStyle_(zoomInDiv);
		container.appendChild(zoomInDiv);
		zoomInDiv.appendChild(document.createTextNode("+"));
		GEvent.addDomListener(zoomInDiv, "click", function() {
			if (map.getZoom() < 4) {
				map.zoomIn();
				if (map.getZoom() == 3) {

					var MarkerList = GoogleMapAddMarker('0');
					var splitArr = MarkerList.split('■');

					//alert(map.getZoom());
					for (var i = 0; i < splitArr.length; i++) {


						/*TMML_OCOD□	0 : seq
						Latitude □		1 : 좌표값 
						Longitude □	2 : 좌표값 
						TMML_BNER		3 : 이미지
						TMML_CST1		4 : 가로
						TMML_CST2		5 : 세로
						*/
						var splitArr2 = splitArr[i].split('□');

						var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
						map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5], '', splitArr2[7]));
					}
				}
			}
		});

		var zoomOutDiv = document.createElement("div");
		this.setButtonStyle_(zoomOutDiv);
		container.appendChild(zoomOutDiv);
		zoomOutDiv.appendChild(document.createTextNode("-"));
		GEvent.addDomListener(zoomOutDiv, "click", function() {
			map.zoomOut();
			if (map.getZoom() <= 2) {
				MakerGoogleMap();
			}
		});

		map.getContainer().appendChild(container);
		return container;
	}

	// By default, the control will appear in the top left corner of the
	// map with 7 pixels of padding.
	TextualZoomControl.prototype.getDefaultPosition = function() {
		return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
	}

	// Sets the proper CSS for the given button element.
	TextualZoomControl.prototype.setButtonStyle_ = function(button) {
		//button.style.textDecoration = "underline";
		button.style.color = "#0000cc";
		button.style.backgroundColor = "white";
		button.style.font = "small Arial";
		button.style.border = "1px solid black";
		button.style.padding = "1px";
		button.style.marginBottom = "1px";
		button.style.textAlign = "center";
		button.style.width = "2em";
		button.style.cursor = "pointer";
	}


	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));

		/*□ : 컬럼 구분 
		■ : 로우 구분 
		*/
		/*TMML_OCOD□	0 : seq
		Latitude □		1 : 좌표값 
		Longitude □	2 : 좌표값 
		TMML_BNER		3 : 이미지
		TMML_CST1		4 : 가로
		TMML_CST2		5 : 세로
		*/
		var splitArr = MarkerArr.split('■');
		//var tempPointArr = splitArr[0].split('□');
		//alert(CenterPosition);
		var tempPointArr = CenterPosition.split(',');
		var first = tempPointArr[0].substring(1, 7);
		var last = tempPointArr[1].substring(0, 7);
		map.setCenter(new GLatLng(first,last ), 3);
		map.addControl(new TextualZoomControl());


		function createMarker(point, index, img, wSize, hSize, Linked, Soon) {

			var baseIcon = new GIcon(G_DEFAULT_ICON);
			baseIcon.iconSize = new GSize(wSize, hSize);

			// Create a lettered icon for this point using our icon class
			var letteredIcon = new GIcon(baseIcon);
			letteredIcon.image = img;

			// Set up our GMarkerOptions object
			markerOptions = { icon: letteredIcon };
			var marker = new GMarker(point, markerOptions);

			//alert(Soon);
			if (Soon != "soon") {

				GEvent.addListener(marker, "click", function() {
					//OverGoogleMap(index, GoogleMapAddMarker(index));
					//alert(index);

					//alert(map.getZoom());
					//if (confirm("이동 하시겠습니까?")) {

					if (map.getZoom() >= 3) {

						//alert(Linked);
						parent.window.location.href = Linked;
					}
					else if (map.getZoom() < 3) {
						OverGoogleMap_s(index, GoogleMapAddMarker(index));
					}
					//}

				})
			};
			return marker;
		}

		GEvent.addListener(map, "dblclick", function() {
			if (map.getZoom() >= 4) {

				map.zoomOut();
				//alert(map.getZoom());
				if (map.getZoom() == 3) {

					var center = map.getCenter();

					OverGoogleMap('0', GoogleMapAddMarker('0'), center.toString());
					//				var MarkerList = GoogleMapAddMarker('0');
					//				var splitArr = MarkerList.split('■');

					//				//alert(map.getZoom());
					//				for (var i = 0; i < splitArr.length; i++) {


					//					/*TMML_OCOD□	0 : seq
					//					Latitude □		1 : 좌표값 
					//					Longitude □	2 : 좌표값 
					//					TMML_BNER		3 : 이미지
					//					TMML_CST1		4 : 가로
					//					TMML_CST2		5 : 세로
					//					*/
					//					var splitArr2 = splitArr[i].split('□');

					//					var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
					//					map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5], splitArr2[6], splitArr2[7]));
					//				}
				}
			}
		});

		for (var i = 0; i < splitArr.length; i++) {


			/*TMML_OCOD□	0 : seq
			Latitude □		1 : 좌표값 
			Longitude □	2 : 좌표값 
			TMML_BNER		3 : 이미지
			TMML_CST1		4 : 가로
			TMML_CST2		5 : 세로
			*/
			var splitArr2 = splitArr[i].split('□');

			var latlng = new GLatLng(splitArr2[1], splitArr2[2]);
			map.addOverlay(createMarker(latlng, splitArr2[0], splitArr2[3], splitArr2[4], splitArr2[5], splitArr2[6], splitArr2[7]));
		}
	}

}


///구글 지도 이미지 표시
function GoogleMapAddMarker(typeCD) {
	var oParms = "";
	//oParms = "KeyWord=" + encodeURIComponent(strSearchWord);
	var returnValue = jQuery.ajax({ url: "/Inc/GoogleAPI.ashx?GoogleMap=" + typeCD, type: 'get', data: oParms, async: false }).responseText;
	return returnValue;
}
function EventPopup() {
    
//    if (getCookie("realtime_popup") != "done") {
//        SetCenterPopup("/popup/Airtel/realtime_popup.html", "realtime", "507px", "413px", "no");
//    }

//    if (getCookie("20100728_popup") != "done") {
//        SetCenterPopup("/p 00728", "310px", "445px", "no");
//    }
//    setTimeout("", 5000);
//    if (getCookie("20100706_popup") != "done") {
//        window.open("/popup/20100706/popup_20100706.html", "20100706", "height=564, width=450, top=0, left=514, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
    //    }
//    if (getCookie("20100917_popup") != "done") {
//        window.open("/popup/20100917/popup_20100917.html", "20100917", "height=585, width=450, top=0, left=0, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
    //    }
//      if (getCookie("20101213_popup") != "done") {
//          window.open("/popup/20101213/popup_20101213.html", "20101213", "height=510, width=400, top=0, left=0, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
//      } 
//      if (getCookie("20110909_popup") != "done") {
//          window.open("/popup/20110909/201109097_popup.html", "20110909", "height=275, width=310, top=0, left=410, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
//      }

//      if (getCookie("20110825_popup") != "done") {
//          window.open("/popup/20110825/20110825_popup.html", "20110825", "height=275, width=310, top=0, left=410, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
//      }

//      if (getCookie("popup_hkphoto") != "done") {
//          window.open("/popup/20110513/popup_hkphoto.html", "20110513", "height=435, width=400, top=0, left=410, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
//      }

//      if (getCookie("20110411_popup") != "done") {
//          window.open("/popup/20110411/20110411_popup.html", "20110411", "height=313, width=310, top=0, left=410, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
//      }
//      if (getCookie("20101224_popup") != "done") {
//          window.open("/popup/20101224/20101224_popup.html", "20101224", "height=313, width=310, top=0, left=410, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
//      }

//      if (getCookie("20101231_newyear") != "done") {
//          window.open("/popup/20101231/20101231_newyear.html", "20101231", "height=513, width=400, top=0, left=730, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
      //      }

//      if (getCookie("20110224_popup") != "done") {
//          window.open("/popup/20110224/20110224_popup.html", "20110224", "height=313, width=310, top=0, left=410, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
      //      }

//      if (getCookie("20111013_popup") != "done") {
//          window.open("/popup/20111013/20111013_popup.html", "20111013", "height=345, width=445, top=0, left=0, scrollbars=no, resizable=no, menubar=no, titlebar=no, toolbar=no, status=no, directories=no");
    //      }

    if (getCookie("20120119_popup") == "done") {
        document.all['divpop'].style.visibility = "hidden";
    }
}

/************************************************************************************************************/
/// 페이지 로딩 완료시 실행
//jQuery(document).ready(function() {
//    //MakerGoogleMap();
//    //setInterval(SetWeatherIntervalLoad, 10000);
//	EventPopup();
//});

var SCount = 1;
function SetWeatherIntervalLoad() {
	//alert('SetWeatherIntervalLoad called\nSCount:' + SCount);
    
	jQuery("#pnlWeatherInfoRegionSelector span:eq(" + SCount +")").click();
	jQuery("#pnlWeatherInfoRegionSelector").hide();
	
	if (jQuery("#pnlWeatherInfoRegionSelector span:eq(" + SCount +")") == jQuery("#pnlWeatherInfoRegionSelector span:last")) {
		SCount = 0;
	}
	SCount++;
}

/************************************************************************************************************/


function getTruncText(pText, pLen) {
    var sText;
    if (pText.length > pLen)
    {
        sText = pText.substring(0, pLen);
        sText = sText + "..";
    }
    else
    {
        sText = pText;
    }

    return sText;

}

function setCookie(name, value, expiredays) {
    var todayDate = new Date();
    todayDate.setDate(todayDate.getDate() + expiredays);

    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function CheckDoneDay() {
    if (document.getElementById("checkbox").checked == true) {
        setCookie("20120119_popup", "done", 1);
    }
    document.all['divpop'].style.visibility = "hidden";
}
