//*
//*
//*
//*
//*

////document.domain="serve.co.kr";;	


function getPageNavigator_dizzo( pageSize, blkSize, totalRowCount, currentPage, link ) {

	var firstImg  = "<img src=/image/community/common/btn_prev02.gif width=15 height=15 hspace=3 border=0>";
	var prevImg   = '<img src="http://businesstv.chosun.com/images/200801/prev.jpg" width="12" height="11" border=0> ';
	var nextImg   = '<img src="http://businesstv.chosun.com/images/200801/next.jpg" width="12" height="11" border=0>';
	var lastImg   = "<img src=/image/community/common/btn_next02.gif width=15 height=15 hspace=3 border=0>";


	if( totalRowCount * pageSize * blkSize == 0 ) return "";

	firstPage = 1;
	lastPage  = Math.ceil( totalRowCount / pageSize );

	currentPage = ( currentPage < 1 ) ? 1 : currentPage;
	currentPage = ( currentPage > lastPage ) ? lastPage : currentPage;

	currentBlkFirstPage = Math.floor((currentPage-1)/blkSize) * blkSize + 1;
	prevBlkLastPage     = currentBlkFirstPage - 1;
	nextBlkFirstPage    = currentBlkFirstPage + blkSize;

	toFirst = (currentPage==firstPage) ? firstImg : "<a href='" +link+firstPage+"'>"+firstImg+"</a>";
	toLast  = (currentPage==lastPage)  ? lastImg  : "<a href='" +link+lastPage+ "'>"+lastImg +"</a>";

	toPrev = (prevBlkLastPage<=firstPage) ? prevImg : "<a href='" +link+prevBlkLastPage+ "'>" +prevImg+"</a>";
	toNext = (nextBlkFirstPage>lastPage)  ? nextImg : "<a href='" +link+nextBlkFirstPage+"'>"+nextImg+"</a>";

	blkPageNavi = "";
	for( i=currentBlkFirstPage; i<currentBlkFirstPage+blkSize && i<=lastPage; i++ ) {
		blkPageNavi += (i==currentBlkFirstPage) ? " " : " | ";
		blkPageNavi += (i==currentPage) ? "<b>"+i+"</b>" : "<a href='"+link+i+"'>"+i+"</a>";
	}

	pageNavi = "";
//    pageNavi += '<div align="center">';
//    pageNavi += '<table border="1" cellspacing="0" cellpadding="0" height="16">';
//    pageNavi += '<tr>';
//    pageNavi += '<td width="15">';
    pageNavi += '	<b>'+ toPrev +'</b>'
//    pageNavi += '		</td>';
 //   pageNavi += '<td width="*">';
    pageNavi += '' + blkPageNavi + '';
//    pageNavi += '</td>';
//    pageNavi += '<td width="15">'; 
    pageNavi += ' <b>'+ toNext +'</b> ';
//    pageNavi += '</td>';
//    pageNavi += '</tr>';
 //   pageNavi += '</table>';
//    pageNavi += '</div>';

	return pageNavi;
}


function getPageNavigator( pageSize, blkSize, totalRowCount, currentPage, func ) {

	var firstImg  = "<img src=/image/community/common/btn_prev02.gif width=15 height=15 hspace=3 border=0>"
	var prevImg   = '<img src="http://businesstv.chosun.com/images/200801/prev.jpg" width="12" height="11" border=0> ';
	var nextImg   = '<img src="http://businesstv.chosun.com/images/200801/next.jpg" width="12" height="11" border=0>';
	var lastImg   = "<img src=/image/community/common/btn_next02.gif width=15 height=15 hspace=3 border=0>"


	if( totalRowCount * pageSize * blkSize == 0 ) return "";

	firstPage = 1;
	lastPage  = Math.ceil( totalRowCount / pageSize );

	currentPage = ( currentPage < 1 ) ? 1 : currentPage;
	currentPage = ( currentPage > lastPage ) ? lastPage : currentPage;

	currentBlkFirstPage = Math.floor((currentPage-1)/blkSize) * blkSize + 1;
	prevBlkLastPage     = currentBlkFirstPage - 1;
	nextBlkFirstPage    = currentBlkFirstPage + blkSize;

	toFirst = (currentPage==firstPage) ? firstImg : "<a href='javascript:" +func+ "(" +firstPage+ ");'>"+firstImg+"</a>";
	toLast  = (currentPage==lastPage)  ? lastImg  : "<a href='javascript:" +func+ "(" +lastPage+ ");'>" +lastImg +"</a>";

	toPrev = (prevBlkLastPage<=firstPage) ? prevImg : "<a href='javascript:" +func+ "(" +prevBlkLastPage+ ");'>" +prevImg+"</a>";
	toNext = (nextBlkFirstPage>lastPage)  ? nextImg : "<a href='javascript:" +func+ "(" +nextBlkFirstPage+ ");'>"+nextImg+"</a>";

	blkPageNavi = "";
	for( i=currentBlkFirstPage; i<currentBlkFirstPage+blkSize && i<=lastPage; i++ ) {
		blkPageNavi += (i==currentBlkFirstPage) ? " " : " | ";
		blkPageNavi += (i==currentPage) ? " <b>"+i+"</b> " : " <a href='javascript:"+func+"("+i+");'>"+i+"</a> ";
	}

	pageNavi = " ";
	pageNavi += toPrev ;
	pageNavi += blkPageNavi ;
	pageNavi += toNext ;

	return pageNavi;
}

function getPageNavigator2( pageSize, blkSize, totalRowCount, currentPage, link ) {

	var firstImg  = "<img src=/image/community/common/btn_prev02.gif width=15 height=15 hspace=3 border=0>"
	var prevImg   = "<img src=/image/community/common/btn_prev.gif width=40 height=15 border=0>"
	var nextImg   = "<img src=/image/community/common/btn_next.gif width=40 height=15 border=0>"
	var lastImg   = "<img src=/image/community/common/btn_next02.gif width=15 height=15 hspace=3 border=0>"


	if( totalRowCount * pageSize * blkSize == 0 ) return "";

	firstPage = 1;
	lastPage  = Math.ceil( totalRowCount / pageSize );

	currentPage = ( currentPage < 1 ) ? 1 : currentPage;
	currentPage = ( currentPage > lastPage ) ? lastPage : currentPage;

	currentBlkFirstPage = Math.floor((currentPage-1)/blkSize) * blkSize + 1;
	prevBlkLastPage     = currentBlkFirstPage - 1;
	nextBlkFirstPage    = currentBlkFirstPage + blkSize;

	toFirst = (currentPage==firstPage) ? firstImg : "<a href='" +link+firstPage+"'>"+firstImg+"</a>";
	toLast  = (currentPage==lastPage)  ? lastImg  : "<a href='" +link+lastPage+ "'>"+lastImg +"</a>";

	toPrev = (prevBlkLastPage<=firstPage) ? prevImg : "<a href='" +link+prevBlkLastPage+ "'>" +prevImg+"</a>";
	toNext = (nextBlkFirstPage>lastPage)  ? nextImg : "<a href='" +link+nextBlkFirstPage+"'>"+nextImg+"</a>";

	blkPageNavi = "";
	for( i=currentBlkFirstPage; i<currentBlkFirstPage+blkSize && i<=lastPage; i++ ) {
		blkPageNavi += (i==currentBlkFirstPage) ? " " : " | ";
		blkPageNavi += (i==currentPage) ? "<b>"+i+"</b>" : "<a href='"+link+i+"'>"+i+"</a>";
	}

	pageNavi = "";
	pageNavi += "<td align=right>" + toFirst + toPrev + "<img src=/image/common/bg_blank.gif width=10 height=1></td>";
	pageNavi += "<td align=center>" + blkPageNavi + "</td>";
	pageNavi += "<td><img src=/image/common/bg_blank.gif width=10 height=8>" + toNext + toLast + "</td>";

	return pageNavi;
}







// ---------------------------------------------------------------------------------------------- //

function trim(str) {
	return str.replace(/(^\s*)|(\s*$)/g, "");
}

function isdigit(s) {
	for( var i=0; i<s.length; i++ )
		if( s.charAt(i)<'0' || s.charAt(i)>'9' ) return false;
	return true;
}

function isdigitdot(s) {
	for( var i=0; i<s.length; i++ )
		if( ( s.charAt(i)<'0' || s.charAt(i)>'9' ) && s.charAt(i) != '.' ) return false;
	return true;
}

function isalpha(s) {
	for( var i=0; i<s.length; i++ )
		if( s.charAt(i)<'A' || (s.charAt(i)>'Z' && s.charAt(i)<'a') || s.charAt(i)>'z' ) return false;
	return true;
}

function isvalidid1(s) {
	if( !isalpha(s.charAt(0)) ) return 0;
	for( var i=1; i<s.length; i++ )
		if( !isalpha(s.charAt(i)) && !isdigit(s.charAt(i)) ) return -1;
	return 1;
}


// ---------------------------------------------------------------------------------------------- //

function null_check( form, field, fieldName ) {

	obj = document.forms[form].all[field];
	val = trim(obj.value);
	if( val == "" || val == null ) {
		alert( fieldName + " À» ÀÔ·ÂÇÏ¼¼¿ä.");
		obj.focus();
		return false;
	}
	return true;
}

function null_check2( obj, fieldName ) {

	val = trim(obj.value);
	if( val == "" || val == null ) {
		alert( fieldName + " À» ÀÔ·ÂÇÏ¼¼¿ä.");
		obj.focus();
		return false;
	}
	return true;
}


// ---------------------------------------------------------------------------------------------- //

function digit_check( obj, fieldName ) {

	var val = trim(obj.value);

	if( !isdigit(val) ) {
		alert( fieldName + " Àº(´Â) ¼ýÀÚ¸¸ ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
		obj.focus();
		return false;
	}
	return true;
}

// ---------------------------------------------------------------------------------------------- //

function length_check1( form, field, fieldName, minLen, maxLen ) {

	obj = document.forms[form].all[field];
	val = trim(obj.value);
	if( val.length < minLen || val.lenght > maxLen ) {
		alert( fieldName + " Àº " +minLen+ " ~ " +maxLen+ " ÀÚ¸®¸¸ °¡´ÉÇÕ´Ï´Ù." );
		obj.focus();
		return false;
	}
	return true;
}


function length_check2( form, field, fieldName, len ) {
	obj = document.forms[form].all[field];
	val = trim(obj.value);
	if( val.length != len ) {
		alert( fieldName + " Àº " +len+ " ÀÚ¸® ÀÌ¾î¾ß¸¸ ÇÕ´Ï´Ù." );
		obj.focus();
		return false;
	}
	return true;
}

function length_check3( obj, fieldName, len ) {
	val = trim(obj.value);
	if( val.length > len ) {
		alert( fieldName + " Àº " +len+ " ÀÚ ±îÁö °¡´ÉÇÕ´Ï´Ù." );
		obj.focus();
		return false;
	}
	return true;
}


// ---------------------------------------------------------------------------------------------- //
// ÁÖ¹Î¹øÈ£ Ã¼Å©
function ssn_check( form, ssn1, ssn2 ) {

	ssn = document.forms[form].all[ssn1].value + document.forms[form].all[ssn2].value ;
	if( !isdigit(ssn) ) return false;

	a = new Array(13);
	for( i=0; i<13; i++ )
		a[i] = parseInt( ssn.charAt(i) );

	b = 11 - ( ( a[0]*2 + a[1]*3 + a[2]*4 + a[3]*5 + a[4]*6 + a[5]*7 + a[6]*8 + a[7]*9 + a[8]*2 + a[9]*3 + a[10]*4 + a[11]*5 ) % 11 );
	if( b > 9 )
		b = b % 10;

	return ( b != a[12] ) ? false : true ;
}


// ---------------------------------------------------------------------------------------------- //
// sy : ½ÃÀÛ¿¬µµ, ey : ³¡¿¬µµ, cy : ¼±ÅÃÇÒ ¿¬µµÀÇ ¸¶Áö¸· µÎÀÚ¸®
function getBirthYear( sy, ey, cy ) {
	var tmp;
	for( i=sy; i<=ey; i++ )
		tmp += "<option value=" + i + (( ((i+"").substr( 2, 2 ))==cy ) ? " selected" : "" ) + ">" + i + "</option>";
	return tmp;
}

// cm : ¼±ÅÃÇÒ ¿ù
function getBirthMonth( cm ) {
	tm = ( cm < 10 ) ? "0"+cm : ""+cm;
	var tmp;
	for( i=1; i<=12; i++ ) {
		ti = ( i < 10 ) ? "0"+i : ""+i;
		tmp += "<option value=" + ti + ((ti==cm)?" selected":"") + ">" + ti + "</option>";
	}
	return tmp;
}

// cd ¼±ÅÃÇÒ ÀÏ
function getBirthDay( cd ) {
	td = ( cd < 10 ) ? "0"+cd : ""+cd;
	var tmp;
	for( i=1; i<=31; i++ ) {
		ti = ( i < 10 ) ? "0"+i : ""+i;
		tmp += "<option value=" +ti + ((ti==cd)?" selected":"") + ">" + ti + "</option>";
	}
	return tmp;
}



// ---------------------------------------------------------------------------------------------- //
// 3 ÀÚ¸® ¸¶´Ù , »ðÀÔ
function insertComma(number) {
	result =""
	number = number + "";
	for( i=0; i<number.length; i++) {
		tmp = number.length-(i+1)
		if(i%3==0 && i!=0) 
			result = ',' + result;
		result = number.charAt(tmp) + result;
	}
	return result;
}


//*************************
//ÀÔ·Â°ª Çü½Ä À¯È¿¼º Ã¼Å©
//*************************
function field_type(field,patten,name)
{ 
       var regNum =/^[0-9]+$/;			//¼ýÀÚ¸¸...
       var regPhone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;			//ÀüÈ­¹øÈ£
       var regMail =/^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/;		//¸ÞÀÏ
       var regDomain =/^[.a-zA-Z0-9-]+.[a-zA-Z]+$/;			//µµ¸ÞÀÎ
       var regAlpha =/^[a-zA-Z]+$/;		//¿µ¹®¸¸...
       var regHost =/^[a-zA-Z-]+$/;		//¿µ¹®°ú - ¸¸..
       var regHangul =/[°¡-ÆR¤¡-¤¾]/;				// ÇÑ±Û..
       var regHangulEng =/[°¡-ÆRa-zA-Z]/;			//ÇÑ±Û°ú¿µ¹®...
       var regHangulOnly =/^[°¡-ÆR]*$/;				//ÇÑ±Û¸¸...
       var regId = /^[a-zA-Z]{1}[a-zA-Z0-9_-]{4,15}$/;		//¾ÆÀÌµð 4ÀÚ~15ÀÚ ÀÌ³» ¿µ¹®°ú¼öÀÚ _,- ¸¸ »ç¿ë, Ã¹ÀÚ ¿µ¹®
       var regDate =/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;				//³¯Â¥Çü½Ä

       patten = eval(patten); 
       if(!patten.test(field.value)){ 
              alert(name + "¿¡ ´ëÇÑ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù."); 
              field.focus(); 
              return false; 
       } 
       return true; 
}
