﻿// JScript 파일
function $c(tagname)
{
    return document.createElement(tagname);
}

function $n(name)
{
    return document.getElementsByName(name);
}

String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
}

//============================================
// prototype.js jqurey.js 공유위한 스크립트
//============================================
var $j = jQuery.noConflict();


//========================================
// 페이지로케이션
//========================================
FnGoLocation = function(sUrl)
{
    location.href = sUrl;
}


//========================================
// 파일다운로드
//========================================
FnFileDown = function(sFile)
{
    $("ifrhidden").src = "/Common/Aspx/FileDown.aspx?dfile=" + Common.unicodeEncoding(sFile);
    return;
}




//========================================
// ActivX 호출
//========================================
function mEmGET(arrayKey, arrayValue, Value) { 
    count = arrayKey.length; 
    for(i=0;i<count;i++) { 
        if(arrayKey[i]==Value) { 
            return arrayValue[i]; 
            break; 
        } 
    } 
} 
// ie ativeX 출력 변경 함수 
function mEmbed() { 
    var emtype; 
    var key = new Array(); 
    var value = new Array(); 
  // error_check=0; 
    for(i=0;i<mEmbed.arguments.length;i++) { 
        data = mEmbed.arguments[i].split('='); 
        key[i] = data[0]; 
        value[i] = data[1]; 
    } 

    contents = ''; 
    srcdata = mEmGET(key,value,'src').toLowerCase(); 

    classid = mEmGET(key,value,'classid'); 
    codebase = mEmGET(key,value,'codebase'); 
    
    
    if(/\.(swf)$/.test(srcdata)) { //flash 
        classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 
        codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.c-ab#version=6,0,29,0'; 
        emtype="flash"; 
    } else if(/\.(wmv|wma|asf|avi|wav|asx|mpeg|mp3|midi|aiff|au|wpl|wm|wmx|wmd|wmz)$/.test(srcdata)){//media 
        classid = 'CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'; 
        codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; 
        emtype="media"; 
    } 
    if(classid && codebase) { 
        contents += '<object'; 
        if(classid) { 
            contents += ' classid="' + classid + '"'; 
        } 
        if(codebase) { 
            contents += ' codebase="' + codebase + '"'; 
        } 
        count = key.length; 
        for(i=0;i<count;i++) { 
            if(value[i]!='') { 
                if(key[i]!='src') { 
                    contents += ' ' + key[i] + '="' + value[i] + '"'; 
                } 
            } 
        } 
        contents += '>'; 
        for(i=0;i<count;i++) { 
            if(value[i]!='') { 
                if(emtype=='flash' && key[i]=='src') { 
                    contents += '<param name="movie" value="' + value[i] + '" />';                   
                } else  if(emtype=='media' && key[i]=='src') { 
                    contents += '<param name="filename" value="' + value[i] + '" />'; 
                } else { 
                    contents += '<param name="' + key[i] + '" value="' + value[i] + '" />'; 
                } 
            } 
        }
        
        if(emtype=='flash') { 
			contents += '<PARAM name=wmode value="transparent">';
			contents += '<PARAM name=allowScriptAccess value="always">';			
		  }
    }
    
    contents += '<embed'; 
    for(i=0;i<count;i++) { 
        if(value[i]!='') { 
            contents += ' ' + key[i] + '="' + value[i] + '"'; 
            if(emtype=='flash')
					contents += ' allowScriptAccess="always"';           
        } 
    } 
    contents += '>'; 
    contents += '</embed>'; 
    if(classid && codebase) { 
        contents += '</object>'; 
    } 
    document.write(contents); 
    //return contents; 
}



//=============================================
// 메뉴 체인지
//=============================================
menuChange = function(obj)
{
    var objArr = $j("img[id*='imgMenu']");
    
    if(obj == null)
    {
        for(i=0; i < objArr.length; i++)
        {
            $j("#" + objArr[i].id).fadeTo("slow", 1);
        }  
        
        return;
    }  
    
    for(i=0; i < objArr.length; i++)
    {
        //objArr[i].src = objArr[i].src.replace("_on", "_off");
        
        if(objArr[i] == obj)
            $j("#" + objArr[i].id).fadeTo("slow", 1);
        else 
            $j("#" + objArr[i].id).fadeTo("slow", 0.4);
    }
    
    //$(obj.id).src = $(obj.id).src.replace("_off", "_on");
    //$j("#" + obj.id).fadeTo("slow", 1);
    
}
