var  baseImgURL;
function imgON(obj)
{
     baseImgURL = obj.src;
     obj.src = obj.src.replace("off", "on");
}
function imgOFF(obj)
{
     obj.src = baseImgURL;
}

function numberonly()
{
    if( event.keyCode < 45 || event.keyCode > 57 ) 
		event.returnValue = false;
}

// ¸Þ´ºÀÇ »ö»óº¯°æ
function Change(Object, Value)
{
    if( Value != "" )
	{
	      Object.style.backgroundColor = Value;
//		  document.all.MUSIC.src='/common/menu.wav';
	}
    else
	      Object.style.backgroundColor = "";
}

function trim( strValue )
{
	var ReturnValue = "";

     if( strValue == "" )
         return "";

	for(i=0;i<strValue.length;i++)
     {
		if(strValue.charAt(i) != " ")
			ReturnValue = ReturnValue + strValue.charAt(i);
	}

     return ReturnValue;
}

function makeCenterWindow(pageURL, windowId, widthWindow, heightWindow, scrolltype)
{
	var height = screen.height;
	var width = screen.width;
	var leftpos = width / 2 - widthWindow / 2;
	var toppos = height / 2 - heightWindow / 2;

	var w = open(pageURL, windowId, "scrollbars="+scrolltype+", resizable=yes, width=" + widthWindow + ", height=" + heightWindow + ", left=" + leftpos + ", top=" + toppos);
	w.focus();
}

function makeCenterWindowScrollResize(pageURL, windowId, widthWindow, heightWindow, scrolltype)
{
	var height = screen.height;
	var width = screen.width;
	var leftpos = width / 2 - widthWindow / 2;
	var toppos = height / 2 - heightWindow / 2;

	var w = open(pageURL, windowId, "scrollbars="+scrolltype+", resizable=yes, width=" + widthWindow + ", height=" + heightWindow + ", left=" + leftpos + ", top=" + toppos);
	w.focus();
}

function imageWindow(what)
{
	var imgwin = makeCenterWindow('/etc/image_view.jsp?imgUrl=' + what , '_blank', 10, 10);
}


//-----------------------------------------------------------------------------------------------------------------------------
var imgResizeFlag = true;
var loofcount = 0;
function resizeImgWindows() 
{
    alert(++loofcount);
    if(imgResizeFlag) 
    {
        pic = document.all('IMGDIV');
        if( eval(pic.height) && eval(pic.width) ) 
        {
            var name = navigator.appName;
            if(name == 'Microsoft Internet Explorer') 
            {
                myHeight = eval(pic).height + 31;
                myWidth  = eval(pic).width + 10;
            } 
            else 
            {
                myHeight = eval(pic).height + 9;
                myWidth  = eval(pic).width;
            }
            clearTimeout();

            var height  = screen.height;
            var width   = screen.width;
            var leftpos = width / 2 - myWidth / 2;
            var toppos  = height / 2 - myHeight / 2;
            self.moveTo(leftpos, toppos);
            self.resizeTo(myWidth, myHeight);
        } 
        else
            setTimeOut(resizeImgWindows(), 1000);
    }
    imgResizeFlag = false;
}

function imgView(param)
{
    var height  = screen.height;
    var width   = screen.width;
    var leftpos = width/2;
    var toppos  = height/2;

    var w = open("about:blank", "_blank", "scrollbars=yes, resizable=yes, width=10, height=10, left=" + leftpos + ", top=" + toppos);
    w.document.open();

    printf = w.document.writeln;
    printf("<HTML>");
    printf("<HEAD>");
    printf("<TITLE>»ó¼¼º¸±â</TITLE>");
    printf("<META HTTP-EQUIV=CONTENT-TYPE CONTENT=TEXT/HTML; CHARSET=EUC-KR>");

    // ÀÌ¹ÌÁö ÀÚµ¿È®´ë ½ºÅ©¸³Æ® 
    printf("<SCRIPT LANGUAGE=JAVASCRIPT>                                         ");
    printf("var imgResizeFlag = true;                                            ");
    printf("var loofcount = 0;                                                   ");
    printf("function resizeImgWindows()                                          ");
    printf("{                                                                    ");
    printf("    if(imgResizeFlag)                                                ");
    printf("    {                                                                ");
    printf("        pic = document.all('IMGDIV');                                ");
    printf("        if( eval(pic.height) && eval(pic.width) )                    ");
    printf("        {                                                            ");
    printf("            var name = navigator.appName;                            ");
    printf("            if(name == 'Microsoft Internet Explorer')                ");
    printf("            {                                                        ");
    printf("                myHeight = eval(pic).height + 50;                    ");
    printf("                myWidth  = eval(pic).width  + 40;                     ");
    printf("            }                                                        ");
    printf("            else                                                     ");
    printf("            {                                                        ");
    printf("                myHeight = eval(pic).height + 9;                     ");
    printf("                myWidth  = eval(pic).width;                          ");
    printf("            }                                                        ");
    printf("            clearTimeout();                                          ");
    printf("                                                                     ");
    printf("            var height  = screen.height;                             ");
    printf("            var width   = screen.width;                              ");
    printf("            var leftpos = width / 2 - myWidth / 2;                   ");
    printf("            var toppos  = height / 2 - myHeight / 2;                 ");
    printf("            if( myHeight  > screen.height-30 )                       ");
    printf("            {                                                        ");
    printf("                 toppos   = 0;                                       ");
    printf("                 myHeight = screen.height-30;                        ");
    printf("            }                                                        ");
    printf("            if( myWidth  > screen.width-40 )                         ");
    printf("            {                                                        ");
    printf("                 leftpos  = 0;                                       ");
    printf("                 myWidth  = screen.width-40;                        ");
    printf("            }                                                        ");
    printf("            self.moveTo(leftpos, toppos);                            ");
    printf("            self.resizeTo(myWidth, myHeight);                        ");
    printf("        }                                                            ");
    printf("        else                                                         ");
    printf("            setTimeOut(resizeImgWindows(), 1000);                    ");
    printf("    }                                                                ");
    printf("    imgResizeFlag = false;                                           ");
    printf("}                                                                    ");
    printf("</SCRIPT>                                                            ");

    printf("</HEAD>");
    printf("<BODY BGCOLOR=FFFFFF TEXT=000000 TOPMARGIN=0 LEFTMARGIN=0>");
    printf("<CENTER><A HREF='javascript: self.close()'><IMG SRC="+param+" ID=IMGDIV BORDER=0 onload='javascript: resizeImgWindows()'></A>");
    w.document.close();
    w.focus();
}

imgResizeFlag2 = true;
function imgViewAuto(param, imgwidth, imgheight)
{
    var height  = screen.height;
    var width   = screen.width;
    var leftpos = width/2;
    var toppos  = height/2;

    leftpos = width / 2 - imgwidth / 2;          
    toppos  = height / 2 - imgheight / 2;        
    var w = open("about:blank", "_blank", "scrollbars=no, resizable=yes, width="+imgwidth+", height="+imgheight+", left=" + leftpos + ", top=" + toppos);
    w.document.open();
    printf = w.document.writeln;
    printf("<HTML>");
    printf("<HEAD>");
    printf("<TITLE>»çÁø»ó¼¼º¸±â</TITLE>");
    printf("<META HTTP-EQUIV=CONTENT-TYPE CONTENT=TEXT/HTML; CHARSET=EUC-KR>");

    // ÀÌ¹ÌÁö ÀÚµ¿È®´ë ½ºÅ©¸³Æ® 
    printf("<SCRIPT LANGUAGE=JAVASCRIPT>                                         ");
    printf("var imgResizeFlag2 = true;                                           ");
    printf("var loofcount = 0;                                                   ");
    printf("function resizeImgWindows()                                          ");
    printf("{                                                                    ");
    printf("    if(imgResizeFlag2)                                               ");
    printf("    {                                                                ");
    printf("        pic = document.all('IMGDIV');                                ");
    printf("        if( eval(pic.height) && eval(pic.width) )                    ");
    printf("        {                                                            ");
    printf("            var name = navigator.appName;                            ");
    printf("            if(name == 'Microsoft Internet Explorer')                ");
    printf("            {                                                        ");
    printf("                myHeight = eval(pic).height + 31;                    ");
    printf("                myWidth  = eval(pic).width + 10;                     ");
    printf("            }                                                        ");
    printf("            else                                                     ");
    printf("            {                                                        ");
    printf("                myHeight = eval(pic).height + 9;                     ");
    printf("                myWidth  = eval(pic).width;                          ");
    printf("            }                                                        ");
    printf("            clearTimeout();                                          ");
    printf("                                                                     ");
    printf("            if( myWidth > screen.width )                             ");
    printf("            {                                                        ");  
    printf("                myHeight   = pic.height*(screen.width/pic.width);    ");
    printf("                myWidth    = screen.width;                           ");
    printf("                pic.width  = screen.width;                           ");
    printf("                pic.height = myHeight;                               ");
    printf("            }                                                        ");
    printf("            var height  = screen.height;                             ");
    printf("            var width   = screen.width;                              ");
    printf("            var leftpos = width / 2 - myWidth / 2;                   ");
    printf("            var toppos  = height / 2 - myHeight / 2;                 ");
    printf("            self.moveTo(leftpos, toppos);                            ");
    printf("            self.resizeTo(myWidth, myHeight);                        ");
    printf("        }                                                            ");
    printf("        else                                                         ");
    printf("            setTimeOut(resizeImgWindows(), 1000);                    ");
    printf("    }                                                                ");
    printf("    imgResizeFlag2 = false;                                          ");
    printf("}                                                                    ");
    printf("</SCRIPT>                                                            ");

    printf("</HEAD>");
    printf("<BODY BGCOLOR=FFFFFF TEXT=000000 TOPMARGIN=0 LEFTMARGIN=0>");
    printf("<A HREF='javascript: self.close()'><IMG SRC="+param+" ID=IMGDIV BORDER=0 onload='javascript: resizeImgWindows()'></A>");
    w.document.close();
    w.focus();
}

function FindZipCode(Zipcode1Name, Zipcode2Name, AddrName)
{
     LinkURL = "/members/findzipcode.php?zipcode1=" + Zipcode1Name + "&zipcode2=" + Zipcode2Name + '&address=' + AddrName;
     makeCenterWindow(LinkURL, "ZIPCODE", 356, 390, "scrollbars=yes");
     //NewWin  = window.open(LinkURL, "ZIPCODE", "width=356, height=390, scrollbars=yes");
     //NewWin.focus();
}

function Login()
{
     makeCenterWindow("/login.php", "loginmenu", 250, 80, "no");
}

function LogOut()
{
    if( confirm('·Î±×¾Æ¿ô ÇÏ½Ã°Ú½À´Ï±î?') )
    {
         document.location = "/logout.php";
    }
}

function PlaySampleSound()
{
	if( eval(document.all("SAMPLEMUSIC")) )
	{
		var SoundDiv = document.all("SAMPLEMUSIC");

        if( SoundDiv.innerHTML == "" )
            SoundDiv.innerHTML = "<EMBED SRC=/music/homenaje_debussy.mp3 height=0 width=0 AUTOSTART=1>";
		else
            SoundDiv.innerHTML = "";
	}
}

function SampleSound(index)
{
	if( eval(document.all("SAMPLEMUSIC")) )
	{
		var SoundDiv = document.all("SAMPLEMUSIC");

		if( index == 1 )
			SoundDiv.innerHTML = "<EMBED SRC=/music/sample1.wma height=0 width=0 AUTOSTART=1></EMBED>";
		else
			SoundDiv.innerHTML = "<EMBED SRC=/music/sample2.wma height=0 width=0 AUTOSTART=1></EMBED>";
	}
}
