//Àü¿ªº¯¼ö ¼±¾ð
var SERVER_URL="http://"+document.domain;

function returnObject(frmIndex,eleIndex,errMessage){
	if(errMessage!='')
		alert(errMessage);
	document.forms[frmIndex].elements[eleIndex].focus();
}

function submitFrm(frmIndex){
	document.forms[frmIndex].submit();
}

function checkAll(frmIndex){
	var totalCount=document.forms[frmIndex].chkID.length;	
	if(totalCount>1){
		if(document.forms[frmIndex].chkID[0].checked){
			for(i=0;i<totalCount;i++){
				document.forms[frmIndex].chkID[i].checked=false;
			}
		}else{
			for(i=0;i<totalCount;i++){
				document.forms[frmIndex].chkID[i].checked=true;
			}
		}
	}else{
		if(document.forms[frmIndex].chkID.checked)
			document.forms[frmIndex].chkID.checked=false;
		else
			document.forms[frmIndex].chkID.checked=true;
	}
	return;
}

function checkAllS(frmIndex){
	var totalCount=document.forms[frmIndex].chkID.length;
	var nChkID;
	if(totalCount>1){
		if(document.forms[frmIndex].CACheckBox.checked){
			for(i=0;i<totalCount;i++){
				nChkID=document.forms[frmIndex].chkID[i];
				if(nChkID.disabled==true){
					nChkID.checked=false;
				}else{
					nChkID.checked=true;
				}
			}
		}else{
			for(i=0;i<totalCount;i++){
				nChkID=document.forms[frmIndex].chkID[i];
				nChkID.checked=false;
			}
		}
	}else{
		if(document.forms[frmIndex].CACheckBox.checked){
			nChkID=document.forms[frmIndex].chkID;
			if(nChkID.disabled==true){
				nChkID.checked=false;
			}else{
				nChkID.checked=true;
			}
		}else{
			document.forms[frmIndex].chkID.checked=false;
		}
	}
	return;
}

function movePage(mPage,sURL){
	setValue();
	document.actFrm.action=sURL;
	document.actFrm.nowPage.value=mPage;
	document.actFrm.submit();
}

function chkMove(mPage,totalPage,sURL){
	if(mPage.value==''){
		alert("ÆäÀÌÁö ¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
		mPage.focus();
		return;
	}
	if(mPage.value*1>totalPage*1){
		alert("ÀÌµ¿ÇÏ·Á´Â ÆäÀÌÁö ¹üÀ§¸¦ ³Ñ¾î¼¹½À´Ï´Ù");
		mPage.focus();
		return;
	}
	setValue();
	document.actFrm.action=sURL;
	document.actFrm.nowPage.value=mPage.value;
	document.actFrm.submit();
}

function openWin(oURL,wwidth,wheight,pName){	//½ºÅ©·Ñ¹Ù ÀÖ´Â »õÃ¢
	var popName;
	if(pName&&pName!=""){
		popName=pName;
	}else{
		popName="popWindow";
	}
	window.open(oURL,popName,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=yes,resizable=yes,menubar=no,status=no,toolbar=no,location=no");
}
function openWinNR(oURL,wwidth,wheight,pName){	//½ºÅ©·Ñ¹Ù ÀÖ´Â »õÃ¢, Å©±âÁ¶Àý ºÒ°¡´É
	var popName;
	if(pName&&pName!=""){
		popName=pName;
	}else{
		popName="popWindow";
	}
	window.open(oURL,popName,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=yes,resizable=no,menubar=no,status=no,toolbar=no,location=no");
}
function openWinS(oURL,wwidth,wheight,pName){	//½ºÅ©·Ñ¹Ù ¾øÀ½
	var popName;
	if(pName&&pName!=""){
		popName=pName;
	}else{
		popName="popWindow";
	}
	window.open(oURL,popName,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=no,resizable=yes,menubar=no,status=no,toolbar=no,location=no");
}
function openWinSNR(oURL,wwidth,wheight,pName){	//½ºÅ©·Ñ¹Ù ¾øÀ½ Å©±âÁ¶Àý ºÒ°¡´É »õÃ¢ ¶ç¿î´Ù
	var popName;
	if(pName&&pName!=""){
		popName=pName;
	}else{
		popName="popWindow";
	}
	window.open(oURL,popName,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=no,resizable=no,menubar=no,status=no,toolbar=no,location=no");
}


function openWinFullScreen(oURL,wwidth,wheight,pName){	//½ºÅ©·Ñ¹Ù ¾øÀ½ Å©±âÁ¶Àý ºÒ°¡´É »õÃ¢ ¶ç¿î´Ù
	var popName;
	if(pName&&pName!=""){
		popName=pName;
	}else{
		popName="popWindow";
	}
	window.open(oURL,popName,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=no,resizable=no,menubar=no,status=no,toolbar=no,location=no,fullscreen");
}


function openWinSTheme(oURL,wwidth,wheight,pName){
	var popName;
	if(pName&&pName!=""){
		popName=pName;
	}else{
		popName="popWindow";
	}
	window.open(oURL,popName,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=yes,resizable=no,menubar=no,status=no,toolbar=no,location=no");
}


//-----------------------------------------------------------------------------------------
// ´Þ·Â ÆË¾÷Ã¢ Ãâ·Â °ü·Ã ÇÔ¼ö
//-----------------------------------------------------------------------------------------
var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;
var doc = (ie)? document.all : document;

function callCalendar(datetime,field){
		dateField = field;
		__showCalendarPanel(datetime,'::');
} 

function __showCalendarPanel(type, param, title, x, y)
{
		if(param == null){
			alert("Javascript:__showCalendarPanel: You must specify the parameter");
			return;
		}
		var separator = ":";
		var pa = param.split(separator);
		
		if(pa.length != 3)	//<= 1 || (pa[0].length <= 0 && pa[1].length <= 0)) 
		{
			alert("Javascript:__showCalendarPanel: You must specify INPUT objects name to be set to local datetime or GMT one");
			return;
		}

		var left = 100;
		var top = 200;
		if(x != null) left = x;
		if(y != null) top = y;
		
		var url = "/common/calendar.asp?type=" + type + "&objLocalDate=" + pa[0] + "&objGMTDate=" + pa[1] + "&initDateTime=" + pa[2] + ( title != null ? "&title=" + title : "");
		var width  = (ie) ? "230":"240";
		if( type == "date" )
			var height = (ie) ? "288":"293";
		else
			var height = (ie) ? "318":"323";
		var ws  = "left=" + left + ",top=" + top + ",menubar = no,width=" + width + ",height=" + height + ",resizable=no,scrollbars=no";
		window.open(url, "__newWin", ws);
}
function setDateTime(local, gmt, type){
	if(type=='date'){
		dateField.value = local.substring(0, 4)
						+ "-" + local.substring(4, 6)
						+ "-" + local.substring(6, 8);
	}
	else{
		dateField.value = local.substring(0, 4)
						+ "-" + local.substring(4, 6)
						+ "-" + local.substring(6, 8)
						+ " " + local.substring(8, 10)
						+ ":" + local.substring(10, 12);
	}

}

// ¿ìÆí¹øÈ£ °Ë»ö ÆË¾÷Ã¢ Ãâ·Â
function openZipSch(frmNm, zipCdNm, adrNm){
	openWinSNR("/common/zipcode_pop.asp?frmNm="+frmNm+"&zipCdNm="+zipCdNm+"&adrNm="+adrNm,100,100,"zipSch");
}

// ½Ç¸íÀÎÁõ ÆË¾÷Ã¢ Ãâ·Â
// µ¹·Á¹ÞÀ» ÀÎÀÚ4°³¸¦ Ãß°¡ ÇÑ´Ù.
function openNameCheck(){
	//openWinSNR("/common/namecheck_pop.asp",100,100,"nameChk");
	var res = window.showModalDialog('/common/namecheck_pop.asp' , 'zip', 'dialogWidth:418px;dialogHeight:616px;scroll:no;status:no;titlebar:no;');

	if(res!=null){
		return res;
	}
	else{
		return false;
	}
}

//XML ¿¬°áÀ» ÅëÇÏ¿© ÇØ´ç ÅØ½ºÆ® µ¥ÀÌÅÍ¸¦ ¹Þ¾Æ¿Â´Ù.
//ÀÚ¹Ù½ºÅ©¸³Æ®·Î ½Ç½Ã°£À¸·Î µ¥ÀÌÅÍ °¡Á®¿Ã¶§ °£´ÜÇÏ°Ô »ç¿ëÇÏÀÚ
function getXMLTextData(src){
	var data;
	var url=src;
	var date=new Date();
	//µ¿ÀÏÇÑ URLÀ» º¸³»¸é Ä³½ÌÀÌ ¸Ô¾î¹ö¸°´Ù. URLÀ» ¹Ù²ãÁÖÀÚ
	if(url.indexOf("?")>=0){
		url+="&timeoffset="+date.getTime();
	}else{
		url+="?timeoffset="+date.getTime();
	}
	if(document.implementation && document.implementation.createDocument){
		// XML º¯¼ö ·Îµù
		xmlReq = new XMLHttpRequest();
		// load the xml file
		xmlReq.open("GET", url, false);
		xmlReq.send(null);
		//totalCount = xmlReq.responseXML.getElementsByTagName("POI").length;
		data=xmlReq.responseText;
		return data;
	}else if(window.ActiveXObject){
		// XML º¯¼ö ·Îµù
		xmlReq = new ActiveXObject("MSXML2.XMLHTTP");
		// Load XML
		xmlReq.open("GET", url, false);
		xmlReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=euc-kr");
		xmlReq.send(null);
		//totalCount=xmlReq.responseXML.getElementsByTagName("POI").length;
		data=xmlReq.responseText;
		return data;
	}else{
		// Browser unknown
		return "";
	}
}

function copyToClipboard(name,data){
	window.clipboardData.setData("Text",data);
	alert(name+"°¡ º¹»çµÇ¾ú½À´Ï´Ù");
}

function pause(m){	//mµ¿¾È ¸ØÃß±â
	var now=new Date();
	var exitTime=now.getTime()+m;
	while(true){
		now=new Date();
		if(now.getTime()>exitTime)
			return;
	}
}

function ShowProgress()
{
	strAppVersion = navigator.appVersion;
	
	if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) {
		winstyle = "dialogWidth=385px; dialogHeight:150px; center:yes";
		window.showModelessDialog("/common/show_progress.asp?nav=ie", null, winstyle);
	}
	else {
		winpos = "left=" + ((window.screen.width-380)/2) + ",top=" + ((window.screen.height-110)/2);
		winstyle="width=380,height=110,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,copyhistory=no," + winpos;
		window.open("/common/show_progress.asp?nav=ns",null,winstyle);
	}
	
	return true;
}

function popDetailImageView(file,width,height){
	openWinS("/common/pop_image_detail.asp?file="+file,width+30,height+60,'enlageImageWindow');
}

//ÆË¾÷Ã¢ »çÀÌÁî ÀÚµ¿ º¯°æ
function resizePop() {
	resizePop(0,0);
}
function resizePop(mw,mh) {
	var obj = navigator.appVersion;
	var hei = 29;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			hei = 35;
		}
	}
	wid = document.body.scrollWidth+10;
	hei = document.body.scrollHeight+hei;
	if(mw>0 && wid>mw) wid = mw;
	if(mh>0 && hei>mh) hei = mh;
	self.resizeTo(wid,hei);
	this.focus();
}

//ÆË¾÷Ã¢ »çÀÌÁî ÀÚµ¿ º¯°æ (³ôÀÌ Á¦ÇÑ)
function resizePopH(mh) {
	resizePop(0, mh);
}

//ÆË¾÷Ã¢ »çÀÌÁî ÀÚµ¿ º¯°æ (Æø Á¦ÇÑ)
function resizePopW(mw) {
	resizePop(mw, 0);
}
function resizePopS(mw,mh){
	var obj = navigator.appVersion;
	var hei = 29;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			hei = 50;
		}
	}

	wid = document.body.scrollWidth+26;
	hei = document.body.scrollHeight+hei;
	if(mw>0 && wid>mw) wid = mw;
	if(mh>0 && hei>mh) hei = mh;
	self.resizeTo(wid,hei);
	this.focus();
}
function resizeFrame(Id){
	var obj = document.getElementById(Id);
	var Body;
	var H, Min;
	// ÃÖ¼Ò ³ôÀÌ ¼³Á¤ (³Ê¹« ÀÛ¾ÆÁö´Â °ÍÀ» ¹æÁö)
	Min = 500;
	// DOM °´Ã¼ ÇÒ´ç
	try{
		if (!document.all && obj.contentWindow.document.location.href == 'about:blank') {
			setTimeout("resizeFrame('"+Id+"')", 10);
			return;
		}
		Body = obj.contentWindow.document.getElementsByTagName('BODY');
		Body = Body[0];
		if (this.Location != obj.contentWindow.document.location.href) {
			H = Body.scrollHeight + 5;
			obj.style.height =  (H<Min?Min:H) + 'px';
			this.Location = obj.contentWindow.document.location.href;
		}
	} catch(e) {
		setTimeout("resizeFrame('"+Id+"')", 10);
		return;
	}
	setTimeout("resizeFrame('"+Id+"')", 100);
}

var g_dlgEbook = null;
function ebookViewWindow( targetURL, width, height, varArg ){
	var szTop = "dialogTop: 0px; ";
	var szLeft = "dialogLeft: 0px; ";
	var sFeatures = szTop + szLeft + "dialogHeight: " + height + "px; dialogWidth: " + width + "px; center: no; edge: raised; help: no; status: no;";
	var advanceArg = new Array();
	advanceArg[0] = window;
	var dlgWin = null;
	var top = 0;
	var left = 0;
	if ( varArg ) {
		dlgWin = window.showModelessDialog( targetURL, varArg, sFeatures );
	} else {
		dlgWin = window.showModelessDialog( targetURL, advanceArg, sFeatures );
	}
	return dlgWin;
}

function fullSCRViewWindow( targetURL, width, height, varArg ){
	var dlgWin = null;
	dlgWin = window.open(targetURL+"?"+varArg,"BookMaker","top=0,left=0,width="+width+",height="+height+",channelmode=no, directories=no, status=no, titlebar=no, toolbar=no, resizable=no, scrollbars=no, menubar=no");
	dlgWin.blur();
	dlgWin.focus();
	return dlgWin;
}
function vieweBook(fname,cname){
	var width =  window.screen.width;
	var height = window.screen.height;// - 34;  
	if ( width > height*2) width = width / 2;
	var argVar = new Array();

	var xfile = "/bookmaker/ebook/"+fname;
	argVar[0] = window;
	argVar[1] = width;  	       
	argVar[2] = height;   	
	argVar[3] = ""; 
	argVar[4] = "";
	argVar[5] = xfile; 
	g_dlgEbook = ebookViewWindow("/BookMaker/autorun.html", width,height,argVar);
}

function getPageSize(){  
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) { //firefox. ½ºÅ©·Ñ¹Ù »ý°åÀ»¶§
		xScroll = document.body.scrollWidth-16;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer,firefox
		windowWidth = self.innerWidth-16;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	} 
  
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){ //firefox
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//¿£ÅÍ¸¦ ÃÆÀ» °æ¿ì ÁöÁ¤µÈ ÇÔ¼ö(fName)À» ½ÇÇàÇÑ´Ù. ÆÄÀÌ¾îÆø½º Áö¿ø
function enterKeyChk(e,fName){
	var keynum;
	if(window.event){
		keynum=e.keyCode;
	}else if(e.which){
		keynum = e.which;
	}
	if(keynum==13){
		eval(fName);
	}
}

//Image Change
function imageChange(imagename, imageurl){
	document.images[imagename].src=imageurl;
}

//flash¸¦ µ¿ÀûÀ¸·Î Ãâ·ÂÇÑ´Ù. »óÈ£ÀÛ¿ë ½Ã ¹®¿¡ ¾øÀ½.
function flashWriteFront (url, width, height, id, bg)
{
	var flObjectElement = document.createElement('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="'+id+'" width="'+width+'" height="'+height+'" align="middle"></OBJECT>');
	 
	var myParamElement1 = document.createElement('<PARAM NAME=allowScriptAccess VALUE="always">');
	var myParamElement2 = document.createElement('<PARAM NAME=movie VALUE="'+url+'">');
	var myParamElement3 = document.createElement('<PARAM NAME=quality VALUE="high">');
	var myParamElement4 = document.createElement('<PARAM NAME=bgcolor VALUE="'+bg+'">');
	var myParamElement5 = document.createElement('<PARAM NAME=pluginspage VALUE="http://www.macromedia.com/go/getflashplayer">');
	var myParamElement6 = document.createElement('<PARAM NAME=type VALUE="application/x-shockwave-flash">');
	var myParamElement7 = document.createElement('<PARAM NAME=width VALUE="'+width+'">');
	var myParamElement8 = document.createElement('<PARAM NAME=height VALUE="'+height+'">');
	var myParamElement9 = document.createElement('<PARAM NAME=swLiveConnect VALUE="true">');
	 
	flObjectElement.appendChild(myParamElement1);
	flObjectElement.appendChild(myParamElement2);
	flObjectElement.appendChild(myParamElement3);
	flObjectElement.appendChild(myParamElement4);
	flObjectElement.appendChild(myParamElement5);
	flObjectElement.appendChild(myParamElement6);
	flObjectElement.appendChild(myParamElement7);
	flObjectElement.appendChild(myParamElement8);
	flObjectElement.appendChild(myParamElement9);

	id.appendChild(flObjectElement);
}

// flash¸¦ µ¿ÀûÀ¸·Î Ãâ·ÂÇÑ´Ù. »óÈ£ÀÛ¿ë ½Ã ¹®¿¡ ¾øÀ½.
function flashWrite (url, id, bg)
{
	var flObjectElement = document.createElement('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="'+id+'" align="middle"></OBJECT>');
	 
	var myParamElement1 = document.createElement('<PARAM NAME=allowScriptAccess VALUE="always">');
	var myParamElement2 = document.createElement('<PARAM NAME=movie VALUE="'+url+'">');
	var myParamElement3 = document.createElement('<PARAM NAME=quality VALUE="high">');
	var myParamElement4 = document.createElement('<PARAM NAME=bgcolor VALUE="'+bg+'">');
	var myParamElement5 = document.createElement('<PARAM NAME=pluginspage VALUE="http://www.macromedia.com/go/getflashplayer">');
	var myParamElement6 = document.createElement('<PARAM NAME=type VALUE="application/x-shockwave-flash">');
	var myParamElement7 = document.createElement('<PARAM NAME=swLiveConnect VALUE="true">');
	 
	flObjectElement.appendChild(myParamElement1);
	flObjectElement.appendChild(myParamElement2);
	flObjectElement.appendChild(myParamElement3);
	flObjectElement.appendChild(myParamElement4);
	flObjectElement.appendChild(myParamElement5);
	flObjectElement.appendChild(myParamElement6);
	flObjectElement.appendChild(myParamElement7);
	 
	id.appendChild(flObjectElement);
}
