﻿	/*
	  (c) 2007 <nox@ag.co.kr>, <noxajax@gmail.com> AhnGraphics Inc.
	  # Notice - required prototype.js
	*/

	var UnicefCommon = {
	    unicef: {'id': 'unicef', 'location': '/common/func/getNavigation.asp'},
	    bf:     {'id' :'bfhi', 'location': '/common/func/getNavigation.asp'},
	    mall:   {'id' :'mall', 'location': '/common/func/getNavigation.asp'},
	    uid: 'unicef_uid',
	    upw: 'unicef_upw'
	}

	function loginObserve() {
		if (!!$('unicef_uid')) {
            Event.observe('LEFT_LOGIN_FORM', 'submit', function(event) {
              	Event.stop(event);
                if (0 >= $(UnicefCommon.uid).getValue().strip().length) {
                   Form.Element.focus(UnicefCommon.uid);
                   alert('회원 아이디를 입력하세요.');
                   return;
                }

                if (0 >= $(UnicefCommon.upw).getValue().strip().length) {
                    alert('비밀번호를 입력하세요.');
                    Form.Element.focus(UnicefCommon.upw);
                    return;
                }

                __url__ = $('LEFT_LOGIN_FORM').action;
                new Ajax.Request(__url__, { asynchronous: false, parameters: $('LEFT_LOGIN_FORM').serialize(true)
                                            , onFailure: function() { alert('오류가 발생했습니다.'); }
                                            , onComplete: function(xmlHttp, json) {
                                                try {
                                                    json = (json || xmlHttp.responseText.evalJSON());
                                                    if (1 == json.error) {
                                                        alert(json.description);
                                                        return;
                                                    }
                                                    alert(json.description);
                                                    location.reload();
                                                } catch (error) {
                                                    alert('로그인 도중 오류가 발생했습니다.');
                                                }
                                            }
                                        }
                                );
                return;
            });
        }
  	}

//    Event.observe(window, 'load', function() {
//        var bodyId = document.body.id;
//        var cate = UnicefCommon.unicef.id
//        var baseBodyId = '', basePath = '', defaultPanel = 0;
//        var path = '', page = '', partn = '^(.*)/([^/]*)$';
//        var match = new RegExp(partn, 'img').exec(location.pathname);
//        if (!!match) {
//            path = match[1];
//            page = match[2];
//            match = new RegExp('/' + UnicefCommon.bf.id + '/*', 'img').exec(location.pathname);
//            if (!!match) cate = UnicefCommon.bf.id
//            match = new RegExp('/' + UnicefCommon.mall.id + '/*', 'img').exec(location.pathname);
//            if (!!match) {
//            	cate = UnicefCommon.mall.id;
//            	makeQuickMenuMall();
//            } else {
//            	makeQuickMenu();
//            }
//        }
//
//		var basePath = location.protocol + '//' + location.hostname;
//        var __url__ = basePath + UnicefCommon.unicef.location + "?"
//                    + "UNICEF_CATE=" + encodeURIComponent(cate)
//                    + "&UNICEF_LOCA=" + encodeURIComponent(path)
//                    + "&UNICEF_BODY=" + encodeURIComponent(bodyId)
//                    + "&UNICEF_PAGE=" + encodeURIComponent(page);
//
//    	new Ajax.Request(__url__, { asynchronous: false, onComplete: function(xmlHttp, json) {
//        	                        json = (json || xmlHttp.responseText.evalJSON());
//        	                        $('areaTop').innerHTML = json.areaTop;
//                                    $('footer').innerHTML = json.footer;
//                                    baseBodyId = (json.baseBody || '');
//                                    basePath = (json.basePath || '');
//                                    if (!!$('memberLogin') && typeof json.memberLogin.content != 'undefined')
//                                        $('memberLogin').innerHTML = json.memberLogin.content;
//                                    if (!!$('subSlideMenu') && typeof json.subSlideMenu != 'undefined') {
//                                        defaultPanel = json.subSlideMenu.defaultPanel;
//                                        $('subSlideMenu').innerHTML = json.subSlideMenu.content;
//                                    }
//
//                                    var support = $('areaSupport');
//                                    if (!!support && !!support.childElements()[0] && 'A' == support.childElements()[0].tagName) {
//        								support.childElements()[0].href = json.support;
//        							}
//	                            }
//	                        }
//	                    );
//
//	    loginObserve();
//        //if (!!$('subSlideMenu')) {
//        //	if (!!baseBodyId) bodyId = baseBodyId;
//        //	if (!basePath) basePath = location.pathname;
//        //    Event.observe('subSlideMenu', 'focus', function(event) { Event.element(event).blur(); });
//		//    var subMenu = new Spry.Widget.Accordion("subSlideMenu", {'defaultPanel': defaultPanel});
//		//    if (!!$('side_' + bodyId)) {
//    	//	    var strSelMenu = $('side_' + bodyId).innerHTML.stripTags();
//        //        $('side_' + bodyId).innerHTML
//        //            = '<span class="checkMenu">&nbsp;</span> ' +
//        //            '<a href="' + basePath + '">' +
//        //            '<span class="txt_boldLocal">' + strSelMenu + '</span></a>';
//        //    }
//        //    subMenu.currentPanel = null;
//        //    subMenu.openPanel(subMenu.getPanels()[defaultPanel]);
//    	//}
//
//        if (typeof windowLoad != 'undefined' && !!windowLoad) windowLoad();
//    });



    var FlashObj = Class.create();
    FlashObj.prototype = {
  	    initialize: function (__hashArg__) {
        	this.hashArg = __hashArg__;
  	    },

  	  	clsid: 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
        codebase: location.protocol + '//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab',
        version: '9, 0, 0, 0',
        wmode: 'opaque', //'transparent',
        quality: 'high',
        type: 'application/x-shockwave-flash',
        pluginspage: location.protocol + '//www.macromedia.com/go/getflashplayer',

	    toString: function() {
	    	var basePath = location.protocol + '//' + location.hostname;
	        if ('object' != typeof this.hashArg /*|| 0 >= typeof this.hashArg.length*/) return '';
	        var tmpVal = $H(this.hashArg);
    	    var tag = new String(), embTag = new String();
    	    embTag = '<embed';
            tag += '<object classid="' + this.clsid + '"';
    	    tag += ' codebase="' + this.codebase + '#version=' + (tmpVal['version'] || this.version).strip() + '"';
    	    if (undefined != tmpVal['id']) {
    		    tag += ' id="' + tmpVal['id'].strip() + '"';
    	    }
            tag += ' width="' + (tmpVal['width'] || 0) + '"';
            tag += ' height="' + (tmpVal['height'] || 0) + '"';
            tag += ' >';
            if (undefined != tmpVal['src']) {
                tag += '<param name="movie" value="' + basePath + '/' + tmpVal['src'].strip() + '" />';
                embTag += ' src="' + basePath + '/' + tmpVal['src'].strip();
                if (undefined != tmpVal['vars']) {
                	embTag += '?' + tmpVal['vars'].strip();
               	}
               	embTag  += '"';
            }

            tag += '<param name="base" value=".">'
            tag += '<param name="allowScriptAccess" value="sameDomain" />';
            tag += '<param name="quality" value="' + (tmpVal['quality'] || this.quality).strip() + '" />';
            embTag += ' quality="' + (tmpVal['quality'] || this.quality).strip() + '"';
            tag += '<param name="wmode" value="' + (tmpVal['wmode'] || this.wmode).strip() + '" />';
            embTag += ' wmode="' + (tmpVal['wmode'] || this.wmode).strip() + '"';
            if (undefined != tmpVal['vars']) {
                tag += '<param name="flashvars" value="' + tmpVal['vars'].strip() + '" />';
            }

            embTag += ' base="."';
            embTag += ' allowScriptAccess="sameDomain"';
            embTag += ' type="' + this.type + '"';
            embTag += ' pluginspage="' + this.pluginspage + '"';
            embTag += ' width="' + (tmpVal['width'] || 0) + '"';
            embTag += ' height="' + (tmpVal['height'] || 0) + '"';
            embTag += ' />';
            tag += embTag + '</object>';
    	    return tag;
  	    },

  	    write: function() { document.write(this.toString()); },
  	    innerHTML : function() { return this.toString(); }
    }
//주민등록번호이동.
    function moveFocus(num,fromform,toform){
      var str = fromform.value.length;
      if(str == num) {
        toform.focus();
      }
    }

//사랑의 선물(아직준비중입니다.)
    function productLoveGift()
    {
        alert('아직 준비중 입니다.');
        return;
    }
