/*============================================================================
 * File Name : common.js
 * Desc      : common javascript
 * Auther    : 박종명
 * Date      : 2007/01/02 최초작성
 * Copyright (c) 2006 witcom.co.kr. All Rights Reserved.
 *
 * 수정내역
 *
 ============================================================================*/

/**
  * 입력 값이 Object 인지를 반환.
  * returns true if a is an object, and array, or a function.
  * It returns false if a is a string, a number, a boolean, or null, or undefined.
  */
function getObject(objectId) { 
	// checkW3C DOM, then MSIE 4, then NN 4. 
	// 
	if(document.getElementById && document.getElementById(objectId)) { 
		return document.getElementById(objectId); 
	} 
	else if (document.all && document.all(objectId)) { 
		return document.all(objectId); 
	} 
	else if (document.layers && document.layers[objectId]) { 
		return document.layers[objectId]; 
	}
	else{ 
		return false; 
	} 
} 

/**
  * 입력 값이 Object 인지를 반환.
  * returns true if a is an object, and array, or a function.
  * It returns false if a is a string, a number, a boolean, or null, or undefined.
  */
function isObject(input) {
	    return (input && typeof input == 'object') || isFunction(input);
}

/**
  * 입력 값이 Function 인지를 반환.
  */
function isFunction(input) {
	    return typeof input == 'function';
}

/**
* 한글을 2byte 로 인식해서 제대로 된 길이를 구함
*/
function getByteLength(value) {
	var byteLength = 0;
	for(var inx = 0; inx < value.length; inx++){
		var oneChar = escape(value.charAt(inx));
		if(oneChar.length == 1) byteLength ++;
		else if(oneChar.indexOf("%u") != -1) byteLength += 2;
		else if(oneChar.indexOf("%") != -1) byteLength += oneChar.length/3;
	}
	return byteLength;
}

/**
* 입력값이 NULL인지 체크
*/
function isNull(value) {
   if (value == null || value == "") {
       return true;
   }
   return false;
}

/**
* 문자열의 양쪽(왼쪽, 오른쪽) 공백을 제거 함수 
*/
function trim(src) 
{ 
	var search = 0;

	while ( src.charAt(search) == " ") 
		search = search + 1;

	src = src.substring(search, (src.length));

	search = src.length - 1;

	while (src.charAt(search) ==" ") 
		search = search - 1;

	return src.substring(0, search + 1);
} 

/**
* 입력값에 스페이스 이외의 의미있는 값이 있는지 체크
*/
function isEmpty(value) {
   if (value == null || value.replace(/ /gi,"") == "") {
       return true;
   }
   return false;
}

/**
* 입력값에 특정 문자(chars)가 있는지 체크
* 특정 문자를 허용하지 않으려 할 때 사용
* ex) if (containsChars(form.name,"!,*&^%$#@~;")) {
*         alert("이름 필드에는 특수 문자를 사용할 수 없습니다.");
*     }
*/
function containsChars(value,chars) {
   for (var inx = 0; inx < value.length; inx++) {
      if (chars.indexOf(value.charAt(inx)) != -1)
          return true;
   }

   return false;
}

/**
* 입력값이 특정 문자(chars)만으로 되어있는지 체크
* 특정 문자만 허용하려 할 때 사용
* ex) if (!containsCharsOnly(form.blood,"ABO")) {
*         alert("혈액형 필드에는 A,B,O 문자만 사용할 수 있습니다.");
*     }
*/
function containsCharsOnly(value,chars) {
   for (var inx = 0; inx < value.length; inx++) {
      if (chars.indexOf(value.charAt(inx)) == -1)
          return false;
   }
   return true;
}

/**
* 입력값이 알파벳인지 체크
* 아래 isAlphabet() 부터 isNumComma()까지의 메소드가
* 자주 쓰이는 경우에는 var chars 변수를
* global 변수로 선언하고 사용하도록 한다.
* ex) var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
*     var lowercase = "abcdefghijklmnopqrstuvwxyz";
*     var number    = "0123456789";
*     function isAlphaNum(input) {
*         var chars = uppercase + lowercase + number;
*         return containsCharsOnly(input,chars);
*     }
*/
function isAlphabet(value) {
   var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   return containsCharsOnly(value,chars);
}

/**
* 입력값이 알파벳 대문자인지 체크
*/
function isUpperCase(value) {
   var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   return containsCharsOnly(value,chars);
}

/**
* 입력값이 알파벳 소문자인지 체크
*/
function isLowerCase(value) {
   var chars = "abcdefghijklmnopqrstuvwxyz";
   return containsCharsOnly(value,chars);
}

/**
* 입력값에 숫자만 있는지 체크
*/
function isNumber(value) {
   var chars = "0123456789";
   return containsCharsOnly(value,chars);
}

/**
* 입력값이 알파벳,숫자로 되어있는지 체크
*/
function isAlphaNum(value) {
   var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
   return containsCharsOnly(value,chars);
}


/**
* 입력값이 알파벳,숫자 . _ 로 되어있는지 체크
*/
function isFileName(value) {
   var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
   return containsCharsOnly(value,chars);
}

/**
* 입력값이 숫자,대시(-)로 되어있는지 체크
*/
function isNumDash(value) {
   var chars = "-0123456789";
   return containsCharsOnly(value,chars);
}

/**
* 입력값이 숫자,콤마(,)로 되어있는지 체크
*/
function isNumComma(value) {
   var chars = ",0123456789";
   return containsCharsOnly(value,chars);
}

/**
* 입력값에서 콤마를 없앤다.
*/
function removeComma(value) {
   return value.replace(/,/gi,"");
}

/**
* 입력값이 사용자가 정의한 포맷 형식인지 체크
* 자세한 format 형식은 자바스크립트의 'regular expression'을 참조
*/
function isValidFormat(value,format) {
   if (value.search(format) != -1) {
       return true; //올바른 포맷 형식
   }
   return false;
}

/**
* 입력값이 이메일 형식인지 체크
*/
function isValidEmail(value) {
   var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
   return isValidFormat(value, format);
}

/**
* 입력값이 전화번호 형식(숫자-숫자-숫자)인지 체크
*/
function isValidPhone(value) {
   var format = /^(\d+)-(\d+)-(\d+)$/;
   return isValidFormat(value,format);
}


/**
 * alert and redirect 
 */
function alertAndRedirect(message, ojumpurl)
{
		alert(message);
		self.location=ojumpurl;
}


/**
 * Scroll bar 가 없는 윈도우를 open한다.
 * open_window(url,name,width,height) 에 popup 명을 'popup'으로 하여 호출
 */
function open_window2(url, name, width, height)
{
    window.open(url, name, "width="+width+",height="+height+",scrollbars=no,menubar=no,status=no,toolbar=no");
}
function open_window(url, width, height)
{
	open_window2(url, "popup", width, height)
}
function auto_open_window(url, name, width, height, left, top){
	window.open(url, name, "width="+width+",height="+height+"left="+left+",top="+top+",scrollbars=no,menubar=no,status=no,toolbar=no");
}

/**
 * Scroll bar 가 있는 윈도우를 open한다. 
 * open_window_scroll(url,name,width,height) 에 popup 명을 'popup'으로 하여 호출
 */
function open_window_scroll2(url, name, width, height)
{
    window.open(url, name, "width="+width+",height="+height+",scrollbars=yes");
}
function open_window_scroll(url, width, height)
{
	open_window_scroll2(url, "popup", width, height);
}

/**
 * 창크기 변경 가능한 윈도우를 open한다. 
 * open_window_resizable(url,name,width,height) 에 popup 명을 'popup'으로 하여 호출
 */
function open_window_resizable2(url, name, width, height)
{
    window.open(url, name, "width="+width+",height="+height+",resizable=yes");
}

function open_window_resizable(url, width, height)
{
	open_window_scroll2(url, "popup", width, height);
}

/**
 * blink()의 subfunction 으로 단독으로 실행되지 않는다.
 * 150ms 단위로 실행되며 's' 라는 object 를 blink 시킨다 
 */
function count() {

	var now = new Date();
	var seconds = now.getSeconds();
	if(seconds%2==1) {
		s.style.visibility="visible";
	} else { 
		s.style.visibility="hidden";
	}

	setTimeout("count()",150);
}
/**
 * Text 를 깜빡이며, count() 와 연동되어 돌아간다. ( Netscape 의 <blink> 태그를 simulate ) 
 */
function blink(text) {
	if(document.layers) {
		document.write('<span class=normal><blink>'+text+'</blink></span>');
	} 
	else { 
		document.write('<span class=normal id="s">'+text+'</span>');
	}
	count();
}

/**
 * Cookie 를 셋팅한다. 
 */
function setCookieOneDay(name, value) {
	var expDate = new Date();

	//valid one minute
	expDate.setTime(expDate.getTime() + (24 * 60 * 60 * 1000));
	setCookie(name,value,expDate,'/');
}

/**
 * Cookie 를 셋팅한다. 
 */
function setCookieId(name, value) {
	var expDate = new Date();

	//valid one minute
	expDate.setTime(expDate.getTime() + (14 * 24 * 60 * 60 * 1000));
	setCookie(name,value,expDate,'/');
}

function setCookieDay(name, value, day) {
	var expDate = new Date();

	//valid one minute
	expDate.setTime(expDate.getTime() + (day * 24 * 60 * 60 * 1000));
	setCookie(name,value,expDate,'/');
}
function setCookie (name, value){  
	var argv = setCookie.arguments;  
	var argc = setCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : '/';  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  

	document.cookie = name + "=" + escape (value) 
					+ ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) 
					+ ((path == null) ? "" : ("; path=" + path)) 
					+ ((domain == null) ? "" : ("; domain=" + domain)) 
					+ ((secure == true) ? "; secure" : "");
}
/**
 * Cookie 값을 가져온다. 
 */
function getCookie(name){
    var nameOfCookie = name + "=";
    var x = 0;
    while (x <= document.cookie.length){
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
            if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                endOfCookie = document.cookie.length;
            return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if ( x == 0 )
            break;
    }
    return "";
}
/**
 * Cookie를 삭제한다.
 */
function DeleteCookie (name,path,domain) {
	var expires = new Date(1900, 1, 1, 1, 1, 1);

	if (getCookie(name)) {
		document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=" + expires.toGMTString();
	}
}

/**
 * 원본으로 복원한다.  
 */
function restore(object){
	if(object){
		object.src=object.altsrc;
		object.altsrc=null;
	}
}

/**
 * 이미지의 src 를 변경한다. 
 */
function change(object, dest){
	if(object){
		object.altsrc = object.src;
		object.src = dest;
	}
}

/**
 * 주어진 텍스트를 클립보드로 복사한다. 익스플로어에서만 동작 
 */
function copy(copyStr){
	if(window.clipboardData.setData) {
		fResult = window.clipboardData.setData("Text", copyStr);
		if(fResult){
			alert('클립보드에 복사되었습니다.');
		}
	}
}

/**
* 반올림한다 -- 소숫점 X 자리까지 남김( X+1 자리에서 반올림 )
*/
function round(number,X){
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

/**
* POPUP Resize
*/
function resize_pop() {
	var obj = navigator.appVersion;
	var hei = 29;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			hei = 35;
		}
	}
	wid = document.body.scrollWidth+10;
	hei = document.body.scrollHeight+hei+10;
	self.resizeTo(wid,hei);
	this.focus();
}
function resize_pop_h() {
	var obj = navigator.appVersion;
	var hei = 29;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			hei = 35;
		}
	}
	hei += 20;
	wid = document.body.scrollWidth+26;
	hei = document.body.scrollHeight+hei;
	if(hei>700)
	{
		hei=700;
	}
	self.resizeTo(wid,hei);
	this.focus();
}
/**
*POPUP Resize2 이미지를 원본크기로 보여준다.(팝업창)
*/
function AutoResize(img){
	foto1 = new Image();
	foto1.src=(img);
	Controlla(img);
}

function Controlla(img){
	if((foto1.width!=0)&&(foto1.height!=0)){
		viewFoto(img);
	}
	else{
		funzione="Controlla('"+img+"')";
		intervallo=setTimeout(funzione,20);
	}
}

function viewFoto(img){
    largh=foto1.width+50;
    altez=foto1.height+85; 
    stringa="width="+largh+",height="+altez;
    finestra=window.open("/common/imageZoom.do?url=" + img,"",stringa);
} 

function onlyNumeric(){
	if(event.keyCode==8||event.keyCode==46||event.keyCode==9){	//백스페이스,DELETE,TAB 허용
	}
	else if((event.keyCode >= 48) && (event.keyCode <= 57)){	// 0-9 허용
	}
	else if((event.keyCode >= 96) && (event.keyCode <= 105)){
	}
	else{
		event.returnValue=false;
	}
}

/**
*
아래내용만 허용
48~57은 숫자 0~9
오른쪽 키패드의 숫자키 96 ~ 105 
←(백스패이스) = 8
TAB = 9 
END = 35
HOME =36 
← = 37
→  = 39
INSERT = 45
DELETE = 46
NUMLOCK = 144
*/
function onlyNum(){
	var key = event.keyCode;
	if(!(key==8||key==9||key==13||key==35||(key>=35&&key<=39)||key==45||key==46||key==144||(key>=48&&key<=57)
	||key>=96&&key<=105)){
		event.returnValue = false;
	}
}


function trans(id,after) 
{ 
	eval(id+'.filters.blendTrans.stop();'); 
	eval(id+'.filters.blendTrans.Apply();'); 
	eval(id+'.src="'+after+'";'); 
	eval(id+'.filters.blendTrans.Play();'); 
} 
function Find_Obj(n, d) { 
	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=Find_Obj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}
// 부메뉴 레이어 숨김/보이기 함수
function Show_Hide() { 
	var i,p,v,obj,args=Show_Hide.arguments;
		for (i=0; i<(args.length-2); i+=3) if ((obj=Find_Obj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}

function getFileExtension(filename){
	var idx = filename.lastIndexOf(".");
	if(idx<0){
		return "";
	}
	else{
		return filename.substring(idx+1);
	}
}

function isValidFile(filename){
	var extn = getFileExtension(filename);
	var inhibit = "jsp,class,js,php,asp,aspx,exe".split(",");

	for(var i=0; i<inhibit.length; i++){
		if(extn==inhibit[i]){
			return false
		}
	}
	return true;
}
function head_select(sel) {
    var idx = sel.selectedIndex;
	if (sel.value != '') {
		self.location.href=sel.value;
    }
}

function changeMonth(prefix)
{
	var year;
	var month;
	var day;
	var loop;
	year = eval("document.all."+prefix+"_year.value");
	month = eval("document.all."+prefix+"_month.value");
	day = eval("document.all."+prefix+"_day");
	
	if(year==''){
		alert("년도를 선택하세요.");
		return;
	}
	if(month==''){
		alert("월을 선택하세요.");
		return;
	}

	if(month==2){
		if((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))){
			loop = 29;
		}
		else{
			loop = 28;
		}
	}
	else if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12){
		loop = 31;
	}
	else{
		loop = 30;
	}
	for(i=1;i<day.length;i++){
		day[i] = null;
	}
	for(i=1; i<=loop; i++){
		day[i]=new Option(i,i);
	}

}

/**
 * 두 날짜의 차이를 일자로 구한다.(조회 종료일 - 조회 시작일)
 *
 * @param val1 - 조회 시작일(날짜 ex.2002-01-01)
 * @param val2 - 조회 종료일(날짜 ex.2002-01-01)
 * @return 기간에 해당하는 일자
 */
function calDateRange(val1, val2)
{
	var FORMAT = "-";

	// FORMAT을 포함한 길이 체크
	if (val1.length != 10 || val2.length != 10)
		return null;

	// FORMAT이 있는지 체크
	if (val1.indexOf(FORMAT) < 0 || val2.indexOf(FORMAT) < 0)
		return null;

	// 년도, 월, 일로 분리
	var start_dt = val1.split(FORMAT);
	var end_dt = val2.split(FORMAT);

	// 월 - 1(자바스크립트는 월이 0부터 시작하기 때문에...)
	// Number()를 이용하여 08, 09월을 10진수로 인식하게 함.
	start_dt[1] = (Number(start_dt[1]) - 1) + "";
	end_dt[1] = (Number(end_dt[1]) - 1) + "";

	var from_dt = new Date(start_dt[0], start_dt[1], start_dt[2]);
	var to_dt = new Date(end_dt[0], end_dt[1], end_dt[2]);

	return (to_dt.getTime() - from_dt.getTime()) / 1000 / 60 / 60 / 24;
}

/***********************************************************************************
**** Select Box Design Script ******************************************************
**** Start *************************************************************************
************************************************************************************/

var nowOpenedSelectBox = "";
var mousePosition = "";

function selectThisValue(thisId,thisIndex,thisValue,thisString) {
	var objId = thisId;
	var nowIndex = thisIndex;
	var valueString = thisString;
	var sourceObj = document.getElementById(objId);
	var nowSelectedValue = document.getElementById(objId+"SelectBoxOptionValue"+nowIndex).value;
	hideOptionLayer(objId);
	if (sourceObj) sourceObj.value = nowSelectedValue;
	settingValue(objId,valueString);
	selectBoxFocus(objId);
	if (sourceObj.onchange) sourceObj.onchange();
}

function settingValue(thisId,thisString) {
	var objId = thisId;
	var valueString = thisString;
	var selectedArea = document.getElementById(objId+"selectBoxSelectedValue");
	if (selectedArea) selectedArea.innerHTML = valueString.replace("&","&amp;");
}

function viewOptionLayer(thisId) {
	var objId = thisId;
	var optionLayer = document.getElementById(objId+"selectBoxOptionLayer");
	if (optionLayer) optionLayer.style.display = "";
	nowOpenedSelectBox = objId;
	setMousePosition("inBox");
}

function hideOptionLayer(thisId) {
	var objId = thisId;
	var optionLayer = document.getElementById(objId+"selectBoxOptionLayer");
	if (optionLayer) optionLayer.style.display = "none";
}

function setMousePosition(thisValue) {
	var positionValue = thisValue;
	mousePosition = positionValue;
}

function clickMouse() {
	if (mousePosition == "out") hideOptionLayer(nowOpenedSelectBox);
}

function selectBoxFocus(thisId) {
	var objId = thisId;
	var obj = document.getElementById(objId + "selectBoxSelectedValue");
	obj.className = "selectBoxSelectedAreaFocus";
	obj.focus();
}

function selectBoxBlur(thisId) {
	var objId = thisId;
	var obj = document.getElementById(objId + "selectBoxSelectedValue");
	obj.className = "selectBoxSelectedArea";
}

function selectBoxOptionRefresh(thisId) {
	var optionHeight = 17; // option 하나의 높이
	var optionMaxNum = 6; // 한번에 보여지는 option의 갯수
	var objId = thisId;
	var obj = document.getElementById(objId);
	var trgObj = document.getElementById(objId+"SelectBoxOptionArea");
	var newOption = "";

	newOption += "		<table cellpadding='0' cellspacing='0' border='0' width='100%' style='table-layout:fixed;word-break:break-all;'>";
	for (var i=0 ; i < obj.options.length ; i++) {
		var nowValue = obj.options[i].value;
		var nowText = obj.options[i].text;
		newOption += "			<tr>";
		newOption += "				<td height='" + optionHeight + "' class='selectBoxOption' onMouseOver=\"this.className='selectBoxOptionOver'\" onMouseOut=\"this.className='selectBoxOption'\" onClick=\"selectThisValue('"+ objId + "'," + i + ",'" + nowValue + "','" + nowText + "')\" style='cursor:hand;'>" + nowText + "</td>";
		newOption += "				<input type='hidden' id='"+ objId + "SelectBoxOptionValue" + i + "' value='" + nowValue + "'>";
		newOption += "			</tr>";
	}
	newOption += "		</table>";

	if(trgObj) {
		if (obj.options.length > optionMaxNum) trgObj.style.height = (optionHeight * optionMaxNum) + "px";
		else trgObj.style.height = (optionHeight * obj.options.length) + "px";
		trgObj.innerHTML = newOption;
		var haveSelectedValue = false;
		for (var i=0 ; i < obj.options.length ; i++) {
			if (obj.options[i].selected == true) {
				haveSelectedValue = true;
				settingValue(objId,obj.options[i].text);
			}
		}
		if (!haveSelectedValue) settingValue(objId,obj.options[0].text);
	}
}


document.onmousedown = clickMouse;
/***********************************************************************************
**** Select Box Design Script ******************************************************
**** End ***************************************************************************
************************************************************************************/
// [주민등록번호 체크]
function chk_jumin(frm1, frm2) {

	var iden = frm1+ frm2;

	if(frm1=="")
	{
		alert("주민등록번호를 입력하여 주십시오.");
		return false;
	}

	if(frm2=="")
	{
		alert("주민등록번호를 입력하여 주십시오.");
		return false;
	}

	if(iden.length != 13) {
		alert("주민등록 번호가 정상이 아닙니다.");
		return false;
	}

	var iden_tot = 0;
	var iden_ad = "234567892345";

	for(i=0; i<=11; i++) {
		iden_tot = iden_tot + parseInt(iden.substring(i, i+1))*parseInt(iden_ad.substring(i, i+1));
	}

	iden_tot = 11 - (iden_tot % 11);

	if(iden_tot == 10) iden_tot = 0;
	else if(iden_tot == 11) iden_tot = 1;

	if(parseInt(iden.substring(12, 13)) != iden_tot) {
		alert("정상적인 주민등록번호가 아닙니다.");
		return false;
	}
	else
	{
		return true;
	}
}


// 숫자 체크
function isNumVal(NUM) {
	for(var i=0;i<NUM.length;i++){
		achar = NUM.substring(i,i+1);
		if( achar < "0" || achar > "9" ){
			return false;
		}
	}
	return true;
}


// 한글/영문만 입력 가능 체크
function isText(str) {
	for(var i=0; i<str.length; i++){
		var chkAt = str.charCodeAt(i);
		if(chkAt < 65){
			return false;
		}
		else{
			if(chkAt > 122 && chkAt <= 127){
				return false;
			}
		}
	}
	return true;
}


// 재 외국인 번호 검사
function isFResNo(s) {
        var sum=0;
        var odd=0;
        buf = new Array(13);
        for(i=0; i<13; i++) { buf[i]=parseInt(s.charAt(i)); }
        odd = buf[7]*10 + buf[8];
        if(odd%2 != 0) { return false; }
        if( (buf[11]!=6) && (buf[11]!=7) && (buf[11]!=8) && (buf[11]!=9) ) {
                return false;
        }
        multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
        for(i=0, sum=0; i<12; i++) { sum += (buf[i] *= multipliers[i]); }
        sum = 11 - (sum%11);
        if(sum >= 10) { sum -= 10; }
        sum += 2;
        if(sum >= 10) { sum -= 10; }
        if(sum != buf[12]) { return false }
        return true;
}


function toAscii(char)  {
	var symbols = " !\"#$%&'()*+'-./0123456789:;<=>?@";
	var loAZ = "abcdefghijklmnopqrstuvwxyz";
	symbols+= loAZ.toUpperCase();
	symbols+= "[\\]^_`";
	symbols+= loAZ;
	symbols+= "{|}~";
	var loc;
	loc = symbols.indexOf(char);
	if (loc >-1) {
		Ascii_Decimal = 32 + loc;
		return (32 + loc);
	}
	return(0);  // If not in range 32-126 return ZERO
}

function toBinary(High, Low) {
	binary_numbers = new Array("0000", "0001", "0010", "0011", "0100", "0101",
	"0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111");
	var hiHex = "ABCDEF";
	if (Low < 10 ) {
		LowNib = Low;
	}
	else {
		LowNib = 10 + hiHex.indexOf(Low);
	}
	if (High  < 10 ) {
		HighNib = High;
	}
	else {
		HighNib = 10 + hiHex.indexOf(High);
	}
	eight_bits = binary_numbers[HighNib] + " " + binary_numbers[LowNib];
	return eight_bits;
}
function Dec2Hex(Decimal) {
	var hexChars = "0123456789ABCDEF";
	var a = Decimal % 16;
	var b = (Decimal - a)/16;
	hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
	L = hexChars.charAt(a);
	H = hexChars.charAt(b);
	return hex;
}
function blinkIt() {
	if (!document.all) return;
	else {
		for(i=0;i<document.all.tags('blink').length;i++){
			s=document.all.tags('blink')[i];
			s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
		}
	}
}

function goPage(pageurl) {
	top.location=pageurl;
}
function swf2(url_root, w, h){
   	  document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' \n"
      +" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' \n"
      +" width='"+w+"' Height='"+h+"'> \n"
      +"<param name='movie' value='"+url_root+"'>\n"
      +"<param name='quality' value='high'>\n"
      //+"<param name='bgcolor' value='#"+bgcolor+"'>\n"
      +"<param name='wmode' value='transparent'>\n"
      +"<embed src='"+url_root+"' "
      +" wmode='transparent' quality='high' width='"+w+"' height='"+h+"' "
      +" type='application/x-shockwave-flash' "
      +" pluginspage='http://www.macromedia.com/shockwav/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>\n"
      +"</embed></object>\n");
}
function moveNext(varControl, varNext) { 
if(varControl.value.length == varControl.maxLength) { 
varNext.focus();varNext.select(); } } 