/*flash menu link*/
var flashLink=new Array();
flashLink[01]="/content/content.php?cont=info01";
flashLink[11]="/content/content.php?cont=info01";
flashLink[12]="/content/content.php?cont=info02";
flashLink[13]="/content/content.php?cont=info03";
flashLink[14]="/content/content.php?cont=info04";
flashLink[15]="/content/content.php?cont=info05";
flashLink[16]="/content/content.php?cont=info06";
flashLink[17]="/content/content.php?cont=info07";

flashLink[02]="/content/content.php?cont=operation01";
flashLink[21]="/content/content.php?cont=operation01";
flashLink[22]="/board/?db=gallery";
flashLink[23]="/content/content.php?cont=operation02";

flashLink[03]="/content/content.php?cont=record01";
flashLink[31]="/content/content.php?cont=record01";
flashLink[32]="/content/content.php?cont=record02";
flashLink[33]="/content/content.php?cont=record03";
flashLink[34]="/content/content.php?cont=record04";

flashLink[04]="/board?db=notice";
flashLink[41]="/board?db=notice";
flashLink[42]="/board?db=news";
flashLink[43]="/board?db=record";
flashLink[44]="/board?db=freeboard";
flashLink[45]="/board?db=news_letter";

flashLink[05]="/content/content.php?cont=support01";
flashLink[51]="/content/content.php?cont=support01";
flashLink[52]="/content/content.php?cont=support02";
flashLink[53]="/content/content.php?cont=support03";

flashLink[60]="/content/content.php?cont=test01";
flashLink[61]="/content/content.php?cont=record01#child";
flashLink[62]="http://www.saferoad-safekids.com";
flashLink[63]="/content/content.php?cont=record01";
flashLink[64]="/content/content.php?cont=record03";

function goFlash(n){
	//alert(n)
	if (!flashLink[n]) return;
	else if (n==62)
	{
		window.open(flashLink[n]);
	}
	

	else location.href=flashLink[n];
}

function menu_OnOver(o,mtd){
	num=o.name.replace("a","");
	if (mtd==1 || num==now_menu)
	{
		img='../_image/common/'+num+'r.gif';
	}
	else 
	{
		img='../_image/common/'+num+'.gif';
	}

	o.src = img;
}

//quick
var quick_limit_top = 0; // ÀüÃ¼ ÆäÀÌÁö ±âÁØ À§ÂÊ ÇÑ°è ÇÈ¼¿ 
var quick_margin_top = 0; // ÇöÀç º¸°í ÀÖ´Â È­¸é ±âÁØ À§ÂÊ ÇÑ°è ÇÈ¼¿
var quick_margin_bottom = 170; // ¾Æ·¡ÂÊ ÇÑ°è ÇÈ¼¿
var quick_speed = 10; // ÇÑ¹ø¿¡ ¿òÁ÷ÀÌ´Â ÇÈ¼¿ °£°Ý
var quick_interval = 10; // ¿òÁ÷ÀÌ´Â ½Ã°£ °£°Ý

setInterval ("quickscroll()", quick_interval);

function quickscroll() {

	qm = document.getElementById ("quickmenu");

	if (qm)	{

		qm_move_y = document.body.scrollTop + quick_margin_top;
		if (qm_move_y < quick_limit_top ) qm_move_y = quick_limit_top;

		nowTop = parseInt(qm.style.top);

		minus = nowTop - qm_move_y;
		if (Math.abs(minus) >= quick_speed ) minus = 0;

		if ( nowTop != qm_move_y) moving = ( nowTop > qm_move_y) ? (quick_speed * -1) : quick_speed;
		else moving = 0;

		nextPos = nowTop + (moving - minus);

		if (nextPos + qm.offsetHeight + quick_margin_bottom > document.body.scrollHeight ) nextPos = document.body.scrollHeight - qm.offsetHeight - quick_margin_bottom;

		qm.style.top = parseInt(nextPos);
	}

}

function imgCbox(N, tabstop)
{
	var objs, cboxes, Img, Span, A;

	if (typeof N == 'undefined') return false;
	if (typeof tabstop == 'undefined') tabstop = true;
	if ((objs=document.getElementsByName(N)) == null) return false;

	for (var i=0; i < objs.length; i++) {
		if (objs[i].tagName.toLowerCase() != "input" || objs[i].type.toLowerCase() != "checkbox") continue;
		
		if (typeof imgCbox.Objs[N] == 'undefined') {
			imgCbox.Objs[N] = new Array;
			imgCbox.ImgObjs[N] = new Array;
		}
		
		var len = imgCbox.Objs[N].length;
		imgCbox.Objs[N][len] = objs[i];
		imgCbox.ImgObjs[N][len] = {};

		// anchor element for tab stop
		A = document.createElement("A");
		if (tabstop) {
			A.href = "javascript:;";
		}
		A.onclick =  new Function("imgCbox.onclick('"+N+"',"+len+")");
		A.style.borderWidth = "0px";
		A.style.cursor = "pointer";

		// for image cache
		Img = document.createElement("IMG");
		Img.src = objs[i].getAttribute("onsrc");
		Img.style.borderWidth = "0px";
		Img.style.display = objs[i].checked?"":"none";
		imgCbox.ImgObjs[N][len]["on"] = Img;
		A.appendChild(Img);

		Img = document.createElement("IMG");
		Img.src = objs[i].getAttribute("offsrc");
		Img.style.borderWidth = "0px";
		Img.style.display = objs[i].checked?"none":"";
		imgCbox.ImgObjs[N][len]["off"] = Img;
		A.appendChild(Img);

		// insert object
		Span = objs[i].parentNode;
		Span.style.display = "none";
		Span.parentNode.insertBefore(A, Span);

	}
}
imgCbox.onclick = function(N, idx) {
	var C = imgCbox.Objs[N][idx];
	var I = imgCbox.ImgObjs[N][idx];

	C.checked = !C.checked;
	if (C.checked) {
		I["on"].style.display = "";
		I["off"].style.display = "none";
	} else {
		I["on"].style.display = "none";
		I["off"].style.display = "";
	}
	
	// fire event
	if (typeof C.onclick != 'undefined' && C.onclick != null) C.onclick();
}
imgCbox.Objs = {};
imgCbox.ImgObjs = {};

//IE PNG use
function setPng24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bpng24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src='';  
    return ''; 
}


function dollyqueenHeight() {
	var h = document.getElementById("navi").scrollHeight + 88;
	var mh = h + 100;

	document.write('<div id="cnt" style="min-height:'+mh+'px;height: auto !important;height:'+h+'px;">');
}

function opensite(url){ if(url != ''){ window.open(url,'sample'); }}



var old=''; 
function menu(name){
	submenu=eval("popupmenu_"+name+".style"); 
	
	if(old!=submenu){ 
		if(old!=''){ 
			old.display='none'; 
		} 
		submenu.display='block'; 
		old=submenu; 
    }else{
		submenu.display='none';
		old='';
	} 
}

function getSchedule(no,event) {
	if (no == 0) msg = "0";
	else var msg = getHttpRequest ("/_include/getSch.php?no="+no);
	onmsg (msg,event);
}

function maincalMove (direction) {
	var datearea = document.getElementById ("minical_date");
	var calarea = document.getElementById ("calarea");

	if (datearea)	{
		date = datearea.innerText.split ("\. ");

		exp = /^0/;
		year = parseInt(date[0].replace(exp,""));
		mon = parseInt(date[1].replace(exp,""));

		if (direction == -1) {
			if ( mon == 1) {	year -= 1; mon = 12;	 }
			else  mon -= 1;
		} 

		if (direction == 1) {
			if ( mon == 12 ) { year += 1;	mon = 1;	}
			else  mon += 1;
		}

		
		if (mon < 10) {
			mon = "0"+mon;
		}

		var msg = getHttpRequest ("/_include/mini_calander.php?year="+year+"&mon="+mon+"&mode=ajax");
		calarea.innerHTML = msg;
		datearea.innerHTML = year+". "+mon+"&nbsp;";
	}
}

function requestTest (no,mode) { // ½Ç±â½ÃÇè ½ÅÃ»

	if (mode == 2)	{
		window.alert ("Á¢¼ö¸¶°¨µÈ ½ÃÇèÀåÀÔ´Ï´Ù\n\n´Ù¸¥ ½ÃÇèÀåÀ» ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À");
		return;
	}

	var w = window.open ("/member/test_request.php?no="+no,"req","width=460px,height=290px,status=no");
	if (w)	w.focus();

}

function requestSafewater (no,mode) { // ½Ç±â½ÃÇè ½ÅÃ»

	if (mode == 2)	{
		window.alert ("Á¢¼ö¸¶°¨µÈ ½ÃÇèÀåÀÔ´Ï´Ù\n\n´Ù¸¥ ½ÃÇèÀåÀ» ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À");
		return;
	}

	var w = window.open ("/content/content.php?cont=safewater_pop&mode=1&no="+no,"req","width=655px,height=700px,status=no,scrollbars=yes");
	if (w)	w.focus();

}

function t_check(f){
	if (!checkBlank(f.content_0,"³»¿ëÀ»")) return false;
}

function goTest(tno) {
	if ( confirm("ÀÚÀü°Å ¸éÇã ÇÊ±â½ÃÇèÀ» ½ÃÀÛÇÏ½Ã°Ú½À´Ï±î?") ) {
		window.open('/main/exec.php?exec_file=member/test_center.php&tno='+tno,'test','width=460 height=550 resizable=no');
		location.reload();
	}
}

function mgPaging(st) { // ¸ÞÀÎ °¶·¯¸® ÆäÀÌÂ¡
	var paging = document.getElementById ("gpaging");
	var current = parseInt (paging.value);
	var recent_gallery = document.getElementById ("recent_gallery");

	if (current + st < 0 ) {
		window.alert ("Ã¹ ÆäÀÌÁöÀÔ´Ï´Ù");
		return;
	}

	var msg = getHttpRequest ("/_include/lateBBS.php?db=gallery&st="+(current+st)+"&mode=ajax");
	if (msg) {
		if (window.showModelessDialog) recent_gallery.filters[0].apply(); // IE Only
		recent_gallery.innerHTML = msg;
		if (window.showModelessDialog) recent_gallery.filters[0].play(); // IE Only
		paging.value = current+st;
	} else {
		window.alert ("¸¶Áö¸· ÆäÀÌÁöÀÔ´Ï´Ù");
		return;
	}
}


/*////////////////////////////////////////////////////////////////////////////////////
//
//	Tulltip Control
//
////////////////////////////////////////////////////////////////////////////////////*/
function onmsg (msg,event) {
	var mbox;
	mbox = document.getElementById ("msgbox");
	event = convevent(event);

	if (msg) {
		if (!mbox) mbox = init_mbox();
		mbox.style.display = "block";
		if (msg == "0") 1;
		else 	mbox.innerHTML = msg;

		_left = event.clientX + document.body.scrollLeft;
		_top = event.clientY + document.body.scrollTop - mbox.offsetHeight - 5;
		if ( _left+document.body.scrollLeft+mbox.offsetWidth+20  > document.body.offsetWidth) _left = _left-mbox.offsetWidth;
		if (  _top < document.body.scrollTop ) _top = event.clientY + document.body.scrollTop + 5;

		mbox.style.left = _left;
		mbox.style.top = _top;
	} else {
		if (mbox) document.body.removeChild (mbox);
	}
}

function init_mbox () {
	mbox = document.createElement ("DIV");
	mbox.id = "msgbox";
	mbox.style.display = "none";
	mbox.style.width = "300px";
	mbox.style.position = "absolute";
	mbox.style.border = "solid 1px pink";
	mbox.style.backgroundColor = "#fff";
	mbox.style.padding = "3px 10px";
	mbox.style.fontWeight = "bold";
	mbox.color = "#000";
	mbox.style.filter = "alpha(opacity=90)";
	mbox.style.opacity = 0.9;
	document.body.appendChild (mbox);

	return mbox;
}

function convevent(ev) { // Explorer ¹× Firebox ÀÌº¥Æ® °´Ã¼ È£È¯
	e = (window.event) ? window.event : ev;
	return e;
}

function chgbanner (img, no, con, type) { // ¹è³Ê¹øÈ£
	var banner = document.getElementById ("eventbanner");

	if ( no ){
		banner.style.cursor = "pointer";
		if ( con ){
			if(type=='http'){
				banner.onclick = function() { window.open(con,"","") }
			}
			else{
				if ( con == "saferoad")
				{
					banner.onclick = function() { window.open("http://www.saferoad-safekids.com","","")}
				}
				else{
					banner.onclick = function() { location.href = "/content/content.php?cont="+con }
				}
			}
		}
		else {
			banner.onclick = function() { location.href = "/content/content.php?cont=event_request&evno="+no }
		}
	}
	else {
		banner.style.cursor = "";
		banner.onclick = "";
	}

	banner.src = "/_data/safeevent/"+img;

}

// Movie Open
function openMovie(dir,name,w,h) {
	var win;
	win = window.open (root_url+"/_data/openMovie.php?dirname="+dir+"&name="+name+"&w="+w+"&h="+h,"Movie","width="+w+"px,height="+h+"px,status=no");

	if ( !win ) window.alert ("À¥ºê¶ó¿ìÀúÀÇ ÆË¾÷¼³Á¤À¸·Î ÀÎÇØ µ¿¿µ»ó ºä¾î¸¦ È£ÃâÇÒ¼ö ¾ø½À´Ï´Ù\\nÆË¾÷ Á¦ÇÑÀ» ÇØÁ¦ÇØ ÁÖ½Ê½Ã¿À");
	else win.focus();
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  ¢Æ   imgOver
//
//**************************************************************************************************************
//
//  Example)
//      <img src="/_image/common/ÀÌ¹ÌÁö.jpg" alt="" title="" onmouseover="imgOver(this)" onmouseout="imgOver(this,'out')">
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function imgOver(imgEl,opt) {
    var src = imgEl.getAttribute('src');
    var ftype = src.substring(src.lastIndexOf('.'), src.length);
    
    if (opt == 'out') imgEl.src = imgEl.src.replace("r"+ftype, ftype);
    else imgEl.src = imgEl.src.replace(ftype, "r"+ftype);
}