// JavaScript Document

//·Ñ¿À¹ö ½ºÅ©¸³Æ®

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Movie
var paramInfo = new Array;

function initParam() {
	var oldSize = paramInfo.length;

	for (var i=0; i<oldSize; i++) {
		paramInfo.length--;
	}
}

function setParam(paramName, paramValue) {
	var idx = paramInfo.length;

	paramInfo[idx] = [];
	paramInfo[idx][0] = paramName;
	paramInfo[idx][1]= paramValue;
}

function playMedia(objID, objSource, objWidth, objHeight, objStyle)
{
	document.write('<OBJECT id="' + objID + '" name="' + objID + '" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" ');
	document.write('WIDTH="' + objWidth + '" HEIGHT="' + objHeight + '" ' + objStyle + '>');

	for (var i=0; i<paramInfo.length; i++) {
		document.write('<PARAM NAME="' + paramInfo[i][0] + '" VALUE="'+ paramInfo[i][1] +'">');		
	}	
	
	document.write('</OBJECT>');
}


 //media player
 var nVolLeftPosition = 0;							// º¼·ý ¹Ù ¹è°æ ½ÃÀÛÁ¡
		var nVolStartPosition = 0;							// º¼·ý ¹Ù ½ÃÀÛ Á¡
		var nVolEndPosition = 40;							// º¼·ý ¹Ù ³¡ Á¡
		var nVolume = 50;									// º¼·ý ÃÊ±â °ª
		var nPrevVol;										// º¼·ýÀÌ º¯°æµÇ±â ÀüÀÇ °ª
		var bIsVolumeSet	 = false;						// º¼·ý¹Ù µå·¡±× ¿©ºÎ
		var nZoomed = 0;							// ±âº»°ª 1 : ÁÜµÊ,   0 : Ãà¼ÒµÊ

		function killErr(){return true;}

		function setVolumeBar(){
			nPrevVol = event.clientX;
			nVolLeftPosition = sound.style.pixelLeft;

			bIsVolumeSet = true;
			document.onmousemove=drag_dropie;
			if (document.all){document.onmouseup=endVolume;}
		}

		function drag_dropie(){
			if (bIsVolumeSet==true){
				var mov = nVolLeftPosition+event.clientX-nPrevVol;
				if ((mov >= nVolStartPosition)  && (mov < nVolEndPosition)){
					cutpoint=nVolEndPosition-sound.style.pixelLeft;
					document.all.soundbg.style.pixelWidth=39-cutpoint;
					//document.all.sbg.width = 58-cutpoint;
					sound.style.pixelLeft=nVolLeftPosition+event.clientX-nPrevVol;
					mplayer.Volume = -2500*(cutpoint/37);
					nVolume=sound.style.pixelLeft
					nVolume1=document.all.sbg.width;
					mplayer.Mute=false;
				}
				return false;
			}
		}

		function endVolume(){
			bIsVolumeSet=false;
		}

		function ris(name, nsdoc)
		{
			var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
			if (name == '') return;
			if (img && img.altsrc) {
				img.src    = img.altsrc;
				img.altsrc = null;
			}
		}

		function cis(name, nsdoc, rpath, preload)
		{ 
			var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
			if (name == '')	return;
			if (img) {
				img.altsrc = img.src;
				img.src    = rpath;
			}
		}
 
    function mutecheck(){
      if(document.all.mplayer.mute==0) document.all.mplayer.mute=1;
      else document.all.mplayer.mute=0;
    }
 

/*************************************************************************
* ÀÌ¹ÌÁö ¸®»çÀÌÁî ÇÔ¼ö
*************************************************************************/

function img_resize(frm,x,y){

var imgInfo = new Image();
imgInfo.src = document.getElementById(frm).src;

var img_x = imgInfo.width;
var img_y = imgInfo.height;
var img_basex = x;
var img_basey = y;
var modbase;


if(img_x >= img_y)	//ÀÌ¹ÌÁö »çÀÌÁî°¡ °¡·ÎÇüÀÌ¶ó¸é
{


	if(img_x > img_basex){
		modbase = img_basex / img_x ;
		img_x = img_x * modbase;

		if(img_y > img_basey)
			img_y = img_y * modbase;
	}


}else if (img_x < img_y){				//ÀÌ¹ÌÁö »çÀÌÁî°¡ ¼¼·ÎÇüÀÌ¶ó¸é


	if(img_y > img_basey){
		modbase = img_basey / img_y ;
			img_y = img_y * modbase;
		if(img_x > img_basex){
			img_x = img_x * modbase;
		}
	}
	

}



document.getElementById(frm).width = img_x;
document.getElementById(frm).height = img_y;


}


function img_resize(frm,x){

var imgInfo = new Image();
imgInfo.src = document.getElementById(frm).src;

var img_x = imgInfo.width;
var img_y = imgInfo.height;
var img_basex = x;
var modbase;


	if(img_x > img_basex){
		modbase = img_basex / img_x ;
		img_x = img_x * modbase;
		img_y = img_y * modbase;
	}

document.getElementById(frm).width = img_x;
document.getElementById(frm).height = img_y;

}

/*************************************************************************
* °ø¹éÁ¦°Å ÇÔ¼ö trim
* »ç¿ë¹ý str.trim();
*************************************************************************/


var TRIM_PATTERN = /(^\s*)|(\s*$)/g; // ³»¿ëÀÇ °ªÀ» ºó°ø¹éÀ» trimÇÏ±â À§ÇÑ°Í(¾Õ/µÚ)
 
String.prototype.trim = function() {
 return this.replace(TRIM_PATTERN, "");
}

/*************************************************************************
* ÆË¾÷ ÇÔ¼ö
*************************************************************************/
function popup(url,x,y){
window.open(url,'','width='+x+',height='+y+',location=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, status=no');
}

/*************************************************************************
* ¸ÞÀÏÃ¼Å©
*************************************************************************/
function isEmailCheck(str) {
	if(str == "") return false;
	var regex = /[-!#$%&'*+/^_~{}|0-9a-zA-Z]+(.[-!#$%&'*+/^_~{}|0-9a-zA-Z]+)*@[-!#$%&'*+/^_~{}|0-9a-zA-Z]+(.[-!#$%&'*+/^_~{}|0-9a-zA-Z]+)*/;
	if(regex.test(str)) return true;
	else return false;
}

/*************************************************************************
* ¼ýÀÚÃ¼Å©
*************************************************************************/
function onlynum(objtext1, msg){
	var inText = objtext1.value;
	var ret;

	for (var i = 0; i < inText.length; i++) {
    ret = inText.charCodeAt(i);
		if (!((ret > 47) && (ret < 58))){
			if (msg == "1"){
				alert("¼ýÀÚ¸¸ ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
				objtext1.value = "";
				objtext1.focus();
			}


			return false;
		}
	}
	return true;
}

function MapPopUp(Pn) {
	if(Pn == 0) {
		window.open('/com/map_pop01.html', '', 'width=618, height=350, scrollbars=yes');
	} else if(Pn == 1) {
		window.open('/com/map_pop03.html', '', 'width=618, height=350, scrollbars=yes');
	} else if(Pn == 2) {
		window.open('/com/map_pop02.html', '', 'width=618, height=350, scrollbars=yes');
	} else {
		window.open('/com/map_pop02.html', '', 'width=618, height=350, scrollbars=yes');
	}
}

/*************************************************************************
* ÆË¾÷Ã¢ ¸®»çÀÌÁî ÇÔ¼ö -youlim 20091023
*************************************************************************/

 function popupResize(imgUrl){

    var popSource = "";
    var obj = document.createElement("img");
    obj.src=imgUrl.src;
    obj.id = 'newImg';
    
    var p = window.open("","","toolbar=no");
    document.body.appendChild(obj);
    
    setTimeout(function(){
     popSource = "<script> window.resizeTo( "+(obj.width+8)+", "+(obj.height+30)+" )<\/script>";
     obj.style.display = "none";
     popSource += "<body style='margin:0000'> <img src='"+imgUrl.src+"' onclick='self.close()'>";
     p.document.write(popSource);
    });
  }

/*************************************************************************
* ¿ÀÇÂÃ¢ ½ºÅ©¸³Æ® - lunamanya 20091217
*************************************************************************/

function newwin(pop,width,height,flag)
{
	var url = pop;
	var wd = width;
	var he = height;
	var scw = (screen.width-wd)/2;
	var sch = (screen.height-he)/2;
	

	if (flag == 0 )
	{
		window.open(url,"0","toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ",top="+sch+",left="+scw+";")
	}
	else
	{
		window.open(url,"0","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ",top="+sch+",left="+scw+";")

	}
}