﻿/*=======================================================================
클래스설명	: 공통함수 처리
작  성  자  : 김현
최초작성일  : 2010년 06월 25일
최종수정일  : 
========================================================================*/

//################################## 롤오버 함수 시작 ##########################################
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
//################################## 롤오버 함수 끝 ##########################################

//################################## 플래쉬 관련 함수 시작 ##########################################
function MakeDistributionFlash(arg) {
    var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="321" height="422" id="seoul" align="middle">';
    flash += '    <param name="allowScriptAccess" value="sameDomain" />';
    flash += '    <param name="movie" value="/Flash/' + arg + '" />';
    flash += '    <param name="quality" value="high" />';
    flash += '    <param name="wmode" value="transparent" />';
    flash += '    <param name="bgcolor" value="#ffffff" />';
    flash += '    <embed src="/Flash/' + arg + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="321" height="422" name="seoul" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>';
    flash += '</object>';

    document.write(flash);
}
//################################## 플래쉬 관련 함수 끝 ##########################################

//################################## 팝업창 관련 함수 시작 ##########################################
//메시지박스 스타일 정의
function jsMessageBoxStyle() {
    return "dialogWidth:" + DIALOGWIDTH + "px;dialogHeight:" + DIALOGHEIGHT + "px;status=no;scroll=no";
}

//에러 메시지 상자를 띠운다.
//sInfo - 출력할 메시지
function jsOpenErrorMessage(strTemp) {
    try {
        XDN_Fn_Progressbar(false);
        var strImsi;
        if (strTemp == null)
            strImsi = window.document.all.errorMessage.value;
        else
            strImsi = strTemp;
        window.showModalDialog("/Common/Dialog/ErrorMessage.htm", strImsi, jsMessageBoxStyle());
    }
    catch (exception) { }
}

//팝업창을 띠운다
//sUrl - 띠울 URL
//sFrame - 띠울이름
//sFeature - 창 속성
function jsOpenDialog(sUrl, sFrame, sFeature) {
    var WindowOpenVal;
    WindowOpenVal = window.open(sUrl, sFrame, sFeature);
    return WindowOpenVal;
}

//가운데, 창 띄우기
//sUrl - URL
//sFrame - 이름
//sFeature - 창 속성
function OpenCenterDialog(sUrl, nWidth, nHeight, sFrame, sFeature) {
    var nTop = 0;
    var nLeft = 0;
    var oReturn = null;
    try {
        if (nHeight == 0) nHeight = 1;
        if (nWidth == 0) nWidth = 0;
        nTop = (window.screen.Height / 2) - (nHeight / 2);
        nLeft = (window.screen.Width / 2) - (nWidth / 2);
        if (nTop < 0) nTop = 0;
        if (nLeft < 0) nLeft = 0;

        oReturn = window.open(
			sUrl,
			sFrame,
			"Width=" + nWidth.toString()
			+ ",Height=" + nHeight.toString()
			+ ",top=" + nTop
			+ ",left=" + nLeft
			+ ((sFeature == null || sFeature == "") ? "" : ",") + sFeature);
    }
    catch (exception) { }
    return oReturn
}

//풀창 띄우기
function jsOpenFullDialog(fileName, isWebSite, WindowName) {
    var x;
    var y;
    try {
        x = window.screen.availWidth;
        y = window.screen.availHeight;
        if (isWebSite == null || isWebSite == false) {
            x = x - 10;
            y = y - 30;
            etcParam = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1";
        }
        else {
            etcParam = "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
        }

        objNewWin = jsOpenDialog(fileName, WindowName, etcParam + ",top=0,left=0,Width=" + x + ",Height=" + y);

        objNewWin.focus();
    }
    catch (exception) { }
    return objNewWin;
}

//모달창
//ex) AlertModal("아이디를 입력해주세요) ==>"아이디를 입력해 주세요."
function AlertModal(rootPath, str, File) {
    var param = new Object();
    param.temp1 = str;

    window.showModalDialog
	(rootPath + '/Common/AlertModal.html', param, "dialogWidth:340px;dialogHeight:180px;help:no;scroll:no;status:no")
}
//################################## 팝업창 관련 함수 끝 ##########################################

//################################## 문자 관련 함수 시작 ##########################################
//검색어 특수문자 체크
function jsCheckSearchBox(controlName) {
    var strValue = controlName.value;
    var strCheckString = "!@#$%^&*_-+=|\\[]{}:;<>/?'\"";
    var temp = "";

    for (var i = 0; i < strCheckString.length; i++) {
        temp = strCheckString.substr(i, 1);

        if (strValue.indexOf(temp) != -1)
            return true;
    }
    return false;
}
//################################## 문자 관련 함수 끝 ##########################################

//################################## 체크 관련 함수 시작 ##########################################
//Null 체크-NullCheck
function NullCheck(InObj, InMsg) {
    if (InObj.value == "") {
        alert(InMsg + ' 입력해 주세요.');
        InObj.focus();
        return false;
    }
    return true;
}

function NullCheck_FS(InObj, InMsg) {
    if (InObj.value == "") {
        alert(InMsg);
        InObj.focus();
        return false;
    }
    return true;
}

//원하는 자리수 체크-NumberCheck,NumStrLengthCheck
function NumberCheck(InObj, InMsg, Length) {
    if (NumStrLengthCheck(InObj.value, Length)) return true;
    alert(InMsg + ' ' + Length + '자리로 입력하십시오.');
    InObj.focus();
    InObj.select();
    return false;
}

function NumStrLengthCheck(InStr, Length) {
    if ((InStr.length != 0) &&
		(!isNaN(InStr)) &&
		(InStr.length == Length))
        return true;
    else
        return false;
}

//글자 이상 체크 (몇글자 이상)-CheckOver
function CheckOver(InObj, InMsg) {
    var Str = InObj.value;

    if (Str.length < 4) {
        alert(InMsg + ' 4글자 이상으로 입력해 주세요.');
        InObj.focus();
        InObj.select();
        return false;
    }
    else if (Str.length > 10) {
        alert(InMsg + ' 10글자 이하로 입력해 주세요.');
        InObj.focus();
        InObj.select();
        return false;
    }

    return true;
}

//전화번호의 대쉬체크('-')-DashCheck
function DashCheck(InObj) {
    if (InObj.value != "") {
        var js_flage1 = 0;

        for (i = 0; i < InObj.value.length; i++) {
            if (InObj.value.charAt(i) == '-') {
                js_flage1 = js_flage1 + 1;
            }
        }

        if (js_flage1 != 2) {
            alert("전화번호에 대시('-')를 넣어주세요.");
            InObj.focus();
            return false;
        }
    }
    return true;
}

//영문/숫자 만 입력
function chkID(str) {
    chk = true
    for (i = 0; i <= str.length - 1; i++) {
        ch = str.substring(i, i + 1);
        if ((ch >= "0" && ch <= "9") || (ch >= "a" && ch <= "z")) {
            chk = true;
        }
        else {
            chk = false;
            break;
        }
    }
    return chk;
}

//숫자 만 입력
function Numeric(str) {
    chk = true

    if (str != "" && str != null) {
        for (i = 0; i <= str.length - 1; i++) {
            ch = str.substring(i, i + 1);
            if (ch >= "0" && ch <= "9") {
                chk = true;
            }
            else {
                chk = false;
                break;
            }
        }
    }

    return chk;
}
//################################## 체크 관련 함수 끝 ##########################################

//################################## 레이어 관련 함수 시작 ##########################################
function MM_showHideLayers() { //v6.0
    var i, p, v, obj, args = MM_showHideLayers.arguments;
    for (i = 0; i < (args.length - 2); i += 3) if ((obj = MM_findObj(args[i])) != null) {
        v = args[i + 2];
        if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }
        obj.visibility = v;
    }
}
//################################## 레이어 관련 함수 끝 ##########################################

//################################## 기타 관련 함수 시작 ##########################################
//공백문자제거 - Trim, LTrim, RTrim
function Trim(str) {
    return RTrim(LTrim(str));
}

function LTrim(str) {
    str_temp = str;
    while (str_temp.length != 0) {
        if (str_temp.substring(0, 1) == " ") {
            str_temp = str_temp.substring(1, str_temp.length);
        } else {
            return str_temp;
        }
    }
    return str_temp;
}

function RTrim(str) {
    str_temp = str;
    while (str_temp.length != 0) {
        int_last_blnk_pos = str_temp.lastIndexOf(" ");
        if ((str_temp.length - 1) == int_last_blnk_pos) {
            str_temp = str_temp.substring(0, str_temp.length - 1);
        } else {
            return str_temp;
        }
    }
    return str_temp;
}
//################################## 기타 관련 함수 끝 ##########################################

//alter
//--------------------------------------------------------------------------------------------------------------------------------------
//function jsAlert() { AlertModal("", "로그인해야 이용 가능 합니다."); }
function jsAlert() { alert("\n로그인해야 이용 가능 합니다."); }
//--------------------------------------------------------------------------------------------------------------------------------------

//################################## 플래쉬 클릭 URL 시작 ##########################################
function place01() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=1" } //서울/경기/인천
function place02() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=2" } //강원
function place03() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=5" } //충청/대전
function place04() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=6" } //대구/경북
function place05() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=7" } //부산/경남/울산
function place06() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=4" } //전북
function place07() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=3" } //전남/광주
function place08() { window.location.href = "/Distribution/SaleLocInfo/SaleAreaLocation.aspx?Area=8" } //제주
//################################## 플래쉬 클릭 URL 끝 ##########################################

//################################## Footer 함수 시작 ##########################################
function goURL(str) {
    if (str != 'x') {
        test = window.open(str, "_blank");
        setTimeout("setFocus();", 400);
    }
}

function setFocus() {
    test.focus();
}
//################################## Footer 함수 끝 ##########################################

//################################## 파일다운로드 함수 시작 ##########################################
function jsClick(File, FilePath, Gubun) {
    if (Gubun == "1")
        location.href = "/Common/AlertModal.aspx?File=" + encodeURIComponent(File) + "&FilePath=" + FilePath;
    else
        location.href = "/Common/AlertModal.aspx?File=" + encodeURIComponent(File) + "&FilePath=" + FilePath + "\\";
    //jsOpenDialog("/Common/AlertModal.aspx?File=" + File + "&FilePath=" + FilePath, "Download", "toolbar=no,status=no,resizable=no,scrollbars=no,Width=10,Height=10");
}
//################################## 파일다운로드 함수 끝 ##########################################
