var currentNum = 1;

function chgimggoodlayer(num) {
	
	objimg=document.getElementById("imggood");

	if(currentNum == 1)	obj1=document.getElementById("chgimgdiv1");
	else				obj1=document.getElementById("chgimgdiv11");

	obj2=document.getElementById("chgimgdiv2");
	
	if (num==1) {
		objimg.src="http://l.yimg.com/ne/imagebox/2006/v2/images/btn_imggood1.gif";
		obj1.style.display="block";
		obj2.style.display="none";
	} 
	else if (num==2) {
		objimg.src="http://l.yimg.com/ne/imagebox/2006/v2/images/btn_imggood2.gif";
		obj1.style.display="none";
		obj2.style.display="block";
	}
}
function chgbg(obj,onoff) {
	if(onoff=="on") {
		obj.className="catebg1";
	} else {
		obj.className="catebg2";
	}
}
function chgimg(objname,imgsrc) {
	obj=document.getElementById(objname);
	obj.src=imgsrc;
}
function setfolder(num,foldername) {
	obj=document.getElementById("selectfolder_ov");
	obj.style.display="none";
	obj2=document.getElementById("selectfolder");
	obj2.style.display="block";
	obj2.innerHTML = foldername;

	// gallery_num setting
	document.fimgupload.gallery_num.value	= num;
}

function viewlayer2(name,onoff) {
	if (onoff=="off") {
		obj=document.getElementById(name);
		obj.style.display="none";
	} else {
		obj=document.getElementById(name);
		obj.style.display="block";
	}
}

function viewlayer(name) {

	obj=document.getElementById(name);
	
	if(obj.style.display == "block")	obj.style.display="none";
	else								obj.style.display="block";
}
function insertcate(mainCat, mainName, subCat, subName, catlistdiv) {

	/*
	insertTxt="";
	if (cate==1) {
		insertTxt=insertTxt+"»ç¶÷µé";
	} else if (cate==2) {
		insertTxt=insertTxt+"Áñ°Å¿ò";
	} else if (cate==3) {
		insertTxt=insertTxt+"½ºÆ÷Ã÷";
	} else if (cate==4) {
		insertTxt=insertTxt+"»ç¶û½º·¯¿ò";
	} else if (cate==5) {
		insertTxt=insertTxt+"¾Æ¸§´Ù¿ò";
	} else if (cate==6) {
		insertTxt=insertTxt+"Æù»çÁø Ä·»çÁø";
	}
	*/
	
	/* ·Î±×ÀÎ Ã¼Å© ÈÄ ·Î±×ÀÎÀÌ ÇÊ¿äÇÑ Ä«Å×°í¸® ÀÏ °æ¿ì´Â reload */
	/*
	if(document.getElementById("yahoo_id").value == "") { // ·Î±×ÀÎ Àü
		
		if(subCat == "AL") {
			
			var goOrNot	= confirm("·Î±×ÀÎÀÌ ÇÊ¿äÇÑ Ä«Å×°í¸® ÀÔ´Ï´Ù.\nÆäÀÌÁö¸¦ ÀÌµ¿ÇÏ½Ã¸é ±×µ¿¾È ÀÔ·ÂÇÑ ³»¿ëÀÌ »ç¶óÁý´Ï´Ù.\n°è¼ÓÇÏ½Ã°Ú½À´Ï±î?");

			if(goOrNot) { // true
				document.location.href='/GALLERY/write.html?cat='+subCat;
			}
			return; // false
		}
	}*/

	// get category real name instead of number
	insertTxt = mainName;

	insertTxt=insertTxt+" &gt <strong>"+subName+"</strong>";

	// registerd user
	if(document.getElementById("selectcatelist2")) {

		obj=document.getElementById("viewcate");
		obj.innerHTML=insertTxt;
		viewlayer('selectcatelist2');
	}
	else {
		obj=document.getElementById("viewcate");
		obj.innerHTML=insertTxt;
		viewlayer('selectcatelist');
	}

	document.fimgupload.sel_large.value	= mainCat;
	document.fimgupload.sel_small.value	= subCat;
}
function viewMenu(menu) {
	if (menu==1) document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_home/*http://kr.image.yahoo.com"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_1_on.gif"></a>');
	else document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_home/*http://kr.image.yahoo.com"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_1_off.gif" onmouseover="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_1_ov.gif\'" onmouseout="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_1_off.gif\'"></a>');
	if (menu==2) document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_cool/*http://kr.image.yahoo.com/GALLERY/cool_main.html"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_2_on.gif"></a>');
	else document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_cool/*http://kr.image.yahoo.com/GALLERY/cool_main.html"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_2_off.gif" onmouseover="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_2_ov.gif\'" onmouseout="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_2_off.gif\'"></a>');
	/*
	if (menu==4) document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_cool/*http://kr.image.yahoo.com/MY/mybox_list.html"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_3_on.gif"></a>');
	else document.write('<a href="#"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_3_off.gif" onmouseover="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_3_ov.gif\'" onmouseout="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_3_off.gif\'"></a>');
	if (menu==5) document.write('<a href="#"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_4_on.gif"></a>');
	else document.write('<a href="#"><img src="http://l.yimg.com/ne/imagebox/2006/v2/images/menu_4_off.gif" onmouseover="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_4_ov.gif\'" onmouseout="this.src=\'http://l.yimg.com/ne/imagebox/2006/v2/images/menu_4_off.gif\'"></a>');
	if (menu==3) document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_jaeyong/*http://kr.image.yahoo.com/PROMO/purejy/jy_vote.html"><img src="http://l.yimg.com/ne/imagebox/2006/promo/purejy/menu_3_1_on.gif"></a>');
	else document.write('<a href="http://kr.rd.yahoo.com/image/imagebox/mainmenu_jaeyong/*http://kr.image.yahoo.com/PROMO/purejy/jy_vote.html"><img src="http://l.yimg.com/ne/imagebox/2006/promo/purejy/menu_3_1_off.gif" onmouseover="this.src=\'http://l.yimg.com/ne/imagebox/2006/promo/purejy/menu_3_1_ov.gif\'" onmouseout="this.src=\'http://l.yimg.com/ne/imagebox/2006/promo/purejy/menu_3_1_off.gif\'"></a>');
 	*/
}

function newwin(a,b,c) {
	window.open(a,b,c);
}

function chg_checkbox_value(obj) {
	if (obj.checked)	obj.value = 0;
	else					obj.value = 1;
}

function insert_object(ob_contents)
{
        document.write(ob_contents);
}


// write submit
function checkMainFrm() {

	var Frm = document.fimgupload;

	if (Frm.sfilelist.value == "")

			alert ("Ã·ºÎµÈ ÀÌ¹ÌÁö°¡ ¾ø½À´Ï´Ù. ´Ù½Ã ½ÃµµÇØ ÁÖ¼¼¿ä.");

	else {

		if(Frm.Mode.value == "Mod" || Frm.yahoo_id.value == "") {

			if(Frm.yahoo_id.value == "" || Frm.member.value == 0) {
				if ( isWhitespace(Frm.user_name.value)){
					alert ("ÀÌ¸§À» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
					Frm.user_name.focus();
					return;					
				}else if( isWhitespace(Frm.user_pwd.value) ){
					alert ("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");				
					Frm.user_pwd.focus();
					return;
				}
			}
			else if(isWhitespace(Frm.gallery_num.value)){
					alert("¸¶ÀÌ¹Ú½º¸¦ ¼±ÅÃÇÏ¼¼¿ä.");
					Frm.gallery_num.focus();
					return;
			}
		}
			
		if ( isWhitespace(Frm.sel_large.value)){
			alert ("Ä«Å×°í¸® ´ëºÐ·ù¸¦ ¼±ÅÃ ÇØ ÁÖ¼¼¿ä.");	
			// Frm.sel_large.focus();
			return;
		}else if(isWhitespace(Frm.sel_small.value)){
			alert ("Ä«Å×°í¸® ¼ÒºÐ·ù¸¦ ¼±ÅÃ ÇØ ÁÖ¼¼¿ä.");	
			// Frm.sel_small.focus();
			return;
		}else if( isWhitespace(Frm.title.value)){
			alert ("Á¦¸ñÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			Frm.title.focus();
			return;
		}
		else {

			/*
			if(Frm.Mode.value == "Mod"){

				Frm.delfilelist.value = delfilelist;
			}
			*/

            switch ( Frm.filenum.value ) {
                case "1" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
                    break;
                case "2" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
                    break;
                case "3" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
                    break;
                case "4" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
                    break;
                case "5" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
        			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
                    break;
                case "6" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
        			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
        			Frm.content_5.value = Frm.yeditor_5.bodyHTML;
                    break;
                case "7" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
        			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
        			Frm.content_5.value = Frm.yeditor_5.bodyHTML;
        			Frm.content_6.value = Frm.yeditor_6.bodyHTML;
                    break;
                case "8" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
        			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
        			Frm.content_5.value = Frm.yeditor_5.bodyHTML;
        			Frm.content_6.value = Frm.yeditor_6.bodyHTML;
        			Frm.content_7.value = Frm.yeditor_7.bodyHTML;
                    break;
                case "9" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
        			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
        			Frm.content_5.value = Frm.yeditor_5.bodyHTML;
        			Frm.content_6.value = Frm.yeditor_6.bodyHTML;
        			Frm.content_7.value = Frm.yeditor_7.bodyHTML;
        			Frm.content_8.value = Frm.yeditor_8.bodyHTML;
                    break;
                case "10" :
			        Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
        			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
        			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
        			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
        			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
        			Frm.content_5.value = Frm.yeditor_5.bodyHTML;
        			Frm.content_6.value = Frm.yeditor_6.bodyHTML;
        			Frm.content_7.value = Frm.yeditor_7.bodyHTML;
        			Frm.content_8.value = Frm.yeditor_8.bodyHTML;
        			Frm.content_9.value = Frm.yeditor_9.bodyHTML;
                    break;
            }
			
			//Frm.content_0.value = Frm.yeditor_0.bodyHTML;	
/*

			Frm.content_1.value = Frm.yeditor_1.bodyHTML;
			Frm.content_2.value = Frm.yeditor_2.bodyHTML;
			Frm.content_3.value = Frm.yeditor_3.bodyHTML;
			Frm.content_4.value = Frm.yeditor_4.bodyHTML;
			Frm.content_5.value = Frm.yeditor_5.bodyHTML;
			Frm.content_6.value = Frm.yeditor_6.bodyHTML;
			Frm.content_7.value = Frm.yeditor_7.bodyHTML;
			Frm.content_8.value = Frm.yeditor_8.bodyHTML;
			Frm.content_9.value = Frm.yeditor_9.bodyHTML;
*/

			Frm.submit();
		}

	}
}

function isWhitespace (s) {
	var whitespace = " \t\n\r";
	var i;
	for (i=0; i<s.length; i++) {
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}

function magalert() {

	alert("½º¶óÀÌµå¼î°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
}

function flashOut() {
	document.all.viewer_fl.setVariable('_root.isOnFlash',1);
	document.all.viewer_fl.setVariable('_root.isOverFlash',0);
	document.all.viewer_fl.setVariable('_root.notOnFlash',0);
}

function flashIn() {
	document.all.viewer_fl.setVariable('_root.isOverFlash',1);
	document.all.viewer_fl.setVariable('_root.notOnFlash',1);
}

function bclick(p){
	
	if(p == "p_gallery_add"){
		f = document.all;  
		yahoo_id = f.yahoo_id.value;
		redirect_url = f.redirect_url.value;

		var url = "/MY/ma_gallery_record_p.html?redirect_url="+redirect_url+"&id="+yahoo_id;
		if(yahoo_id == ""){
			alert("·Î±×ÀÎÈÄ »ç¿ëÇÏ¼¼¿ä!");
			return;
		}
		window.open(url, 'mag_p' ,'left=400,top=400,width=100,height=144,toolbar=0,menubar=0,status=1,scrollbars=0,resizable=0');
	}
}

function changeList(showNum, hideNum) {

	var showObj, hideObj;
	showObj = document.getElementById("chgimgdiv"+showNum);
	hideObj = document.getElementById("chgimgdiv"+hideNum);

	showObj.style.display = "block";
	hideObj.style.display = "none";

	currentNum = showNum;
}
