﻿//팝업 띄우기...
function openPopup(url, winW, winH, scroll, winName) {
    var obj;
    var setup = "width=" + winW + ",height=" + winH + ",toolbar=no,location=no,status=no,menubar=no,top=10,left=50,scrollbars=" + scroll + ",resizable=no";
    if (!winName) winName = "";
    try {
        obj = window.open(url, winName, setup);
        obj.focus();
    }
    catch (e) {
        alert("차단된 팝업창을 허용해 주십시오.");
    }
}


//open full screen
function openFullScreen(url) {
    var setup = "fullscreen=1,scrollbars=0";
    var win = window.open(url, "popup", setup);
}

//단순 오픈
function openPage(url) {
    var win = window.open(url);
}

// image rollover rollout
function rollover(obj) {
    var oImg = document.getElementById(obj);
    var imgSrc = oImg.src;
    oImg.src = imgSrc.replace("off", "on");
}
function rollout(obj) {
    var oImg = document.getElementById(obj);
    var imgSrc = oImg.src;
    oImg.src = imgSrc.replace("on", "off");
}
/* Image rollover without ID */
function imgover(img) {
    var image = img.src;

    if (image.indexOf('on.gif') < 0) {
        currentUrl = image.substr(0, image.indexOf('off.gif'));
        img.src = currentUrl + "on.gif";
    }
    else {
        currentUrl = image.substr(0, image.indexOf('on.gif'));
        img.src = currentUrl + "off.gif";
    }
}
// Flash ExternalInterface Return Value
function swfInit(src) {
    var url;
    switch (src) {
        //-- load_url 
        case "top_xml": url = "xml/warrants_stock.xml"; break;
        case "brand_xml": url = "xml/gift_brand.xml"; break;
        case "intro_xml": url = "xml/gift_intro.xml"; break;
        //-- etc link 
        case "link_faq": url = "javascript:alert('faq');"; break;
        case "link_qa": url = "javascript:alert('qa');"; break;
        case "link_guide": url = "javascript:alert('guide');"; break;
    }
    return url;
}



function set_reserve_date(date) {
    alert(date);
}

//show Flash Object ; 1 (파일경로, 가로, 세로, 아이디, 배경색, 변수, 윈도우모드)
function showFlashObject(objID, objSource, objWidth, objHeight, objQuality, objWmode, objBgcolor) {
    var pageUrl = self.window.location.href;
    //default value setting
    if (objID == "") objID = "ShockwaveFlash1";
    if (objWidth == "") objWidth = "0";
    if (objHeight == "") objHeight = "0";
    if (objQuality == "") objQuality = "high";

    document.writeln('<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="' + objWidth + '" height="' + objHeight + '" id="' + objID + '" align="middle">');
    document.writeln('<param name="movie" value="' + objSource + '" />');
    document.writeln('<param name="allowScriptAccess" value="always" />');
    document.writeln('<param name="menu" value="false" />');
    document.writeln('<param name="quality" value="high" />');
    document.writeln('<param name="bgcolor" value="' + objBgcolor + '" />');
    document.writeln('<param name="wmode" value="' + objWmode + '" />');
    document.writeln('<embed src="' + objSource + '" allowScriptAccess="always" menu="false" quality="high" bgcolor="' + objBgcolor + '" wmode="' + objWmode + '" width="' + objWidth + '" height="' + objHeight + '" name="' + objID + '" id="' + objID + '" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.writeln('</object>');
}


//show Media Object ; 1
function showMediaObject(objID, objSource, objWidth, objHeight, autostart, showcontrols) {
    //default value setting
    if (objID == "") objID = "MovieClip1";
    if (objWidth == "") objWidth = "400";
    if (objHeight == "") objHeight = "345";
    if (autostart == "") autostart = "1";
    if (showcontrols == "") showcontrols = "0";

    document.writeln('<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="' + objID + '" width="' + objWidth + '" height="' + objHeight + '">');
    document.writeln('<param name="AutoSize" value="0">');
    document.writeln('<param name="AutoStart" value="' + autostart + '">');
    document.writeln('<param name="AutoRewind" value="true">');
    document.writeln('<param name="ClickToPlay" value="0">');
    document.writeln('<param name="Enabled" value="1">');
    document.writeln('<param name="EnableTracker" value="1">');
    document.writeln('<param name="EnableContextMenu" value="0">');
    document.writeln('<param name="ShowStatusBar" value="0">');
    document.writeln('<param name="ShowControls" value="' + showcontrols + '">');
    document.writeln('<param name="ShowAudioControls" value="' + showcontrols + '">');
    document.writeln('<param name="ShowCaptioning" value="0">');
    document.writeln('<param name="Mute" value="0">');
    document.writeln('<param name="ShowDisplay" value="0">');
    document.writeln('<param name="filename" value="' + objSource + '">');
    document.writeln('<!--[if !IE]>-->');
    document.writeln('	<object type="video/x-ms-wmv" data="' + objSource + '" width="' + objWidth + '" height="' + objHeight + '">');
    document.writeln('	<param name="AutoStart" value="' + autostart + '">');
    document.writeln('	<param name="AutoRewind" value="true">');
    document.writeln('	<param name="Enabled" value="1">');
    document.writeln('	<param name="EnableTracker" value="1">');
    document.writeln('	<param name="EnableContextMenu" value="0">');
    document.writeln('	<param name="ShowStatusBar" value="0">');
    document.writeln('	<param name="ShowControls" value="' + showcontrols + '">');
    document.writeln('	<param name="ShowAudioControls" value="' + showcontrols + '">');
    document.writeln('	<param name="ShowCaptioning" value="0">');
    document.writeln('	<param name="ShowDisplay" value="0">');
    document.writeln('	<param name="url" value="' + objSource + '">');
    document.writeln('	<param name="src" value="' + objSource + '">');
    document.writeln('	</object>');
    document.writeln('<!--<![endif]-->');
    document.writeln('</object>');
}




// 플래시 호출 flashWrite(파일경로, 가로, 세로)
function flashWrite(url,width,height){
    // 플래시 코드 정의
    var flashStr=
    "<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='"+width+"' height='"+height+"' align='middle'>"+
    "<param name='allowScriptAccess' value='always' />"+
    "<param name='movie' value='"+url+"' />"+
    "<param name='menu' value='false' />"+
    "<param name='quality' value='high' />"+
    "<param name='bgcolor' value='#FFFFFF' />"+
    "<param name='wmode' value='transparent'>"+
    "<embed src='"+url+"' menu='false' quality='high' width='"+width+"' height='"+height+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
    "</object>";
    // 플래시 코드 출력
    document.write(flashStr);
}



// 플래시 호출 flashWrite(파일경로, 가로, 세로)
function flashWrite_Layer(url,width,height,top,left,divNm){
    // 플래시 코드 정의
    var flashStr=
    "<div style='position:absolute;z-index:99;top:0px;left:0px;display:none;' id='"+divNm+"'>" +
    "<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='"+width+"' height='"+height+"' align='middle'>"+
    "<param name='allowScriptAccess' value='always' />"+
    "<param name='movie' value='"+url+"' />"+
    "<param name='menu' value='false' />"+
    "<param name='quality' value='high' />"+
    "<param name='bgcolor' value='#FFFFFF' />"+
    "<param name='wmode' value='transparent'>"+
    "<embed src='"+url+"' menu='false' quality='high' width='"+width+"' height='"+height+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
    "</object></div>";
    // 플래시 코드 출력
    document.write(flashStr);
    

                                
}


//familysite 
function familysite() {
    var obj = document.getElementById('familysitelist');
    if (obj.style.display != "none")
        obj.style.display = "none";
    else
        obj.style.display = "block";
}
//mybrand 
function mybrand() {
    var obj = document.getElementById('mybrandList');
    if (obj.style.display != "none")
        obj.style.display = "none";
    else
        obj.style.display = "block";
}
//productInfo 
function productInfo() {
    var obj = document.getElementById('productInfoList');
    if (obj.style.display != "none")
        obj.style.display = "none";
    else
        obj.style.display = "block";
}
function selectListView(oSelectList) {
    var oSelectList = document.getElementById(oSelectList);
    if (oSelectList.style.display != "none")
        oSelectList.style.display = "none";
    else
        oSelectList.style.display = "block";
}

// Flash ExternalInterface Return Value
function swfInit(src) {
    var url;
    switch (src) {
        //-- load_url 
        case "top_xml": url = "xml/warrants_stock.xml"; break;
        case "brand_xml": url = "xml/gift_brand.xml"; break;
        case "intro_xml": url = "xml/gift_intro.xml"; break;
        //-- etc link 
        case "link_faq": url = "javascript:alert('faq');"; break;
        case "link_qa": url = "javascript:alert('qa');"; break;
        case "link_guide": url = "javascript:alert('guide');"; break;
    }
    return url;
}

var objectTag = "";
/*
function flashWrite(swf_name,swf_file,swf_width,swf_height) {
var objectTag = "<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='"+swf_width+"' height='"+swf_height+"' id='"+ swf_name +"' align='middle'><param name='allowScriptAccess' value='always'><param name='movie' value='" + swf_file +"'><param name='quality' value='high'><param name='bgcolor' value='#000000'><embed src='" + swf_file +"' quality='high' bgcolor='#000000' width='"+swf_width+"' height='"+swf_height+"' name='"+ swf_name +"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></object>";
document.write(objectTag);		
objectTag = "";
}
*/
function set_reserve_date(date) {
    alert(date);
}

// 외국인 등록번호 검사
function Check_fgnno(fgnno) {
    var sum = 0;
    var odd = 0;
    buf = new Array(13);
    for (i = 0; i < 13; i++) { buf[i] = parseInt(fgnno.charAt(i)); }
    odd = buf[7] * 10 + buf[8];
    if (odd % 2 != 0) { return false; }
    if ((buf[11] != 6) && (buf[11] != 7) && (buf[11] != 8) && (buf[11] != 9)) {
        return false;
    }
    multipliers = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
    for (i = 0, sum = 0; i < 12; i++) { sum += (buf[i] *= multipliers[i]); }
    sum = 11 - (sum % 11);
    if (sum >= 10) { sum -= 10; }
    sum += 2;
    if (sum >= 10) { sum -= 10; }
    if (sum != buf[12]) { return true } 	// 형식에 맞지 않을때
    return false; 						// 형식에 맞을때
}
//오직 숫자만 입력하도록...
function onlyNumber() {
    if ((event.keyCode < 48) || (event.keyCode > 57))
        event.returnValue = false;
}

// 자바 스크립트로 입력값 체크 하기...
function filterCheck(filter) {
    if (filter) {
        var sKey = String.fromCharCode(event.keyCode);
        var Rx = new RegExp(filter);
        if (!Rx.test(sKey)) event.returnValue = false;
    }
}

//PNG
function setPNG24(obj) {
    obj.width = obj.height = 1;
    obj.className = obj.className.replace(/\bPNG24\b/i, '');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "',sizingMethod='image');"
    obj.src = '';
    return '';
}



//******************************************************************************************************
// Eexplanation : RollOver 버튼
//******************************************************************************************************
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_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_findObj(n, d) { //v4.0
    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 && document.getElementById) x = document.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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init == true) with (navigator) {
        if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
            document.MM_pgW = innerWidth; document.MM_pgH = innerHeight; onresize = MM_reloadPage;
        } 
    }
    else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload();
}

function MM_findObj(n, d) { //v4.0
    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 && document.getElementById) x = document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.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;
    }
}

 


function win_close(GoUrl) {
    try {
        if (document.popup.no_view.checked == true)	//체크박스 사용안할라면 이줄만 주석처리
            SetCookie("popup" + varPIdx, "done", 1);
    }
    catch (e) {
    }

    try {
        if (document.all("no_view").checked == true)	//체크박스 사용안할라면 이줄만 주석처리
            SetCookie("popup" + varPIdx, "done", 1);
    }
    catch (e)
	{ }

    if (GoUrl != "") {
        Gogogo(GoUrl);
    }

    PageClose();
}


function Gogogo(GoUrl) {
    if (GoUrl != "") {

        try {
            opener.location.href = GoUrl;       //부모창 바뀌는곳
            PageClose();
            return;
        }
        catch (e) {
        }

        try {
            parent.location.href = GoUrl;       //IFRAME 팝업일때
            PageClose();
            return;
        }
        catch (e)
		{ }


    }

    PageClose();
}


function Go_PrdDetail(Url , Target) {
 
    if(Target == "opener")
    {
        opener.location.href = Url ;
    }

    if(Target == "parent")
    {
        parent.location.href = Url ;
    }

    if(Target == "")
    {
        location.href = Url ;
    }

}


//창닫기			
function PageClose() {


    try {
        parent.document.getElementById("DivPopup_" + varPIdx).style.display = "none";
        return;
    }
    catch (e)
	{ }

    try {
        self.close();
        return;
    }
    catch (e)
	{ }



}

function Request(valuename) {
    var rtnval;
    var nowAddress = unescape(location.href); //현재 url주소값 가져오기
    var parameters = new Array();
    parameters = (nowAddress.slice(nowAddress.indexOf("?") + 1, nowAddress.length)).split("&");
    for (var i = 0; i < parameters.length; i++) {
        if (parameters[i].indexOf(valuename) != -1) {
            rtnval = parameters[i].split("=")[1];
            if (rtnval == undefined || rtnval == null) {
                rtnval = "";
            }
            return rtnval;
        }
    }
}

//================================================================================
//이하 아이하우스에서 가지고 오는 부분...
function heightBlank(h) {
    var strHB;

    strHB = "<table cellpadding=0 cellspacing=0><tr height=" + h + "><td></td></tr></table>";

    document.write(strHB);
}



function RowLine(w) {
    var strHB;

    strHB = "<table width=" + w + " border=0 cellspacing=0 cellpadding=0><tr height=1><td bgcolor=CEBEBA></td></tr></table>";

    document.write(strHB);
}

////////////////////////////////////////////////////////////////////////////////////////////
//	버전 : Ver 1.0.0
//	작성자 : 
//	작성일 : 2009.04.20
//	설명 : int, float만 입력체크
//	Example:
//	onKeyDown="only_num('int');" onKeyPress="only_num('int');" onKeyUp="only_num('int');"
////////////////////////////////////////////////////////////////////////////////////////////
function fn_OnlyNum(obj, type) {
    /*
    type
    -> 'int' : 양의 정수
    -> 'float' : 양의 실수
    -> '-int' : 음의 정수 포함
    -> '-float' : 음의 실수 포함
    */
    var val = obj.value.toString();
    var regexp = /[^-\.0-9]/g;
    var repexp = '';

    val = val.replace(regexp, repexp);
    regexp = '';
    repexp = '';

    switch (type) {
        case 'int':
            regexp = /[^0-9]/g;
            break;

        case 'float':
            regexp = /^(-?)([0-9]*)(\.?)([^0-9]*)([0-9]*)([^0-9]*)/;
            break;

        case '-int':
            regexp = /^(-?)([0-9]*)([^0-9]*)([0-9]*)([^0-9]*)/;
            break;

        case '-float':
            regexp = /^(-?)([0-9]*)(\.?)([^0-9]*)([0-9]*)([^0-9]*)/;
            break;

        default:
            regexp = /[^0-9]/g;
            break;
    }

    switch (type) {
        case 'int':
            repexp = '';
            break;

        case 'float':
            repexp = '$2$3$5';
            break;

        case '-int':
            repexp = '$1$2$4';
            break;

        case '-float':
            repexp = '$1$2$3$5';
            break;

        default:
            regexp = /[^0-9]/g;
            break;
    }

    val = val.replace(regexp, repexp);
    obj.value = val;
}

//좌우공백제거
String.prototype.trim = function() {
    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

//작성자 이상현
//레이어  View     
//ViewID : 보여지는 객체의 아이디
//Id_Array : 해당 작업시 처리되는 전체 객체 아이디
function LayerShow(ViewID , Id_Array)
{
    var Id_Ar = Id_Array.split(",");
    for(var ii = 0 ; ii < Id_Ar.length ; ii++)
    {
        if(ViewID == Id_Ar[ii])
        {
            $("#"+Id_Ar[ii]).show();
        }
        else
        {
            $("#"+Id_Ar[ii]).hide();
        }
    }
}

function LayerShowTab(ViewID , Id_Array)
{
 
 
    var Id_Ar = Id_Array.split(",");
    for(var ii = 0 ; ii < Id_Ar.length ; ii++)
    {
        var IdVar = "#"+Id_Ar[ii];
        var ImgSrc = "";
 
        if(ViewID == Id_Ar[ii])
        {
            $(IdVar).show();
		    try
		    {
		        ImgSrc = $(IdVar + "_tImg").attr("src").replace("on.gif",".gif");
		        ImgSrc = ImgSrc.replace(".gif","on.gif");
		    }
		    catch(e)
		    {}
        }
        else
        {
            $(IdVar).hide();
		    try
		    {
		    ImgSrc = $(IdVar + "_tImg").attr("src").replace("on.gif",".gif");
		    }
		    catch(e)
		    {}
        }
         
        try
        {
            $(IdVar + "_tImg").attr({ src: ImgSrc });
        }
        catch(e)
        {}

		        
    }
}



function ChageTabImg(ViewID , Id_Array)
{
 
    var Id_Ar = Id_Array.split(",");
    for(var ii = 0 ; ii < Id_Ar.length ; ii++)
    {
        var IdVar = "#"+Id_Ar[ii];
        var ImgSrc = "";
 
        if(ViewID == Id_Ar[ii])
        {
		    try
		    {
		        ImgSrc = $(IdVar).attr("src").replace("on.gif",".gif");
		        ImgSrc = ImgSrc.replace(".gif","on.gif");
		    }
		    catch(e)
		    {}
        }
        else
        {
		    try
		    {
		    ImgSrc = $(IdVar).attr("src").replace("on.gif",".gif");
		    }
		    catch(e)
		    {}
        }
		
        try
        {
            $(IdVar).attr({ src: ImgSrc });
        }
        catch(e)
        {}

		        
    }
}



//1000 단위 마다 콤마를 찍어보자...
 function fnMoneyType(v) {
    v = v.toString();
    if (v.length > 3) {
            var mod = v.length % 3;
            var retval = (mod > 0 ? (v.substring(0,mod)) : "");
            for (i=0 ; i < Math.floor(v.length / 3); i++) {
                    if ((mod == 0) && (i == 0)) {
                            retval += v.substring(mod+ 3 * i, mod + 3 * i + 3);
                    } else {
                            retval+= "," + v.substring(mod + 3 * i, mod + 3 * i + 3);
                    }
            }
            return retval;
    } else {
            return v;
    }
} 
  
  
String.prototype.numberFormat=function() { 
    return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,'); 
}   
 
 

String.prototype.toInteger = function() {
 return this.replace(/[^0-9]/g, '') * 1;
}
