//  Å¸°Ù, ³¯Â¥(8ÀÚ¸®), ¸¶¿ì½ºÀÌº¥Æ® °ªÀ» ³Ö°í ´Þ·ÂÀ» ±×·ÁÁØ´Ù.
function calenda(starget) {
	calenda(starget,'','');
}

function calenda(starget,sdate) {
	calenda(starget,sdate,'');
}

function calenda(starget,sdate,e) {

	var bFlag = false;
	var i,j;
	var syy, smm, sdd;

	var toDate = new Date();
	var today = '';
	if(!today){
		todayY = toDate.getFullYear();
		todayM = toDate.getMonth() + 1;
		todayD = toDate.getDay();
		if(todayM < 10){
			todayM = '0' + todayM;
		}
		if(todayD < 10){
			todayD = '0' + todayD;
		}
		today = '' + todayY + todayM + todayD;
	}
	//alert(today);
	
	if(!sdate){
		var sdate = get_value(starget);
	}
	
	if(!sdate || !IsNumeric(sdate)){
		var toDate = new Date();
		syy = toDate.getFullYear();
		smm = toDate.getMonth() + 1;
		sdd = toDate.getDay();
		sdate = toDate.getDate();
	}
	else{
		syy = sdate.substring(0,4);
		smm = sdate.substring(4,6);
		sdd = sdate.substring(6,8);
	}
	
	/*
    if(smm.substring(0,1) == "0") {
		smm = smm.substring(1,2);
	}
    if(sdd.substring(0,1) == "0") {
		sdd = sdd.substring(1,2);
	}
	*/
	
	//alert(sdate+':'+syy + ',' + smm + ',' + sdd);


	var date = new Date(parseInt(syy,10),parseInt(smm,10)-1,'01');
	var day = 1;
	var trtd = "";

	// ¹è¿­À» ¼±¾ð ÇÑ´Ù.
	var a1 = new Array();
	var a2 = new Array();
	var a3 = new Array();
	var a4 = new Array();
	var a5 = new Array();
	var a6 = new Array();

	// ¹è¿­À» ÃÊ±âÈ­ ÇÑ´Ù.
	for (i = 0 ; i < 7; i++) {
		a1[i] = "";
		a2[i] = "";
		a3[i] = "";
		a4[i] = "";
		a5[i] = "";
		a6[i] = "";
	}

	var aCalenda = new Array();
	var iLastDay = DaysInMonth(parseInt(smm,10),parseInt(syy,10));							// ¸¶Áö¸· ³¯Â¥¸¦ ±¸ÇÑ´Ù.
	// ÀÌÁß ¹è¿­À¸·Î ¸¸µé¾î ÁØ´Ù.
	for (i = 1 ; i < 7 ; i++) {
		aCalenda[i-1] = eval("a" + i);
	}

	/*
		1ÀÏÀÇ ¿äÀÏ ºÎÅÍ ½ÃÀÛÇØ¼­ ¹øÈ£¸¦ ³Ö´Â´Ù.
		ex) ¸ñ [0][4] = 1 
	*/
	for (i = 0 ;i < 6 ; i++) {
		for (j = 0 ; j < 7; j++) {
			if (i == 0 && j == date.getDay()) {
				bFlag = true;
			}

			if (bFlag == true && day <=iLastDay ) {
				aCalenda[i][j] = day ;
				day += 1;
			}
			else {
				aCalenda[i][j] = "";
			}
		}
	}

	/*
		´ÙÀ½´Þ °ú ÀÌÀü ´Þ °è»ê ÇÏ´Â °÷
	*/
	var sYearPre = "";
	var sYearNex = "";
	var sMonthPre = "";
	var sMonthNex = "";
	

	//syy,smm
	switch(parseInt(smm,10)) {
		case 1:
			sYearPre = parseInt(syy,10) - 1;
			sYearNex = syy;

			sMonthPre = '12';
			sMonthNex = '02';
			break;
		case 12:
			sYearPre = syy;
			sYearNex = parseInt(syy,10) + 1;

			sMonthPre = '11';
			sMonthNex = '01';
			break;
		default:
			sYearPre = syy;
			sYearNex = syy;

			sMonthPre = parseInt(smm,10) - 1;
			sMonthNex = parseInt(smm,10) + 1;
			break;
	}
	
	if(parseInt(sMonthPre,10) < 10){
		sMonthPre = '0' + parseInt(sMonthPre,10);
	}
	if(parseInt(sMonthNex,10) < 10){
		sMonthNex = '0' + parseInt(sMonthNex,10);
	}
	if(parseInt(smm,10) < 10){
		smm = '0' + parseInt(smm,10);
	}
	if(parseInt(sdd,10) < 10){
		sdd = '0' + parseInt(sdd,10);
	}


	/*
    if(smm.substring(0,1) == "0") {
		smm = smm.substring(1,2);
	}
    if(sdd.substring(0,1) == "0") {
		sdd = sdd.substring(1,2);
	}
	*/
	
	trtd += "<tr><td colspan=7>";
	trtd += "<table width='100%' height='100%' cellpadding=0 cellSpacing=0><tr bgColor=#ffffff >";
		trtd += "<td width='5' class=txtnormal  heidht='22' align='left' onclick=\"parent.calenda('"+starget+"','"+(parseInt(sYearPre,10)-1)+""+smm+""+sdd+"')\" style='cursor:pointer' title=\"("+(parseInt(sYearPre,10)-1)+"³â"+smm+"¿ù)\"><img src='./images/date/il_arrow_bottom.gif'></td> " ;
		trtd += "<td class=txtnormal  heidht='22' align='center' onclick=\"calenda('"+starget+"','"+sYearPre+""+sMonthPre+""+sdd+"')\" style='cursor:pointer' title=\"("+sYearPre+"³â"+sMonthPre+"¿ù)\"><img src='./images/date/il_arrow_bottom.gif'></td>" ;
		trtd += "<td class=txtnormal align='center'>"+syy+"³â"+smm+"¿ù</td>";
		trtd += "<td class=txtnormal align='center' onclick=\"calenda('"+starget+"','"+sYearNex+""+sMonthNex+""+sdd+"')\" style='cursor:pointer' align=left title=\"("+sYearNex+"³â"+sMonthNex+"¿ù)\"><img src='./images/date/il_arrow2_bottom.gif'></td>";
		trtd += "<td width='5' onclick=\"calenda('"+starget+"','"+(parseInt(sYearNex,10)+1)+""+smm+""+sdd+"')\" style='cursor:pointer' align=right title=\"("+(parseInt(sYearNex,10)+1)+"³â"+smm+"¿ù)\"><img src='./images/date/il_arrow2_bottom.gif'></td></tr></table>";
	trtd += "</td></tr>";
	/*
		¿äÀÏÀ» ³Ö¾î ÁØ´Ù.
	*/
	trtd += "<TR bgColor=#ffffff> <TD colspan=7><IMG height=20 src='./images/date/il_carendar_tit01.gif' width=177></TD></TR>";

	/*
		tr td¸¦ Æ÷ÇÔÇÑ ½ºÆ®¸µÀ» ¸¸µç´Ù.
	*/
	for ( i = 0 ; i < 6 ; i++) {
		trtd += "<tr bgColor=#ffffff>"
		for ( j = 0; j < 7 ; j++) {
			if (aCalenda[i][j] == "") {
				var spointerCursor = "";
				var sOnClick = "";
			}
			else {
				var spointerCursor = "style='cursor:pointer'";
				var sOnClick = "onclick=\"set_value('"+starget+"','"+ syy + smm + (aCalenda[i][j] < 10 ? '0'+aCalenda[i][j]:aCalenda[i][j])+"');hideObj('calendadiv');\"";
			}

			trtd += "<td  vAlign=bottom align=right class=txtnormal width='25' heidht='22' " + spointerCursor + sOnClick + " >" ;
			if (j == 0 || j== 6 || parseInt(sdd) == aCalenda[i][j]) {
				if (parseInt(sdd) == aCalenda[i][j]) {
					trtd += "<font style='font-weight: bold;' >";
				}
				else if ( j == 0 ) {
					trtd += "<font color=red >";
				}
				else {
					trtd += "<font color=blue >";
				}
			}
			trtd += aCalenda[i][j];

			if (j == 0 || j== 6 || parseInt(sdd) == aCalenda[i][j]) {
				trtd += "</font>";
			}

			trtd +="</td>" ;
		}
		trtd += "</tr>"
	}
		
	var	str = 
	" <html><head>" +
	"</head>" +
	"<body leftmargin='0' topmargin='0'>" +
	"<table width='176' height=160 border=0 cellpadding=0 cellSpacing=1 bgcolor=#e9e9e9>" +
	"" + trtd +
	" <tr bgColor=#ffffff><TD colspan=4></td> " +
	"<td align=left onclick=\"set_value('"+starget+"','"+today+"');hideObj('calendadiv')\" style='cursor:pointer'>¿À´Ã</td>" +
	"<TD align=right class=txtnormal onclick=\"hideObj('calendadiv')\" style='cursor:pointer'>Ãë¼Ò</td><td width='25'></td></tr>" +
	" </table></body></html>";

	//alert(str);
	/*
		´Þ·Â ³×ºñ °ÔÀÌ¼Ç ½Ã ¸¶¿ì½º ÀÌº¥Æ® À§Ä¡¸¦ ÀÐÀ¸¸é ¾ÈµÈ´Ù.
	*/
	var top = 0;
	var left = 0;
	var width = 250;
	var height = 250;
	if (e) {
		top = e.clientY + document.body.scrollTop;
		left = e.clientX + document.body.scrollLeft;
		//alert(top + "/" +left);
	}
	
	/*
		´Þ·Â Ã¢ÀÇ¤Ó Å©±â°¡ µµÅ¥¸ÕÆ®º¸´Ù Å©¸é ´Þ·ÂÃ¢ÀÇ À§Ä¡¸¦ ¹Ù²Û´Ù.
	*/
	
	if (document.body.scrollHeight  < (top + 250)) {
		top = document.body.scrollHeight - 200;
		
	}
	if (document.body.scrollWidth < (left + 250) ) {
		left = document.body.scrollWidth - 200 ;
	}
	
	var cal = getObj( 'calendadiv');
	if(cal){
		//hFrame.location.reload();
		
			//hFrame.document.write(str);
			cal.innerHTML = str;
			
			//cal.style.visibility = "hidden";
		//cal.style.display='block';
		//bShowFlag = true;

		showObj(cal)
//			alert();
		// ´Þ·Â À©µµ¿ìÀÇ À§Ä¡
		if(e){
			cal.style.top = top;
			cal.style.left = left;
		}
		cal.style.height = height;
		cal.style.width = width;
			
	}
	else{
		// div ¸¸µé¾î¼­ Ãâ·Â
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id', 'calendadiv');
		   
		   if (width) {
		       newdiv.style.width = width;
		   }
		   
		   if (height) {
		       newdiv.style.height = height;
		   }
		   
		   if ((left || top) || (left && top)) {
		       newdiv.style.position = "absolute";
		       
		       if (left) {
		           newdiv.style.left = left;
		       }
		       
		       if (top) {
		           newdiv.style.top = top;
		       }
		   }
		   newdiv.style.zIndex = 1;
		   newdiv.style.display = 'inline';
		   
		   if (str) {
		       newdiv.innerHTML = str;
		   }
		   
		   document.body.appendChild(newdiv);
				
		//document.write('<div id="calendadiv" name="calendadiv" style="position:absolute; z-index:1; left: '+left+'; top: '+top+'; width: '+width+'; height: '+height+'; display:inline;">'+str+'</div>'); 
	}
	
//alert();


}


/*
// This is the Default Calendar Theme 
.tblCalendar{border:2px #333 solid;border-collapse:collapse;font:normal 11px Verdana, Arial, sans-serif;background:#E5E5E5;} 
.tblCalendar td{border:1px #333 solid;text-align:center;padding:2px;} 
.tblCalendar td.SelectedDay{background:#999999;color:red;} 
.tblCalendar td.Title{font-weight:bold;background:#000000;color:#C0C0C0;} 
.tblCalendar .WeekName td{font-weight:bold;} 

// These are some customised themes. The class name has to be passed to the function as the 4th argument
.CalendarStyle0{border:2px #0000FF solid;border-collapse:collapse;font:normal 11px Verdana, Arial, sans-serif;background:#F2F2F2;} 
.CalendarStyle0 td{border:1px #0000FF solid;text-align:center;padding:2px;} 
.CalendarStyle0 td.SelectedDay{background:#999999;color:blue;font-weight:bold;} 
.CalendarStyle0 td.Title{font-weight:bold;background:#006699;color:#C0C0C0;} 
.CalendarStyle0 .WeekName td{font-weight:bold;} 

.CalendarStyle1{border:2px #000 solid;border-collapse:collapse;font:normal 11px Verdana, Arial, sans-serif;background:#000;} 
.CalendarStyle1 td{border:1px #333 solid;text-align:center;padding:2px;color:#FFFFFF;} 
.CalendarStyle1 td.SelectedDay{background:#000;color:red;} 
.CalendarStyle1 td.Title{font-weight:bold;background:#000000;color:#C0C0C0;} 
.CalendarStyle1 .WeekName td{font-weight:bold;} 

.CalendarStyle2{border:2px #333 solid;border-collapse:collapse;font:normal 11px Verdana, Arial, sans-serif;background:#A8DCB7;} 
.CalendarStyle2 td{border:1px #333 solid;text-align:center;padding:2px;} 
.CalendarStyle2 td.SelectedDay{background:#999999;color:red;} 
.CalendarStyle2 td.Title{font-weight:bold;background:#378D44;color:#C0C0C0;} 
.CalendarStyle2 .WeekName td{font-weight:bold;} 

.CalendarStyle3{border:1px red solid;border-collapse:collapse;font:normal 11px Verdana, Arial, sans-serif;background:#FFFFFF;} 
.CalendarStyle3 td{border:1px #F3F3F3 solid;text-align:center;padding:2px;} 
.CalendarStyle3 td.SelectedDay{background:#F3F3F3;color:red;} 
.CalendarStyle3 td.Title{font-weight:bold;background:#ED0000;color:#FFF;} 
.CalendarStyle3 .WeekName td{font-weight:bold;} 
*/

function Calendar(Year, Month, Day, ContainerId) 
{ 
    //Calendar.MonthNames = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); 
    Calendar.MonthNames = new Array('1¿ù', '2¿ù', '3¿ù', '4¿ù', '5¿ù', '6¿ù', '7¿ù', '8¿ù', '9¿ù', '10¿ù', '11¿ù', '12¿ù'); 
    //If no parameter is passed use the current date. 
    this.oDate = new Date(); 
    this.Year = (Year == null) ? this.oDate.getFullYear() : Year; 
    this.Month = (Month == null) ? this.oDate.getMonth() : Month - 1; 
    this.Day = (Day == null) ? 0 : Day; 
    this.oDate = new Date(this.Year, this.Month, 1); 
    this.PrevMonth = new Date(this.Year, this.Month - 1, 1); 
	this.NextMonth = new Date(this.Year, this.Month + 1, 1); 
    this.WeekStart = this.oDate.getDay(); 
    // Get the number of months in current month 
    this.MonthDays = Math.round((this.NextMonth.getTime() - this.oDate.getTime()) / 86400000) + 1; 
    
	var PrevYear = (this.Month > 0)? this.Year: this.Year - 1;
	var NextYear = (this.Month < 11)? this.Year: this.Year + 1;
	var PrevMonth = (this.Month - 1) % 12;
	var NextMonth = (this.Month + 1) % 12;

    this.HTML = '<table style="border:1px red solid;border-collapse:collapse;font:normal 11px Verdana, Arial, sans-serif;background:#FFFFFF;" cellspacing="0">'; 
    // Title bar 
    //this.HTML += '<tr><td colspan="7" class="Title">' + Calendar.MonthNames[this.Month] + ' ' + this.Year + '</td></tr>'; 
    this.HTML += '<tr>'
		+ '<td style="font-weight:bold;background:#ED0000;color:#FFF;" onclick="Calendar('+PrevYear+','+PrevMonth+','+Day+','+ContainerId+')">&lt</td>'
		+ '<td colspan="5" style="font-weight:bold;background:#ED0000;color:#FFF;">' + Calendar.MonthNames[this.Month] + ' ' + this.Year + '</td>'
		+ '<td style="font-weight:bold;background:#ED0000;color:#FFF;" onclick="Calendar('+NextYear+','+NextMonth+','+Day+','+ContainerId+')">&gt</td>'
		+ '</tr>';
    // Week Names 
    this.HTML += '<tr style="font-weight:bold;"><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>'; 
    this.HTML += '<tr>'; 
    // Fill the previous month days with space 
    for(DayCounter = 0; DayCounter < this.WeekStart; DayCounter++) 
    { 
        this.HTML += '<td style="border:1px #F3F3F3 solid;text-align:center;padding:2px;">&nbsp;</td>'; 
    } 
    // Populate current month 
    for(DayCounter = 1; DayCounter < this.MonthDays; DayCounter++) 
    { 
        if((DayCounter + this.WeekStart) % 7 == 1) this.HTML += '<tr>'; 
		
        this.HTML += '<td ' 
			+ ((DayCounter == this.Day)? ' style="background:#F3F3F3;color:red;" ' : ' style="border:1px #F3F3F3 solid;text-align:center;padding:2px;" ')
			+ 'onclick=alert(' + DayCounter + ')'
			+ ' >'; 
		this.HTML += DayCounter; 
		this.HTML += '</td>'; 

		if((DayCounter + this.WeekStart) % 7 == 0) this.HTML += '</tr>'; 
    } 
    // Fill the next month days with space 
    for(j = (42 - (this.MonthDays + this.WeekStart)), DayCounter = 0; DayCounter <= j; DayCounter++) 
    { 
        this.HTML += '<td style="border:1px #F3F3F3 solid;text-align:center;padding:2px;">&nbsp;</td>'; 
        if((j - DayCounter) % 7 == 0) this.HTML += '</tr>'; 
    } 
    this.HTML += '</table>'; 
    // Check whether the Container Id is null 
    if(ContainerId != null) 
    { 
        this.Container = document.getElementById(ContainerId); 
        // If an object exists with the given ContainerId insert the Calendar into the object 
        if(this.Container) 
            this.Container.innerHTML = this.HTML; 
        // Else create an element with the given id and insert the calendar 
        else 
            document.write('<div id="' + ContainerId + '">' + this.HTML + '</div>'); 
            
        this.Container = document.getElementById(ContainerId); 
        
    } 

    // Returns Id of the element containing the calendar 
    return ContainerId; 
} 

//////////////////////////////////////
// check loading time
if(!start_time){
	var current = new Date();
	var start_time = current.getTime();
}
function check_loadtime(){
	var current = new Date();
	var end_time = current.getTime();
	var load_time = end_time - start_time;
	//alert("loading time:"+load_time+"msec");
}

///////////////////////////////////////////////////////////
// common script function

var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
	return getObj(name,false);  
}

function getObj(name, doc)
{
	if(!name)
		return;
	if(typeof(name) == 'object'){
		return name;
	}
		
	var obj = false;
	
	if(!doc){
		doc = document;
	}

/*
	if(doc.forms){
		var temp;
		var name0;
		var aryObj = new Array();

		for(i = doc.forms.length - 1; i >= 0; i--){
			if(!doc.forms[i].elements || doc.forms[i].elements == undefined){
				continue;
			}
			
			for(j = doc.forms[i].elements.length - 1; j >= 0; j--){
				temp = doc.forms[i].elements[j];
				name0 = temp.name;
				if(temp.name == name){
					obj = doc.forms[i].elements[j];
					//alert(obj);
					if(obj.type == 'radio'){
						aryObj.push(obj);		
					}
					else{
						obj = doc.forms[i].elements[j];
						return obj;
					}

				}
			}
		}
		
		if(aryObj.length > 0){
			obj = aryObj;
		}
		
	}
	if(obj){
		return obj;
	}
*/

	if (doc.all && doc.all != undefined)
	{
		obj = doc.all[name];
		//alert('all:'+name+',obj:'+obj+',type:'+obj.type);
	}	
	if(obj){
		return obj;
	}
	
	if (doc.getElementById && doc.getElementById != undefined)
	{
		obj = doc.getElementById(name);
		//alert('getElementById:'+name+',obj:'+obj+',type:'+obj.type);
	}
	if(obj){
		return obj;
	}
	
	
	
	if (doc.layers && doc.layers != undefined)
	{
	 	obj = doc.layers[name];
	 	//alert('layers:'+name+',obj:'+obj+',type:'+obj.type);
	}
	
	
	
	
	
	if(!obj){
		//alert(name + '°´Ã¼¸¦ Ã£À»¼ö ¾ø½À´Ï´Ù.-getObj()');
	}
	
	return obj;
  
}

/*
 * ÁöÁ¤ÇÑ °´Ã¼¿¡ Æ÷Ä¿½º¸¦ À§Ä¡½ÃÅ´
 */
function setFocus(name){
	setFocus(name, false);
}

function setFocus(name, doc){
	if(!doc){
		doc = document;
	}
	
	var obj = getObj(name,doc);
	if(obj){
		obj.focus();
	}
}

function visible(obj,flag)
{
	if (!DHTML) return;
	if(!obj)
		return;
	if(typeof(obj) == 'string'){
		obj = getObj(obj);
	}
	if(obj && typeof(obj) == 'object'){
		obj.style.visibility = (flag) ? 'visible' : 'hidden';
	}
}

var texttop = 400;

function move(obj, amount)
{
	if (!DHTML) return;

	if(!obj)
		return;
	if(typeof(obj) == 'string'){
		obj = getObj(obj);
	}
	if(obj && typeof(obj) == 'object'){
		top = obj.style.top;
		top += amount;
		obj.style.top = top;
	}
}


function changeColor(obj, col)
{
	if (!DHTML) return;
	if(!obj)
		return;
	if(typeof(obj) == 'string'){
		obj = getObj(obj);
	}
	if(obj && typeof(obj) == 'object'){
		obj.style.color = col;
	}
}

function setCursor(obj, cursor)
{
	if (!DHTML) return;
	if(!obj)
		return;
	if(typeof(obj) == 'string'){
		obj = getObj(obj);
	}
	if(obj && typeof(obj) == 'object'){
		obj.style.cursor = cursor;
	}
}

function showObj(obj){
	changeStyle(obj, 'display', 'inline');
}

function hideObj(obj){
	changeStyle(obj, 'display', 'none');	
}

function isVisible(obj){
	var display = getStyle(obj, 'display');
	return (display == 'inline')? true : false;
}

function changeStyle(obj, styleName, value)
{
	obj = getObj(obj);
	
	if(obj && typeof(obj) == 'object'){
		//alert(obj.style[styleName]);
		if(obj.style[styleName]){
			obj.style[styleName] = value;
		}
	}
}

function getStyle(obj, styleName)
{
	obj = getObj(obj);
	
	if(obj && typeof(obj) == 'object'){
		//alert(obj.style[styleName]);
		if(obj.style[styleName]){
			return obj.style[styleName];
		}
	}
	
	return false;
}


function changeImage(obj, image)
{
	if (!DHTML) return;
	if(!obj)
		return;
	if(typeof(obj) == 'string'){
		obj = getObj(obj);
	}
	if(obj && typeof(obj) == 'object'){
		obj.src = image;
	}
}

// Copyright ?2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js
function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");
	
	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match('/\b[\w-.]+(\s*\{)/g');
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of 
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}


// setStyleById: given an element id, style property and 
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}
	
	// try styleSheets
	var sheets = document.stylesheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClass(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = document.stylesheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}

	return null;
}

// setStyleByTag: given an element type, style property and 
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
		var sheets = document.stylesheets;
		if(sheets.length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				if(rules.length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
						ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								s[p] = v;
							}			
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

// getStyleByTag: given an element type and style property, return
// the property's value
// args:
//  e - element type
//  p - property
function getStyleByTag(e, p) {
	var sheets = document.stylesheets;
	if(sheets.length > 0) {
		for(var i = 0; i < sheets.length; i++) {
			var rules = sheets[i].cssRules;
			if(rules.length > 0) {
				for(var j = 0; j < rules.length; j++) {
					var s = rules[j].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[j] == e) {
							return s[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((s[p] != "") && (s[p] != null)) &&
						   (rules[j].selectorText == e)) {
							return s[p];
						}
					}

				}
			}
		}
	}

	// if we don't find any style sheets, return the value for the first
	// element of this type we encounter without a CLASS or STYLE attribute
	var elements = document.getElementsByTagName(e);
	var sawClassOrStyleAttribute = false;
	for(var i = 0; i < elements.length; i++) {
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if((node.attributes.item(j).nodeName == 'class') ||
			   (node.attributes.item(j).nodeName == 'style')){
			   sawClassOrStyleAttribute = true;
			}
		}
		if(! sawClassOrStyleAttribute) {
			return elements.item(i).style[p];
		}
	}
}


// explode string
function explodeStr(separator, str)
{
	if(!separator || !str){
		return false;
	}

	//alert("sep:"+separator+", str:" + str);

	var aryStr = new Array(0);
	var startPos = 0;
	var endPos = 0;
	var subStr = '';
	var lenStr = str.length;
	var lenSep = separator.length;
	
	do{
		endPos = str.indexOf(separator, startPos);
		if(endPos > 0){
			subStr = str.substr(startPos, endPos - startPos);
			if(subStr != separator){
				aryStr.push(subStr);
				
				startPos = endPos + lenSep;
			}
		}
		else if(startPos < lenStr){
			subStr = str.substr(startPos);
			if(subStr != separator){
				aryStr.push(subStr);
			}
		}
	}
	while(endPos > 0);

	return (aryStr.length > 0)? aryStr : false;
}

/*
 * Timer Start
 */
function StartTimer(funcName,milliSec) {
	if(!funcName){
		return false;
	}
	
	if(milliSec == false || milliSec == 0){
		milliSec = 1000;
	}
	
	//alert('start timer');
   timerID  = setTimeout(funcName, milliSec);
   
   return timerID
}

/*
 * Timer Remove
 */
function StopTimer(timerID) {
   if(timerID) {
      clearTimeout(timerID);
   }
}


/////////////////////////////////////////////////////////////////////////
// user script function

// ÇÃ·¡½Ã ÇÔ¼ö
function flash(w, h, u, t)
{
	//alert(u);
	html = '';
	html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="daum_pr" width="' + w + '" height="' + h + '">';
	html += '<param name="movie" value=" '+ u + '">';
	html += '<param name="loop" value="true">';
	html += '<param name="menu" value="false">';
	html += '<param name="quality" value="high">';
	html += '<param name="bgcolor" value="#ffffff">';
	if(t == "y")
	{
		html += '<param name="wmode" value="transparent">';
	}
	html += '<embed src="' + u + '"loop="true" menu="false" quality="high" wmode="transparent" bgcolor="#000000" width="'+w+'" height="'+h+'" name="daum_pr" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="' +  w + '" height="' + h + '"><\/embed>';
	html += '<\/object>';
	document.write(html);
	
/*	document.write("<object classid='clsid: D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + w + "' height='" + h + "'>");
	document.write("  <param name='movie' value='" + u + "'>");
	document.write("  <param name='quality' value='high'>");

	if(t == "y")
	{
		document.write("  <param name='wmode' value='transparent'>");
	}
	document.write("  <embed type='application/x-shockwave-flash' src='" + u + "' width='" + w + "' height='" + h + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>");
	document.write("</object>");
	*/
	
}

// left_menu init 
function menu_init(page_path){
	if(page_path == ''){
		var page_path = ".";
	}

// Left ¸Þ´º ·Ñ¿À¹ö °øÅë(ÀÌ¹ÌÁö³×ÀÓÀ» °¢ ÆÄÆ® img Æú´õ¾È¿¡ "'left_menu' + ¹øÈ£"·Î ÅëÀÏ, µû¶ó¼­ ¸Þ´º°¡ °¡Àå ¸¹Àº ÆÄÆ®¸¦ ±âÁØÀ¸·Î °¹¼ö¸¸ ¸ÂÃçÁÖ¸é µÊ)
	left_menu1_on = new Image();
	left_menu1_on.src = page_path + "/img/left_menu1_.gif";
	left_menu1_off = new Image();
	left_menu1_off.src = page_path + "/img/left_menu1.gif";

	left_menu2_on = new Image();
	left_menu2_on.src = page_path + "/img/left_menu2_.gif";
	left_menu2_off = new Image();
	left_menu2_off.src = page_path + "/img/left_menu2.gif";

	left_menu3_on = new Image();
	left_menu3_on.src = page_path + "/img/left_menu3_.gif";
	left_menu3_off = new Image();
	left_menu3_off.src = page_path + "/img/left_menu3.gif";

	left_menu4_on = new Image();
	left_menu4_on.src = page_path + "/img/left_menu4_.gif";
	left_menu4_off = new Image();
	left_menu4_off.src = page_path + "/img/left_menu4.gif";

	left_menu5_on = new Image();
	left_menu5_on.src = page_path + "/img/left_menu5_.gif";
	left_menu5_off = new Image();
	left_menu5_off.src = page_path + "/img/left_menu5.gif";

	left_menu6_on = new Image();
	left_menu6_on.src = page_path + "/img/left_menu6_.gif";
	left_menu6_off = new Image();
	left_menu6_off.src = page_path + "/img/left_menu6.gif";
}

// left menu focus off
function inact(imgName)
{
//	imgOn = eval(imgName + "_on.src");
//	document[imgName].src = imgOn;

	
	obj = getObj(imgName);
	if(obj){
		
		var oldName = obj.src;
		var ext = oldName.substring(oldName.length-4);
		var name = oldName.substring(0,oldName.length-4);
		
		//alert("inact:"+name);
		var pos = oldName.indexOf("_" + ext);
		if(pos > 0){
			return;
		}
		var newName = name + "_" + ext;
		obj.src = newName;
		//alert(newName);
		
		setCursor(obj,'hand');
		
	}
 	
}

// left menu focus on
function act(imgName)
{
//	imgOff = eval(imgName + "_off.src");
//	document[imgName].src = imgOff;

	obj = getObj(imgName);
	if(obj){
		
		var oldName = obj.src;
		var ext = oldName.substring(oldName.length-4);
		
		//alert("inact:"+name);
		var pos = oldName.indexOf("_" + ext);
		if(pos <= 0){
			return;
		}
		
		var name = oldName.substring(0,oldName.length-5);
		var newName = name + ext;
		obj.src = newName;
		//alert(newName);
	}

}

// Å×½ºÆ® ¼±ÅÃ¸®½ºÆ®¸¦ ¼¼ÆÃ(¿©¼º °Ç°­Ã¼Å©,¾ö¸¶¸¦ À§ÇÑ Ã¼Å©,´ÙÀÌ¾îÆ® Ã¼Å©,¿î¼¼ Ã¼Å©)
function init_sel_test(page_code, selName){
	var aryLink = false;
	var aryTitle = false;

	page_code = new String(page_code);
	
	// ¿©¼º °Ç°­Ã¼Å©
	if(!aryLink){
		var aryWomanLink = new Array("test_mens","test_bio","pp_period","test_ovul","test_set","test_prev","test_match","pp_birth");
		var aryWomanTitle = new Array("³» »ý¸®°Ç°­Ã¼Å©","»ý¸®¹ÙÀÌ¿À¸®µë","»ý¸®ÁÖ±â°è»ê","¹è¶õÀÏ Å×½ºÆ®","»ý¸®¿¹Á¤ÀÏ","³ª¸¸ÀÇ ÇÇÀÓ¹ý","Ç÷¾×Çüº° ¼Ó±ÃÇÕ ¿¬¾Ö","¾ç·Â/À½·Â »ýÀÏº¯È¯");
		
		for(i = aryWomanLink.length - 1; i >= 0; i--){
			if(page_code.indexOf(aryWomanLink[i]) >= 0){
				aryLink = aryWomanLink;
				aryTitle = aryWomanTitle;
				//alert('woman:'+i);
				break;
			}
		}
	}

	// ¾ö¸¶¸¦ À§ÇÑ Ã¼Å©
	if(!aryLink){
		var aryMomLink = new Array("test_week","test_birth","test_btype","test_luck","test_size");
		var aryMomTitle = new Array("ÀÓ½ÅÁÖ¼ö°è»ê","Ãâ»ê¿¹Á¤ÀÏ°è»ê","¾Æ±âÇ÷¾×ÇüÃ¼Å©","¿ì¸®¾ÆÀÌ ¿î¼¼","¿¹»óÅ°Ã¼Å©");
		for(i = aryMomLink.length - 1; i >= 0; i--){
			if(page_code.indexOf(aryMomLink[i]) >= 0){
				aryLink = aryMomLink;
				aryTitle = aryMomTitle;
				//alert('mom:'+i);
				break;
			}
		}
	}
	
	// ´ÙÀÌ¾îÆ® Ã¼Å©
	if(!aryLink){
		var aryDietLink = new Array("test_fat","test_bdiet","test_hdiet");
		var aryDietTitle = new Array("ºñ¸¸µµÃ¼Å©","Ç÷¾×Çü ´ÙÀÌ¾îÆ® ","º°ÀÚ¸® ´ÙÀÌ¾îÆ®");
		for(i = aryDietLink.length - 1; i >= 0; i--){
			if(page_code.indexOf(aryDietLink[i]) >= 0){
				aryLink = aryDietLink;
				aryTitle = aryDietTitle;
				//alert('diet:'+i);
				break;
			}
		}
	}

	// ¿î¼¼ Ã¼Å©
	if(!aryLink){
		var aryLuckLink = new Array("test_utoday","test_horo","test_ulove","test_ugunghap","test_ulife");
		var aryLuckTitle = new Array("¿À´ÃÀÇ ¿î¼¼","º°ÀÚ¸®¿î¼¼","·¯ºê¿î¼¼","±ÃÇÕ","½Å³âÅäÁ¤ºñ°á");
		for(i = aryLuckLink.length - 1; i >= 0; i--){
			if(page_code.indexOf(aryLuckLink[i]) >= 0){
				aryLink = aryLuckLink;
				aryTitle = aryLuckTitle;
				//alert('luck:'+i);
				break;
			}
		}
	}

	var selObj = getObj(selName);
	if(!selObj){
		return;
	}
	
	// remove elements
	for(i = selObj.options.length - 1; i >= 0; i--){
		 selObj.remove(i);
	}

	// insert elements	
	if(aryLink && aryLink.length > 0){
		for(i = 0; i < aryLink.length; i++){
			var optionObj = document.createElement('option');
			var text = aryTitle[i];
			var link = aryLink[i];
			if(link.indexOf('test') >= 0){
				link += '_form';
			}
			
		    optionObj.text = text;
		    optionObj.value = link;
			if(page_code.indexOf(aryLink[i]) >= 0){
				selectedIndex = i;
			}
			
			//alert(optionObj.text);
			
			//selObj.add(optionObj);
			/*var newElement = document.createElement("option");
			newElement.setAttribute("name",name);
			newElement.setAttribute("id",name);
			newElement.setAttribute("value",value);
			newElement.setAttribute("type","hidden");
			*/
			//selObj.options.appendChild(optionObj);
			selObj.options[i] = optionObj;
		}
		
		selObj.selectedIndex = selectedIndex;
	}

}


// prev view list (»ó´ã½Ç,¿ì¸ÕÆÁ...)
function prev_view(page_code){
	prev_view(page_code,0);
}

function prev_view(page_code,view_no){
	if(!page_code)
		return;
	
	if(!view_no){
		view_no = 0;
	}
	
	if(!view_no || view_no <= 0){
		alert('µî·ÏµÈ ÀÌÀü ³»¿ëÀÌ ¾ø½À´Ï´Ù!');
		return;
	}
	
	link(page_code,'view_no='+view_no);
}

// next view list (»ó´ã½Ç,¿ì¸ÕÆÁ...)
function next_view(page_code){
	next_view(page_code,0);
}

function next_view(page_code,view_no){
	if(!page_code)
		return;

	if(!view_no){
		view_no = 0;
	}
	
	if(!view_no || view_no <= 0){
		alert('µî·ÏµÈ ´ÙÀ½ ³»¿ëÀÌ ¾ø½À´Ï´Ù!');
		return;
	}
	
	link(page_code,'view_no='+view_no);
}


// print
function print_page(page_code)
{
	if(!page_code)
		return;

//	alert("print"+page_code);

	if(window.name == "pp"){
	//	alert("print"+page_code);
		window.print();
	}
	else{
		link("pp_print");
	}
}

// send email
function send_email(page_code){
	send_email(page_code,'email');
}
function send_email(page_code,email_obj)
{
	if(!page_code || !email_obj){
		return;
	}

	alert('ÁË¼ÛÇÕ´Ï´Ù! ¼­ºñ½º ÁØºñÁßÀÔ´Ï´Ù.');
	return;
	
	email = check_input_value(email_obj, 'email', '', '', 'ÀÌ¸ÞÀÏ', true);
	if(!email){
		//alert();
		return;
	}
//	alert("send_email"+page_code);

	if(window.name == "pp"){
	//	alert("send_email"+page_code);
		myform.submit();
	}
	else{
		link("pp_email", "page_code="+page_code+"&email="+email);
	}
}




/*
 * ÀÔ·Â»óÀÚ¿¡¼­ ÀÔ·Â¹®ÀÚ¸¦ Ã¼Å©ÇÏ¿© ¼³Á¤µÈ ¹®ÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¸é Æ÷Ä¿½º¸¦ ´ÙÀ½À¸·Î ÀÌµ¿½ÃÅ´    
 */
function checkLength(curr,next,maxLen){
	if(!curr){
		return;
	}
	
	curr = getObj(curr);

	next = getObj(next);
	
	if(!curr || !curr.value){
		return;
	}
	
	var value = String(curr.value);
	if(value && value.length >= maxLen){
		if(next){
			next.focus();
		}
	}
}

/*
 * Æù¹øÈ£ ÀÔ·ÂÇÊµå(phone1,phone2,phone3)¸¦ Ã¼Å©ÇÏ¿© ÀÔ·ÂµÈ ÀüÃ¼ Æù¹øÈ£¸¦ ÀÐ¾î¿È   
 */
function set_phone_num(phone1,phone2,phone3,phone_num){

	var num1 = '010';
	var num2 = '';
	var num3 = '';
	if(phone_num){
		num1 = phone_num.substr(0,3);
		num2 = phone_num.substr(3,phone_num.length - 7);
		num3 = phone_num.substr(phone_num.length-4,4);	

		//alert('num:'+phone_num+',num1:'+num1+',num2:'+num2+',num3:'+num3);					
	}
	
	set_value(phone1, num1);
	set_value(phone2, num2);
	set_value(phone3, num3);

	return;
/*	
	var obj1 = getObj(phone1);
	var obj2 = getObj(phone2);
	var obj3 = getObj(phone3);

	if(obj1 && !obj2 && !obj3){
		if(obj1.value){
			obj1.value = phone_num;
		}
	}
	else if(obj1 && obj2 && obj3){
		var num1 = '010';
		var num2 = '';
		var num3 = '';
		if(phone_num){
			num1 = phone_num.substr(0,3);
			num2 = phone_num.substr(3,phone_num.length - 7);
			num3 = phone_num.substr(phone_num.length-4,4);	

			//alert('num:'+phone_num+',num1:'+num1+',num2:'+num2+',num3:'+num3);					
		}
		
		if(obj1.options){
			for(var i = obj1.options.length - 1; i >= 0; i--){
				if(obj1.options[i].value == num1){
					obj1.selectedIndex = i;
					break;
				}
			}
		}
		else{
			obj1.value = num1;
		}
		obj2.value = num2;
		obj3.value = num3;
	}
	*/
}

/*
 * Æù¹øÈ£ ÀÔ·ÂÇÊµå(phone1,phone2,phone3)¸¦ Ã¼Å©ÇÏ¿© ÀÔ·ÂµÈ ÀüÃ¼ Æù¹øÈ£¸¦ ÀÐ¾î¿È   
 */
function check_phone_num(phone1,phone2,phone3){
	if(!phone1 || !phone2 || !phone3){
		alert('Æù¹øÈ£¸¦ ÁöÁ¤ÇØÁÖ¼¼¿ä');
		return false;
	}
	
	var phone_num;
	var phone_num1;
	var phone_num2;
	var phone_num3;
	
	phone_num1 = get_value(phone1);
	phone_num2 = get_value(phone2);
	phone_num3 = get_value(phone3);
	
	if(!phone_num1){
		alert('Æù¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		setFocus(phone1);
		return false;
	}

	if(!phone_num2){
		alert('Æù¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		setFocus(phone2);
		return false;
	}

	if(!phone_num3){
		alert('Æù¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		setFocus(phone3);
		return false;
	}
		
	if(phone_num1 && phone_num2 && phone_num3){
		phone_num = "" + phone_num1 + phone_num2 + phone_num3
	}
	//alert("phone:"+phone_num);
	
	return phone_num;
}

/*
 * °ü¸®ÇÁ·Î±×·¥ ¿¬°á  
 */
function submit_member(params){
	submit_member(params,false);
}

function submit_member(params, doc){
	
	if(!params){
		return false;
	}
	
	if(!doc){
		doc = document;
	}
	
	var hFrame = getObj( 'memberFrame', doc);
	
	if(hFrame == false){
	//	alert('ÇÁ·¹ÀÓÀ» Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return false;
	}

	var path = doc.location.pathname;
	path = path.replace("index.php","");
	if(!path){
		path = "/";
	} 
	
	var url = 'http://' + doc.location.host + path + 'member.php?' + params;
	//var url = 'http://www.imsin4u.com/web_new/member.php?' + params;
	
	//alert(url);
	
	hFrame.src = url;
	//hFrame.submit();
	
	return;
}

/*
 * member ÇÁ·¡ÀÓÀ» ÃÊ±âÈ­ÇÔ
 */
function init_member(){
	
	var doc = document;
	
	var hFrame = getObj( 'memberFrame', doc);
	
	if(hFrame == false || hFrame == null){
	//	alert('ÇÁ·¹ÀÓÀ» Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return false;
	}
	
	hFrame.src = '';

//	alert(hFrame.src);	
	
	return;
}

/*
 * Æù¹øÈ£·Î ÀÎÁõ¹øÈ£¸¦ »ý¼ºÇÔ   
 */
function get_auth_num(phone_num) {
	
	if(!phone_num){
		return false;
	}
	
	var auth_num = phone_num.substring(phone_num.length - 6,phone_num.length - 2);
	auth_num = '' + (Math.floor(Math.random() * 9) + 1) + phone_num.substring(phone_num.length - 4,phone_num.length - 2) +  + Math.floor(Math.random() * 10) + phone_num.substring(phone_num.length - 2);

	return auth_num;	
}

/*
 * ÀÔ·ÂµÈ Æù¹øÈ£·Î ÀÎÁõ¹øÈ£SMS¸¦ Àü¼ÛÇÔ   
 */
function send_auth_sms(phone_num, auth_num) {
	
	if(!phone_num){
		return false;
	}
	
	submit_member('mode=send_auth_num&phone=' + phone_num + '&auth_num=' + auth_num);
	
	return true;

}

/*
 * ÀÔ·ÂµÈ ÀÎÁõ¹øÈ£ È®ÀÎÇÏ¿© °¡ÀÔÃ³¸®ÇÔ   
 */
function check_auth_sms(phone_num, auth_num,call_func,time_count) {
	
	if(!phone_num){
		return false;
	}
	
	a = "";
	
	submit_member('mode=check_auth_num&phone=' + phone_num + '&auth_num=' + auth_num+ "&call_func=" + call_func + "&time_count=" + time_count + "&host=" + document.location.host + "&a=" + a);
	
	return true;

}



/*
 * ÀÔ·ÂµÈ Æù¹øÈ£·Î ºñ¹Ð¹øÈ£SMS¸¦ Àü¼ÛÇÔ   
 */
function send_pass_sms(phone1,phone2,phone3) {
	
	phone_num = check_phone_num(phone1,phone2,phone3);
	
	if(!phone_num){
		return;
	}
	
	var answer = confirm("ÀÔ·ÂÇÏ½Å ¹øÈ£("+phone_num+")·Î Á¢¼Óºñ¹Ð¹øÈ£¸¦ Àü¼ÛÇÒ±î¿ä?");
	if (!answer){
		return;		
	}

	submit_member('mode=send_pwd&phone=' + phone_num);
	
	return;

}

/*
 *
 */
function send_wap_url(phone1,phone2,phone3,user_data){
	phone_num = check_phone_num(phone1,phone2,phone3);
	if(!phone_num){
		return;
	}
	
	var answer = confirm("ÀÔ·ÂÇÏ½Å ¹øÈ£["+phone_num+"]·Î ·ÎÁîµ¥ÀÌ Á¢¼Ó¹®ÀÚ¸¦ Àü¼ÛÇÒ±î¿ä?");
	if (!answer){
		return;		
	}

	var user_data = get_value('user_data');
	
	submit_member('mode=send_callback&phone=' + phone_num + "&user_data=" + user_data);
	
	return;	
}

// goto link
function link(page_code){
	link(page_code, false);
}

function link(page_code, param)
{
	if(!page_code)
		return;
	if(param == undefined){
		param = '';
	}
	else{
		param += '&';
	}
	
	var prev_code = get_value('page_code');
	
	// DEBUG - checking page_code, param
	//alert("page_code:"+page_code+",param:"+param);
	
	var pos = page_code.indexOf("_");
	var main_code = '';
	if(pos > 0){
		main_code = page_code.substring(0,pos);
	}
	
	if(main_code == "pp"){
		//alert('popup:'+page_code);
		popup(main_code,page_code,param);		
	}
	else if(main_code == "sample"){
		//alert('popup:'+page_code);
		popup(main_code,page_code,param);		
	}
	else{
		var myform = getObj('myForm');
		if(myform){
			if(param && param.length > 0){
				//var aryParam = explodeStr('&', param);
				var aryParam = param.split('&');
				if(aryParam){
					var len = aryParam.length;
					for(i = 0; i < len; i++){
						par = aryParam[i];
						//ary = explodeStr('=',par);
						ary = par.split('=');
						if(ary){
							name = ary[0];
							value = ary[1] ? ary[1] : '';
							//alert("name:"+name+",value:"+value);	
							
							if(name){
								var elem = getObj(name);
								if(elem){
									elem.value = value.toString();
								}
								else{
									var newElement = document.createElement("input");
									newElement.setAttribute("name",name);
									newElement.setAttribute("id",name);
									newElement.setAttribute("value",value);
									newElement.setAttribute("type","hidden");
									
									myform.appendChild(newElement);
								}
							}
						}
					}
				}				

			}		
		
			var len = myform.elements.length;
			for(i = 0; i < len; i++){
				var name = myform.elements[i].name;
				var id = myform.elements[i].id;
				var type = myform.elements[i].type;
				var value =myform.elements[i].value;
				if((id && id != undefined) && (!name || name == undefined)){
					name = id;
					
				}
				
		   		if(name && value && type == 'hidden'){
		   			if(name == 'page_code' || name == 'prev_code'){
		   				continue;
		   			}
		   			
		   			param += name + '=' + value + '&';
		   		}
		   	}
		}
		
		//alert(param);
		//location = '/index.php?page_code=' + page_code + '&' + param + '&prev_code=' + prev_code;
		document.location.href = document.location.pathname + '?page_code=' + page_code + '&' + param + '&prev_code=' + prev_code;
		//alert('bb');
	}
}

// popup
function popup(name,page_code)
{
	popup(name,page_code,'');
}

function popup(name,page_code,param)
{
	if(!page_code)
		return;
	
//	var myform = getObj('myForm');
//	myform.action = page_code;  
//	alert(document.location.pathname);
	var host = document.location.hostname;
	var path = document.location.pathname;
	var url = path +"?page_code=" + page_code + "&" + param;

	if(name == window.name){
		document.location.href = url;
		return this;
	}
	else{
		newWin = window.open(url, name,'left=100,top=10,width=720,height=600,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no');
		newWin.focus();
		return newWin;
	}
}

/*
 * ÀÔ·ÂµÈ Æù¹øÈ£¿Í ºñ¹Ð¹øÈ£·Î º»ÀÎ¿©ºÎ(·Î±×ÀÎ)¸¦ Ã¼Å©ÇÔ  
 */
function login(phone1,phone2,phone3,passwd) {

	phone_num = check_phone_num(phone1,phone2,phone3);
	if(!phone_num){
		return;
	}

	// check passwd
	if(!passwd){
		alert('ºñ¹Ð¹øÈ£¸¦ Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return;
	}
	else{
		passwd = getObj(passwd);
		if(typeof(passwd) == 'object'){
			passwd_no = passwd.value;
		}
	}
	
	if(!passwd_no){
		alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
		
		if(passwd){
			passwd.focus();
		}
		return;
	}

	// check prev_code
	var prev_code = getObj('prev_code');
	if(prev_code){
		if(typeof(prev_code) == 'object'){
			prev_code = prev_code.value;
		}
	}
	else{
		prev_code = 'index';
	}
	submit_member('mode=login&phone=' + phone_num + '&passwd=' + passwd_no + '&prev_code=' + prev_code);

	//document.location.href = './index.php?'+'mode=login&phone=' + phone_num + '&passwd=' + passwd_no + '&prev_code=' + prev_code;

//	submit_member('mode=login&phone=' + phone_num + '&passwd=' + passwd_no);
	
	return;

}

/*
 * ·Î±×¾Æ¿ô ÀÔ·ÂµÈ Æù¹øÈ£¿Í °ü·Ãµ¥ÀÌÅÍ¸¦ Áö¿ò    
 */
function logout(){
	//alert("logout");
	
	var myform = getObj('myForm');
	if(!myform){
		//alert('myFormÀ» Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return;
	}
	
	var elem_list = '';
	var len = myform.elements.length;
	for(i = 0; i< len; i++){
   		if(myform.elements[i].type == 'hidden' && myform.elements[i].name == 'user_data'){
   			myform.elements[i].value = '';
   			break;
		}
   	}

	
   	alert("Á¤»óÀûÀ¸·Î ·Î±×¾Æ¿ô µÇ¾ú½À´Ï´Ù. °¨»çÇÕ´Ï´Ù!");
   	
	//myForm.submit();
	link('index');
}

/*
 * ÀûÁß·ü Åë°èµ¥ÀÌÅÍ ¾÷µ¥ÀÌÆ®
 */
function update_happy_rate(objName){
	if(typeof(objName) == 'Object'){
		objName = objName.name;
	}
	
	submit_member('mode=update_happy_rate&target=' + objName);

	return;
}

/*
 * ÀÔ·ÂµÈ Æù¹øÈ£·Î ¿ùÁ¤¾× ¼­ºñ½º °¡ÀÔÃ³¸®  
 */
function auth_confirm(phone1,phone2,phone3,call_func) {

	phone_num = check_phone_num(phone1,phone2,phone3);
	if(!phone_num){
		return;
	}
	//alert('auth:'+phone_num);
	
	var a = '';
	var obj = getObj('a');
	if(obj && obj.value){
		a = obj.value;
	}
	
	var request = "mode=auth&phone=" + phone_num + "&call_func=" + call_func + "&host=" + document.location.host + "&a=" + a;
	//alert(request);
	
	submit_member(request);
	
	return;

}

/*
 * ÀÔ·ÂÇÑ ±âº»Á¤º¸¸¦  ¾÷µ¥ÀÌÆ®ÇÔ  
 */
function update_info(data){
	update_info(data,false);
}

function update_info(data,next){
	//alert('update_info:' + data);

	if(!data){
		return;
	}
	var obj = getObj('user_data');
	if(!obj){
		return;
	}
	var user_data = obj.value;

	obj = getObj('user_phone');
	var user_phone = '';
	if(obj){
		user_phone = obj.value;
	}
	
	var request = 'mode=update_info&user_phone='+ user_phone + '&data=' + data + '&old_data=' + user_data + '&next=' + next;
	//alert(request);	
	
	submit_member(request);
	
	return;	
}

/*
 * Ã³¸®¿Ï·áÈÄ ÀÌÀüÆäÀÌÁö·Î µ¹¾Æ°¨  
 */
function goto_prev(){
//	var myform = getObj('myForm');
	
//	var page_code = null;
//	var prev_code = myform.prev_code;
	var page_code = get_value('prev_code');
	
//	if(prev_code){
//		page_code = prev_code.value;
//	}
	//alert(page_code);
	
	if(page_code == undefined || !page_code){
		//alert('ÀÌÀüÆäÀÌÁö°¡ ¾ø½À´Ï´Ù. ¸ÞÀÎÆäÀÌÁö·Î ÀÌµ¿µË´Ï´Ù.');
		page_code = 'index';
	}
	
//	var prev_param = myform.prev_param;
//	if(!prev_param){
//		prev_param = '';
//	}
	var param = get_value('prev_param');
	if(param == undefined){
		param = '';
	}
	//alert(param);
	
	//alert('prev_page:'+page_code+',prev_param:'+param);
	
	//link(page_code,param.toString());
	link(page_code);
	
} 

/*
 * Ãë¼Ò½Ã ÀÌÀüÆäÀÌÁö·Î µ¹¾Æ°¨  
 */
function cancel(){
	goto_prev();
} 

//À±³âÀ» Æ÷ÇÔÇÏ¿© °¢ ¿ùÀÇ ³¯ ¼ö °è»êÇÏ´Â ÇÔ¼ö ±× ´ÞÀÇ ¸¶Áö¸· ³¯À» ¸®ÅÏ ÇÑ´Ù
function DaysInMonth(WhichMonth, WhichYear) {
	var DaysInMonth = 31;

	if (WhichMonth == 4 || WhichMonth == 6 || WhichMonth == 9 || WhichMonth == 11) DaysInMonth = 30;
	if (WhichMonth == 2 && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
	if (WhichMonth == 2 && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;

	return DaysInMonth;
}

/*
 * ´Þ·Â¾ÆÀÌÄÜ Å¬¸¯½Ã ÀÛÀº ´Þ·Â Ç¥½Ã   
 */
//  Å¸°Ù, ÀÌº¥Æ® °ªÀ» ³Ö°í ´Þ·ÂÀ» ±×·ÁÁØ´Ù.
// TODO - ´Þ·Â ·ÎÁ÷ ¼öÁ¤  
function open_calendar(syy,smm,starget,event,pat) {
	var bFlag = false;
	var i,j;
	var syy, smm;

    if(smm.substring(0,1) == "0") {
		smm = smm.substring(1,2);
	}

	// ³×ºñ °ÔÀÌ¼Ç ¾Æ´Ï¸é ³¯Â¥Á¤º¸°¡ ¾ø´Ù Á¤º¸¸¦ »ý¼º ÇÑ´Ù.
	if (event != null && pat != null) {   /// ¿À´Ã³¯Â¥ ÀÚµ¿»ý¼ººÎºÐ
		var toDate = new Date();
		syy = toDate.getYear();
		smm = toDate.getMonth() + 1;
		today = toDate.getDate();
	}



	var date = new Date(syy,smm-1,'01');
	var day = 1;
	var trtd = "";

	// ¹è¿­À» ¼±¾ð ÇÑ´Ù.
	var a1 = new Array();
	var a2 = new Array();
	var a3 = new Array();
	var a4 = new Array();
	var a5 = new Array();
	var a6 = new Array();

	// ¹è¿­À» ÃÊ±âÈ­ ÇÑ´Ù.
	for (i = 0 ; i < 7; i++) {
		a1[i] = "";
		a2[i] = "";
		a3[i] = "";
		a4[i] = "";
		a5[i] = "";
		a6[i] = "";
	}

	var aCalenda = new Array();
	var iLastDay = DaysInMonth(smm,syy);							// ¸¶Áö¸· ³¯Â¥¸¦ ±¸ÇÑ´Ù.
	// ÀÌÁß ¹è¿­À¸·Î ¸¸µé¾î ÁØ´Ù.
	for (i = 1 ; i < 7 ; i++) {
		aCalenda[i-1] = eval("a" + i);
	}

	/*
		1ÀÏÀÇ ¿äÀÏ ºÎÅÍ ½ÃÀÛÇØ¼­ ¹øÈ£¸¦ ³Ö´Â´Ù.
		ex) ¸ñ [0][4] = 1 
	*/
	for (i = 0 ;i < 6 ; i++) {
		for (j = 0 ; j < 7; j++) {
			if (i == 0 && j == date.getDay()) {
				bFlag = true;
			}

			if (bFlag == true && day <=iLastDay ) {
				aCalenda[i][j] = day ;
				day += 1;
			}
			else {
				aCalenda[i][j] = "";
			}
		}
	}

	/*
		´ÙÀ½´Þ °ú ÀÌÀü ´Þ °è»ê ÇÏ´Â °÷
	*/
	var sYearPre = "";
	var sYearNex = "";
	var sMonthPre = "";
	var sMonthNex = "";
	

	//syy,smm
	switch(parseInt(smm)) {
		case 1:
			sYearPre = parseInt(syy) - 1;
			sYearNex = syy;

			sMonthPre = 12;
			sMonthNex = 2;
			break;
		case 12:
			sYearPre = syy;
			sYearNex = parseInt(syy) + 1;

			sMonthPre = 11;
			sMonthNex = 1;
			break;
		default:
			sYearPre = syy;
			sYearNex = syy;

			sMonthPre = parseInt(smm) - 1;
			sMonthNex = parseInt(smm) + 1;
			break;
	}
	trtd += "<tr><td colspan=7>";
	trtd += "<table width='100%' height='100%' cellpadding=0 cellSpacing=0><tr bgColor=#ffffff >";
		trtd += "<td width='40' class=txtnormal  heidht='22' align='left' onclick=\"calenda('"+(parseInt(sYearPre)-1)+"','"+sMonthPre+"','"+starget+"')\" style='cursor:hand' title=\"("+(parseInt(sYearPre)-1)+"-"+sMonthPre+")\"><img src='./images/date/il_arrow_bottom.gif'><img src='./images/date/il_arrow_bottom.gif'></td> " ;
		trtd += "<td class=txtnormal  heidht='22' align='center' onclick=\"calenda('"+sYearPre+"','"+sMonthPre+"','"+starget+"')\" style='cursor:hand' title=\"("+sYearPre+"³â-"+sMonthPre+"¿ù)\"><img src='./images/date/il_arrow_bottom.gif'></td>" ;
		trtd += "<td class=txtnormal align='center'>"+syy+"³â"+parseInt(smm)+"¿ù</td>";
		trtd += "<td class=txtnormal align='center' onclick=\"calenda('"+sYearNex+"','"+sMonthNex+"','"+starget+"')\" style='cursor:hand' align=left title=\"("+sYearNex+"-"+sMonthPre+")\"><img src='./images/date/il_arrow2_bottom.gif'></td>";
		trtd += "<td width='40' onclick=\"calenda('"+(parseInt(sYearNex)+1)+"','"+sMonthNex+"','"+starget+"')\" style='cursor:hand' align=right title=\"("+(parseInt(sYearNex)+1)+"-"+sMonthPre+")\"><img src='./images/date/il_arrow2_bottom.gif'><img src='./images/date/il_arrow2_bottom.gif'></td></tr></table>";
	trtd += "</td></tr>";
	/*
		¿äÀÏÀ» ³Ö¾î ÁØ´Ù.
	*/
	trtd += "<TR bgColor=#ffffff> <TD colspan=7><IMG height=20 src='./images/date/il_carendar_tit01.gif' width=177></TD></TR>";

	/*
		tr td¸¦ Æ÷ÇÔÇÑ ½ºÆ®¸µÀ» ¸¸µç´Ù.
	*/
	for ( i = 0 ; i < 6 ; i++) {
		trtd += "<tr bgColor=#ffffff>"
		for ( j = 0; j < 7 ; j++) {
			if (aCalenda[i][j] == "") {
				var sHandCursor = "";
			}
			else {
				var sHandCursor = "style='cursor:hand'";
			}

			
			trtd += "<td  vAlign=bottom align=right class=txtnormal width='25' heidht='22' onclick=\"parent.inputDate('"+syy+"','"+smm+"','"+aCalenda[i][j]+"','"+starget+"')\" "+sHandCursor+">" ;
			if (j == 0 || j== 6 || today == aCalenda[i][j]) {
				if ( j == 0 || today == aCalenda[i][j]) {
					trtd += "<font color=red>";
				}
				else {
					trtd += "<font color=blue>";
				}
			}
			trtd += aCalenda[i][j];

			if (j == 0 || j== 6 || today == aCalenda[i][j]) {
				trtd += "</font>";
			}

			trtd +="</td>" ;
		}
		trtd += "</tr>"
	}

	
		
	var	str = 
	" <html><head><style type='text/css'>table { border: none } img { border: none } td { font-size: 9px; } : " +
	" .screen { font-family: µ¸¿òÃ¼; font-size: 19pt; color: #000000; line-height: 16px; } </style>	 " +
	"</head>" +
	"<body leftmargin='0' topmargin='0'>" +
	"<table width='176' height=160 border=0 cellpadding=0 cellSpacing=1 bgcolor=#e9e9e9>" +
	"<form name='calenda'>" + trtd +
	" <tr bgColor=#ffffff><TD colspan=4></td> " +
	"<td align=left onclick=\"parent.TodayInput('"+starget+"')\" style='cursor:hand'>¿À´Ã</td>" +
	"<TD align=right class=txtnormal onclick=\"parent.CancelClose('"+starget+"');\" style='cursor:hand'>Ãë¼Ò</td><td width='25'></td></tr>" +
	"</form> </table></body></html>";

		/*
			´Þ·Â ³×ºñ °ÔÀÌ¼Ç ½Ã ¸¶¿ì½º ÀÌº¥Æ® À§Ä¡¸¦ ÀÐÀ¸¸é ¾ÈµÈ´Ù.
		*/
		if (event != null) {
			top = event.clientY+document.body.scrollTop;
			left = event.clientX+document.body.scrollLeft;
			//te_top = document.body.scrollHeight ;
			//te_left = document.body.scrollWidth ;
			//alert(top + "/" +left);
		}

//		alert(top+":"+left);
		/*
			´Þ·Â Ã¢ÀÇ¤Ó Å©±â°¡ µµÅ¥¸ÕÆ®º¸´Ù Å©¸é ´Þ·ÂÃ¢ÀÇ À§Ä¡¸¦ ¹Ù²Û´Ù.
		*/
		if (document.body.scrollHeight  < (top + 250)) {
			top = document.body.scrollHeight - 200;
			
		}
		if (document.body.scrollWidth < (left + 250) ) {
			left = document.body.scrollWidth - 200 ;
			
		}

		//document.IFRM_DATE.location.reload();
 		//document.IFRM_DATE.document.write(str);
 		
			document.all.calendadiv.style.visibility = "";
			document.all.calendadiv.style.display= "";

/*
		// Åä±ÛÀÌ´Ù. º¸ÀÌ°í ¾Èº¸ÀÌ°í
		if (event == null || bShowFlag == true) {
			
			document.all.calendadiv.style.visibility = "";
			document.all.calendadiv.style.display= "";

			/// °Ç°­»óÅÂ Ãâ·ÂÃ¢ ÀÖÀ»°æ¿ì
			//document.all.desc.style.visibility= "hidden";
			bShowFlag = false;
			
		}
		else {

			document.all.calendadiv.style.visibility = "hidden";
			document.all.calendadiv.style.display='none';
			/// °Ç°­»óÅÂ Ãâ·ÂÃ¢ ÀÖÀ»°æ¿ì
			//document.all.desc.style.visibility= "";
			bShowFlag = true;
		}


		// ´Þ·Â À©µµ¿ìÀÇ À§Ä¡
		document.all.calendadiv.style.top = top;
		document.all.calendadiv.style.width = 250;
		document.all.calendadiv.style.left = left;
		document.all.calendadiv.style.height = 250;
*/

		//aa = document.all.calendadiv.style.height;
		//bb =document.all.calendadiv.style.width;

		//alert(top+"/"+left+"/"+aa+"/"+bb);

} 
 
 
/*
 * ¸ñ·Ï³»¿ëº¸±â ÆäÀÌÁö·Î ÀÌµ¿ 
 */
function list_view(page_code, view_no){
	list_view(page_code, view_no, false, false, false);
}
function list_view(page_code, view_no, kind, search){
	list_view(page_code, view_no, kind, search, false);
}
function list_view(page_code, view_no, kind, search, board_page){

//	var kind = get_value(kind_obj);
//	var search = get_value(search_obj);
	
	if(!view_no || view_no <= 0){
		alert('µî·ÏµÈ ³»¿ëÀÌ ¾ø½À´Ï´Ù!');
		return;
	}

	if(kind == undefined){
		kind = '';
	}
	if(search == undefined){
		search = '';
	}

	//alert('view_no='+view_no+'&kind='+kind+'&search='+search);
	
	link(page_code, 'view_no='+view_no+'&kind='+kind+'&search='+search+'&board_page='+board_page);

	return;
}
  
/*
 * ÇØ´ç ¸ñ·Ï¸®½ºÆ® ÆäÀÌÁö·Î ÀÌµ¿  
 */
function list_page(page_code){
	list_page(page_code, 1, false, false);
}  

function list_page(page_code, view_no, kind, search){

	if(kind == undefined){
		kind = '';
	}
	if(search == undefined){
		search = '';
	}
	
	//alert('view_no='+view_no+'&kind:'+kind+',search:'+search);
	
	link(page_code,'view_no='+view_no+'&kind='+kind+'&search='+search);
	
	return;
	
}

/*
 * °Ë»ö ¸ñ·Ï¸®½ºÆ® º¸±â ÆäÀÌÁö·Î ÀÌµ¿ 
 */
function list_search(page_code){
	list_search(page_code, false, false);
}  

function list_search(page_code, kind_obj, search_obj){
	var kind = get_value(kind_obj); // Å×¸¶ÄÚµå
	var search = get_value(search_obj); // ÀÔ·Â°Ë»ö¾î
	
	if(kind == undefined){
		kind = '';
	}
	if(search == undefined){
		search = '';
	}
	
	//alert('kind:'+kind+',search:'+search);
	
	link(page_code,'kind='+kind+'&search='+search);
	return;
}

/*
 * ¸ñ·Ï¸®½ºÆ® ÇÏ´Ü ³»ºñ°ÔÀÌ¼Ç Ãâ·Â  
 */
function set_list_nevi(nevi_name, page_no, total_page, step_count, page_code, kind, search){
//	alert(page_no+','+total_page+','+step_count+','+page_code+','+kind+','+search);

	var nevi = getObj(nevi_name);
	if(!nevi){
		return;
	}
	
	page_no = new Number(page_no);
	total_page = new Number(total_page);
	step_count = new Number(step_count);
	if(page_no == 0){
		page_no = 1;
	}
	
	if(kind == undefined){
		kind = '';
	}
	if(search == undefined){
		search = '';
	}

	var first_no = Math.floor((page_no-1)/step_count) * step_count + 1;
	var end_no = first_no + step_count - 1;	
	if(end_no > total_page){
		end_no = total_page;
	}
	var prev_no = first_no - step_count;	
	if(prev_no <= 0){
		prev_no = first_no;
	}
	var next_no = first_no + step_count;	
	if(next_no > total_page){
		next_no = first_no;
	}
	
	//alert(page_no+','+total_page+','+step_count+','+first_no+','+end_no+','+prev_no+','+next_no);
	
	var neviHTML = '';
	neviHTML += '<table cellspacing="0" cellpadding="0">';
	neviHTML += '  <tr>';
	
	// first button
	neviHTML += '    <td style="padding-right: 4px">';
	if(page_no > 1){
		neviHTML += '<a href="javascript:list_page(\''+page_code+'\',1,\''+kind+'\',\''+search+'\')" onfocus="this.blur()">';
	}
	neviHTML += '<img src="./images/bdbtn_first.gif">';
	if(page_no > 1){
		neviHTML += '</a>';
	}
	neviHTML += '</td>';
	
	// prev button
	neviHTML += '    <td style="padding-right: 4px">'
	if(prev_no != first_no){
		neviHTML += '<a href="javascript:list_page(\''+page_code+'\','+(prev_no)+',\''+kind+'\',\''+search+'\')" onfocus="this.blur()">';
	}
	neviHTML += '<img src="./images/bdbtn_prev.gif">';
	if(next_no != first_no){
		neviHTML += '</a>';
	}
	neviHTML += '</td>';
	
	// number link
	for(var i = first_no; i <= end_no; i++){
		neviHTML += '<td class="count">';
		if(i == page_no){
			neviHTML += '<b>';
		}
		else{
			neviHTML += '<a href="javascript:list_page(\''+page_code+'\','+(i)+',\''+kind+'\',\''+search+'\')" onfocus="this.blur()">';
		}

		neviHTML += i;

		if(i == page_no){
			neviHTML += '</b>';
		}
		else{
			neviHTML += '</a>';
		}
		neviHTML += '</td>';
	}

	// next button
	neviHTML += '    <td style="padding-right: 4px">'
	if(next_no != first_no){
		neviHTML += '<a href="javascript:list_page(\''+page_code+'\','+(next_no)+',\''+kind+'\',\''+search+'\')" onfocus="this.blur()">';
	}
	neviHTML += '<img src="./images/bdbtn_next.gif">';
	if(next_no != first_no){
		neviHTML += '</a>';
	}
	neviHTML += '</td>';
	
	// last button
	neviHTML += '    <td style="padding-right: 4px">';
	if(page_no < total_page){
		neviHTML += '<a href="javascript:list_page(\''+page_code+'\','+(total_page)+',\''+kind+'\',\''+search+'\')" onfocus="this.blur()">';
	}
	neviHTML += '<img src="./images/bdbtn_last.gif">';
	if(page_no < total_page){
		neviHTML += '</a>';
	}
	neviHTML += '</td>';

	neviHTML += '  </tr>';
	neviHTML += '</table>';

//	alert(neviHTML);
	
//	document.write(neviHTML);
	if(nevi){
		nevi.innerHTML = neviHTML;
	}
} 


/*
 * ÁöÁ¤ÇÑ ÆûÀÇ ÀÔ·Â¶õÀÇ ³»¿ëÀ» ÃÊ±âÈ­ ½ÃÅ´  
 */
function reset_form(forName){
	
	var myform = getObj(forName);
	if(!myform){
		alert(forName + 'À» Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return;
	}
	
	var elem_list = '';
	var len = myform.elements.length;
	for(i = 0; i< len; i++){
		set_value(myform.elements[i], '');
		/*elem_type = myform.elements[i].type;
		if(elem_type == 'text' || elem_type == 'password'){
			myform.elements[i].value = '';		
		}*/
   	}

	return;	
}

/*
 * »õ·Î¿î hidden °´Ã¼¸¦ »ý¼ºÇÔ
 */
function insert_hidden(name, value){
	insert_hidden(name, value, false);
}

function insert_hidden(name, value, doc){
	if(!doc){
		doc = document;
	}
	
	if(name){
		var elem = getObj(name);
		if(elem){
			elem.value = value;
		}
		else{
			var newElement = doc.createElement("input");
			newElement.setAttribute("name",name);
			newElement.setAttribute("value",value);
			newElement.setAttribute("type","hidden");

			var myform = getObj('myForm');
			if(myform){
				myform.appendChild(newElement);
			}
		}
	}
	
}

/*
 * Æ¯Á¤¹®ÀÚ¿­À» ÁöÁ¤ÇÑ ¹®ÀÚ¿­·Î º¯È¯ÇØ¼­ ¹ÝÈ¯  
 */
function replace_str(str, search, change){
	if(!str || !search){
		return str;
	}
	
	if(!change){
		change = '';
	}
	
	var pos = 0;
	var start = 0;
	var output = '';
	do{
		pos = str.indexOf(search, start);
		if(pos < 0){
			output += str.substr(start);
			
			break;
		}
		else{
			//alert('start:'+start+',pos:'+pos+','+page.substr(start, pos));
			output += str.substr(start, pos - start) + change;
			
			start = pos + search.length;
		}
	}while(pos >= 0);
	
	//alert(output);
	
	return output;
} 

/*
 * ÁöÁ¤ÇÑ °´Ã¼ÀÇ °ªÀ» ¼³Á¤ÇÔ 
 */ 
function set_value(objName, value){
	return set_value(objName, value, false);
}

function set_value(objName, value, doc){
	//alert('set_value('+objName+',' + value+','+doc+')');

	if(!value || value == undefined){
		value = '';
	}

	if(!doc || doc == undefined){
		doc = document;
	}

	var obj = getObj(objName, doc);
	
	if(!obj || obj == undefined){
		//alert("obj is null");
		return;
	}
		
	if(obj.type == undefined){
		var objLength = obj.length;
		if(objLength != undefined){
			//alert('obj length:'+objLength);
			if(obj[0].checked != undefined){ // set radio multi buttons  
				var selObj;
				if(!value){
					selObj = obj[0];
				}
				for(var i = 0; i < objLength; i++) {
					//alert('index:'+i+',checked='+obj[i].checked);
					obj[i].checked = false;
					if(obj[i].value == value.toString()) {
						selObj = obj[i];
						break;
					}
				}
				if(selObj){
					selObj.checked = true;
				}
			}	
		}
	}
	else if(obj.type == 'radio' || obj.type == 'checkbox'){ // set radio button
		//alert('radio or checkbox');
		/*for (var i in obj) {      
			if (obj[i].value == value.toString()) {  
				alert('index:'+i+',checked='+obj[i].checked);       
				obj[i].checked=true;      
			}
			else if (obj[i].value != value.toString()) {         
				obj[i].checked=false;      
			}
		}
		*/
		var objLength = obj.length;
		if(objLength != undefined){
			//alert('radio - obj length:'+objLength);
			if(obj[0].checked != undefined){ // set radio multi buttons  
				var selObj;
				if(!value){
					selObj = obj[0];
				}
				for(var i = 0; i < objLength; i++) {
					//alert('index:'+i+',checked='+obj[i].checked);
					obj[i].checked = false;
					if(obj[i].value == value.toString()) {
						selObj = obj[i];
						break;
					}
				}
				if(selObj){
					selObj.checked = true;
				}
			}	
		}
		else if(value.toString() == '1' || value.toString() == 'true'){
			obj.checked = true;
		}
		else if(value.toString() == '0' || value.toString() == 'false'){
			obj.checked = false;
		}
		else {
			obj.checked = (obj.value == value.toString());
			//obj.value = value.toString();
		}
		
		
	}
	else if(obj.options != undefined){ // set select options 
		//alert('options - obj length:'+obj.options.length);
		var index = 0;
		for(var i = obj.options.length - 1; i >= 0; i--){
			if(obj.options[i].value == value.toString()){
				index = i;
				break;
			}
		}
		obj.selectedIndex = index;
	}
	else if(obj.value != undefined){ // set etc object  
		//alert("last - " + obj.value);
		obj.value = value.toString();
	}
}
  

/*
 * ¸ÖÆ¼¼¿·¢Æ® °´Ã¼¿¡ °ªÀ» ¼³Á¤ÇÔ  
 */   
function set_multi_value(objName, value){
	set_multi_value(objName, value, false);
}

function set_multi_value(objName, value, doc){

	if(!value){
		value = '';
	}
	else{
		aryValue = value.split('|');		
	}
	
	if(!doc){
		doc = document;
	}

	var obj = getObj(objName, doc);
	if(!obj){
		return;
	}
	
	var objLength = obj.length;
	if(objLength != undefined){
		for(var i = 0; i < objLength; i++) {
			obj[i].checked = false;

			if(value){
				for(var j = aryValue.length - 1; j >= 0; j--) {
					if(obj[i].value == aryValue[j]){
						obj[i].checked = true;
						break;		
					}
				}
			}
		}
	}
	
	return;
}


/*
 * ÁöÁ¤ÇÑ °´Ã¼ÀÇ °ªÀ» °¡Á®¿È   
 */ 
function get_value(objName){
	return get_value(objName, false);
}

function get_value(objName, doc){
	//alert('get_value('+objName+','+doc+')');

	if(!doc || doc == undefined){
		doc = document;
	}

	var obj = getObj(objName, doc);
	if(!obj || obj == undefined){
		
		return false;
	}
	
	//alert('get_value('+obj.value+','+obj.type+','+doc+')');
	
	if(obj.type == undefined){
		var objLength = obj.length;
		if(objLength != undefined){
			//alert('obj length:'+objLength);
			if(obj[0].checked != undefined){ // set radio multi buttons  
				for(var i = 0; i < objLength; i++) {
					//alert('index:'+i+',checked='+obj[i].checked);
					if(obj[i].checked == true) {
						return obj[i].value;
					}
				}
			}	
		}
	}
	else if(obj.type == 'checkbox'){ // set radio button
		//alert(obj.length);
		if(obj.value){
			return (obj.checked? obj.value : false);
		}
		else{
			return (obj.checked? true : false);
		}
	}
	else if(obj.type == 'radio'){ // set radio button
		//alert(obj.length);
		return get_radio_value(obj,doc);
	}
	else if(obj.type == 'select-multiple'){ // set list 
		var myArray = new Array();
		for(var x=0; x < obj.length; x++) 
			if(obj[x].selected == true)
				myArray[myArray.length] = obj[x].value;
		return myArray;

	}
	else if(obj.options != undefined){ // set select options 
		return obj.options[obj.selectedIndex].value;
	}
	else if(obj.value != undefined){ // set etc object  
		//alert(obj.value);
		return obj.value;
	}
	
	return '';
}

/*
 * ¸ÖÆ¼¼¿·¢Æ® °´Ã¼¿¡¼­ ¼±ÅÃ°ªÀ» ÀÐ¾î¿È
 */   
function get_radio_value(objName){
	get_radio_value(objName, false);
}

function get_radio_value(objName, doc){
	//alert('get_radio_value('+objName+','+doc+')');

	if(!objName){
		return false;
	}

	if(typeof(objName) == 'object'){
		name0 = (objName.name)? objName.name : objName.id;
	}
	
	if(!doc){
		doc = document;
	}

	if(doc.forms){
		var numForms = doc.forms.length;
		var form;
		var i;
		var j;
		var obj;
		for(i = 0; i < numForms; i++){
			form = doc.forms[i];
			if(!form || form == undefined || !form.elements || form.elements == undefined){
				continue;
			}
			
			var numElem = form.elements.length;
			for(j = 0; j < numElem; j++){
				obj = form.elements[j];
				if(obj.name == name0 && obj.checked == true){
					return (obj.value? obj.value : true);
				}
			}
		}
	}

	var obj = getObj(objName, doc);
	if(!obj){
		return false;
	}
		
	var objLength = obj.length;
	if(objLength != undefined && objLength > 0){
		var value = '';
		for(var i = 0; i < objLength; i++) {
			//alert('index:'+i+',checked='+obj[i].checked);
			if(obj[i].checked == true) {
				if(value.length > 0){
					value += '|';
				}
				value += obj[i].value;
			}
		}
		return value;
	}

	if(obj.value){
		return (obj.checked? obj.value : false);
	}
	else{
		return (obj.checked? true : false);
	}
	
	return false;
	
}

/*
 * ¸ÖÆ¼¼¿·¢Æ® °´Ã¼¿¡¼­ ¼±ÅÃ°ªÀ» ÀÐ¾î¿È
 */   
function get_multi_value(objName){
	get_multi_value(objName, false);
}

function get_multi_value(objName, doc){
	//alert('get_value('+objName+','+doc+')');

	if(!doc){
		doc = document;
	}

	var obj = getObj(objName, doc);
	if(!obj){
		return;
	}
		
	var objLength = obj.length;
	if(objLength != undefined){
		var value = '';
		for(var i = 0; i < objLength; i++) {
			//alert('index:'+i+',checked='+obj[i].checked);
			if(obj[i].checked == true) {
				if(value.length > 0){
					value += '|';
				}
				value += obj[i].value;
			}
		}
		return value;
	}

	return false;
}
  
/*
 * ÀÔ·Â¶õÀÇ µ¥ÀÌÅÍ ÀÔ·Â¿©ºÎ ¹× µ¥ÀÌÅÍÇü½ÄÀ» Ã¼Å©ÇÔ  
 */
function check_input_value(objName, inputType, minValue, maxValue, msgTitle){
	return check_input_value(objName, inputType, minValue, maxValue, msgTitle, false, false);
}

function check_input_value(objName, inputType, minValue, maxValue, msgTitle, valueCheck){
	return check_input_value(objName, inputType, minValue, maxValue, msgTitle, valueCheck, false);
}

function check_input_value(objName, inputType, minValue, maxValue, msgTitle, valueCheck, doc){
	if(doc == false){
		doc = document;
	}
	
	if(!msgTitle){
		msgTitle = '';
	}
	else{
		msgTitle = '['+ msgTitle + ']';
	}
	
	// ÃÖ¼Ò°ª(¼ýÀÚ,±æÀÌ)
	var min = 0;
	if(minValue){
		minValue = new Number(minValue);
		if(minValue){
			min = minValue.valueOf();
		}
	}
	
	// ÃÖ´ë°ª(¼ýÀÚ,±æÀÌ)
	var max = 0;
	if(maxValue){
		maxValue = new Number(maxValue);
		if(maxValue){
			max = maxValue.valueOf();
		}
	}
	
	var obj = getObj(objName, doc);
	if(!obj){
		//alert(objName + '°´Ã¼¸¦ Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return false;
	}
	if(obj.value == undefined){
		alert(objName + 'Àº ÀÔ·Â¶õÀÌ ¾Æ´Õ´Ï´Ù.');
		return false;
	}
	
	var value = obj.value;
	if(!value){
		if(valueCheck){	// ÇÊ¼öÀÔ·Â¶õ ÀÏ¶§¸¸ ¸Þ¼¼Áö Ãâ·Â  
			alert( msgTitle + ' ÀÔ·ÂÀ» È®ÀÎÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}
		else{
			return true;
		}
	}
	
	if(inputType == 'date'){ // check date format 
		
		if(!IsNumeric(value)){
			alert( msgTitle + ' ÀÔ·ÂÀº ¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}

		if(value.length != 8){
			alert( msgTitle + ' ÀÔ·ÂÀº 8ÀÚ¸®¼ýÀÚ¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.(¿¹:20070515)');
			obj.focus();
			return false;
		}	

		date = new Number(value);
		if(min > 0 && date < min){
			alert( msgTitle + ' ÀÔ·ÂÀº [' + min + '] ÀÌ»óÀÇ ³¯Â¥¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}
		if(max > 0 && date > max){
			alert( msgTitle + ' ÀÔ·ÂÀº [' + max + '] ÀÌÇÏÀÇ ³¯Â¥¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}
				
		year = new Number(value.substr(0,4));
		month = new Number(value.substr(4,2));
		day = new Number(value.substr(6,2));
		var valid = true;
		
		if(month <= 0 || month > 12){
			valid = false;
		}
		else {
			if(day <= 0 || day > 31){
				valid = false;
			}
			else{
				if(month == 2){
					if(day > 29){
						valid = false;
					}
					else if( ((year % 100) == 0 && (year % 400) != 0) && day > 28){
						valid = false;
					}
				}
				else if((month == 4 || month == 6 || month == 9 || month == 11) && day > 30){
					valid = false;
				}
			}
		}
		if(!valid){
			alert( msgTitle + ' ÀÔ·Â ³¯Â¥¸¦ È®ÀÎÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}
	}
	else if(inputType == 'email'){ // check email format 
		if(!validEmail(value)){
			alert( msgTitle + ' ÀÌ¸ÞÀÏ Çü½Ä¿¡ ¸ÂÁö ¾Ê½À´Ï´Ù. È®ÀÎÈÄ ´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä.(¿¹:postmaster@samsinsoft.com)');
			obj.focus();
			return false;
		
		}
	}
	else if(inputType == 'number'){ // check number format 
		if(!IsNumeric(value)){
			alert( msgTitle + ' ÀÔ·ÂÀº ¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}
		
		if(min > 0){
			if(min > value){
				alert( msgTitle + ' ÀÔ·ÂÀº [' + min + '] ÀÌ»óÀÇ ¼ýÀÚ¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
				obj.focus();
				return false;
			}
		}
		if(max > 0){
			if(max < value){
				alert( msgTitle + ' ÀÔ·ÂÀº [' + max + '] ÀÌÇÏÀÇ ¼ýÀÚ¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
				obj.focus();
				return false;
			}
		}
		
	}
	else if(inputType == 'phone'){ // check phone format 

		value = replace_str(value, '-', '');
		value = replace_str(value, ' ', '');
		
		if(!IsNumeric(value)){
			alert( msgTitle + ' ÀÔ·ÂÀº ¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}

		if(value.length > 11 || value.substr(0,1) != '0'){
			alert( msgTitle + ' ÀÔ·ÂÀ» È®ÀÎÇØÁÖ¼¼¿ä.');
			obj.focus();
			return false;
		}
		
	}
	else{
		var length = value.length;
		if(min > 0){
			if(min > length){
				alert( msgTitle + ' ÀÔ·ÂÀº [' + min + 'ÀÚ¸®] ÀÌ»óÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.');
				obj.focus();
				return false;
			}
		}
		if(max > 0){
			if(max < length){
				alert( msgTitle + ' ÀÔ·ÂÀº [' + max + 'ÀÚ¸®] ÀÌÇÏ¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
				obj.focus();
				return false;
			}
		}

	}
		
	return value;
}

/*
 * ¼ýÀÚ¿©ºÎ È®ÀÎ  
 */
function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
	var Char;
	
	for (i = sText.length - 1; i >= 0; i--) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			return false;
		}
	}
	return true;
}

/*
 * ÇöÀç ³¯Â¥¹ÝÈ¯(yyyymmdd) 
 */
function nowtime_8(){
	var now=new Date(); // ÇöÀç½Ã°£ °¡Á®¿À±â
	var year=now.getFullYear(); // ³âµµ °¡Á®¿À±â
	var month=now.getMonth() + 1; // ¿ù °¡Á®¿À±â (+1)
	var date=now.getDate(); // ³¯Â¥ °¡Á®¿À±â

	var nowtime = '' + year + (month < 10?'0':'') + month + (date < 10?'0':'') + date;
	//alert(nowtime);
	
	return nowtime;
				
}


/*
 * ÀÌ¸ÞÀÏ ÁÖ¼Ò Æ÷¸Ë È®ÀÎ  
 */
function validEmail(eAddr) 
{ 
//	var lenSuffix = (usEmail) ? 4 : 3;
	var result = false;
	var ndxAt = ndxDot =  0;
	    
	ndxAt  = eAddr.indexOf("@");
	ndxDot = eAddr.lastIndexOf(".") ;
	    
	if ((ndxDot < 0) || (ndxAt < 0)){
	   //alert("Your email address lacks '.' or '@'.\n\nThe format is 'you@dom.suf'"); 
	}
	else if (ndxDot < ndxAt){
	   //chkDot = !( confirm("You entered a 'dot' before the '@'\nAre you sure that is right?") );
	}
//	else if ( (ndxDot2 - 3) <= ndxAt){
	   //alert("You may be missing your domain name.\n\nThe format is 'you@dom.suf'");
//	}
//	else if (tmpStr.length < ndxDot2 + lenSuffix) {
	   //usEmail = !( confirm("You have fewer than 3 characters as a domain suffix.\nAre you sure that is right?") );
//	}
	else {
	    result = true; 
	}
	    
	return result; 
}

/*
 * ³¯Â¥ ½ºÆ®¸µ¿¡ '/'¸¦ Ãß°¡ÇÔ
 */

function add_slash(date){
	return add_slash(date, false, true);
}

function add_slash(date, slash){
	return add_slash(date, slash, true);
}

function add_slash(date, slash, write_flag){
	if(!date){
		return false;
	}

	if(!slash){
		slash = '/';
	}

	if(write_flag == undefined){
		write_flag = true;
	}
	
	date = date.toString();
	if(date.length != 8){
		return date;
	}
	
	var output = date.substr(0,4) + slash + date.substr(4,2) + slash + date.substr(6);

//	alert(output);
	
	if(write_flag){
		document.write(output);
	}
	
	return output;	
}

/*
 * ³»°Ô¸Â´Â Å×½ºÆ® Ã£±â ¿¬°á  
 */
function search_test(age_type,marry_type,sex_type,choice_type){
	var age_type = get_value(age_type);
	var marry_type = get_value(marry_type);
	var sex_type = get_value(sex_type);	
	var choice_type = get_value(choice_type);
	
	var param = '';
	param += 'sel_age_type=' + age_type;
	param += '&sel_marry_type=' + marry_type;
	param += '&sel_sex_type=' + sex_type;
	param += '&sel_choice_type=' + choice_type;
	
	//alert(param);
	link('test_search',param);
}


///////////////////////////////////////////////////////////////////////////
// ±âÅ¸ ÇÔ¼ö    

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function alertFormData(formName){
	
	var myform = getObj(formName);
	if(!myform){
		alert(formName+'À» Ã£À»¼ö ¾ø½À´Ï´Ù.');
		return;
	}
	
	var elem_list = '';
	var len = myform.elements.length;
	for(i = 0; i< len; i++){
   		elem_list += "no:" + i;
   		elem_list += ",type:" + myform.elements[i].type;
   		elem_list += ",name:" + myform.elements[i].name;
   		elem_list += ",value:" + myform.elements[i].value;
   		elem_list += "\r\n";
   	}
   	alert(elem_list);
	
}


function openW(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}

// window resize
function resize(w, h){
	window.resizeTo(w, h);
	//alert("resize:"+w+","+h);
/*	
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    if(w){
	    window.innerWidth = w;
	}
	if(h){
	    window.innerHeight = h;
	}
  } else if( document.documentElement) {
    //IE 6+ in 'standards compliant mode'
    if(document.documentElement.clientWidth && w){
	    document.documentElement.clientWidth = w;
	}
   	if(document.documentElement.clientHeight && h ){
	    document.documentElement.clientHeight = h;
    }
  } else if( document.body ) {
    //IE 4 compatible
    if(document.body.clientWidth && w ){
	    document.body.clientWidth = w;
	}
	if(document.body.clientHeight && h ){
    	document.body.clientHeight = h;
    }
  }
 */
}




function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}	

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
