// jquery 마우스오버시 이미지 변환
/*
$(function() { 
	$(".rollover a img").hover(function(){ 
	$(this).attr("src", $(this).attr("src").replace(".gif", "_on.gif")); 
	}, function(){ 
	$(this).attr("src", $(this).attr("src").replace("_on.gif", ".gif")); 
	}); 
});
*/
// 전체메뉴보이기 숨기기
function slide_view(){
	document.getElementById("slidemenu").style.display = "block";
}
function slide_hide(){
	document.getElementById("slidemenu").style.display = "none";
}

// 즐겨찾기
function bookmark(){
window.external.AddFavorite('http://council.daegu.go.kr/')
}


// 프린트페이지
function init(print) {
	if(print == "print")
	{		
		document.getElementById("printInfo").style.display = "none"; // printInfo 문구 삭제
		this.print();
	}
	else
	{
		document.getElementById("docuPrint").innerHTML = opener.getPageDocuHtml();		
		this.focus();
	}
}

// 방송 페이징
function Page(a)
{
	document.pagefrm.page.value=a;
	pagefrm.submit();
}
// 글쓰기
function jsCheckNull( toCheck ) {
     var chkstr   = toCheck + "";
     var is_Space = true ;
 
     if ( ( chkstr == "") || ( chkstr == null ) )
	   return( true );
 
     for ( j = 0 ; is_Space && ( j < chkstr.length ) ; j++)
     {
	     if( chkstr.substring( j , j+1 ) != " " )
         {
	       is_Space = false ;
         }
     }
     return ( is_Space );
}
 
function checkit(){
	//if(jsCheckNull(document.myform.ys_id.value)) {
	//   alert("실명인증이나 로그인후 이용해주세요!");
	//   history.go(-1);
	//   return false
	//}
	if(jsCheckNull(document.register.name.value)) {
	   alert("이름을 입력하세요!");
	   document.register.name.focus();
	   return false
	}
	if(jsCheckNull(document.register.passwd.value)) {
	   alert("글 수정/삭제를 위해 비밀번호가 필요합니다.");
	  document.register.passwd.focus();
	  return false
	}
	if(jsCheckNull(document.register.subject.value)) {
	   alert("제목을 입력하세요");
	   document.register.subject.focus();
	   return false
	}
	if(jsCheckNull(document.register.comment.value)) {
	   alert("내용을 입력하세요.");
	   document.register.comment.focus();
	   return false
	}
}
 
function OnlyNumber()
{
   if((event.keyCode<48)||(event.keyCode>57))
	{
   	    alert('숫자 입력만 가능합니다.!');
		event.returnValue=false;
	}
}
 
 
function password_change()
{
		var passwd = document.getElementById('dis_password');
		if(passwd.style.display=="block") passwd.style.display = "none";
		else passwd.style.display = "block";
 
}

// 방청신청
function jsCheckNull( toCheck )
{
     var chkstr   = toCheck + "";
     var is_Space = true ;

     if ( ( chkstr == "") || ( chkstr == null ) )
	   return( true );

     for ( j = 0 ; is_Space && ( j < chkstr.length ) ; j++)
     {
	     if( chkstr.substring( j , j+1 ) != " " )
         {
	       is_Space = false ;
         }
     }
     return ( is_Space );
}

function checkit(){
	if(jsCheckNull(document.myform.name.value)) {
	   alert("이름을 입력하세요!");
	   document.myform.name.focus();
	   return false
	}
	if(jsCheckNull(document.myform.email.value)) {
	   alert("이메일을 입력해주세요");
	   document.myform.email.focus();
	   return false
	}
	if(jsCheckNull(document.myform.job.value)) {
	   alert("직업을 입력해주세요");
	   document.myform.job.focus();
	   return false
	}
	if(jsCheckNull(document.myform.tel1.value)) {
	   alert("휴대전화 번호를 입력해주세요");
	   document.myform.tel1.focus();
	   return false
	}
	if(jsCheckNull(document.myform.tel2.value)) {
	   alert("휴대전화 번호를 입력해주세요");
	   document.myform.tel2.focus();
	   return false
	}
	if(jsCheckNull(document.myform.tel3.value)) {
	   alert("휴대전화 번호를 입력해주세요");
	   document.myform.tel3.focus();
	   return false
	}
	if(jsCheckNull(document.myform.addr.value)) {
	   alert("주소를 입력해주세요");
	   document.myform.addr.focus();
	   return false
	}
	if(jsCheckNull(document.myform.content.value)) {
	   alert("참관목적을 입력해주세요");
	   document.myform.content.focus();
	   return false
	}
	if(jsCheckNull(document.myform.inwon.value)) {
	   alert("인원을 입력해주세요");
	   document.myform.inwon.focus();
	   return false
	}

	 document.myform.submit();

}

function OnlyNumber()
{
   if((event.keyCode<48)||(event.keyCode>57))
	{
   	    alert('숫자 입력만 가능합니다.!');
		event.returnValue=false;
	}
}
// 프리로딩이미지
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
 
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// 통합검색
function idx_detail() {
wrd=document.inxform.keyword.value;
	if(wrd=="") {
		alert("검색어를 입력하십시오.");
		document.inxform.keyword.focus();
		document.inxform.keyword.select();
		return false;
	}
len=wrd.length;
	if(len<2) {
		alert("검색어는 2자이상 입력하세요.");
		document.inxform.keyword.focus();
		document.inxform.keyword.select();
		return false;
	}
	for(i=0; i<len; i++) {
	ch=wrd.charCodeAt(i);
		if(ch<40 || ch>41 && ch<48 || ch>57 && ch<65 || ch>90 && ch<97 || ch>122 && ch<256) {
			alert("허용되지 않는 검색어 입니다.");
			document.inxform.keyword.focus();
			document.inxform.keyword.select();
			return false;
		}
	}
}

// 목록상자 new
function goto_url(fid, targ, opt) {
	var obj = document.getElementById(fid);
	var url = obj.options[obj.selectedIndex].value;
	if(!url) {
		alert('이동하실 목록을 선택해주세요');
	}
	else if(targ) {
		window.open(url, targ, opt);
	} else {
		location.href = url;
	}
}

// 글자확대축소
defsize = 9;
function zoom_it(n) {
	defsize += n;
	if(defsize < 15 && defsize > 5) {
		objs = document.getElementById("fontSize");
		objs.style.fontSize = defsize + "pt";
	} else {
		defsize += -n;
	}
}

// 인쇄
function getPageDocuHtml() {
return document.getElementById("content").innerHTML;
}

// 아이프레임 높이 자동조절
function calcHeight()
{
  //find the height of the internal page
  var the_height=
    document.getElementById('the_iframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('the_iframe').height=
      the_height;
}

// 플래시 및 미디어플레이어
var GLOBAL_URL = "";
var GLOBAL_HTTP_SCHEME = "http";
var ACTIVEX_PATCH = new Object();
ACTIVEX_PATCH.write = function(url,width,height,type)
{
	if (null == type)
	{
		ACTIVEX_PATCH._writeFlashPlayer(url,width,height);
	}
	else
	{
		ACTIVEX_PATCH._writeWMPlayer(url,width,height);
	}
}

ACTIVEX_PATCH._writeWMPlayer = function(url,width,height,id)
{
	document.write('<object id="MediaPlayer1" name="MediaPlayer1" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"');
	document.write('codebase="'+GLOBAL_HTTP_SCHEME+'://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"');
	document.write('standby="..."  type="application/x-oleobject"');
	document.write('bgcolor="DarkBlue" width="'+width+'" height="'+height+'">');
	document.write('<param name="AutoStart" value="0">');
	document.write('<param name="AutoSize" value="1">');
	document.write('<param name="AnimationAtStart" value="1">');
	document.write('<param name="DisplayMode" value="1">');
	document.write('<param name="Enabled" value="true">');
	document.write('<param name="Filename" value="'+url+'">');
	document.write('<param name="ShowControls" value="1">');
	document.write('<param name="ShowAudioControls" value="0">');
	document.write('<param name="ShowDisplay" value="0">');
	document.write('<param name="ShowGotoBar" value="0">');
	document.write('<param name="ShowPositionControls" value="0">');
	document.write('<param name="ShowStatusBar" value="0">');
	document.write('<param name="ShowCaptioning" value="0">');
	document.write('<param name="Tracker" value="0">');
	document.write('<param name="TransparentAtStart" value="0">');
	document.write('<param name="Volume" value="0">');
	document.write('<embed type="application/x-mplayer2" pluginspage="'+GLOBAL_HTTP_SCHEME+'://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"');
	document.write('id="NSPlay" name="MediaPlayer1" displaysize="4" autosize="1"  showcontrols="1"');
	document.write('showdisplay="0" showstatusbar="0"  width="'+width+'" height="'+height+'" src="'+url+'"');
	document.write('autostart="0"></embed>');
	document.write('</object>');
}

ACTIVEX_PATCH._writeFlashPlayer = function(url,width,height,id)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+GLOBAL_HTTP_SCHEME+'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="main_index" align="middle">');
	document.write('<param name="movie" value="'+GLOBAL_URL+url+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	//document.write('<param name="FlashVars" value="'+pageNum+'">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="'+GLOBAL_URL+url+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="'+GLOBAL_HTTP_SCHEME+'://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" menu="false"></embed>');
	document.write('</object>');
}

// 메인메뉴 스크립트
function initNavigation(seq) {
	nav = document.getElementById("topmenu");
	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	navLen = nav.childNodes.length;

	allA = nav.getElementsByTagName("a")
	for(k = 0; k < allA.length; k++) {
		allA.item(k).onmouseover = allA.item(k).onfocus = function () {
			nav.isOver = true;
		}
		allA.item(k).onmouseout = allA.item(k).onblur = function () {
			nav.isOver = false;
			setTimeout(function () {
				if (nav.isOver == false) {
					if (nav.menu[seq])
						nav.menu[seq].onmouseover();
					else if(nav.current) {
						menuImg = nav.current.childNodes.item(0);
						if(menuImg.tagName == "IMG") {
							if(menuImg.src.match("_on.gif"))
								menuImg.src = menuImg.src.replace("_on.gif", ".gif");								
						}
						if (nav.current.submenu)
							nav.current.submenu.style.display = "none";
						nav.current = null;
					}
				}
			}, 7000);
		}
	}

	for (i = 0; i < navLen; i++) {
		navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI")
			continue;

		navAnchor = navItem.getElementsByTagName("a").item(0);
		navAnchor.submenu = navItem.getElementsByTagName("ul").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);
				if(menuImg.tagName == "IMG") {
					if(menuImg.src.match("_on.gif"))
						menuImg.src = menuImg.src.replace("_on.gif", ".gif");
				}
				if (nav.current.submenu)
					nav.current.submenu.style.display = "none";
					nav.current.style.backgroundImage = "none"; // 1차메뉴에 배경있을때
					nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				if(menuImg.tagName == "IMG") {
					if(!menuImg.src.match("_on.gif"))
						menuImg.src = menuImg.src.replace(".gif", "_on.gif");
				}
				if (this.submenu)
					this.submenu.style.display = "block";
					this.style.backgroundImage = "url(../images/common/mainmenu/menu_on.gif)"; // 1차메뉴에 배경있을때
					this.style.backgroundRepeat = "no-repeat";
					this.style.backgroundPosition = "center bottom";
					nav.current = this;
			}
			nav.isOver = true;
		}
		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}
	if (nav.menu[seq])
		nav.menu[seq].onmouseover();
}

// 메인페이지 게시판
function newsInitTabMenu_bill(menuContainerID) {

	var tabAnchor = document.getElementById(menuContainerID).getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;
		thismenu.menuContainer = document.getElementById(menuContainerID);
		thismenu.targetEl = document.getElementById(thismenu.href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		if (thismenu.getElementsByTagName("img").item(0)) {
			thismenu.getElementsByTagName("img").item(0).onclick = function () {
				this.src = this.src.replace(".gif", "_on.gif");
			}
		}

		thismenu.onclick =  newsTabMenuClick;

		if (!thismenu.menuContainer.first) {
			thismenu.menuContainer.first = thismenu;
		}
	}
	document.getElementById(menuContainerID).first.onclick();
}
function newsInitTabMenu_notice(menuContainerID) {

	var tabAnchor = document.getElementById(menuContainerID).getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;
		thismenu.menuContainer = document.getElementById(menuContainerID);
		thismenu.targetEl = document.getElementById(thismenu.href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		if (thismenu.getElementsByTagName("img").item(0)) {
			thismenu.getElementsByTagName("img").item(0).onclick = function () {
				this.src = this.src.replace(".gif", "_on.gif");
			}
		}

		thismenu.onclick =  newsTabMenuClick;

		if (!thismenu.menuContainer.first) {
			thismenu.menuContainer.first = thismenu;
		}
	}
	document.getElementById(menuContainerID).first.onclick();
}
function newsInitTabMenu_gallery(menuContainerID) {

	var tabAnchor = document.getElementById(menuContainerID).getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;
		thismenu.menuContainer = document.getElementById(menuContainerID);
		thismenu.targetEl = document.getElementById(thismenu.href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		if (thismenu.getElementsByTagName("img").item(0)) {
			thismenu.getElementsByTagName("img").item(0).onclick = function () {
				this.src = this.src.replace(".gif", "_on.gif");
			}
		}

		thismenu.onclick =  newsTabMenuClick;

		if (!thismenu.menuContainer.first) {
			thismenu.menuContainer.first = thismenu;
		}
	}
	document.getElementById(menuContainerID).first.onclick();
}
function newsTabMenuClick() {
	currentmenu = this.menuContainer.current;

	if (currentmenu != this) {
		if (currentmenu) {
			currentmenu.targetEl.style.display = "none";
			if (currentmenu.getElementsByTagName("img").item(0)) {
				currentmenu.getElementsByTagName("img").item(0).src = currentmenu.getElementsByTagName("img").item(0).src.replace("_on.gif", ".gif");
				currentmenu.getElementsByTagName("img").item(0).onclick = function () {
					this.src = this.src.replace(".gif", "_on.gif");
				}
			}
			currentmenu.className = currentmenu.className.replace(" on", "");
		}

		this.targetEl.style.display = "block";
		if (this.getElementsByTagName("img").item(0)) {
			this.getElementsByTagName("img").item(0).src = this.getElementsByTagName("img").item(0).src.replace("_on.gif", ".gif");

			this.getElementsByTagName("img").item(0).onclick();
			this.getElementsByTagName("img").item(0).onclick = null;
		}
		if (this) {
			this.className += " on";
		}
		this.menuContainer.current = this;
	}
	return false;
}

