﻿/**
 * File Name : default.js
 * Description : 기본스크립트 설정
 * @author Web business Team / Choi Hyun Mi
 * Email : designtj@olymcompnay.com
 * Date : 2011.02.11
 * Update : 2011.02.11
 * Copyright (c) 2011 OLYM Communications. All Rights Reserved.
 */

//------------------------------------------------------------------------------
// png 파일 ie6에서도 투명유지
//------------------------------------------------------------------------------
function setPng24(obj) {
  obj.width=obj.height=1;
  obj.className=obj.className.replace(/\bpng24\b/i,'');
  obj.style.filter =
  "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
  obj.src=''; 
  return '';
}	

//------------------------------------------------------------------------------
// 롤오버
//------------------------------------------------------------------------------
function rollover(obj){
  var img_name = obj.getElementsByTagName("img").item(0).src;
  var img_extension = img_name.substring(img_name.lastIndexOf(".")+1);
  var img_on = "_over."+img_extension;
  var img_off = "_off."+img_extension;
  obj.getElementsByTagName("img").item(0).src = img_name.replace(img_off, img_on);
}

//------------------------------------------------------------------------------
// 롤아웃
//------------------------------------------------------------------------------
function rollout(obj){
  var img_name = obj.getElementsByTagName("img").item(0).src;
  var img_extension = img_name.substring(img_name.lastIndexOf(".")+1);
  var img_on = "_over."+img_extension;
  var img_off = "_off."+img_extension;
  obj.getElementsByTagName("img").item(0).src = img_name.replace(img_on, img_off);
}

//------------------------------------------------------------------------------
// 플래쉬 연결
//------------------------------------------------------------------------------
function flash_maker(url, width, height, mode) {
  var flashbody = "";
  flashbody = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+width+"' height='"+height+"' id='Untitled-1' align='middle'>";
  flashbody += "<param name='movie' value='"+url+"' />";
  flashbody += "<param name='quality' value='high' />";
  flashbody += "<param name='wmode' value='"+mode+"' />";
  flashbody += "<param name='menu' value='false' />";
  flashbody += "<param name='allowScriptAccess' value='sameDomain' />";
  flashbody += "<param name='allowFullScreen' value='false' />";
  flashbody += "<embed src='"+url+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='"+mode+"' width='"+width+"' height='"+height+"'></embed>"
  flashbody += "</object>";
  document.write(flashbody);
}

//------------------------------------------------------------------------------
// Flash 대체이미지
//------------------------------------------------------------------------------

var ShockMode = 0;
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
	if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		ShockMode = 1;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	&& (navigator.userAgent.indexOf("Windows 9")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('ShockMode = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) ');
		document.write('<\/SCRIPT\> ');
		
}
	
//------------------------------------------------------------------------------
// 사이트맵
//------------------------------------------------------------------------------
function showHideLayer(stat){
  if(stat){
    document.all.sitemap.style.visibility = "visible";
  }else{
    document.all.sitemap.style.visibility = "hidden";
  }
}

//------------------------------------------------------------------------------
// div 내용 업로드
//------------------------------------------------------------------------------
function sub_page_replace(urllink,divid) {

    var url = urllink;
    var param = '';
    new Ajax.Updater({ success: divid }, url, {
      method: 'get',
      parameters: param,
      onFailure: reportError,
      evalScripts: true
    });

}

function reportError(request) {
  alert('Sorry. There was an error.');
}

//------------------------------------------------------------------------------
// 콤보박스
//------------------------------------------------------------------------------

function toggleView(target){
    var sTarget = target.href.split("#");
    var aTarget = document.getElementById(sTarget[sTarget.length-1]);
    if(aTarget.style.display == "none") aTarget.style.display = "block";
    else aTarget.style.display = "none";    
}

//------------------------------------------------------------------------------
// 새창팝업
//------------------------------------------------------------------------------
function pupup(url,width,height){ 
 window.open(url,'','width='+width+',height='+height); 
}

/**
 * 레이어 토글
 */
function layer_toggle(id){
  if(document.getElementById(id).style.display == "none"){
    document.getElementById(id+"_detail").style.display = "";
    document.getElementById(id).style.display = "";
  }else{
    document.getElementById(id+"_detail").style.display = "none";
    document.getElementById(id).style.display = "none";
  }
}


//-----------------------------------------------------------------------------------
// 화면확대축소
//-----------------------------------------------------------------------------------
var nowZoom = 100; // 현재비율 
var maxZoom = 1500; // 최대비율(500으로하면 5배 커진다) 
var minZoom = 80; // 최소비율 

//화면 확대. 
function zoomIn() 
{ 
    if (nowZoom < maxZoom) 
    { 
        nowZoom += 10; //25%씩 커진다. 
    } 
    else 
    { 
        return; 
    } 
    document.body.style.zoom = nowZoom + "%"; 
	//document.getElementById('wrap').style.zoom = nowZoom + "%"; 
} 


//화면 줄인다. 
function zoomOut() 
{ 
    if (nowZoom > minZoom) 
    { 
        nowZoom -= 10; //25%씩 작아진다. 
    } 
    else 
    { 
        return; 
    } 
    document.body.style.zoom = nowZoom + "%"; 
	//document.body.style.sco
} 

//화면 원래대로 
function zoomDefault() 
{ 
    nowZoom = 100; 
    document.body.style.zoom = nowZoom + "%"; 
} 

//글씨크기
var chFont = new Array('0.8','0.9','0.95','1.5','2','2.5','3');
var dfFont = 2;

function changeFsize(fs) {
  var obj = document.getElementById('wrap');
  var fsize = dfFont;

  if(fs == 'flarge')
    fsize += 1;
  else if(fs == 'fsmall')
    fsize -= 1;
  else
	fsize = 2;
  
  if(fsize < 0) {
	alert('더이상 작아지지 않습니다.');
	fsize = 0;
  }
  if(fsize > 6) {
	alert('더이상 커지지 않습니다.');
	fsize = 6;
  }
  
  fSize = chFont[fsize] + 'em';
  dfFont = fsize;
  obj.style.fontSize = fSize;
}

