﻿var currentFontSize = 4;

switchFontSize=function(ckname,val){
	var bd = $E('BODY');
	switch (val) {
		case 'inc':
			if (CurrentFontSize+1 < 7) {
				bd.removeClass('fs'+CurrentFontSize);
				CurrentFontSize++;
				bd.addClass('fs'+CurrentFontSize);
			}		
		break;
		case 'dec':
			if (CurrentFontSize-1 > 0) {
				bd.removeClass('fs'+CurrentFontSize);
				CurrentFontSize--;
				bd.addClass('fs'+CurrentFontSize);
			}		
		break;
		default:
			bd.removeClass('fs'+CurrentFontSize);
			CurrentFontSize = val;
			bd.addClass('fs'+CurrentFontSize);		
	}
	Cookie.set(ckname, CurrentFontSize,{duration:365});
}

function switchTool(name, value) {
	createCookie(name, value, 365);
	//window.location.reload();
	window.location.reload();
	return;
}


function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };

//addEvent - attach a function to an event
function jaAddEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function getElem (id) {
	var obj = document.getElementById (id);
	if (!obj) return null;
	var divs = obj.getElementsByTagName ('div');
	if (divs && divs.length >= 1) return divs[divs.length - 1];
	return null;
}

function getFirstDiv (id) {
	var obj = document.getElementById (id);
	if (!obj) return null;
	var divs = obj.getElementsByTagName ('div');
	if (divs && divs.length >= 1) return divs[0];
	return obj;
}

function instr(str, item){
	var arr = str.split(" ");
	for (var i = 0; i < arr.length; i++){
		if (arr[i] == item) return true;
	}
	return false;
}

function equalHeight (elems, offset){
  if (!offset) offset = 0;
	if (!elems) return;
	var maxh = 0;
	for (var i=0; i<elems.length; i++)
	{
		if (elems[i]) {
			var els = elems[i].getElementsByTagName ('div');
			if (els) el = els[0]; else el = elems[i];
			if(el.scrollHeight > maxh) maxh = el.scrollHeight;
		}
	}
	for (i=0; i<elems.length; i++){
		if (elems[i]) elems[i].style.height = (maxh+offset) + "px";
	}
}

function equalHeightInit (){	
	var ja_botsl = document.getElementById('ja-botsl');
	if (!ja_botsl) return;
	var ja_boxes = getElementsByClass ('ja-box.*', ja_botsl, 'div');
	equalHeight (ja_boxes, 0);
}

jaAddEvent (window, 'load', equalHeightInit);
jaAddEvent (window, 'resize', equalHeightInit);

jaToolsHover = function() {
	var jautw = document.getElementById("jausertoolswrap");	
	if (!jautw) return;

	jautw.onmouseover=function() {
		this.className="ja-toolswraphover";
	}
	jautw.onmouseout=function() {
		this.className="";
	}
}

jaAddEvent (window, 'load', jaToolsHover);

headerDuration = 100;
headerInt = 13;
headerStep = null;
headerTimeout = 0;
headerToggle = 1; //1: Expend, -1: collapse
tophd = null;
headerHeight = 0;
function toggleHeaderInit () {
  tophd = document.getElementById ('ja-topsl');
  tophdleft = document.getElementById ('ja-topsl-left');
  tophdright = document.getElementById ('ja-topsl-right');
  if (!tophd) return;

  obj = document.getElementById ('ja-topsl-left');
  if (obj && headerHeight < obj.scrollHeight) headerHeight = obj.scrollHeight;
  obj = document.getElementById ('ja-topsl1');
  if (obj && headerHeight < obj.scrollHeight) headerHeight = obj.scrollHeight;
  obj = document.getElementById ('ja-topsl2');
  if (obj && headerHeight < obj.scrollHeight) headerHeight = obj.scrollHeight;
  obj = document.getElementById ('ja-topsl3');
  if (obj && headerHeight < obj.scrollHeight) headerHeight = obj.scrollHeight;
//alert(headerHeight);
  headerStep = parseInt(headerHeight*headerInt / headerDuration);
  //headerTimeout = setTimeout (toggleHeaderGo, headerInt);
  if (headerToggle < 0) {
		headerToggle = 1;
		toggleHeader (null);
	}
}

function toggleHeader (aobj) {
  if (!tophd) return;
  headerToggle = -(headerToggle);
  if (aobj)
  {
	  if (headerToggle > 0)
	  {
		  aobj.className = "ja-cb";
		  aobj.href = "#collapse";
		  aobj.title = "Collapse Spotlight";
	  } else {
		  aobj.className = "ja-ob";
		  aobj.href = "#expend";
		  aobj.title = "Expend Spotlight";
	  }
  }
  if (headerToggle > 0) {
		tophd.style.display = "block";
	} else {
		tophd.style.overflow = "hidden";
		if (document.getElementById('ja-bigicon')) document.getElementById('ja-bigicon').style.display = "none";
	}
  headerTimeout = setTimeout (toggleHeaderGo, headerInt);
}

function toggleHeaderGo () {
  if (headerTimeout) {
    clearTimeout (headerTimeout);
    headerTimeout = 0;
  }
  if (!tophd) {
	  return;
  }
  headerTimeout = setTimeout (toggleHeaderGo, headerInt);
  var stop = false;
  var h = tophd.offsetHeight;
  h += headerStep * headerToggle;
  //alert(h);
  if (h <= 0){
    h = 0;
    tophd.style.display = "none";
    stop = true;      
  }
  if (h > headerHeight){
    //alert(tophd.scrollHeight);
    h = headerHeight;
    stop = true;
	 tophd.style.overflow = "";
	 tophd.style.display = "";
	 if (document.getElementById('ja-bigicon')) document.getElementById('ja-bigicon').style.display = "";
  }
  if (tophdleft) tophdleft.style.height = h + "px";
  if (tophdright) tophdright.style.height = h + "px";
  if (tophd) tophd.style.height = h + "px";
  
  if (stop) {
	clearTimeout (headerTimeout);
    headerTimeout = 0;
	createCookie("HeaderToggle", headerToggle, 365);
  }
}

function preloadImages () {
	var imgs = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var imgsrc = arguments[i];
		imgs[i] = new Image();
		imgs[i].src = imgsrc;
	}
}


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	var j = 0;
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (var i = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	//alert(searchClass + j);
	return classElements;
}

function addMouseOver (objs) {
	if (objs){
		for (i=0; i<objs.length; i++){
			objs[i].onmouseover=function() {
				this.className+=" hover";
			}
			objs[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
			}
		}
	}
}

function jashowtabcontent (obj) {
	var tabdisplay = document.getElementById ('ja-tab-content');
	if (!tabdisplay) return;
	var tabcontents = getElementsByClass ('ja-tab-content', obj, "DIV");
	if (!tabcontents) return;
	tabdisplay.innerHTML = tabcontents[0].innerHTML;
	jatabresetclass(obj);
}

function jatabresetclass (obj) {
	var jatab = document.getElementById ('ja-tabswrap');
  if (jatab) {
	  var lis = getElementsByClass ('ja-tab-li', jatab, "LI");
    if (!lis) return;
    for (var i=0; i<lis.length; i++) {
      lis[i].className = lis[i].className.replace(new RegExp(" ja-tab-hover\\b"), "");
    }
    obj.className += " ja-tab-hover";
  }
}

function jatabinit (){
	var jatab = document.getElementById ('ja-tabswrap');
  if (jatab) {
	  var tabcontents = getElementsByClass ('ja-tab-content', jatab, "DIV");
	  if (tabcontents) {
	   var tabdisplay = document.getElementById ('ja-tab-content');
	   var divobj = document.createElement ("DIV");

	   divobj.style.display = "block";
	   divobj.style.position = "absolute";
	   divobj.style.top = "-1000px";
	   divobj.style.width = tabdisplay.offsetWidth + "px";
	   document.body.appendChild (divobj);
	   var maxh = 0;
      for (var i=0; i<tabcontents.length; i++) {
        divobj.innerHTML = tabcontents[i].innerHTML;
        if (maxh < divobj.offsetHeight) maxh = divobj.offsetHeight;
      }
     tabdisplay.style.height = (maxh - 20) + "px"; 
	   document.body.removeChild (divobj);
    }
	  var lis = getElementsByClass ('ja-tab-li', jatab, "LI");
    if (!lis) return;
    jashowtabcontent (lis[0]);
    
  }
}

jaAddEvent (window, 'load', jatabinit);

function jaInitHover () {
  addMouseOver (getElementsByClass('search', null, 'DIV'));
}
jaAddEvent (window, 'load', jaInitHover);

//

function validate(elm)
{

    // ****************************************************************************
	// VARIBLE USED TO TEST FOR VALID NUMERS AND STRINGS
    // *****************************************************************************
    var pattern = /^(0|-?[1-9][0-9]*)$/;
    if (pattern.test(elm.value)) {
        return true;
    }
    else {
        return false;
    }
}


function prodkey()
{
  var m_sn = document.getElementById("machineSerial");
  var p_key = document.getElementById("productKey");

  
 if(validate(m_sn) == false) {
    alert("숫자만 입력할 수 있습니다.");
    m_sn.value = ""; 
    m_sn.focus();    
  } else {
 

  if(m_sn.value.length == 9) {
//    p_key.value = m_sn.value - 0 + 1; 

    sn1 = m_sn.value.charAt(m_sn.value.length - 4) - 0; 
    sn2 = m_sn.value.charAt(m_sn.value.length - 3) - 0; 
    sn3 = m_sn.value.charAt(m_sn.value.length - 2) - 0; 
    sn4 = m_sn.value.charAt(m_sn.value.length - 1) - 0; 

    pdN = "A1";
    
   

    switch(sn1+sn2) {

    case 0:
        prodKey1 = pdN + "15" ;
        break;

    case 1:
        prodKey1 = pdN + "A1" ;        
	break;

    case 2:
        prodKey1 = pdN + "49" ;        
	break;

    case 3:
        prodKey1 = pdN + "73" ;        
	break;


    case 4:
        prodKey1 = pdN + "2A" ;        
	break;


    case 5:
        prodKey1 = pdN + "31" ;        
	break;

    case 6:
        prodKey1 = pdN + "27" ;        
	break;

    case 7:
        prodKey1 = pdN + "98" ;        
	break;

    case 8:
        prodKey1 = pdN + "86" ;        
	break;

    case 9:
        prodKey1 = pdN + "72" ;        
	break;

    case 10:
        prodKey1 = pdN + "A6" ;        
	break;

    case 11:
        prodKey1 = pdN + "53" ;        
	break;

    case 12:
        prodKey1 = pdN + "69" ;        
	break;

    case 13:
        prodKey1 = pdN + "8T" ; 
	break;

    case 14:
        prodKey1 = pdN + "32" ;        
	break;

    case 15:
        prodKey1 = pdN + "5B" ;        
	break;

    case 16:
        prodKey1 = pdN + "9Z" ;        
	break;

    case 17:
        prodKey1 = pdN + "17" ;        
	break;

    case 18:
        prodKey1 = pdN + "34" ;        
	break;

    default:
	break;
   }  

    switch(sn3+sn4) {

    case 0:
        prodKey2 = "A2" + "32" ;
        break;

    case 1:
        prodKey2 = "B3" + "69" ;        
	break;

    case 2:
        prodKey2 = "C2" + "24" ;        
	break;

    case 3:
        prodKey2 = "D5" + "13" ;        
	break;


    case 4:
        prodKey2 = "E8" + "33" ;        
	break;

    case 5:
        prodKey2 = "F3" + "E9" ;        
	break;

    case 6:
        prodKey2 = "G7" + "57" ;        
	break;

    case 7:
        prodKey2 = "HB" + "39" ;        
	break;

    case 8:
        prodKey2 = "I6" + "92" ;        
	break;

    case 9:
        prodKey2 = "J4" + "46" ;        
	break;

    case 10:
        prodKey2 = "K8" + "3F" ;        
	break;

    case 11:
        prodKey2 = "LV" + "61" ;        
	break;

    case 12:
        prodKey2 = "M3" + "84" ;        
	break;

    case 13:
        prodKey2 = "N9" + "2N" ; 
	break;

    case 14:
        prodKey2 = "P6" + "19" ;        
	break;

    case 15:
        prodKey2 = "2Q" + "54" ;  
	break;

    case 16:
        prodKey2 = "R8" + "59" ;        
	break;

    case 17:
        prodKey2 = "S1" + "T3" ;        
	break;

    case 18:
        prodKey2 = "T4" + "81" ;        
	break;

    default:
	break;
   }  

    switch(sn3+sn4) {

    case 0:
        prodKey3 = "Z2" + "1A" ;
        break;

    case 1:
        prodKey3 = "G3" + "2Y" ;        
	break;

    case 2:
        prodKey3 = "B2" + "45" ;        
	break;

    case 3:
        prodKey3 = "5D" + "95" ;        
	break;

    case 4:
        prodKey3 = "E8" + "14" ;        
	break;

    case 5:
        prodKey3 = "3R" + "36" ;        
	break;

    case 6:
        prodKey3 = "G7" + "Y7" ;        
	break;

    case 7:
        prodKey3 = "N2" + "43" ;        
	break;

    case 8:
        prodKey3 = "M6" + "84" ;        
	break;

    case 9:
        prodKey3 = "4K" + "J8" ;        
	break;

    case 10:
        prodKey3 = "V8" + "24" ;        
	break;

    case 11:
        prodKey2 = "LV" + "61" ;        
	break;

    case 12:
        prodKey3 = "P3" + "96" ;        
	break;

    case 13:
        prodKey3 = "9Q" + "13" ; 
	break;

    case 14:
        prodKey3 = "FG" + "3T" ;        
	break;

    case 15:
        prodKey3 = "4L" + "54" ;  
	break;

    case 16:
        prodKey3 = "W3" + "18" ;        
	break;

    case 17:
        prodKey3 = "7H" + "27" ; 
	break;

    case 18:
        prodKey3 = "6U" & "36" ;        
	break;

    default:
	break;
   }  
   
   p_key.value = prodKey1 + prodKey2 + prodKey3; 
   
   
  } 
  else 
  {
    alert("시리얼번호는 9자리 숫자이어야 합니다."); 
    m_sn.value = ""; 
    m_sn.focus();
  }
 }  

}

 <!--      

    function toclipboard(str)  

    {  

        str.select();  

         var clip = str.createTextRange();  

       clip.execCommand('copy');  

        alert("제품키: " + str.value);  

    }  

    -->  

