String.prototype.trim = function() 
{ 
	str = this != window ? this : str; 
	return str.replace(/^\s+/g,'').replace(/\s+$/g,''); 
}

// 변환하려는 숫자가 문자열이 아닐 경우 최대 16자리까지만 변환 가능 
// 이후 숫자는 엉터리로 나옴.. 한계인듯???
String.prototype.number_format = function()
{
	return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,');
}


	function GorelaData()
	{
		this.browser = getBrowser();
		
		function getBrowser()
		{
			var browser = {agent:null, opera:false, msie:false, firefox:false, netscape:false, safari:false, version:false};
			var ua = window.navigator.userAgent.toLowerCase();
			var agent, version;
			if(ua.match("opera"))
			{
				browser.agent = "opera";
				browser.opera = true;
	//			browser.version = trim(ua.split("opera")[1]);
			}
			else if(ua.match("msie"))
			{
				browser.agent = "msie";
				browser.msie = true;
	//			browser.version = trim(ua.split("msie")[1].split(";")[0]);
			}
			else if(ua.match("firefox"))
			{
				browser.agent = "firefox";
				browser.firefox = true;
	//			browser.version = trim(ua.split("firefox")[1].split("/")[1]);
			}
			else if(ua.match("netscape"))
			{
				browser.agent = "netscape";
				browser.netscape = true;
	//			browser.version = trim(ua.split("netscape")[1].split("/")[1]);
			}
			else if(ua.match("safari"))
			{
				browser.agent = "safari";
				browser.safari = true;
	//			browser.version = trim(ua.split("safari")[1].split("/")[1]);
			}
			
			return browser;
		}
	}	
	window.gorelaData = new GorelaData()

	function setStartPage(url)
	{
		if(!gorelaData.browser.msie) return false;
		
		try
		{
			var obj = document.createElement("DIV");
			obj.style.behavior='url(#default#homepage)';
			obj.setHomePage(url);
			delete obj;
			return true;
		}
		catch(err) 
		{
			return false;
		}
	}

	function WindowOpen(Url, popName, popwidth, popheight, status){
        var height = screen.height;
        var width = screen.width;
        var left = 0;
        var top = 0;
        popheight = popheight + 27;
		
		if(status != undefined)
		{
			var tmp = status.split("|");
			var newStatus = "";
			for(var i=0; i<tmp.length; i++)
			{
				newStatus += ", " + tmp[i] + "=yes";
			}
		}

		window.open(Url, popName, "width="+popwidth+", height="+popheight+", left="+left+", top="+top+newStatus)
    }

    function WindowOpenCenter(Url, popName, popwidth, popheight){
        var LeftPosition = (screen.width) ? (screen.width-popwidth)/2 : 0;
        var TopPosition = (screen.height) ? (screen.height-popheight)/2 : 0;
        var settings = 'height='+popheight+',width='+popwidth+',top='+TopPosition+',left='+LeftPosition+',status=no,toolbar=no,menubar=no,location=no,fullscreen=no,resizable=no,scrollbars=no';
        win = window.open(Url,popName,settings)
    }


    function PopupWindowOpen(Url, popName, popwidth, popheight, left, top){

        window.open(Url, popName, "width="+popwidth+",height="+popheight+",scrollbars=no,toolbar=no,left="+left+",top="+top+"")
    }

	 function PopupWindowOpen2(Url, popName, popwidth, popheight, left, top){

        window.open(Url, popName, "width="+popwidth+",height="+popheight+",scrollbars=yes,toolbar=no,left="+left+",top="+top+"")
    }

    // 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 '';
    }

    // 이미지사이즈에 맞게 팝업창 (이미지,디렉토리,width,height)
    function image_window(img, w, h)
    {
        var winl = (screen.width-w)/2;
        var wint = (screen.height-h)/3;

        if (w >= screen.width) {
            winl = 0;
            h = (parseInt)(w * (h / w));
        }

        if (h >= screen.height) {
            wint = 0;
            w = (parseInt)(h * (w / h));
        }

        var js_url = "<script language='JavaScript1.2'> \n";
            js_url += "<!-- \n";
            js_url += "var ie=document.all; \n";
            js_url += "var nn6=document.getElementById&&!document.all; \n";
            js_url += "var isdrag=false; \n";
            js_url += "var x,y; \n";
            js_url += "var dobj; \n";
            js_url += "function movemouse(e) \n";
            js_url += "{ \n";
            js_url += "  if (isdrag) \n";
            js_url += "  { \n";
            js_url += "    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x; \n";
            js_url += "    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y; \n";
            js_url += "    return false; \n";
            js_url += "  } \n";
            js_url += "} \n";
            js_url += "function selectmouse(e) \n";
            js_url += "{ \n";
            js_url += "  var fobj      = nn6 ? e.target : event.srcElement; \n";
            js_url += "  var topelement = nn6 ? 'HTML' : 'BODY'; \n";
            js_url += "  while (fobj.tagName != topelement && fobj.className != 'dragme') \n";
            js_url += "  { \n";
            js_url += "    fobj = nn6 ? fobj.parentNode : fobj.parentElement; \n";
            js_url += "  } \n";
            js_url += "  if (fobj.className=='dragme') \n";
            js_url += "  { \n";
            js_url += "    isdrag = true; \n";
            js_url += "    dobj = fobj; \n";
            js_url += "    tx = parseInt(dobj.style.left+0); \n";
            js_url += "    ty = parseInt(dobj.style.top+0); \n";
            js_url += "    x = nn6 ? e.clientX : event.clientX; \n";
            js_url += "    y = nn6 ? e.clientY : event.clientY; \n";
            js_url += "    document.onmousemove=movemouse; \n";
            js_url += "    return false; \n";
            js_url += "  } \n";
            js_url += "} \n";
            js_url += "document.onmousedown=selectmouse; \n";
            js_url += "document.onmouseup=new Function('isdrag=false'); \n";
            js_url += "//--> \n";
            js_url += "</"+"script> \n";

        var settings;

            settings  ='width='+w+',';
            settings +='height='+h+',';
      
        settings +='top='+wint+',';
        settings +='left='+winl+',';
        settings +='scrollbars=no,';
        settings +='resizable=yes,';
        settings +='status=no';


        win=window.open("","image_window",settings);
        win.document.open();
        win.document.write ("<html><head> \n<meta http-equiv='imagetoolbar' CONTENT='no'> \n<meta http-equiv='content-type' content='text/html; charset=utf-8'>\n");
        var size = "이미지 사이즈 : "+w+" x "+h;
        win.document.write ("<title>"+size+"</title> \n");
        if(w >= screen.width || h >= screen.height) {
            win.document.write (js_url);
            var click = "ondblclick='window.close();' style='cursor:move' title=' "+size+" \n\n 이미지 사이즈가 화면보다 큽니다. \n 왼쪽 버튼을 클릭한 후 마우스를 움직여서 보세요. \n\n 더블 클릭하면 닫혀요. '";
        }
        else
            var click = "onclick='window.close();' style='cursor:pointer' title=' "+size+" \n\n 클릭하면 닫혀요. '";
        win.document.write ("<style>.dragme{position:relative;}</style> \n");
        win.document.write ("</head> \n\n");
        win.document.write ("<body leftmargin=0 topmargin=0 bgcolor=#dddddd style='cursor:arrow;'> \n");
        win.document.write ("<table width=100% height=100% cellpadding=0 cellspacing=0><tr><td align=center valign=middle><img src='"+img+"' width='"+w+"' height='"+h+"' border=0 class='dragme' "+click+"></td></tr></table>");
        win.document.write ("</body></html>");
        win.document.close();

        if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
    }

	//인기검색어 by tuna
	function easy_search(searchword) { //인기검색어 클릭시
	//alert("호출성공");
	//window.open("http://search.ebay.com/"+searchword,'pop2','width=890,top=0,left=0, scrollbars=yes, toolbar=yes, location=yes, menubar=yes, status=yes, resizable=yes '); 
	window.open("http://search.ebay.com/"+searchword); 
	PopupWindowOpen2("/mygorela/easy_app.html", "title", "295", "505","900","0");
 }

 function go_partner(url, title, width, height) {
	var obj = document.frm;

	PopupWindowOpen(url, title, width, height);
}


function containsCharsOnly(input,chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) == -1)
           return false;
    }
    return true;
}

function isNumber(input) {
    var chars = "0123456789";
    return containsCharsOnly(input,chars);
}

//replaceAll(인자,바꿀인자,바뀌는인자)
function replaceAll(strTemp, strValue1, strValue2){
  while(1){
    if( strTemp.indexOf(strValue1) != -1 )
       strTemp = strTemp.replace(strValue1, strValue2);
    else
       break;
  }
   return strTemp;
 
}

// Ajax 실행시 Loading 이미지 레이어 위치값 조정
function setAjaxLoadingLayerTop(top)
{
	top = (top == undefined) ? 200 : top;
	var ajax_loading_top = parseInt(document.body.scrollTop) + top;
	$('#ajax-loading').css('top', ajax_loading_top+'px')
}


function securityConnect(frm, check)
{
	frm.action = (check == true) ? LOGIN_HOME_URL_SSL : LOGIN_HOME_URL;
}
