function dateToblackmindStyle() {
		$$('.entry_date').each( function(elem) {
			var date = elem.innerHTML.split(" ");
			var d1 = date[0].split("/");
			elem.innerHTML = d1[0] + "<span class=\"sep\">/</span>" + d1[1] + "<span class=\"sep\">/</span>" + d1[2];
		});

}

function photosMove() {
		var entries = $$('.entry');
		entries.each( function(entry) {
				var id = entry.id;
				var images = "";
				$$('#'+id+' .images img').each( function(photo) {
					images += photo.src + ";";
					photo.style.display = "none";
				});

				var images_text = images.split(";");
				
				images_text.each( function( text ) {
				//	if(text != "") 
				//		$(entry.id + "_images").innerHTML += "<img src=\"" + text + "\" alt=\"blackmind photo\" />";
				});
				

		});
		if(entries.length > 0) {
			entries[entries.length-1].style.marginBottom = "20px";
		}
}

function pagingEvent() {
		$$('.pages').each( function(page) {
			if(page.innerHTML.indexOf("selected")==-1) {
			/*	page.addEvent('mouseover', function() {
					page.style.background = "#252525";
				});			
				page.addEvent('mouseout', function() {
					page.style.background = "";
				});*/
				// 클릭시 점선없애기
				page.addEvent('focus', function() {
					document.body.focus();
				});
			}
		});
}

function menuSelect() {

	$('blog_button').addEvent('mouseover', function() {
			this.src = baseImageURL + "bt_hover_blog.gif";
	});
	$('blog_button').addEvent('mouseout', function() {
			this.src = baseImageURL + "bt_blog.gif";
	});

	$('localog_button').addEvent('mouseover', function() {
			this.src = baseImageURL + "bt_hover_localog.gif";
	});
	$('localog_button').addEvent('mouseout', function() {
			this.src = baseImageURL + "bt_localog.gif";
	});

	$('taglog_button').addEvent('mouseover', function() {
			this.src = baseImageURL + "bt_hover_taglog.gif";
	});
	$('taglog_button').addEvent('mouseout', function() {
			this.src = baseImageURL + "bt_taglog.gif";
	});

	$('keylog_button').addEvent('mouseover', function() {
			this.src = baseImageURL + "bt_hover_keylog.gif";
	});
	$('keylog_button').addEvent('mouseout', function() {
			this.src = baseImageURL + "bt_keylog.gif";
	});

	$('medialog_button').addEvent('mouseover', function() {
			this.src = baseImageURL + "bt_hover_medialog.gif";
	});
	$('medialog_button').addEvent('mouseout', function() {
			this.src = baseImageURL + "bt_medialog.gif";
	});

	$('guestbook_button').addEvent('mouseover', function() {
			this.src = baseImageURL + "bt_hover_guestbook.gif";
	});
	$('guestbook_button').addEvent('mouseout', function() {
			this.src = baseImageURL + "bt_guestbook.gif";
	});
}

function defaultInput () {
	$$('input.name').each( function(i) {
		if(i.value == "") {
			i.value = "이름";
		}
	});
	$$('input.password').each( function(i) {
		if(i.value == "") {			
			i.value = "1234";
		}
	});
}

function checkName(obj) {
	if(obj.value == "이름") {
		obj.value = "";
	}
}

function checkPW(obj) {
	if(obj.value == "1234") {
		obj.value = "";
	}
}

function checkComment(id) {
	if($('name_'+id) != null) {
		if(($('name_' + id).value == "") || ($('name_' + id).value == "이름")) {
			$('name_' + id).focus();
			alert("이름을 입력하십시오");
			return false;
		}		
	}

	if($('pw_' + id) != null) {
		if(($('pw_' + id).value == "1234")) {
			$('pw_' + id).value = "";
			$('pw_' + id).focus();

			alert("비밀번호를 입력하십시오");
			return false;
		}	
	}

	if(($('txt_' + id).innerHTML == "")) {
		$('txt_' + id).focus();
		alert("내용을 입력하십시오");
		return false;
	}

	return true;
}

var toolbarSlide = null;
function showToolbar() {
	if(toolbarSlide != null) 
		toolbarSlide.slideIn();
}
function hideToolbar() {
	if(toolbarSlide != null) 
		toolbarSlide.slideOut();
}

var switchSlide = null;
var showSwitch = false;

function swapSwitch() {
	if(switchSlide != null) {
		switchSlide.toggle();

		if(showSwitch) {
			$('switch_image').src = baseImageURL + "bt_switch.gif";
		} else {
			$('switch_image').src = baseImageURL + "bt_switch_hide.gif";
		}

		showSwitch = !showSwitch;
	}
}

window.addEvent('domready', function() {
		dateToblackmindStyle();
		photosMove();
		defaultInput();
		pagingEvent();
		menuSelect();
});