//¼ýÀÚ Ã¼Å©
function checkNum(NUM){
    $val = parseInt(NUM);
    return (isNaN($val)) ? false : true;
}

//--------------------------------- trim() -----------------------------------------
function trim(strSource) {
	return jQuery.trim(strSource); 
}

//-------------------------------  ÀÌ¹ÌÁö Ã¼Å©  -----------------------------------
function chkIMG(File){
	$ext = File.substring(File.lastIndexOf(".") + 1);
	if($ext.toLowerCase().match(/(jpg|gif|png)/)){
		return true;
	}else{
		return false;
	}
}

function scView(URL,W,H){
	if(W && H){
		window.open(URL,"","width=" + W + ",height=" + H + ",scrollbars=yes")
	}else{
		window.open(URL,"","width=660,height=780,scrollbars=yes")
	}
}

function openWindow(popupWidth, popupHeight, url)
{
	$popupX = (screen.width-popupWidth) / 2;
	$popupY = (screen.height-popupHeight) / 2;
	$status = "toolbar=no, location=no, directories=no, status=no, "; 
	$status +=	"menubar=no, resizable=no, scrollbars=no, width="+popupWidth+", height="+popupHeight+", left="+$popupX+", top="+$popupY;	
	window.open(url, "", $status);  
}

function openWindowEditor(popupWidth, popupHeight, url)
{
	popupWidth = 920;
	popupHeight = 615;
	$popupX = (screen.width-popupWidth) / 2;
	$popupY = (screen.height-popupHeight) / 2;
	$status = "toolbar=no, location=no, directories=no, status=no, "; 
	$status +=	"menubar=no, resizable=no, scrollbars=no, width="+popupWidth+", height="+popupHeight+", left="+$popupX+", top="+$popupY;
	
	window.open(url, "winEditor", $status);  
}

function goEditorType(tostNo, imgSize, type) {
	if(type == "3001MAP"){
		document.location.href="/maptost/mapTostEditor.do?productNo="+tostNo+"&fileSize="+imgSize;
	}else{
		openImageEditor(tostNo, imgSize);
	}
}


function openWindowPopup(popupWidth, popupHeight, url)
{
	$popupX = (screen.width-popupWidth) / 2;
	$popupY = (screen.height-popupHeight) / 2;
	$status = "toolbar=no, location=no, directories=no, status=no, "; 
	$status +=	"menubar=no, resizable=no, scrollbars=1, width="+popupWidth+", height="+popupHeight+", left="+$popupX+", top="+$popupY;
	window.open(url, "", $status);  
}

function addrPopupSend(page){
	if(page == 0){
		openWindow(580, 590, "/campaign/campaignAddressList.do?type=comm");
	}else{
		openWindow(580, 590, "/campaign/campaignRecentAddressList.do?type=comm");
	}
}

//¼±ÅÃÇÑ ÀüÈ­¹øÈ£ºÎ Àü¼ÛÃ¢À¸·Î(ÆË¾÷¿ë)...
function addAddressPopup(phone, xmlURL){
	getMovieName("sendWindow").setADD_SendList(phone, xmlURL);
}
   
//-------------------------------  °Ô½ÃÆÇ ¸®½ºÆ®  -----------------------------------
function sendForm(page){
	if( trim($('form[name="recvForm"] input[name="searchString"]').val()) ){
		searchPost(page);
	}
}
function readPost(brdSrno,page){	
	$('form[name="recvForm"] input[name="brdSrno"]').val(brdSrno);
	$('form[name="recvForm"]').attr("action",page + ".do");
	$('form[name="recvForm"]').submit();
}
function readEventPost(evtSrno,brdSrno,page){	
	$('form[name="recvForm"] input[name="evtSrno"]').val(evtSrno);
	$('form[name="recvForm"] input[name="brdSrno"]').val(brdSrno);
	$('form[name="recvForm"]').attr("action",page + ".do");
	$('form[name="recvForm"]').submit();
}	
function writePost(page){
	$('form[name="recvForm"]').attr("action",page + ".do");
	$('form[name="recvForm"]').submit();
}
function searchPost(page){
	$('form[name="recvForm"] input[name="p"]').val(1);
	$('form[name="recvForm"]').attr("action",page + ".do");
	$('form[name="recvForm"]').submit();
}
function pagePost(p,page){
	$('form[name="recvForm"] input[name="p"]').val(p);
	$('form[name="recvForm"]').attr("action",page + ".do");
	$('form[name="recvForm"]').submit();
}

function downLoad(N){
	document.location.href = "/downLoad.do?filSrno=" + N;
}

//-------------------------------  ÀÔ·Â µ¥ÀÌÅ¸ Ã¼Å©  -----------------------------------

// ¿µ¹® ÇÑ±Û ¹®ÀÚ¿­ ±æÀÌ
function calBytes(str)
{
  $tcount = 0;

  $tmpStr = new String(str);
  $temp = $tmpStr.length;

  $onechar = "";
  for ( $k = 0; $k < $temp; $k++ )
  {
    $onechar = $tmpStr.charAt($k);
    if (escape($onechar).length > 4)
    {
      $tcount += 2;
    }
    else
    {
      $tcount += 1;
    }
  }

  return $tcount;
}

//ÇÑ±ÛÀÌ ÀÖÀ»°æ¿ì true
function isInKorean(str)
{
	$tmpStr = new String(str);
	$temp = $tmpStr.length;
	$result = false;
	$onechar = "";
	for ( $k = 0; $k < $temp; $k++ )
	{
	    $onechar = $tmpStr.charAt($k);
	    
	    if (escape($onechar).length > 4)
	    {
	    	return true;
	    }
	}

	return $result;
}

// ÇÑ±ÛÀÌ¿ÜÀÇ Ä³¸¯ÅÍ°¡ ÀÖÀ»°æ¿ì false
// ÇÑÀÚ³ª ¼ýÀÚ ¿µ¹®ÀÇ °æ¿ì false 
function checkKoreanOnly( koreanChar ) 
{
	if ( koreanChar == null ) 
		return false ;

	for( $i=0; $i < koreanChar.length; $i++)
	{ 

		$c=koreanChar.charCodeAt($i); 

		//( 0xAC00 <= c && c <= 0xD7A3 ) ÃÊÁßÁ¾¼ºÀÌ ¸ðÀÎ ÇÑ±ÛÀÚ 
		//( 0x3131 <= c && c <= 0x318E ) ÀÚÀ½ ¸ðÀ½ 

		if( !( ( 0xAC00 <= $c && $c <= 0xD7A3 ) || ( 0x3131 <= $c && $c <= 0x318E ) ) ) 
		{      
			return false ; 
		}
	}  
	return true ;
}


// ¿µ¹® ÀÌ¿ÜÀÇ Ä³¸¯ÅÍ°¡ ÀÖÀ»°æ¿ì false 
function checkEnglishOnly( englishChar ) 
{  
	if ( englishChar == null ) 
		return false ;
    
	for( $i=0; i < englishChar.length;i++)
	{          
		$c=englishChar.charCodeAt(i);       
		
		if( !( (  0x61 <= c && c <= 0x7A ) || ( 0x41 <= c && c <= 0x5A ) ) ) 
		{         
			return false ;       
		}
	}      
	return true ;
} 


// ¼ýÀÚ ÀÌ¿ÜÀÇ Ä³¸¯ÅÍ°¡ ÀÖÀ»°æ¿ì false 
function checkDigitOnly( digitChar ) 
{  
	if ( digitChar == null ) 
		return false ;
    
	for($i=0; $i < digitChar.length; $i++)
	{          
		$c=digitChar.charCodeAt($i);       
		if( !(  0x30 <= $c && $c <= 0x39 ) ) 
		{         
			return false ;       
		}
	}      
	return true ;
}

// ¼ýÀÚ ÀÌ¿ÜÀÇ Ä³¸¯ÅÍ°¡ ÀÖÀ»°æ¿ì ÃÊ±âÈ­
function fSetNumType(obj,event)
{
 // »ç¿ë¿¹ : <input type="text" name="text" onKeyUp="javascript:numOnly(this,event);"> 
	$keycode = (event.keyCode ? event.keyCode : event.which);
	if ($keycode == 9 || $keycode == 37 || $keycode == 39) 
		return; 
	
	$isNumber = true;
	$returnValue = ""; 
	
	for ($i = 0; $i < $(obj).val().length; $i++)
	{ 
		if ($(obj).val().charAt($i) >= "0" && $(obj).val().charAt($i) <= "9")
		{ 
			$returnValue += $(obj).val().charAt($i); 
		}
		else
		{ 
			$returnValue += ""; 
			$isNumber = false;
		} 
	}
	
	if(!$isNumber){
		alert("¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
	}
	
	$(obj).focus();
	$(obj).val($returnValue);
} 



function checkEmail(email)
{
	 if(email.indexOf("@") < 0)
	 {
		 return false;
	 }
	 
	 if(email.indexOf(".") < 0)
	 {
		 return false;
	 }
	 
	 return true;
}

//ÀÌ¸ÞÀÏ ¼¿·ºÆ®¹Ú½º·Î ¼±ÅÃ
function changeEmail()
{
    if($('form[name="regform"] select[name="emailService1"]').val() == "")
    {
  	  $('form[name="regform"] input[name="email2"]').val("");
  	  $('form[name="regform"] input[name="email2"]').attr("disabled",false);
  	  $('form[name="regform"] input[name="email2"]').focus();
    }else{
  	  $('form[name="regform"] input[name="email2"]').val($('form[name="regform"] select[name="emailService1"]').val());
  	  $('form[name="regform"] input[name="email2"]').attr("disabled",true);
	}
}

//¿ìÆí¹øÈ£ Ã£¾Æ¼­ °ª ³Ö¾îÁÖ±â.
function setZipCode(zip, addr)
{
	$("#zipCode").val(zip);
	$("#userAddress1").val(addr);
}

//¾ÆÀÌµð °ª ³Ö¾îÁÖ±â.
function setId(id)
{	
	$("#userId").val(id);
	$("#idCheck").val("Y");
	$("#userId").attr("disabled",true);
}

function check_jumin() {
    $chk =0;    
    $yy = $('form[name="regform"] input[name="userResno1"]').val().substring(0,2);
    $mm = $('form[name="regform"] input[name="userResno1"]').val().substring(2,4);
    $dd = $('form[name="regform"] input[name="userResno1"]').val().substring(4,6);
    $sex = $('form[name="regform"] input[name="userResno2"]').val().substring(0,1); 
    
    $ssn1 = $('form[name="regform"] input[name="userResno1"]');
    $ssn2 = $('form[name="regform"] input[name="userResno2"]');

    // ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÚ¸®¼ö¿¡ ¸Â°Ô ÀÔ·ÂÇß´ÂÁö Ã¼Å©
    if ($ssn1.val().length!=6) {
        alert ('ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿À');
        $ssn1.focus();
        return false;
    }
    if ($ssn2.val().length != 7 ) {
        alert ('ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿À.');
        $ssn2.focus();
        return false;
    }
    if (isNaN($ssn1.val()) || isNaN($ssn2.val())) {
    	$ssn1.val("");
    	$ssn2.val("");
        alert('ÁÖ¹Îµî·Ï¹øÈ£´Â ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.');
        return false;
    }
    if (($ssn1.val().length!=6)||($mm <1||$mm>12||$dd<1)){
    	$ssn1.val("");	
        alert ('ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®°¡ Àß¸øµÇ¾ú½À´Ï´Ù.');
        $ssn1.focus();
        return false;
    }
    if (($sex != 1 && $sex !=2 )||($ssn2.val().length != 7 )){
    	$ssn2.val("");
        alert ('ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®°¡ Àß¸øµÇ¾ú½À´Ï´Ù.');
        $ssn2.focus();
        return false;
    }

    for ($i = 0; $i <=5 ; $i++) {
        $chk = $chk + (($i%8+2) * parseInt($ssn1.val().substring($i,$i+1)))
    }
    for ($i = 6; $i <=11 ; $i++) {
        $chk = $chk + (($i%8+2) * parseInt($ssn2.val().substring($i-6,$i-5)))
    }

    $chk = 11 - ($chk %11)
    $chk = $chk % 10

    if ($chk != $ssn2.val().substring(6,7)) {
    	$ssn1.val("");
    	$ssn2.val("");
        alert ('¸ÂÁö ¾Ê´Â ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù.');
        $ssn1.focus();
        return false;
    }

    return true;
}

function checkBiz(){
	$num = $('form[name="regform"] input[name="officeResno1"]').val()
		   +$('form[name="regform"] input[name="officeResno2"]').val()
		   +$('form[name="regform"] input[name="officeResno3"]').val();
	$istype='';
    if($num && checkBizcode($num) && getBiztype($num)) ;
    else alert($num+' : »ç¾÷ÀÚ ¹øÈ£°¡ Àß¸øµÇ¾ú½À´Ï´Ù.');
}
//»ç¾÷ÀÚ¹øÈ£ Ã¼Å©
function checkBizcode(num) {
    $reg = /([0-9]{3})-?([0-9]{2})-?([0-9]{5})/;
    if (!$reg.test(num)) return false;
    num = RegExp.$1 + RegExp.$2 + RegExp.$3;
    $cVal = 0;
    for ($i=0; $i<8; $i++) {
        $cKeyNum = parseInt(((_tmp = $i % 3) == 0) ? 1 : ( _tmp  == 1 ) ? 3 : 7);
        $cVal += (parseFloat(num.substring($i,$i+1)) * $cKeyNum) % 10;
    }
    $li_temp = parseFloat(num.substring($i,$i+1)) * 5 + '0';
    $cVal += parseFloat($li_temp.substring(0,1)) + parseFloat($li_temp.substring(1,2));
    return (parseInt(num.substring(9,10)) == 10-($cVal % 10)%10);
}

//»ç¾÷ÀÚ ÇüÅÂ ±¸ºÐ
function getBiztype(num) {
    $reg = /([0-9]{3})-?([0-9]{2})-?([0-9]{5})/;
    if (!$reg.test(num)) return false;
    num = RegExp.$2;

    if(num<80) return '°³ÀÎ»ç¾÷ÀÚ';
    else if(num>=90) return '¸é¼¼»ç¾÷ÀÚ';
    else if(num==81 || num==86 || num==87) return '¹ýÀÎº»Á¡';
    else if(num==83) return '±¹°¡';
    else if(num== 85) return 'ÁöÁ¡¹ýÀÎ';
    else return false;
}

function checkCorp(){
    $num = $('form[name="regform"] input[name="corpcode"]').val();
    if(!$num || !checkCorpcode($num)) alert($num+' : ¹ýÀÎ¹øÈ£°¡ Àß¸øµÇ¾ú½À´Ï´Ù.');
}
//¹ýÀÎ¹øÈ£ Ã¼Å©
function checkCorpcode(num) {
    $reg = /([0-9]{6})-?([0-9]{7})/;
    if (!$reg.test(num)) return false;
    num = RegExp.$1 + RegExp.$2;
    $cVal = 0;
    for ($i=0; $i<12; $i++) {
        $cKeyNum = parseInt(((_tmp = $i % 2) == 0) ? 1 : 2);
        $cVal += parseFloat(num.substring($i,$i+1)) * $cKeyNum;
    }
    $cVal = '0' + $cVal;

    $prty = ($cVal.length==3) ? parseInt(10- $cVal.substring(2, 3)) : parseInt(10- $cVal.substring(3, 4));
    return (parseInt(num.substring(12,13))==$prty);
}
function checkIdChar( englishChar ) 
{  

	if ( englishChar == null ) 
		return false ;
    
	for( $i=0; $i < englishChar.length;$i++)
	{          
		$c=englishChar.charCodeAt($i);       
		
		if( !( (  0x61 <= $c && $c <= 0x7A ) || 0x30 <= $c && $c <= 0x39) ) 
		{         
			return false ;       
		}
	}
	
	return true ;
} 

//·Î±×ÀÎÃ¼Å©
function isLogin(userNo)
{
	if(userNo == "")
	{
		if(confirm("·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ÆäÀÌÁöÀÔ´Ï´Ù.\n\n·Î±×ÀÎ ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î ?"))
			openWindow('500','330','https://www.mtost.net/login/loginForm.do');
		else
			return;
	}
}	
	
/*
*	ÀÔ·ÂµÇ´Â ¹®ÀÚ ±æÀÌ Ã¼Å©
*/
function checkLen(maxlen,field)
{
	$temp=""; //µé¾î¿À´Â ¹®ÀÚ°ª...
	$msglen=0;
	$msglen = maxlen*2;
	$value= $(field).val();
	$l =  $(field).val().length; 
	$tmpstr = "" ;
	
	if ($l == 0)
	{
	 $value = maxlen*2;
	}
	else 
	{
	    for($k=0;$k<$l;$k++)
	    {
			$temp = $value.charAt($k);
			
			if (escape($temp).length > 4)
				$msglen -= 2;
			else
				$msglen--;
			if($msglen < 0) 
			{
				alert("ÃÑ ¿µ¹® "+(maxlen*2)+"ÀÚ ÇÑ±Û " + maxlen + "ÀÚ ±îÁö µî·ÏÇÏ½Ç¼ö ÀÖ½À´Ï´Ù.");
				$(field).val($tmpstr);
				break;
			}
			else 
			{
				$tmpstr += $temp;
			}
		}
	}
}

function special_str_check(obj) {
	$str = $(obj).val();
	for ($i=0; $i < $str.length; $i++) {
	     $ch_char = $str.charAt($i);
	     $ch = $ch_char.charCodeAt();
	     if( ($ch >= 33 && $ch <= 47) || ($ch >= 58 && $ch <= 64) || ($ch >= 91 && $ch <= 96) || ($ch >= 123 && $ch <= 126) ) {
		      alert("Æ¯¼ö¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù");
		      $(obj).val($str.replace($ch_char, ''));
		      return;
	     }
	}
}
	
// input value control
function vContr2(obj) {
	$("#"+obj).removeClass().addClass("text2 imp"); 
}	

function commLink(linkUrl){
	if(linkUrl == '0'){
		opener.document.location.href= "/tostshop/tostCompanyDetailList.do?menuCd=30401000&c=1";
	}else if(linkUrl == '1'){
		opener.document.location.href= "/tostshop/tostGenenalDetailList.do?menuCd=30402000&c=1";
	}else if(linkUrl == '2'){
		opener.document.location.href= "/tostshop/tostLogoList.do";
	}
}

function slidMenu(num, obj) {
	$id_num = 'subCategory_'+num;
	if($("#"+$id_num).css("display") != 'block') {
		$("#"+$id_num).css("display","block");		
		if($(obj).parent().hasClass("cur")) $(obj).parent().removeClass().addClass("on cur");
		else $(obj).parent().removeClass().addClass("on");
		$(obj).removeClass().addClass("on"); 
	} else {
		$("#"+$id_num).css("display","none");
		if($(obj).parent().hasClass("on cur")) $(obj).parent().removeClass().addClass("cur");
		else $(obj).parent().removeClass().addClass("");
		$(obj).removeClass().addClass("off");
	}
}

function openImageEditor(product,seq) 
{
	if (seq=='240x320') seq = 2; 
	else if (seq=='176x144') seq = 1;
	else if (seq=='391x320') seq = 3;
	openWindowEditor('920','615', '/tostshop/tostEditor.do?productNo='+product+'&fileSize='+seq);
}
function openImageEditorType(product,seq) 
{
	if (seq=='240x320') seq = 2; 
	else if (seq=='176x144') seq = 1;
	else if (seq=='391x320') seq = 3;
	openWindowEditor('920','615', '/mobile/mobileEditor.do?productNo='+product+'&fileSize='+seq);
}

function focus_foot() {
	$("#footer").focus();
}

function focusMove(trg) {
	$("#election").focus();
}


function mainHeaderRe(){
	$url = "/mainHeaderRe.do";
	($).ajax({
		type : "POST",
		contentType: 'application/x-www-form-urlencoded; charset=euc-kr',
		url : $url,
		dataType: "html",
		success: function( data, textStatus )
		{	
			$("#header").html(data) ;					
			$("#header").show();
		}
	});	
}

function autoValign() {} // ½æ³×ÀÏ ÀÚµ¿ À§Ä¡ Á¶Á¤

function checkSendBoxBtn(){
	$url = location.href.split("/");	
	if($url[$url.length-1] == ""){
	}else if($url[3] != "member" && $url[3] != "campaign" && $url[3] != "login"){
		//$("#sendBoxBtnPos").html("<a href=\"javascript:openSendBox();\" title=\"¸Þ½ÃÁö ¹ß¼ÛÇÏ±â\"><img src=\"/images/web/main_new/btn_openSendBox.gif\" alt=\"¸Þ½ÃÁö ¹ß¼ÛÇÏ±â\" id=\"btnSendBox\" /></a>");
		$("#sendBoxBtnPos").html("<!--a href=\"#\" title=\"¸Þ½ÃÁö ¹ß¼ÛÇÏ±â\"--><img src=\"/images/web/main_new/btn_openSendBox.gif\" alt=\"¸Þ½ÃÁö ¹ß¼ÛÇÏ±â\" id=\"btnSendBox\" onclick=\"javascript:openSendBox(); return false;\" style=\"cursor:pointer\" /><!--/a-->");
	}
}

function movieTip(){ // µ¿¿µ»ó 
	openWindow(580 , 520, "/popup/mmsPlusGuide.html" );
}

/******************************** function js ************************************/
//Trim
function Trim(obj1)
{
	return jQuery.trim(strSource); 
}

// Input String null checking
function validFieldText(objInput, msgStr)
{
	if(Trim($(objInput).val()) == "") 
	{
		alert("" + msgStr + " ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		$(objInput).focus();
		return false;
	}

	return true;
}

// Input String null checking(with select)
function validFieldSelect(objInput, msgStr)
{ 
	if(Trim($(objInput).val()) == "") 	
	{
		alert("" + msgStr + " ¼±ÅÃÇØÁÖ¼¼¿ä.");
		$(objInput).focus();
		return false;
	}

	return true;
}

// openPopup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openPopup(goUrl, PName, PWidth, PHeight, PScroll)
{
	$winLeft	= (screen.width - PWidth) / 2;
	$winTop	= (screen.height - PHeight) / 2;
	
	window.open(goUrl, PName, 'width='+PWidth+',height='+PHeight+',statusbar=no,scrollbars='+PScroll+',toolbar=no,resizable=no,left='+$winLeft+',top='+$winTop);
}

// ¼ýÀÚ¸¸ ÀÔ·Â ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// »ç¿ë : <input type='text' name='name' maxLength=10 onKeyDown="JavaScript:onlyNumber(this);">
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function onlyNumber(inbuf)
{		
	$e = window.event;

	if ($e.keyCode >= 48 && $e.keyCode <= 57 || $e.keyCode >= 96 && $e.keyCode <= 105 || $e.keyCode == 8 || $e.keyCode == 46 || $e.keyCode >= 35 && $e.keyCode <= 39 || $e.keyCode == 9)
	{
		return;
	} else
		$e.returnValue = false;
}

// Ã¼Å©¹Ú½º ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MainCheck() 
{
	$('form[name="checkForm"] input[name="cname"]').each(function(idx){
		if($('form[name="checkForm"] input[name="check"]').attr("checked")!=undefined){
			$(this).attr("checked",true);	
		}else{
			$(this).attr("checked",false);	
		}	
	});
}

// ³¯Â¥°è»ê
/*
 * ymd : y(¿¬µµ), m(¿ù), d(ÀÏ)
 * addVal : °¡°¨°ª(Á¤¼öÇü)
 * dDate : °¡°¨ ±âÁØ ³¯Â¥
 * gubun : ±¸ºÐÀÚ
 * 
 * ex. 5ÀÏÈÄ
 * addDate('d', 5, '2009-01-01', '-') 
*/
function addDate(ymd, addVal, dDate, gubun) {
	$yyyy="";
	$mm="";
	$dd="";
	$nDate=null;
	$nYear=null; 
	$nMonth=null; 
	$nDay =null;		
	if(gubun != "") {
		dDate = dDate.replace(eval("/\\" + gubun + "/g"), "");
	}
	$yyyy = dDate.substr(0,4);
	$mm = dDate.substr(4,2);
	$dd = dDate.substr(6,2);
	
	if(ymd == "y") {
		$yyyy = ($yyyy * 1) + (addVal * 1);
	} else if(ymd == "m") {
		$mm = ($mm * 1) + (addVal * 1);
	} else if(ymd == "d") {
		$dd = ($dd * 1) + (addVal * 1);
	} 
	
	$nDate = new Date($yyyy, $mm -1 , $dd);
	$nYear = $nDate.getFullYear();
	$nMonth = $nDate.getMonth() + 1;
	$nDay = $nDate.getDate();
	
	$nMonth = $nMonth < 10 ? "0" + $nMonth : $nMonth;
	$nDay = $nDay < 10 ? "0" + $nDay : $nDay;
	
	$reDate = "";
	if(gubun != "") {
		$reDate = $nYear + gubun + $nMonth + gubun + $nDay;
	} else {
		$reDate = $nYear + $nMonth + $nDay;
	}
	
	return $reDate;
		
}

function day2(d) {	// 2ÀÚ¸® ¼ýÀÚ º¯°æ
	var str = new String();
	
	if (parseInt(d) < 10) {
		str = "0" + parseInt(d);
	} else {
		str = "" + parseInt(d);
	}
	return str;
}

//Å©·Î½º ºê¶ó¿ìÂ¡À» À§ÇØ ÄÚµù Ãß°¡
if(navigator.userAgent.indexOf('Firefox') >= 0)
{
    (function(){
        var events=["mousedown", "mouseover", "mouseout", "mousemove", "mousedrag", "click", "dblclick"];
        for(var i = 0 ; i < events.length ; i++)
        {
            window.addEventListener(events[i], function(e){
                window.event = e;
            }, true);
        }
    }());
};

