/************************************************************************
* blinkÅÂ±×¸¦ °¡´ÉÇÏ°Ô ¸¸µé¾îÁÜ.
************************************************************************/
function doBlink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  // Make sure it is IE4
  if (document.all)
    setInterval("doBlink()",500)
}
window.onload = startBlink;

/************************************************************************
* ºóÄ­ÀÌ¸é ÀÔ·ÂÇÏ¶ó°í ¾Ë¸².
************************************************************************/
function null_chk(obj,name) {
	str = obj.value;
	if( str == "" ) {
		alert(name+"Ç×¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		obj.value = "";
		obj.focus();
		return false;
	}
	return true;
}

/************************************************************************
* Step 1 Start
* ½Ç·ºÆ®¹Ú½º, checkbox, radio ¼±ÅÃ ½±°Ô ÇÏ±â
* <script>setSelect('name','value')</script>
************************************************************************/
function setValue(obj,value) {
	if( value ) {
		if( isObject(obj) ) {
			f = obj;
		} else {
			f = document.getElementById(obj);
		}
		switch( f.type ) {
			case "select-one":
			case "select-multiple":
				setSelect(obj,value);
				break;
			case "radio":
				setRadio(obj,value);
				break;
			case "checkbox":
				setCheckbox(obj,value);
				break;
		}
	}
}
function setSelect(obj,value){
	if(value){
		f = document.getElementById(obj);
		l = f.options.length;
		v = value.split(",");
		for( i=0; i<l; i++ ) {
			for( j=0;j<v.length;j++ ) {
				if( f[i].value == v[j] ) {
					f[i].selected = true;
				}
			}
		}
	}
}
function setCheckbox(obj,value){
	if(value){
		f = document.getElementsByName(obj);
		l = f.length;
		v = value.split(",");
		for( i=0; i<l; i++ ) {
			for( j=0;j<v.length;j++ ) {
				if( f[i].value == v[j] ) {
					f[i].checked = true;
				}
			}
		}
	}
}
function setRadio(obj,value){
	if(value) {
		f = document.getElementsByName(obj);
		l = f.length;
		for( i=0; i<l; i++ ) {
			if( f[i].value == value ) {
				f[i].checked = true;
			}
		}
	}
}
/************************************************************************
* Step1 End
************************************************************************/

/************************************************************************
* ÆäÀÌÁö³Ñ±â±â
************************************************************************/
function goPage( val) {
	var frm = document.paging;
	for(var i=0; i<frm.elements.length; i++) {
		var e = frm.elements[i];
		if(e.type == "hidden" && e.name == "page" ) e.value = val;
	}
	frm.submit();
}

/************************************************************************
* ÀÌ¹ÌÁö¿¡ ¸Â°Ô Ã¢ ¶ç¿ì±â
************************************************************************/
function imgPop(src) {
	var imgObj = new Image();
	imgObj.src = src;
	if( imgObj.width >= screen.availWidth || imgObj.height >= screen.availHeight ) {
		var wopt = "scrollbars=yes,status=no,resizable=no";
	} else {
		var wopt = "scrollbars=no,status=no,resizable=no";
	}
	wopt += ",width=" + imgObj.width;
	wopt += ",height=" + imgObj.height;
	var wbody = "<head><title>ÀÌ¹ÌÁöº¸±â</title>";
	wbody += "<script language='javascript'>";
	wbody += "function finalResize(){";
	wbody += "  var oBody=document.body;";
	wbody += "  var oImg=document.images[0];";
	wbody += "  var xdiff=oImg.width-oBody.clientWidth;";
	wbody += "  var ydiff=oImg.height-oBody.clientHeight;";
	wbody += "  window.resizeBy(xdiff,ydiff);";
	wbody += "}";
	wbody += "moveTo('0','0');";
	wbody += "</"+"script>";
	wbody += "</head>";
	wbody += "<body onLoad='finalResize()' style='margin:0'>";
	wbody += "<a href='javascript:window.close()'><img src='" + src + "' border=0></a>";
	wbody += "</body>";
	winResult = window.open("about:blank","",wopt);
	winResult.document.open("text/html", "replace");
	winResult.document.write(wbody);
	winResult.document.close();
	return;
}


/************************************************************************
* ¿ìÆí¹øÈ£Ã£±â
************************************************************************/
function findZip(formName,fzip1,fzip2,faddr1,faddr2) {
	openWin("/util/zipCode.php?formName=" + formName + "&fzip1=" + fzip1 + "&fzip2=" + fzip2 + "&faddr1=" + faddr1 + "&faddr2=" + faddr2,"width=400,height=400,left=" + ( event.screenX - 200 ) + ",top=" + ( event.screenY - 200 ) + ",scrollbars=yes");
}


/************************************************************************
* ÆË¾÷Ã¢ ¿ÀÇÂ.
************************************************************************/
function openWin( url, arg ) {
	window.open( url, 'Win' , '' + arg );
	// resizeTo(), moveTo()
}

/************************************************************************
* Step 6 Start
* NullÀÎÁö Ã¼Å©
************************************************************************/
function IsNull(object,obj_nm) {
		var  obj = document.header.elements[object];

        if(( obj.value == " ")||( obj.value == "") || ( obj.value == null )){
        	alert(obj_nm+" ÀÔ·Â ¹Ù¶ø´Ï´Ù.");
            obj.focus();
            return false;
        }
        return true;
}

function IsNullHidden(obj,obj_nm) {

		if(( obj.value == " ")||( obj.value == "") || ( obj.value == null )){
        	alert(obj_nm+" ÀÔ·Â ¹Ù¶ø´Ï´Ù.");
            obj.focus();
            return false;
        }
        return true;
}

/************************************************************************
*  ¼ýÀÚ°¡ À¯È¿ÇÑÁö¸¦ °Ë»ç
************************************************************************/
function IsInteger(st)
{
    if ( !IsEmpty(st) ){
          for (j=0; j<st.length; j++) {
             if (((st.substring(j, j+1) < "0") || (st.substring(j, j+1) > "9")))
                return false;
          }
    } else {
          return false ;
    }
    return true ;

}

/************************************************************************
* °ø¹éÁ¦°Å
************************************************************************/
function trim(objValue) 
{
	var oval=objValue;
	
	var myre1=/^(\s)+(\S*)/g; //ltrim 
	var myre2=/(\S*)(\s+)$/g; //rtrim 
	
	oval=myre1.test(oval) ? oval.replace(myre1,"$2") : oval; 
	oval=myre2.test(oval) ? oval.replace(myre2,"$1") : oval; 
	
	return oval;
//document.all.tg.value=oval; 
}

/************************************************************************
* ¼ýÀÚÃ¼Å©
************************************************************************/
function isNumber(formname) 
{
   var form = eval("document.reg_form." + formname);

  for(var i = 0; i < form.value.length; i++) {
	 var chr = form.value.substr(i,1);
	 if(chr < '0' || chr > '9') {            
		return false;
	 }
  }
  return true;   
}

function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}
function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
function isBoolean(a) {
    return typeof a == 'boolean';
}
function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}
function isFunction(a) {
    return typeof a == 'function';
}
function isNull(a) {
    return typeof a == 'object' && !a;
}
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}
function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isString(a) {
    return typeof a == 'string';
}
function isUndefined(a) {
    return typeof a == 'undefined';
}

//DESIGN _ text¹Ú½ºÀÇ ¹é±×¶ó¿îµå ÀÌ¹ÌÁö ±³Ã¼
function ch (obj) 
{ 
 if(obj.style.backgroundImage == "") return; 
 
 obj.style.backgroundImage=""; 
} 

//»óÇ° µ¥¸ó ½ÅÃ»
function productDemon(loginStatus,fileName,orderCnt) {
	if (!loginStatus || loginStatus<1) {
		alert("·Î±×ÀÎ ÈÄ ½ÅÃ»ÇÏ½Ç¼ö ÀÖ½À´Ï´Ù. ");
		return false;
	}
	if (orderCnt>0) {
		if(confirm("ÇØ´ç Á¦Ç°À» ÀÌ¹Ì ½ÅÃ»ÇÏ¼Ì½À´Ï´Ù. ´Ù½Ã ½ÅÃ»ÇÏ½Ã°Ú½À´Ï±î?	")) {
			document.location.href='/products/product_order.php?lt='+fileName;
		} else {
			return false;
		}
	} else {
		if (confirm("ÇØ´ç»óÇ°À» ½ÅÃ»ÇÏ½Ã°Ú½À´Ï±î?	")) {
			document.location.href='/products/product_order.php?lt='+fileName;
		}	
	}
}
