
/***************************************
* DEXT Upload Prgress Bar
***************************************/
function fShowProgress()
{
	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/Progress/show_progress.asp?nav=ie",'_blank', 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/Progress/show_progress.asp?nav=ns",'_blank',winstyle);
  }

	return true;
}

function fShowProgress2(form)
{
	 strAppVersion = navigator.appVersion; 
  if (form.attach1.value != "") {
    if (strAppVersion.indexOf('MSIE')!=-1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) { 
      winstyle = "dialogWidth=385px; dialogHeight:150px; center:yes"; 
      window.showModelessDialog("/Common/Progress/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/Progress/show_progress.asp",null,winstyle); 
    } 
  }

  if (form.attach2.value != "") {
    if (strAppVersion.indexOf('MSIE')!=-1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) { 
      winstyle = "dialogWidth=385px; dialogHeight:150px; center:yes"; 
      window.showModelessDialog("/Common/Progress/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/Progress/show_progress.asp",null,winstyle); 
    } 
  }

	return true;
}

/***************************************
* IMAGE_ROLLOVER  
***************************************/
function menuOn1(imgEl)
{
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}

function menuOut1(imgEl)
{
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}


function goMenu(Val,Sel)
{
	Sel.value = '';
	if (Val) location=Val;
	
}


/***************************************
* faq 관련 스크립트 
***************************************/
function View(tid,obj){
	var viewClass = "b"; /* 활성 클래스명 */
	var trView = (document.all) ? "block" : "table-row";
	var objBox = document.getElementById(tid).rows
	if(objBox[obj+1].style.display=="none"){
		for(i=0;i<objBox.length;i++){
			if(i%2==0){
				objBox[i].cells[1].className = objBox[i].cells[1].className.replace(viewClass,"")
			}else{objBox[i].style.display="none";}
		}
		objBox[obj].cells[1].className = objBox[obj].cells[1].className + " " + viewClass
		objBox[obj+1].style.display= trView;
	}else{
		objBox[obj].cells[1].className = objBox[obj].cells[1].className.replace(viewClass,"")
		objBox[obj+1].style.display="none"
	}
}
function qnaClick(tid){
	var objBox = document.getElementById(tid).rows
	for(i=0;i<objBox.length;i++){
		if(i%2==0){
			objBox[i].onclick = function(){View(tid,this.rowIndex)}
			objBox[i].style.cursor = "pointer";
		}else{
			objBox[i].style.display = "none";
		}
	}
}

/***************************************
* top button 
***************************************/ 
ScroolTop = function(className, id) {
  this.IE = document.all ? 1 : 0;
  this.NN = document.layer ? 1 : 0;
  this.N6 = document.getElementById ? 1 : 0;
  if(this.IE) this.layer = document.all(id);
  else if(this.NN) this.layer = document.layer[id];
  else if(this.N6) this.layer = document.getElementById(id);
  else return;
  this.className = className;
  this.top = this.oldY = parseInt(this.layer.style.top,10);
  setInterval(this.className + ".move()", 10);
}
ScroolTop.prototype.move = function() {
    var diffY = (this.IE) ? document.body.scrollTop+this.top : self.pageYOffset+this.top; // 표준에는 document.documentElement.scrollTop
    if(diffY != this.oldY) {
        var percentY = .1 * (diffY - this.oldY);
        percentY = (percentY > 0) ? Math.ceil(percentY) : Math.floor(percentY);

        this.oldY += percentY;
        this.layer.style.top = this.oldY + "px";
    }
}

function goTop(orix,oriy,desx,desy) {
  var Timer;
  var winHeight = document.body.scrollTop;
  if(Timer) clearTimeout(Timer);
  startx = 0;
  starty = winHeight;
  if(!orix || orix < 0) orix = 0;
  if(!oriy || oriy < 0) oriy = 0;
  var speed = 7;
  if(!desx) desx = 0 + startx;
  if(!desy) desy = 0 + starty;
  desx += (orix - startx) / speed;
  if (desx < 0) desx = 0;
  desy += (oriy - starty) / speed;
  if (desy < 0) desy = 0;
  var posX = Math.ceil(desx);
  var posY = Math.ceil(desy);
  window.scrollTo(posX, posY);
  if((Math.floor(Math.abs(startx - orix)) < 1) && (Math.floor(Math.abs(starty - oriy)) < 1)){
    clearTimeout(Timer);
    window.scroll(orix,oriy);
  }else if(posX != orix || posY != oriy){
    Timer = setTimeout("goTop("+orix+","+oriy+","+desx+","+desy+")",15);
  }else{
    clearTimeout(Timer);
  }
}

/***************************************
* 스크롤 탑 버튼
***************************************/
/*function gotop(){
  document.body.scrollTop=0;
}*/

/***************************************
* 페이지 focus blur
***************************************/
function bluring(){ 
	if (event.srcElement!=null) {
		if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
	}	
} 
document.onfocusin=bluring; 
 
/***************************************
* 이미지 롤오버 ex) <img src="url" onmouseover="menuOn(this,'gif');" onmouseout="menuOut(this,'gif');" border="0">
***************************************/
function menuOn(imgEl,file)
{
	imgEl.src = imgEl.src.replace("."+ file +"", "_on."+ file +"");
}

function menuOut(imgEl,file)
{
	imgEl.src = imgEl.src.replace("_on."+ file +"", "."+ file +"");
}

/***************************************
* OPENER url 바꾸기
***************************************/
function opener_url(url)
{
	opener.location=url;
}

/***************************************
* 팝업 화면 중앙에 띄우기 - Win_pop();
***************************************/
function Win_pop(newwin,w,h,s) { // newwin:url, w:가로사이즈, h:세로사이즈, s:스크롤 여부(yes or no)
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'width='+w+',height='+h+',top='+wint+',left='+winl+',resizable=yes,scrollbars='+s+',toolbars=no,status=no,menu=no';
  win = window.open(newwin, "new1", winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/***************************************
* TOOGLE 함수
***************************************/
function toggle(e) { // TYPE A
  if (e.style.display == "none") {
     e.style.display = "";
  } else {
     e.style.display = "none";
  }
}

/***************************************
* 아이프레임 스크롤바 색 변경
***************************************/
function setScrollColor(objFrame) 
{  
  try 
  { 
    self[objFrame.name].document.body.style.scrollbarFaceColor = "#eeeeee";
    self[objFrame.name].document.body.style.scrollbarHighlightColor = "#ffffff";
    self[objFrame.name].document.body.style.scrollbarShadowColor = "#FFFFFF";
    self[objFrame.name].document.body.style.scrollbar3dLightColor = "#b6b6b6";
    self[objFrame.name].document.body.style.scrollbarArrowColor = "#333333";
    self[objFrame.name].document.body.style.scrollbarTrackColor = "";
    self[objFrame.name].document.body.style.scrollbarDarkshadowColor = "";
  } 
  catch(oException) 
  { 
    // 접근보안일때 아무런 일도 하지 않는다. 
  } 

}

/***************************************
* CONTENT TAB MENU
***************************************/
// TAB TYPE
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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_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 goMenu(Val,Sel)
{
	Sel.value = '';
	if (Val) location=Val;
	
}

/***************************************
* 이미지로 바로 팝업띄우기
****************************************/
function view(what) { 
  var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=0,location=no,menu=no,width=10,height=10'); 
  imgwin.focus(); 
  imgwin.document.open(); 
  imgwin.document.write("<html>\n"); 
  imgwin.document.write("<head>\n"); 
  imgwin.document.write("<title>IMAGE VIEW</title>\n"); 

  imgwin.document.write("<sc"+"ript>\n"); 
  imgwin.document.write("function resize() {\n"); 
  imgwin.document.write("pic = document.il;\n"); 

  imgwin.document.write(" var imgw = eval(pic).width; ");
  imgwin.document.write("  if (eval(pic).width > 800){ eval(pic).width = 800\n "); //800px보다크면 800으로
  imgwin.document.write(" } else if(eval(pic).width < 800){ eval(pic).width = eval(pic).width\n} "); //800px보다작으면 원래크기로

  imgwin.document.write(" if (eval(pic).height) { var name = navigator.appName\n"); 
  imgwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 40; myWidth = eval(pic).width + 10;\n"); 
  imgwin.document.write("  } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n"); 
  imgwin.document.write("  clearTimeout();\n"); 
  imgwin.document.write("  var height = screen.height;\n"); 
  imgwin.document.write("  var width = screen.width;\n"); 
  imgwin.document.write("  var leftpos = width / 2 - myWidth / 2;\n"); 
  imgwin.document.write("  var toppos = height / 2 - myHeight / 2; \n"); 
  imgwin.document.write("  self.moveTo(leftpos, toppos);\n");
  imgwin.document.write("  if (myWidth > width) { myWidth = width; }\n");
  imgwin.document.write("  self.resizeTo(myWidth, myHeight+10);\n"); 
  imgwin.document.write("}else setTimeOut(resize(), 100);}\n"); 
  imgwin.document.write("</sc"+"ript>\n"); 

  imgwin.document.write("</head>\n"); 
  imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">\n'); 

  imgwin.document.write("<img border=\"0\" src=\""+what+"\" name=il onload='resize();' style='cursor:pointer' onclick='window.close();'>\n"); 

  imgwin.document.write("</body>\n");
  imgwin.document.close(); 
}

/***************************************
* MOVIE  컨트롤 관련
***************************************/

function mplay(){ //PLAY
  document.getElementById('mdefault').style.display='block';
  document.getElementById('mplayer').play();
}
function mpause(){ //PAUSE
  document.getElementById('mplayer').pause();
}
function mstop(){ //STOP
  document.getElementById('mplayer').stop();
}

//볼륨바
var nVolLeftPosition = 0;				// 볼륨 바 배경 시작점
var nVolStartPosition = 19;			// 볼륨 바 시작 점
var nVolEndPosition = 63;				// 볼륨 바 끝 점
var nVolume = 63;								// 볼륨 초기 값
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=63-cutpoint;
			//document.all.sbg.width = 58-cutpoint;
			sound.style.pixelLeft=nVolLeftPosition+event.clientX-nPrevVol;
			mplayer.Volume = -2500*(cutpoint/63);
			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 mresize(no)
{
  url=document.getElementById('mplayer').FileName;  
  url='/pr/pop_mediafull.asp?url='+url;
  document.getElementById('mplayer').stop();
  window.open(url,'fwin','status=no,scrollbars=yes,menubar=no,resizable=no,fullscreen=yes');
}

function mzoom(){
  url=document.getElementById('mplayer').FileName;  
  url='/pr/pop_media.asp?url='+url;
  document.getElementById('mplayer').stop();
  Win_pop(url,484,362);   
}

/***************************************
* OBJECT 파일 패치 - IE PATCH(이올라스 패치)
***************************************/
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;
}

//FLASH
function playFlash(objID, objSource, objWidth, objHeight, objStyle, cabVersion, embedAttr)
{
	document.write('<OBJECT id="' + objID + '" name="' + objID + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');

	if (cabVersion != '') {
		document.write('codebase="' + self.window.document.protocol + '"://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + cabVersion + '" ');
	}
	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('<embed src="' + objSource + '" width="' + objWidth + '" height="' + objHeight + '" ' + embedAttr + '>');
	document.write('</OBJECT>');
}

//MOVIE
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>');
}

/*********************************************************************************************************************
 이미지 리사이징
*********************************************************************************************************************/
function adjustImageWidth(target_img, maxWidth)
{
	var newHeight, newWidth;
	var newImg;

	newImg = new Image();
	newImg.src = target_img.src;
	imgw = newImg.width;
	imgh = newImg.height;
		
	if (imgw > maxWidth)
	{
		newWidth = maxWidth;
		newHeight = imgh;

		newWidth = Math.min(newWidth, Math.round((imgw*newHeight)/imgh));
		newHeight = Math.min(Math.round((imgh*newWidth)/imgw), newHeight);
	}
	else
	{
		newWidth = imgw;
		newHeight = imgh;
	}

	target_img.onload = null;
	target_img.src = newImg.src;
	target_img.width = newWidth;
	target_img.height = newHeight;
}

/*********************************************************************************************************************
 Ajax Function
*********************************************************************************************************************/
function getHttprequest(url)
{
  var xmlhttp = null;

  if(window.XMLHttpRequest)
  {
    xmlhttp = new XMLHttpRequest();
  }
  else
  {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  xmlhttp.open('GET', url, false);
  xmlhttp.onreadystatechange = function() {
                                            if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') 
                                            {
                                              responseText = xmlhttp.responseText;
                                            }
                                          }
  xmlhttp.send('');
  return responseText = xmlhttp.responseText;
}
