/* ------------------------------------------------------------
 * Name      : common.js
 * Created   : 2009/11 cnscamp by psj
 * Updated  :
 ------------------------------------------------------------ */
 
 /*----------------------------------------------------------------------------------------
* 	isAccess(e)
*	example : 
*	if (isAccess(event)) {
*	}
*	return : true | false
*	date : 2007.5.1

*	descript : 
	¸¶¿ì½ºÅ¬¸¯ÀÌ³ª Å°º¸µå·Î ¼±ÅÃµÈ »óÅÂÀÎÁö ÆÇ´Ü

	ÅÇÅ°·Î ÇØ´ç ¿µ¿ª¿¡ Æ÷Ä¿½º°¡ °£ÈÄ ´Ù½Ã ÅÇÀ¸·Î ³Ñ¾î°¥ °æ¿ì onkeypress ÀÌº¥Æ®°¡ ¹ß»ýÇÏ¿© ¿øÇÏ´Â ÀÌº¥Æ® Ã³¸®°¡ ¾ÈµÈ´Ù.
	¸¶¿ì½º³ª ¿£ÅÍÅ°°¡ ´­·¯Áø °æ¿ì keycode = 1)¸¸ ÀÌº¥Æ®°¡ ¹ß»ýÇÏ°Ô Ã³¸®ÇÑ´Ù.
	Netscape/Firefox/Opera ÀÇ °æ¿ì e.which 1·Î Ã¼Å©, Safari ÀÇ °æ¿ì window.event 0 À¸·Î Ã¼Å©
	IEÀÇ °æ¿ì event.button ÀÌ³ª keycode 13(¿£ÅÍÅ°)·Î Ã¼Å©
----------------------------------------------------------------------------------------*/
function isAccess(e) {
	
	var keynum;
	var ismouseClick = 1;
	
	if (window.event) {		//IE & Safari
		keynum = e.keyCode;
		
		//SafariÀÇ °æ¿ì ¸¶¿ì½ºÅ¬¸¯Àº keynum 0 ÀÌ ³Ñ¾î¿È
		if (event.button == 0 || keynum == 0){
			ismouseClick = 0;
		}		
		
	} else if ( e.which ){		// Netscape/Firefox/Opera
		keynum = e.which;
		
		if (keynum == 1) {
			ismouseClick = 0;
		}		
		
	}
	
	//¸¶¿ì½º Å¬¸¯ÀÌ°Å³ª ¿£ÅÍÅ°¸¦ ´©¸¥°æ¿ì true°ª ¹ÝÈ¯
	if ( ismouseClick == 0 || keynum == 13 ) {
		return true;
	} else {
		return false;
	}
}


/*	±ÛÀÚÈ®´ëÃà¼Ò */	
var currentFontSize = 1;

function zoomUtil(state, e){
	var idx;
	var arrFontSize = new Array();

	arrFontSize[0] = "65%";
	arrFontSize[1] = "75%";
	arrFontSize[2] = "85%";
	arrFontSize[3] = "100%";
	arrFontSize[4] = "110%";
	arrFontSize[5] = "120%";
	arrFontSize[6] = "130%";
	
	if (isAccess(e)) {
		if (state == "plus") {		
						
			if (currentFontSize < 6 ) {
				idx = currentFontSize + 1;
				currentFontSize = idx;
			}else{
				idx = 6;
				currentFontSize = idx;
			}			
		
		} else if (state == "default") {
			idx = 1;
			currentFontSize = idx;
		
		} else if (state == "minus") {			
			
			if ( currentFontSize >= 1) {
				idx = currentFontSize - 1;
				currentFontSize = idx;
			}else{
				idx = 0;
				currentFontSize = idx;
			}
			
		}		
	}
	
	document.body.style.fontSize = arrFontSize[idx];
	
	return false;	
}
 

/* È­¸éÈ®´ë ½ºÅ©¸³Æ®(IE¿¡¼­¸¸ µ¿ÀÛ) */ 
var zoomRate = 10;
var curRate = 100;
var minRate = 100;
var maxRate = 200;
function initZoom()
{
 document.body.style.position="relative";
 document.body.style.zoom = '100%';
 curRate = 100;
}

initZoom();


function zoomInOut(value){
 var ue = navigator.userAgent.toLowerCase();
 if(ue.indexOf('firefox')!=-1){ alert("ÀÍ½ºÇÃ·Î·¯¿¡¼­¸¸ µ¿ÀÛÇÕ´Ï´Ù."+"\nÆÄÀÌ¾îÆø½º ºê¶ó¿ìÀú ¸Þ´º [º¸±â]-[Å©±âÁ¶Á¤]À» ÀÌ¿ëÇÏ¼¼¿ä."); }
 else if(ue.indexOf('opera')!=-1){ alert("ÀÍ½ºÇÃ·Î·¯¿¡¼­¸¸ µ¿ÀÛÇÕ´Ï´Ù."+"\n¿ÀÆä¶ó ºê¶ó¿ìÀú ¸Þ´º [º¸±â]-[Zoom]À» ÀÌ¿ëÇÏ¼¼¿ä."); }
 else if(ue.indexOf('chrome')!=-1){ alert("ÀÍ½ºÇÃ·Î·¯¿¡¼­¸¸ µ¿ÀÛÇÕ´Ï´Ù."+"\n±¸±Û Å©·Ò ºê¶ó¿ìÀú ¸Þ´º [±Û²Ã Å©±â]¸¦ ÀÌ¿ëÇÏ¼¼¿ä."); }
 else if(ue.indexOf('safari')!=-1){ /* alert("ÀÍ½ºÇÃ·Î·¯¿¡¼­¸¸ µ¿ÀÛÇÕ´Ï´Ù."+"\n»çÆÄ¸® ºê¶ó¿ìÀú ¸Þ´º [º¸±â]-[ÅØ½ºÆ® Å©°Ô]/[ÅØ½ºÆ® ÀÛ°Ô]¸¦ ÀÌ¿ëÇÏ¼¼¿ä."); */ }
 else if(ue.indexOf('msie')!=-1){  }
 else { alert("ÀÍ½ºÇÃ·Î·¯¿¡¼­¸¸ µ¿ÀÛÇÕ´Ï´Ù.\n"+ue+"\nºê¶ó¿ìÀú ¸Þ´ºÀÇ È®´ëÃà¼Ò ±â´ÉÀ» ÀÌ¿ëÇÏ¼¼¿ä."); }
 if(((value=="plus")&&(curRate >= maxRate))||((value == "minus") && (curRate <= minRate))){return;} 
  if(value=="plus"){curRate = parseInt(curRate) + parseInt(zoomRate);}
  else if (value=="minus"){curRate = parseInt(curRate) - parseInt(zoomRate);}
  else{curRate = 100}
  document.body.style.zoom = curRate + '%';
}

 

/*******************************************************************************************
 ' ±â   ´É : ÆË¾÷°¡¿îµ¥¶ç¿ì±â
 ' »ç¿ë¹ý : onclick="open_window('ÆÄÀÏ¸í','pop', 910, 370, 'no', 'no', 'no', 'no')"
 ' ÀÛ¼ºÀÏ : 2009.04.13
*******************************************************************************************/

function open_window(url,  name,  width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = (toolbar == 'yes') ? 'yes' : 'no';
  menubar_str = menubar  == 'yes' ? 'yes' : 'no';
  statusbar_str = statusbar  == 'yes' ? 'yes' : 'no';
  scrollbar_str = scrollbar  == 'yes' ? 'yes' : 'no';
  resizable_str = resizable == 'yes'  ? 'yes' : 'no';
     // ÆË¾÷ °¡¿îµ¥·Î ¶ç¿ì±â

   var left = Math.ceil( (window.screen.width  - width) / 2 );
   var top = Math.ceil( (window.screen.height - height) / 2 );

  
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}


