/**
 * Å¬·¡½º¸í : MyPicture()
 * ±â    ´É : ÀÛÇ°¿¡ »ç¿ëµÇ´Â ÇÔ¼ö/¸Þ¼­µå
 * ÀÛ ¼º ÀÏ : 2008.01.05, ÀÌÁö¹Ìµð¾î, Á¤¿ø±¤
 *
 */
MyPicture = function () {
	// ·Î±×ÀÎÃ¼Å©
	this.ChkLogin = function () {
		if (MyLib.Cookies("MEMBER[ID]") == "") {
			if (confirm("·Î±×ÀÎÇÏ¼Å¾ß ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ´Â ÆäÀÌÁöÀÔ´Ï´Ù.\n\n·Î±×ÀÎÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?") == true) {
				Login();
			}
			return false;
		}
		return true;
	}
	// ·Î±×ÀÎÃ¼Å©2
	this.ChkLogin2 = function () {
		if (MyLib.Cookies("MEMBER[ID]") == "") {
		    Login();
		    return false;
		}
		return true;
	}

	// ÀÌ¹ÌÁö È®´ë
	this.GetImage = function (idx) {
		MyLib.ArtGalleryOpen(MyLib.TopDir + '/ArtGallery/Main.aspx?n=' + idx, 'ARTGALLERY', 800, 650);
	}

	// ÀÛ°¡ °¶·¯¸®
	this.GetGallery = function (idx) {
		MyLib.WinOpen('../ATS/Gallery.aspx?n=' + idx, 'GALLERY', 800, 650);;
	}

	// µ¿¿µ»ó
	this.GetVideo = function (idx) {
		MyLib.WinOpen('../PIC/MovieList.aspx?n=' + idx, 'MOVIE', 557, 403);
	}

	// ÀÛÇ°¹®ÀÇ
	this.GetInquiry = function (idx) {
		if (this.ChkLogin2() == false) {
			return;
		}

		location.href = MyLib.TopDir + "/Center/Email.aspx?m=NEW&c=1";
	}

	// ÀÛÇ°ÃßÃµ
	this.GetRecommend = function (idx) {
		if (this.ChkLogin2() == false) {
			return;
		}

        location.href = "mailTo:";
		//window.alert("ÁØºñÁßÀÔ´Ï´Ù.");
	}

	// e-¸Ó´Ï ÃæÀü
	this.GetMoney = function (type) {
		if (this.ChkLogin2() == false) {
			return;
		}

		//window.alert("ÁØºñÁßÀÔ´Ï´Ù.");

		switch (type) {
			case "0" : // ÇöÀç Ã¢¿¡¼­ °¡±â
				location.href = MyLib.TopDir + "/MyPage/MyMoney.aspx";
				break;

			case "1" : // »õ Ã¢ ¶ç¿ì°í ÇöÀçÃ¢ ´Ý±â
				// window.open();
				window.close();
				break;

			default : // Ã¢ ¶ç¿ö¼­ °¡±â
				location.href = MyLib.TopDir + "/MyPage/MyMoney.aspx";
				break;
		}
	}

	// ±¸¸Å
	this.GetBuying = function (idx) {
		if (this.ChkLogin2() == false) {
			return;
		}

		window.open(MyLib.TopDir + "/PIC/Buying.aspx?n=" + idx, "BUYING", "width=617, height=650, left=10, top=10, scrollbars=yes");
	}

	// °ü½ÉÀÛÇ° Ãß°¡
	this.SetWish = function (idx, mode) {
		if (mode == "POP") {
		    if (MyLib.Cookies("MEMBER[ID]") == "") {
			    alert("·Î±×ÀÎÈÄ ÀÌ¿ë °¡´ÉÇÕ´Ï´Ù.");
			    return false;
		    }
        } else {
		    if (this.ChkLogin() == false) {
			    return;
		    }
        }

        if (idx) {
		    var xml;

		    xml = new XmlHttp("GET", MyLib.TopDir + "/PIC/List.aspx?n=" + idx + "&m=WSH", []);
		    xml.Init();
    		
		    if (xml.Msg != "") {
   		        window.alert(xml.Msg);
		    } else {
		        window.alert("ÇØ´ç ÀÛÇ°À» °ü½ÉÀÛÇ°¿¡ µî·ÏÇÏ¿´½À´Ï´Ù.");
		    }
        } else {
            window.alert("ÀÛÇ°ÀÌ ¾ø½À´Ï´Ù.");
        }
	}

	// ¼³¸í º¯°æ
	this.SetDetails = function (type, seq, idx, mode) {
		switch (type) {
			case "PIC" :
				for (var i = 1; i <= 4; i++) {
					MyLib.Object("_PIC_" + i + "_").style.fontWeight = seq == i ? "bold" : "";
				}

				if (seq == 1) {
					MyLib.Object("_PIC_DTLS_").style.display = "";
					MyLib.Object("_PIC_LIST_").style.display = "none";
					MyLib.Object("_PIC_LIST_").src = "about:blank;"
				} else if (seq == 2) {
					MyLib.Object("_PIC_DTLS_").style.display = "none";
					MyLib.Object("_PIC_LIST_").style.display = "";
					MyLib.Object("_PIC_LIST_").src = MyLib.TopDir + "/PIC/Atcs.aspx?r=" + idx + "&s=NEWS";
				} else if (seq == 3) {
					MyLib.Object("_PIC_DTLS_").style.display = "none";
					MyLib.Object("_PIC_LIST_").style.display = "";
					MyLib.Object("_PIC_LIST_").src = MyLib.TopDir + "/PIC/Atcs.aspx?r=" + idx + "&s=COLM";
				} else if (seq == 4) {
					MyLib.Object("_PIC_DTLS_").style.display = "none";
					MyLib.Object("_PIC_LIST_").style.display = "";
					MyLib.Object("_PIC_LIST_").src = MyLib.TopDir + "/PIC/Atcs.aspx?r=" + idx + "&s=EXHB";
				}

				break;
			case "ATS" :
				for (var i = 1; i <= 2; i++) {
					MyLib.Object("_ATS_" + i + "_").style.fontWeight = seq == i ? "bold" : "";
				}

				if (seq == 1) {
					MyLib.Object("_ATS_DTLS_").style.display = "";
					MyLib.Object("_ATS_LIST_").style.display = "none";
					MyLib.Object("_ATS_LIST_").src = "about:blank"
				} else if (seq == 2) {
					MyLib.Object("_ATS_DTLS_").style.display = "none";
					MyLib.Object("_ATS_LIST_").style.display = "";
					MyLib.Object("_ATS_LIST_").src = MyLib.TopDir + "/PIC/Pics.aspx?r=" + idx + (typeof mode != "undefined" ? "&m=" + mode : "");
				}

				break;
		}
	}

	// Á¤·Ä ¼±ÅÃ
    this.SetOrder = function (v1, v2) {
        var frm = document.search;
        
        frm.of.value = v1;
        frm.ot.value = v2;
        frm.submit();
    }

	// ÀÛ°¡ °Ë»ö
	this.SrcArts = function (val) {
        var frm = document.search;
		var xml;
		var doc = "";

		xml = new XmlHttp("GET", MyLib.TopDir + "/PIC/List.aspx?v=" + val + "&m=ATS", []);
		xml.Init();

		try {
			var res = xml.Msg.split("\r\n");

			for (var i = 0; i < res.length; i++) {
				var item = res[i].split("\t");

				if (typeof item[1] != "undefined") {
					doc += (doc == "" ? "" : " | ") + "<a onclick='MyPicture.SetArts(\"" + item[0] + "\");' style='cursor:pointer;" + (frm.at.value == item[0] ? "font-weight:bold;" : "") + "'>" + item[1] + "</a>";
				}
			}
		} catch (e) {
			window.alert("¿¹±âÄ¡ ¾ÊÀº ¿À·ù·Î ÀÛ°¡¸¦ °Ë»öÇÏ´Âµ¥ ½ÇÆÐÇÏ¿´½À´Ï´Ù.");
			return;
		}

		MyLib.Object("_ATS_").innerHTML = "<div style=\"overflow:auto;width:215px;height:76px;\">" + doc + "</div>";
		MyLib.Object("_ATL_").style.display = "";
		MyLib.Object("_ATL_0").style.fontWeight = val ? "" : "bold";
		MyLib.Object("_ATL_1").style.fontWeight = val ? "bold" : "";
		MyLib.Object("_ATL_").focus();
	}

	// ÀÛ°¡ ¼±ÅÃ
	this.SetArts = function (val) {
        var frm = document.search;

        frm.at.value = val;
        frm.submit();
	}

	// ¿À´Ã º» ÀÛÇ° Ãß°¡ µî
	this.SetView = function (idx, img, type) {
		var day = new Date();
		var y = day.getFullYear();
		var m = day.getMonth() + 1;
		var d = day.getDate();
		var ymd = y + (m < 10 ? "0" : "") + m + (d < 10 ? "0" : "") + d;
		var db1 = MyLib.Cookies("PIC[DATE]");
		var db2 = unescape(MyLib.Cookies("PIC[LIST]"));

		if (db1 != ymd) {
			db2 = "";
			MyLib.Cookies("PIC[DATE]", ymd, 1);
		}

		var arr = db2.split("^");
		var ndb = "";
		var cnt = 0;

		for (var i = 0; i < arr.length; i++) {
			var data = arr[i].split(":");

			if (cnt >= 9) {
				break;
			}

			if (data[0] != idx) {
				ndb += (ndb == "" ? "" : "^") + arr[i];
				cnt++;
			}
		}

		ndb = (idx + ":" + img + ":" + type) + (ndb == "" ? "" : "^") + ndb;

		MyLib.Cookies("PIC[LIST]", ndb, 1);
	}

    // ÀÛÇ°µ¿¿µ»ó º¯°æÇÏ±â
	this.PlayMovies = function (obj, media_id) {
        MyLib.FlashWrite3(obj, 'http://play.tagstory.com/player/TS00@' + media_id, 335, 289, media_id, '#ffffff', 'transparent');
	}

    // Best
    this.MovieHtmlCopy = function (id) {
        var doc = "";
        
        // ¾ÆÀÌµð Áßº¹ Ã¼Å©ÇÏ±â
	    xml = new XmlHttp("GET", MyLib.TopDir + "/PIC/MovieHtml.aspx?mi=" + id, []);
	    xml.Init();

        // ·Î±×ÀÎ ¿©ºÎ
        doc = xml.Msg;

        // Ä«ÇÇÇÏ±â
        window.clipboardData.setData('Text' , doc);
        alert('ÇÃ·¹¾î¾î ¼Ò½º°¡ º¹»çµÇ¾ú½À´Ï´Ù.\n\nHTMLÀ» Áö¿øÇÏ´Â °Ô½ÃÆÇ¿¡ ºÙ¿©³Ö±â(Ctrl+V)ÇÏ¼¼¿ä.')
    }
}

var MyPicture = new MyPicture();
