﻿//<![CDATA[
// JScript 파일
function setTitle(){
	document.title = "(주)참피온 - ... Since 1976 역사가 증명하는 품질의 자부심";
	goNewsArticle('scrollstage');
}

function goNewsArticle(id) {
	var scrollCtrl = new ScrollControl(id, {inteval:35,freeze:3000,height:'11'});     
}

function bottomSet(){
	MM_preloadImages('image/member_box_bt01_.gif','image/member_box_bt02_.gif');
}

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_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_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 ItemAdd(objname, textname, valuename)
{
	var obj = document.getElementById(objname);
	obj.add(new Option(document.getElementById(textname).value,document.getElementById(valuename).value));
	obj.reInitializeSelectBox();
}
 
function winopen(url,name,option){
	window.open(url,name,option);
}

function english_check(str)
{
	lower_str = str.toLowerCase();
		
	for(i=0; i<lower_str.length; i++)
	{
		ch = lower_str.charAt(i);
		if(ch < 'a' || ch > 'z')
			return false;
	}
	return true;
}

function string_digit_check(str)
{
	lower_str = str.toLowerCase();
		
	for(i=0; i<lower_str.length; i++)
	{
		ch = lower_str.charAt(i);
		if(((ch < 'a') || (ch > 'z')) && ((ch < '0') ||(ch > '9')))
			return false;
	}
	return true;
}

function digit_check(str)
{
	lower_str = str.toLowerCase();
			
	for(i=0; i<lower_str.length; i++)
	{
		ch = lower_str.charAt(i);	
		if((ch < '0') || (ch > '9'))
			return 0;
	}
	return 1;
}

function confirm_select(e,v){
	var i;
	if(e){
		for(i=0 ; i< e.length ; i++){
			if( e.options[i].value == v){
				e.options[i].selected = true; 
			}
		}
	}
}

function confirm_radio(e,v){
	var i;
	var len = e.length;
	if(len >= 1){
	  for(i=0;i < len;i++){
		if(e[i].value == v){
			e[i].checked = true;
		}
	  }
	}else{
	    if(e.value == v)
	        e.checked = true;
	}
}

function isChecked( elm ) {
	var elmflag = 0;
	var len = elm.length;
	if(len >= 1){
	  for ( var i=0; i<elm.length; i++ ) {
		if ( elm[i].checked )
			elmflag = 1;
	  }
	}else{
	  if(elm.checked) elmflag = 1;
	}
	
	if(elmflag == 0)
		return false;
	else
		return true;
}

function getCheckValue(elm)
{
    var rValue = "";
    var len = elm.length;
    if(len >= 1){
       for ( var i=0; i<elm.length; i++ ) {
		  if ( elm[i].checked )
			rValue = elm[i].value;
	   }
	}else{
	   if(elm.checked) rValue = elm.value;
	}
	
	return rValue;
}

//메뉴 스타일 변경
function chgMenuStyle(obj,cnts){
	var e = document.getElementById(obj);
	for(i=1;i<=cnts;i++){
		var oe = eval("document.getElementById('menu"+i+"')");
		oe.className = "menu";
	}
	e.className = "menuselect";
}

function goSearch(){
	form = document.Form1;
		
	if(!form.Top1_sWords.value) {
		window.alert("검색어를 입력해 주세요.");
		form.Top1_sWords.focus();
	}else {
		document.location.href = "/product/product_list.aspx?searchWords=" + form.Top1_sWords.value;
	}
}

function goSearch_local(){
	form = document.Form1;
		
	if(!form.Top1_Textbox1.value) {
		window.alert("검색어를 입력해 주세요.");
		form.Top1_Textbox1.focus();
	}else {
		document.location.href = "/product/product_list.aspx?searchWords=" + form.Top1_Textbox1.value;
	}
}

/* 
* 통화단위 형식 처리 (-00,000,000.00000) (음수, 소숫점) 
* 원소스 : Nextream, http://jsguide.net/ver2/examples/index.php?mode=view&uid=155 
* 수정 : 동철, onuo.com 
*/ 
function number_format(numstr, ret) { 
    numstr = SetComma(DelComma(numstr)); 
    if (ret) 
        ret.value = numstr; 
    return numstr; 
} 

// 숫자에 콤마를 찍는다. 
function SetComma(numstr) { 
    numstr = String(numstr); 
    var re0 = /^(-?\d+)(\d{3})($|\..*$)/; 
    if (re0.test(numstr)) 
        return numstr.replace(re0, 
            function(str,p1,p2,p3) { 
                return SetComma(p1) + ',' + p2 + p3; 
            } 
        ); 
    else 
        return numstr; 
} 
String.prototype.SetComma = function () { 
    return SetComma(this); 
} 

// 문자를 숫자로 정리한다. 
function DelComma(numstr) { 
    numstr = String(numstr); 
    if (numstr == '') return '0'; 
    else if (numstr == '-') return '0'; 
    else if (numstr == '0-') return '-0'; 
    numstr = numstr.replace(/[^\d\.-]/g,''); 
    numstr = String(numstr.match(/^-?\d*\.?\d*/)); 
    numstr = numstr.replace(/^(-?)(\d*)(.*)/, 
        function(str,p1,p2,p3) { 
            p2 = (p2>0) ? String(p2.match(/[1-9]\d*$/)) : '0'; 
        //    p2 = (p2>0) ? String(parseInt(p2,10)) : '0'; 
            return p1 + p2 + p3; 
        } 
    ); 
    return numstr; 
} 
String.prototype.DelComma = function () { 
    return DelComma(this); 
} 

// 소숫점 자릿수를 조정한다.(버림) 
function cutFloat(numstr, length) { 
    numstr = String(numstr); 
    eval('var re0 = /.*\\.\\d{'+ length +'}/;'); 
    if (re0.test(numstr)) 
        numstr = String(numstr.match(re0)); 
    return numstr; 
} 
String.prototype.cutFloat = function (length) { 
    return cutFloat(this,length); 
}

function chkMsgLength(intMin,intMax,objMsg,st) {
	var length = lengthMsg(objMsg.value);
	st.innerHTML = length;//현재 byte수를 넣는다
	if (length > intMax) {
		alert("최대 " + intMax + "자를 넘을 수 없습니다.");
		objMsg.value = objMsg.value.replace(/rn$/, "");
		objMsg.value = assertMsg(intMax,objMsg.value,st );
		return false;
	}
}

function lengthMsg(objMsg) {
	var nbytes = 0;
	for (i=0; i<objMsg.length; i++) {
		var ch = objMsg.charAt(i);
		if(escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch == 'n') {
			if (objMsg.charAt(i-1) != 'r') {
				nbytes += 1;
			}
		} else if (ch == '<' || ch == '>') {
			nbytes += 4;
		} else {
			nbytes += 1;
		}
	}
	return nbytes;
}

function number_only(obj) {
				if(/[^0123456789,-.]/g.test(obj.value)) {
					alert("숫자가 아닙니다.\n\n0-9의 정수만 허용합니다.");
					obj.value = "";
					obj.focus();
				}else if(obj.value != ""){
				    obj.value = number_format(obj.value);
				}
	    }
function number_only2(obj) {
				if(/[^0123456789,.]/g.test(obj.value)) {
					alert("숫자가 아닙니다.\n\n0-9의 정수 및 .만 허용합니다.");
					obj.value = "";
					obj.focus();
				}else if(obj.value != ""){
				    obj.value = number_format(obj.value);
				}
	    }
function number_only3(obj) {
				if(/[^0123456789,]/g.test(obj.value)) {
					alert("숫자가 아닙니다.\n\n0-9의 정수만 허용합니다.");
					obj.value = "";
					obj.focus();
				}else if(obj.value != ""){
				    obj.value = number_format(obj.value);
				}
	    }
function number_only4(obj) {
				if(/[^0123456789]/g.test(obj.value)) {
					alert("숫자가 아닙니다.\n\n0-9의 정수만 허용합니다.");
					obj.value = "";
					obj.focus();
				}
	    }

function assertMsg(intMax,objMsg,st ) {
	var inc = 0;
	var nbytes = 0;
	var msg = "";

	var msglen = objMsg.length;
	for (i=0; i<msglen; i++) {
		var ch = objMsg.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else if (ch == 'n') {
			if (objMsg.charAt(i-1) != 'r') {
				inc = 1;
			}
		} else if (ch == '<' || ch == '>') {
			inc = 4;
		} else {
			inc = 1;
		}
		if ((nbytes + inc) > intMax) {
			break;
		 }
		nbytes += inc;
		msg += ch;
	}
	st.innerHTML = nbytes; //현재 byte수를 넣는다
	return msg;
}

function KeyEventHandle()
{
//	alert(event.keyCode);
	if(event.ctrlKey == true && event.keyCode == 78)
	{
		event.keyCode = 0;
		event.cancelBubble = true;
		event.returnValue = false; 
	}
}

function norightclick(e) {  // 다른 모든 브라우저에서 작동
    var evt = e || event; 

      if (window.Event) {   // 다시, IE 또는 NAV ?
         if (evt.which == 2 || evt.which == 3)
            return false;
      } else if (event.button == 2 || event.button == 3) {
         event.cancelBubble = true
         event.returnValue = false;
         return false;
      }
}

function nocontextmenu() { // IE4에서만 적용, 다른 브라우저는 무시
      event.cancelBubble = true
      event.returnValue = false;
      return false;
}


function usafeView (asOrderId){
    //창을 화면의 중앙에 위치
    iXPos = (window.screen.width - 700) / 2;
    iYPos = (window.screen.height - 600) / 2;
    var asMallId = "champion";
//    var asMallId = "test00";
    window.open("https://gateway.usafe.co.kr/esafe/InsuranceView.asp?mall_id=" + asMallId + "&order_id=" + asOrderId, "전자보증서", "width=710, height=600, scrollbars=yes, left=" + iXPos + ", top=" + iYPos);
}

function popNoInterestCardInfo(){
    winopen("/product/pop_noInterestCardInfo.aspx","_blank","width=530,height=500,menubars=no,scrollbars=yes");
}

function usafe(strActPage) 
{
	window.open("https://www.usafe.co.kr:447/usafeShopCheck.asp?com_no="+strActPage,"", "width=500, height=370, scrollbars=no, location=yes,status=yes,left=0, top=0"); 
}

function submitTopPrdSearch(){
	form = document.aspnetForm;
		
	if(!form.ctl00_txtTopPrdSrchWords.value) {
		window.alert("검색어를 입력해 주세요.");
		form.ctl00_txtTopPrdSrchWords.focus();
		return false;
	}else {
		return true;
	}
}

function bookmarksite(title,url){ 
  if (window.sidebar) // firefox 
    window.sidebar.addPanel(title, url, ""); 
  else if(window.opera && window.print){ // opera 
    var elem = document.createElement('a'); 
    elem.setAttribute('href',url); 
    elem.setAttribute('title',title); 
    elem.setAttribute('rel','sidebar'); 
    elem.click(); 
  } 
  else if(document.all)// ie 
    window.external.AddFavorite(url, title); 
} 

//]]>
