//È­Æó FormatÀ¸·Î º¯È¯
function round (n, d) {
	n = n - 0;
	d = d || 2;  
	
	var f = Math.pow(10, d);
	n = Math.round(n * f) / f;
	n += Math.pow(10, - (d + 1));
	n += '';  
	
	return d == 0 ? n.substring(0, n.indexOf('.')) : n.substring(0, n.indexOf('.') + d + 1);
}

function formatCurrency (n, d) {
	n = round (n, d);  
	
	for (var i = n.indexOf('.') - 3; i > 0; i -= 3) {
		n = n.substring(0, i) + ',' + n.substring(i);
	}
	n = n.substring(0, n.indexOf('.'));
	return n;
}

//Æ÷Ä¿½º °ü·Ã Ã³¸®
function changeFocusColor(me) {	
	me.style.backgroundColor = "#ffffe0" ;
	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function changeBlurColor(me) {
	me.style.backgroundColor = "#ffffff" ;
}


// ¹®ÀÚ¿­³»ÀÇ °ø¹é Á¦°Å
function trim(varSTR) {
	var result = "";
   for( var i = 0; i < varSTR.length; i++ ) {
      if( varSTR.charAt(i) != ' ' ) result = result + varSTR.charAt(i);
   }
	return result;
	
}

// Open Window  --  ÆÄÀÏ¸í,Ã¢ÀÌ¸§,°¡·Î,¼¼·Î)
function WindowOpener(fileName,windowName,theWidth,theHeight,theScrollBar,theResizable) {
	var winapp
   if (windowName == "newWindow"){
      windowName = new String(Math.round(Math.random() * 100000));
    }
    winapp = window.open(fileName,windowName,"screenX=300,screenY=100,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+theScrollBar+",resizable="+theResizable+",width="+theWidth+",height="+theHeight)
    winapp.focus();
}

// form ³»ÀÇ °°Àº element °³¼ö
function getElementsCount(formname, elementname, isvalue){
	var cntelement=0;
	var tform = document.forms[formname];
	for(var i=0;i<tform.elements.length;i++){
		if(tform.elements[i].name==elementname){
			if(isvalue==true){	// °ªÀÌ ÀÖ´Â°æ¿ì¸¸
				if(tform.elements[i].value!='')cntelement=cntelement+1;
			}else{
				cntelement=cntelement+1;
			}
		}
	}
	return cntelement
}


//¸¶¿ì½º¿À¹ö ÇÒ¶§ ÀÌ¹ÌÁö º¯°æ ½ºÅ©¸³Æ® ½ÃÀÛ
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_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_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];}
}
			

// »óÇ°´Þ·Â ¶ç¿ì±â
function WindowOpenProd(strLocation)
{   
    msgWindow=window.open(strLocation,"DisplayWindow","width=640,height=400,scrollbars=yes");
}


// ÀÌº¥Æ® ÆäÀÌÁö¿¡¼­ »óÇ°°Ë»öÇÏ´Â °Å
function viewSchedule(strValue) {
	document.frmGo.pkg_code.value=strValue;
	document.frmGo.submit();
}

function trim(strValue)
{

	var pkg_code_length  	= strValue.length;	
	var tmp_pkg_code    	= "";
	
	for (var i = 0; i < pkg_code_length; i++)
	{
            one_kname=strValue.substring(i,i+1);
   	    
   	    if (one_kname!=" ")
   	    {
    	       tmp_pkg_code=tmp_pkg_code+one_kname;
   	    }
	}

    return tmp_pkg_code;
}

function SrchOtherCodeUp() {
	if (trim(document.frmGo.pkg_code_up.value).length < 10) {
		alert("»óÇ°ÄÚµå´Â 10ÀÚ¸® ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä");
		document.frmGo.pkg_code_up.focus();
		return;
	}
	document.frmGo.pkg_code.value=trim(document.frmGo.pkg_code_up.value);
	document.frmGo.action="/app/wsv/packageproduct/pk-11300.asp";
	document.frmGo.submit();	
}

function SrchOtherCodeDown() {
	if (trim(document.frmGo.pkg_code_down.value).length < 10) {
		alert("»óÇ°ÄÚµå´Â 10ÀÚ¸® ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä");
		document.frmGo.pkg_code_down.focus();
		return;
	}
	document.frmGo.pkg_code.value=trim(document.frmGo.pkg_code_down.value);
	document.frmGo.action="/app/wsv/packageproduct/pk-11300.asp";
	document.frmGo.submit();	
}


//´º½ºÆ¼Ä¿ ½ºÅ©¸³Æ® ½ÃÀÛ
// Main function
function Ultimate(Utype,Umsgs,Ucursor,Uwidth,Uheight,Ubgcolor,Ubackground,Uspeed,Udelay,Ufirst) {
		
	document.writeln('<span id="Ubox" style="position:relative;width:'+Uwidth+';height:'+Uheight+';overflow:hiden;background-color:'+Ubgcolor+' ;background-image:url('+Ubackground+')">')
	document.writeln('<div style="position:absolute;width:'+Uwidth+';height:'+Uheight+';clip:rect(0 '+Uwidth+' '+Uheight+' 0);left:0;top:0">')
	
	if (Utype==0) {
		document.writeln('<div id="Utxt" style="position:absolute;width:'+Uwidth+';left:0;top:'+Uheight+';">')
		document.write(Umsgs[Ufirst]);
		Uscroll(Utxt,Umsgs,Uheight,Uspeed,Udelay,Ufirst);
	}
	if (Utype==1) {
		document.writeln('<div id="Utxt"  style="position:absolute;width:'+Uwidth+';left:'+Uwidth+';top:0;">')
		document.write(Umsgs[Ufirst]);
		Uside(Utxt,Umsgs,Uwidth,Uspeed,Udelay,Ufirst);
	}
	if (Utype==2) {
		document.writeln('<div id="Utxt"  style="position:absolute;width:'+Uwidth+';left:'+(Uwidth*-1)+';top:0;">')
		document.write(Umsgs[Ufirst]);
		Ureverseside(Utxt,Umsgs,Uwidth,Uspeed,Udelay,Ufirst,false);
	}
	if (Utype==3) {
		document.writeln('<div id="Utxt"  style="position:absolute;width:'+Uwidth+';left:0;top:0;overflow:hiden;background-color:'+Ubgcolor+' ;">')
		document.write(Umsgs[Ufirst]);
		document.writeln('</div>')
		document.writeln('<div id="Umask"  style="position:absolute;width:'+Uwidth+';left:0;top:0;overflow:hiden;background-color:'+Ubgcolor+' ;">')
		document.write(Ucursor);
		Utouch(Utxt,Umask,Umsgs,Ucursor,Uwidth,Uspeed,Udelay,Ufirst,1,false);
	}
	document.writeln('</div>')
	document.writeln('</div>')
	document.writeln('</span>')
}

// Moves
function Uscroll(IDdiv,Umsgs,Uheight,Uspeed,Udelay,Ufirst){
	ttxt=eval(IDdiv);
	Ustep=eval(Ufirst);
	if (ttxt.style.pixelTop>0&&ttxt.style.pixelTop<=5){
	ttxt.style.pixelTop=0;
	setTimeout("Uscroll(ttxt,Umsgs,Uheight,Uspeed,Udelay,Ustep)",Udelay);
	return
	}
	else {
		if (ttxt.style.pixelTop>=ttxt.offsetHeight*-1){
		ttxt.style.pixelTop-=5
		setTimeout("Uscroll(ttxt,Umsgs,Uheight,Uspeed,Udelay,Ustep)",Uspeed);
		return
		}
		else {
		ttxt.style.pixelTop=Uheight;
		if (Ustep>=Umsgs.length-1)
			Ustep=0
			else		
			Ustep++;
		ttxt.innerHTML=Umsgs[Ustep];
		Uscroll(ttxt,Umsgs,Uheight,Uspeed,Udelay,Ustep);
		}
	}
}

function Uside(IDdiv,Umsgs,Uwidth,Uspeed,Udelay,Ufirst){
	ttxt=eval(IDdiv);
	Ustep=eval(Ufirst);
	if (ttxt.style.pixelLeft>0&&ttxt.style.pixelLeft<=5){
	ttxt.style.pixelLeft=0;
	setTimeout("Uside(ttxt,Umsgs,Uwidth,Uspeed,Udelay,Ustep)",Udelay);
	return
	}
	else {
		if (ttxt.style.pixelLeft>=ttxt.offsetWidth*-1){
		ttxt.style.pixelLeft-=5
		setTimeout("Uside(ttxt,Umsgs,Uwidth,Uspeed,Udelay,Ustep)",Uspeed);
		return
		}
		else {
		ttxt.style.pixelLeft=Uwidth;
		if (Ustep>=Umsgs.length-1)
			Ustep=0
			else		
			Ustep++;
		ttxt.innerHTML=Umsgs[Ustep];
		Uside(ttxt,Umsgs,Uwidth,Uspeed,Udelay,Ustep);
		}
	}
}

function Ureverseside(IDdiv,Umsgs,Uwidth,Uspeed,Udelay,Ufirst,stop){
	ttxt=eval(IDdiv);
	Ustep=eval(Ufirst);
	if (ttxt.style.pixelLeft>0&&ttxt.style.pixelLeft<=5&&(!stop)) {
	setTimeout("Ureverseside(ttxt,Umsgs,Uwidth,Uspeed,Udelay,Ustep,true)",Udelay);
	return
	}
	else {
		if (ttxt.style.pixelLeft<ttxt.offsetWidth){
		ttxt.style.pixelLeft+=5;
		setTimeout("Ureverseside(ttxt,Umsgs,Uwidth,Uspeed,Udelay,Ustep)",Uspeed);
		return
		}
		else {
		ttxt.style.pixelLeft=Uwidth*-1;
		if (Ustep>=Umsgs.length-1)
			Ustep=0
			else		
			Ustep++;
		ttxt.innerHTML=Umsgs[Ustep];
		Ureverseside(ttxt,Umsgs,Uwidth,Uspeed,Udelay,Ustep);
		}
	}
}

function Utouch(IDdiv,IDmask,Umsgs,Ucursor,Uwidth,Uspeed,Udelay,Ufirst,Ufirstsens,stop){
	ttxt=eval(IDdiv);
	tmask=eval(IDmask);
	Ustep=eval(Ufirst);
	Usens=eval(Ufirstsens);
	if (tmask.style.pixelLeft>Uwidth){
	tmask.style.pixelLeft=Uwidth;
	setTimeout("Utouch(ttxt,tmask,Umsgs,Ucursor,Uwidth,Uspeed,Udelay,Ustep,-1)",Udelay);
	return
	}
	else if (tmask.style.pixelLeft>=-5&&tmask.style.pixelLeft<0&&(!stop)){
	tmask.style.pixelLeft=-5;
	if (Ustep>=Umsgs.length-1)
			Ustep=0
			else		
			Ustep++;
	ttxt.innerHTML=Umsgs[Ustep];
	setTimeout("Utouch(ttxt,tmask,Umsgs,Ucursor,Uwidth,Uspeed,Udelay,Ustep,1,true)",Udelay);
	return
	}
	else {
		tmask.style.pixelLeft+=(5*Usens);
		setTimeout("Utouch(ttxt,tmask,Umsgs,Ucursor,Uwidth,Uspeed,Udelay,Ustep,Usens)",Uspeed);
		return
	}
}
// ´º½ºÆ¼Ä¿ ½ºÅ©¸³Æ® ³¡


// Open Window  --  ÆÄÀÏ¸í,Ã¢ÀÌ¸§,°¡·Î,¼¼·Î)
function WindowOpen(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// IsNumber 
function IsNumber(ItemValue){
   var result = true;
   for( var i = 0; i < ItemValue.length; i++ ) {
      if( ItemValue.charAt(i)<"0"||ItemValue.charAt(i)>"9"){
          result = false;
          break;
      }
   }
   return result;
}  

// ¾ÆÀÌÇÁ·¹ÀÓ ´Ã¸®´Â ¼Ò½º
function eventLoad() {
    document.domain = "icarus.n-nuri.com";
}

// IS DATE ( yyyymmdd )
function IsDate5( ymd ){
  
   var yyyy, mm, dd
   if(ymd.length!=8){ return false; }		// length : year(4), month(2), day(2)
   if(!IsNumber(ymd) ){ return false; }	// check number
   if(ymd.charAt(0)!="1"&&ymd.charAt(0)!="2"){ return false; }			// year > 2999
   yyyy = parseInt(ymd.substring(0,4));						// year string -> integer
   if(ymd.charAt(4)=="0") mm = parseInt(ymd.charAt(5));			
   else mm = parseInt(ymd.substring(4,6))					// month string -> integer
   if(ymd.charAt(6)=="0") dd = parseInt(ymd.charAt(7));
   else dd = parseInt(ymd.substring(6,8))							// day string -> integer
   if( mm==0||dd==0||mm>12||dd>31||(mm==2&&dd>29)||(mm==2&&yyyy%4!=0&&dd>28) ) return false;
   else if( (mm==4||mm==6||mm==9||mm==11)&&dd>30)  return false;
   return true;
}


