﻿var http = 'http://www.noir-online.com'
var https = 'http://www.noir-online.com'

function open_pop(openUrl, width, height)
{
    var cw=width;
    var ch=height;
    var sw=screen.availWidth;
    var sh=screen.availHeight;
    var px=(sw-cw)/2;
    var py=(sh-ch)/2;    
    var k = window.open(openUrl,'noir_pop','toolbar=no,resizable=no,location=no,menubar=no,scrollbars=no,location=no,width='+cw+',height='+ch+', top='+py+', left='+px+'');
    if( k != null){
        k.focus();
    }
}

function open_pop2(openUrl, width, height)
{
    var cw=width;
    var ch=height;
    var sw=screen.availWidth;
    var sh=screen.availHeight;
    var px=(sw-cw)/2;
    var py=(sh-ch)/2;    
    var k = window.open(openUrl,'noir_pop','toolbar=no,resizable=no,location=no,menubar=no,scrollbars=yes,location=no,width='+cw+',height='+ch+', top='+py+', left='+px+'');
    if( k != null){
        k.focus();
    }
}

/*
function write_flash(width, height, name)
{
    var html = '';
    html += '<object width="'+ width +'" height="'+ height +'" style="z-index:100; text-align:center;" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + location.protocol + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0">';
    html += '    <param name="movie" value="'+ name +'" />';
    html += '    <param name="quality" value="high" />';
    html += '    <param name="wmode" value="Transparent" />';
    html += '    <embed src="'+ name +'" quality="high" pluginspage="' + location.protocol + '://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed>';
    html += '</object>';
    document.write(html);
}
*/
function write_flash(width, height, name)
{
    var html = '';
    html += "<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width=" + width + " height=" + height + ">";
    html += "<param name=movie value=" + name + ">";
    html += "<param name=allowScriptAccess value=always>";
    html += "<param name=quality value=high>";
    html += "<param name=wmode value=transparent>";
    html += "<embed src=" + name + " wmode=transparent quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width=" + width + " height=" + width + " allowScriptAccess=always></embed></object>";
    document.write(html);
}

function view_flash()
{
    var html = '';
    html += '<div style="position:absolute; width:520px; height:330px; top:50%; left:50%; margin-top:-165px; margin-left:-260px; cursor:pointer; background-image:url(\'/images/view_big.gif\');" onclick="$(\'#flash_dmo\').remove();$(this).remove(); ">';
    html += '    <div style="width:480px; height:270px; margin:40px auto 0px auto;">' 
    html += '        <object id="flash_dmo" width="480" height="270" style="z-index:1; " classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + location.protocol + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0">';
    html += '            <param name="movie" value="/images/flash/dmo.swf" />';
    html += '            <param name="quality" value="high" />';
    html += '            <param name="wmode" value="Transparent" />';
    html += '            <embed src="/images/flash/dmo.swf" quality="high" pluginspage="' + location.protocol + '://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="480" height="270"></embed>';
    html += '        </object>';
    html += '    </div>';
    html += '<div>' 
    $('body').append(html);    
}

function getFlashObject(flashSrc, objWidth, objHeight, etcParam, flaName) {
		var tag = "";
		var baseFlashDir="";
		flashSrc = '/images/flash/' + flashSrc;
		alert(flashSrc);

		if ( etcParam != "" || etcParam != null ) {
			if ( etcParam.substr(0, 1) == "?" )
				flashSrc += etcParam;
			else
				flashSrc += "?" + etcParam;
		}

		tag += "<object id=\"" + flaName + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
		tag += "codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ";
		tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
		tag += "<param name=\"movie\" value=\"" + flashSrc + "\">";
		tag += "<param name=\"menu\" value=\"true\">";
		tag += "<param name=\"quality\" value=\"high\">";
		tag += "<param name=\"wmode\" value=\"transparent\">";
		tag += "<embed name=\"" + flaName + "\" src=\"" + flashSrc + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
		tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
		tag += "wmode=\"transparent\"></embed>";
		tag += "</object>";

		document.write(tag);
	}

function request(valuename)
{
    var rtnval = "";
    var nowAddress = unescape(location.href);
    var parameters = (nowAddress.slice(nowAddress.indexOf("?")+1,nowAddress.length)).split("&");
    
    for(var i = 0 ; i < parameters.length ; i++) {
        var varName = parameters[i].split("=")[0];
        if(varName.toUpperCase() == valuename.toUpperCase()) {
            rtnval = parameters[i].split("=")[1];
            break;
        }
    }
    return rtnval;
}

function color_change(target)
{   
    var color = '#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff'.split(' ');    
    var tid;
    var cnt=0;
     
    function change()
    {
        if(cnt<10){target.css("background","url('') no-repeat " + color[cnt]); cnt++;}
        else clearInterval(tid);
    }
    tid = setInterval(change, 30);
}

function top_flash(main, sub)
{   
    $form = $('#form2');
    if(main == 0) {
        if(sub == 0) $form.attr('action',http + '/index.aspx');
        else if(sub == 1) $form.attr('action',https + '/member/intro.aspx'); 
    } 
    else if(main == 1){
        if(sub == 1) $form.attr('action',http + '/news/main.aspx');
        else if(sub == 2) $form.attr('action',http + '/news/main.aspx');
        else if(sub == 3) $form.attr('action',http + '/news/update.aspx');
        else if(sub == 4) $form.attr('action',http + '/news/workreport.aspx');
        else if(sub == 5) $form.attr('action',http + '/news/report.aspx');
        //else if(sub == 6) $form.attr('action',http + '/news/report.aspx');
        else if(sub == 6) $form.attr('action',http + '/news/event.aspx');
    }
    else if(main == 2){
        if(sub == 1) $form.attr('action',http + '/guide/main.aspx');
        else if(sub == 2) $form.attr('action',http + '/guide/main.aspx');
       
    }
    else if(main == 3){        
        if(sub == 1) $form.attr('action',http + '/pds/download.aspx'); 
        else if(sub == 2) $form.attr('action',http + '/pds/download.aspx');
    }  
    else if(main == 4){
        if(sub == 1) location.href(http + '/comm/main.aspx?fc=free'); 
        else if(sub == 2) location.href(http + '/comm/main.aspx?fc=free');
        else if(sub == 3) location.href(http + '/board/screenView.aspx');
        else if(sub == 4) location.href(http + '/comm/main.aspx?fc=tip');
        else if(sub == 5) $form.attr('action',http + '/comm/bug_view.aspx');
        else if(sub == 6) location.href(http + '/comm/main.aspx?fc=idea');
        else if(sub == 7) location.href(http + '/comm/main.aspx?fc=survey');
        
        if( sub == 1 || sub == 2 || sub == 3 || sub == 4 || sub == 6 ||sub == 7 ){
            return;
        }
    }  
    else if(main == 5){
        if(sub == 1) $form.attr('action',http + '/support/faq.aspx'); 
        else if(sub == 2) $form.attr('action',http + '/support/faq.aspx');
    }
    else if(main == 6){
        if(sub == 1) $form.attr('action',http + '/comm/main.aspx');
        else if(sub == 2) $form.attr('action',http + '/comm/main.aspx');        
    }
    else if(main == 7){
        if(sub == 1) $form.attr('action',http + '/shop/main.aspx');
        else if(sub == 2) $form.attr('action',http + '/shop/main.aspx');        
        else if(sub == 3) $form.attr('action',http + '/shop/item.aspx');        
        else if(sub == 4) $form.attr('action',http + '/shop/list.aspx');         
    } 
    $form.submit();
   
}

ValidateMsg = function() 
{
};
ValidateMsg.prototype = {
    fade_msg : function(target, msg){         
        var html = '<div class="msg_arrow" title="'+ $(target).attr('class') +'"><div class="div1"></div><div class="div2"><p>'+ msg +'</p></div></div>';
        $('body').append(html);
        
        var type = $(target).attr('type');
        var msg_height =  parseInt($('.msg_arrow').css('height')) / 2;
        var target_top =  $(target).offset().top;
        var target_left =  $(target).offset().left;
        var target_height = 0;
        var target_width = 0;
        
        if(type == 'text' || type == 'password') {
            var top = target_top + ((parseInt($(target).css('height')) + parseInt($(target).css('border-width')) * 2) / 2) - msg_height;
            var left = target_left + parseInt($(target).css('width')) + 18;
        }
        else if(type == 'radio') {
            var top = target_top + 6 - msg_height;
            var left = target_left + 18;
        }
        else {
            var top = target_top + ((parseInt($(target).css('height'))) / 2) - msg_height;
            var left = target_left + parseInt($(target).css('width')) + 5;
        }
         
        $('.msg_arrow').css({'top' : top, 'left' : left});
        $('.msg_arrow').fadeIn();
        this.msg_event(target); 
    },
    msg_event : function(target)
    {
        var type = $(target).attr('type');
        if(type == 'text' || type == 'password') {
            $(target).focus(function(){$('.msg_arrow[title="'+ $(target).attr('class') +'"]').remove();});
        }
        else if(type == 'radio') {
//            var id = $(target).attr('id');
//            var name = $(target).attr('name');
//            $('input[name="'+ name +'"]').each(function(){
//                if($(this).attr('id') != id) {
//                     $(this).focus(function(){$('.msg_arrow[title="'+ $(target).attr('class') +'"]').remove();});
//                }
//            });
             $(target).focus(function(){$('.msg_arrow[title="'+ $(target).attr('class') +'"]').remove();});
        }
        else {
             $(target).click(function(){$('.msg_arrow[title="'+ $(target).attr('class') +'"]').remove();});
        }
    }  
}

Validate = function()
{   
};
Validate.prototype = {
    security_name : function(value){
        return /[a-z]/i.test(value) && /^[a-z0-9]{6,}$/i.test(value);
    },
    security_code : function(value){
        return /^[a-z0-9]{6,}$/i.test(value);
    },
    phone_number : function(value){
        return /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/.test(value);
    },
    e_mail : function(value){
        return /^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+.[a-zA-Z]+$/.test(value); 
    },
    social_number : function(value){
        a = new Array(13);
        for (var i=0; i < 13; i++)
            a[i] = parseInt(value.charAt(i));
        var k = 11 - (((a[0] * 2) + (a[1] * 3) + (a[2] * 4) + (a[3] * 5) + (a[4] * 6) + (a[5] * 7) + (a[6] * 8) + (a[7] * 9) + (a[8] * 2) + (a[9] * 3) + (a[10] * 4) + (a[11] * 5)) % 11);
        if (k > 9) k -= 10;
        if (k != a[12]) return false;
        else return true; 
    },
    gtcard : function(value){
        return /^[A-Z]{5}$/i.test(value);
    }, 
    evcard : function(value){
        return /^[A-Z]{4}$/i.test(value);
    },
    okcash : function(value){
        return /^[A-Z0-9]{5}$/i.test(value);
    }, 
    key : function(e, keycode){        
        for(var i=0; i<keycode.length; i++) {
            if(e.keyCode == keycode[i]) {
                if(window.event){window.event.keyCode = '';};
                return false;
            } 
        } 
        return true;
    }
}


/***************************************************
 * 처음 작성일 : 2009년 11월 26일
 * 처음 작성자 : 손원철
 * 용       도 : 이미지 비율에 맞추어 리사이즈 
 ***************************************************/
function imageResize(img,maxWidth,maxHeight){
   var width = parseInt(img.width);
   var height = parseInt(img.height);
   
   var resizeWidth = width;
   var resizeHeight = height;
  
   if(width > maxWidth || height > maxHeight){
      if(width > height)
      {
         resizeWidth = maxWidth;
         resizeHeight = Math.round((height * resizeWidth) / width);
      }
      else
      {
         resizeHeight = maxHeight;
         resizeWidth = Math.round((width * resizeHeight) / height);
      }
   }
   else
   {
      resizeWidth = width;
      resizeHeight = height;
   }
 
   img.width = resizeWidth;
   img.height = resizeHeight;
   
   return img;  
}
 
 
function getEnterCount(ele){
    
    var enterCount = 0;
    var eleValue = ele.value;
    for( var i = 0 ; i < eleValue.length; i++){
        if( eleValue.charAt(i) == '\n' )
            enterCount++;
    }
    return enterCount;
}






var PopupManager = {

    initUrl: '',
    
    popup : function( url , name, top, left, width, height, param){
        
        var pop = window.open( this.initUrl,name,'top='+top+', left='+left+', width='+width+', height='+height+', toolbar=no,resizable=no,location=no,menubar=no,scrollbars=no,location=no');
        if(pop!=null){
            pop.location.href(url);
        }
            
        
    }

};
