//document.oncontextmenu=new Function("return false")


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.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 setTextBox()
{    
    document.all.txtLoginID.style.backgroundImage = document.all.txtLoginID.value == '' ? "url('http://img.karma2.co.kr/img/img_common/login_id.gif')" : ''
    document.all.txtLoginPwd.style.backgroundImage = document.all.txtLoginPwd.value == '' ? "url('http://img.karma2.co.kr/img/img_common/login_pw.gif')" : ''
}

function trim(str) 
{
	var count = str.length;
	var len = count;                
	var st = 0;

	while ((st < len) && (str.charAt(st) <= ' ')) 
		st++;

	while ((st < len) && (str.charAt(len - 1) <= ' ')) 
		len--;

	return ((st > 0) || (len < count)) ? str.substring(st, len) : str ;   
}

//ÀÚ¸´¼öÃ¼Å© ÇÏ¿© ¸ÂÀ¸¸é ´ÙÀ½À¸·Î Æ÷Ä¿½º ÀÌµ¿
function len_check( val1, len, val2 )
{    
	var obj
	if ( val1.value.length == len ) 
	{      
		obj = eval(val2);
		obj.focus();
		return;
    }
}

function checkObject(object,message)
{
	if( !trim(object.value) )
	{
		alert( message );
		object.value = "";
		object.focus();
		return false;
	}
	return true;	
}

function containsChars(input,chars) 
{
    for (var inx = 0; inx < input.length; inx++) 
    {
       if (chars.indexOf(input.charAt(inx)) != -1)
           return true;
    }
    return false;
}

function containsCharsOnly(input,chars) 
{
	for (var inx = 0; inx < input.length; inx++) 
	{
		if (chars.indexOf(input.charAt(inx)) == -1)
			return false;
	}
	return true;
}

function isValidEmail(input) {
    //var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    //var format = /^[0-9a-z]([-_\.]?[0-9a-z])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,3}$/;
    var format = /^[0-9a-z]([0-9a-z-_\.])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,3}$/;
    if (input.search(format) != -1) {
        return true; //¿Ã¹Ù¸¥ Æ÷¸Ë Çü½Ä
    }
    return false;
}

function isNumDash(input) 
{
	var chars = "0123456789-";
	return containsCharsOnly(input,chars);
}

function isAlphabet(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    return containsCharsOnly(input,chars);
}

function isAlphabetNum(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    return containsCharsOnly(input,chars);
}

function isNumber(input) {
    var chars = "0123456789";
    return containsCharsOnly(input,chars);
}

function isOKChar(input) {
    var chars = "<>;' ";
    return containsChars(input,chars);
}

function openPopCenter( url, wname, sizeW, sizeH )
{
	var nLeft  = screen.width/3;
	var nTop  = screen.height/3;
 
	opt = ",toolbar=no,menubar=no,location=no,scrollbars=no,status=no";
	openobj = window.open(url, wname, "left=" + nLeft + ",top=" +  nTop + ",width=" + sizeW + ",height=" + sizeH  + opt );
	openobj.focus()
}

function openPop( url, wname, sizeW, sizeH )
{
	opt = ",toolbar=no,menubar=no,location=no,scrollbars=no,status=no";
	openobj = window.open(url, wname, "left=10,top=10,width=" + sizeW + ",height=" + sizeH  + opt );
	openobj.focus()
}

function Jumin_wrong(it){				   
	IDtot = 0;
	IDAdd="234567892345";

	for(i=0;i<12;i++){
		IDtot=IDtot+parseInt(it.substring(i,i+1))*parseInt(IDAdd.substring(i,i+1));
	}
	IDtot=11-(IDtot%11);
	if(IDtot==10){
		IDtot=0;
	}else if(IDtot==11){
		IDtot=1;
	}
	if(parseInt(it.substring(12,13))!=IDtot)
		return true;
}

function countString(str){
	var sum=0;
	for(i=0;i<str.length;i++){
		if(str.charCodeAt(i)<200){
			sum+=1;//¿µ¾î³ª ¼ýÀÚµéÀÏ¶§..
		}
		else{
			sum+=2;//ÇÑ±ÛÀÌ³ª Æ¯¼ö¹®ÀÚ µéÀÏ¶§..
		}
	}
	return sum;	
}

function view_photo(img_url){
	window.open("/lib/editbox/imgViewer.asp?img=" + img_url, "photo", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=no, resizable=yes");
}

function CheckLogin()
{
    if( document.all.hLValue.value != "true" ){
        alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇØÁÖ¼¼¿ä');
		document.all.txtLoginID.focus();
		return false;
    }
}

// ·Î±×ÀÎ Ã¼Å©ÈÄ ÆË¾÷À¸·Î ¿ÀÇÂ
function CheckLoginPop( url, locX, locY )
{	
	if( document.all.hLValue.value == "true" ){
		var nLeft  = 10;
		var nTop  = 10;
		
		if( screen.width <= 1024 )
	        nTop = 10;
 
		opt = ",toolbar=no,menubar=no,location=no,scrollbars=no,status=no";
		
		try{
		openobj = window.open(url, 'openpop', "left=" + nLeft + ",top=" +  nTop + ",width=200,height=200" + opt );
		openobj.focus()
		}
		catch(e){ alert('ÆË¾÷ÀÌ Â÷´ÜµÇ¾î ÀÖ½À´Ï´Ù. ÆË¾÷ Â÷´Ü ÈÄ ÀÌ¿ëÇØ ÁÖ¼¼¿ä.') }
	}
	else{
		alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇØÁÖ¼¼¿ä');
		try{document.all.txtLoginID.focus();}
		catch(e){location.href="http://www.karma2.co.kr/Main/Login/LoginMain.aspx?xurl=" + location.href }
		return false;
	}
}

// ·Î±×ÀÎ Ã¼Å©(ºÎ¸ðÃ¢)ÈÄ ÆË¾÷À¸·Î ¿ÀÇÂ
function CheckPLoginPop( url, locX, locY )
{	
	if( parent.document.all.hLValue.value == "true" ){
		var nLeft  = screen.width/3;
		var nTop  = screen.height/3;
		
		if( screen.width <= 1024 )
	        nTop = 10;
 
		opt = ",toolbar=no,menubar=no,location=no,scrollbars=no,status=no";
		openobj = window.open(url, 'openpop', "left=" + nLeft + ",top=" +  nTop + ",width=0,height=0" + opt );
		openobj.focus()
	}
	else{
		alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇØÁÖ¼¼¿ä');
		document.all.txtLoginID.focus();
		return false;
	}
}

// ·Î±×ÀÎ Ã¼Å©ÈÄ °ü·Ã url·Î
function CheckLoginURL( url, locX, locY )
{	
	if( document.all.hLValue.value == "true" ){
		location.href = url;	
	}
	else{
	    //location.href = "http://www.karma2.co.kr/Main/Login/LoginMain.aspx?xurl=" + url;
	    location.href = "http://www.karma2.co.kr/Main/Login/LoginMain.aspx?xurl=" + url;
		//alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇØÁÖ¼¼¿ä');
		//document.all.txtLoginID.focus();
		return false;
	}
}

function OpenLoginPop( locX, locY )
{
	var IE = document.all?true:false;

	try{
			if (IE) { 
				tempX = event.clientX + document.body.scrollLeft;
				tempY = event.clientY + document.body.scrollTop;
			}
			else {  
				tempX = e.pageX;
				tempY = e.pageY;
			}  
			if (tempX < 0){tempX = 0;}
			if (tempY < 0){tempY = 0;}
			
			document.all.ifrmLayer.style.left = tempX;
			document.all.ifrmLayer.style.top = tempY-100;
	}
	catch(e){
			var tempX  = screen.width/3;
			var tempY  = screen.height/3;
			
			document.all.ifrmLayer.style.left = tempX;
			document.all.ifrmLayer.style.top = tempY;
	}
	
	if( locX != 0 )	document.all.ifrmLayer.style.left = locX;		// ÁÂÇ¥°ªÀÌ Á¸ÀçÇÏ¸é ÁËÇ¥°ªÀ¸·Î ¼ÂÆÃ
	if( locY != 0 )	document.all.ifrmLayer.style.top = locY;		// ÁÂÇ¥°ªÀÌ Á¸ÀçÇÏ¸é ÁËÇ¥°ªÀ¸·Î ¼ÂÆÃ
	
	document.all.ifrmPop.src = "/Main/Login/LoginPop.aspx";
	
	document.all.ifrmLayer.style.visibility = "visible"
	
	return;
}

// ·¹ÀÌ¾î ÆË¾÷( iframe ) ´Ý±â
function ifrmLayerClose()
{
	parent.ifrmLayer.style.visibility = 'hidden'
}

// Ã¢ Å©±â Á¶Àý
function WinResize()
{
	var Dwidth = parseInt(document.body.scrollWidth);
	var Dheight = parseInt(document.body.scrollHeight);
	var divEl = document.createElement("div");
	divEl.style.position = "absolute";
	divEl.style.left = "0px";
	divEl.style.top = "0px";
	divEl.style.width = "100%";
	divEl.style.height = "100%";

	document.body.appendChild(divEl);
	while(1)
	{
	    try{window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);break;}
	    catch(e){}
	}
	//window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
	document.body.removeChild(divEl);	
}

// Opener °¡ Á¸ÀçÇÏ¸é Å¸°ÙÀÌ Opener, ±×·¸Áö ¾ÊÀ¸¸é »õÃ¢
function CheckOpener( url )
{
	try{
		opener.location.href = url;
		opener.focus();
	}
	catch(e){
		var obj = window.open( url, '_blank', '' )
		obj.focus();	
	}	
}

// ·¹ÀÌ¾î Ã¢ ´Ý±â
function Close_layer( objLayer ){
	objLayer.style.display = 'none';
}

// ·¹ÀÌ¾î ¼û±â±â/¿­±â
function TogleLayer( obj )
{
	if (obj.style.visibility == "hidden")
		obj.style.visibility = "visible";
	else
		obj.style.visibility = "hidden";
}


// a ¸µÅ© ¹× input type image ¿¡ blur
function allblur() {
	var inputs = document.getElementsByTagName("input");
	var alinks = document.links;
	var tmp = []; var j = 0;
	
    /*
	for(i = 0; i < inputs.length; i ++) {
		if(inputs[i].type != "image") continue;
		tmp[j] = inputs[i];
		j ++;
	}
	inputs = tmp;
    */
	//for(i = 0; i < inputs.length; i ++) inputs[i].onfocus = function() { this.blur(); }
	
	for(i = 0; i < alinks.length; i ++) alinks[i].onfocus = function() { this.blur(); }
}
window.onload=allblur


document.write("<META http-equiv='Page-Enter' content='blendTrans(Duration=0.2)'>")
document.write("<META http-equiv='Page-Exit' content='blendTrans(Duration=0.2)'>")

// ÄíÅ° ¼³Á¤
function SetCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setHours( todayDate.getHours() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

// ÄíÅ° ºÒ·¯¿À±â
function GetCookie(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

/**** Ajax °ü·Ã ÇÔ¼ö ½ÃÀÛ ****/
var ajax = {};
ajax.xhr = {};

ajax.xhr.Request = function(url, params, callback, method, seq) {
    this.url = url;
    this.params = params;
    this.callback = callback;
    this.method = method;
    this.send();
    this.seq = seq
}
ajax.xhr.Request.prototype = {
    getXMLHttpRequest: function() {
        if (window.ActiveXObject) {
            try {
                return new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    return new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e1) { return null; }
            }
        } else if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        } else {
            return null;
        }
    },
    send: function() {
        this.req = this.getXMLHttpRequest();

        var httpMethod = this.method ? this.method : 'GET';
        if (httpMethod != 'GET' && httpMethod != 'POST') {
            httpMethod = 'GET';
        }
        var httpParams = (this.params == null || this.params == '') ?
		                 "TimeStamp=" + new Date().getTime() : this.params + "&TimeStamp=" + new Date().getTime();

        var httpUrl = this.url;
        if (httpMethod == 'GET' && httpParams != null) {
            httpUrl = httpUrl + "?" + httpParams;
        }
        this.req.open(httpMethod, httpUrl, true);
        this.req.setRequestHeader(
			'Content-Type', 'application/x-www-form-urlencoded');
        var request = this;
        this.req.onreadystatechange = function() {
            request.onStateChange.call(request);
        }
        this.req.send(httpMethod == 'POST' ? httpParams : null);

    },
    onStateChange: function() {
        this.callback(this.req, this.seq);
    }
}
/**** Ajax °ü·Ã ÇÔ¼ö ³¡ ****/