﻿
// Execute HTML
// modified based on bbs.blueidea.com
function exeHTML(btn) {
		var textareas = btn.parentNode.parentNode.getElementsByTagName("textarea")
		var srcCode = textareas[0].value;

		var winname = window.open('', "_blank", '');
        winname.document.open('text/html', 'replace');
		winname.opener = null;
        winname.document.write(srcCode);
        winname.document.close();
}

$(function() {
	var author = $("#author");
	if(author) {
		author.focus(function() {
			if(this.value == "名字*") {
				this.value= "";
			}
			$(this).removeClass("empty");
		}).blur(function() {
			if(this.value == "") {
				this.value= "名字*";
				$(this).addClass("empty");
			}
		}); 
	}
	
	var email = $("#email");
	if(email) {
		email.focus(function() {
			if(this.value == "邮箱*") {
				this.value= "";
			}
			$(this).removeClass("empty");
		}).blur(function() {
			if(this.value == "") {
				this.value= "邮箱*";
				$(this).addClass("empty");
			}
		}); 
	}
	
	var url = $("#url");
	if(url) {
		url.focus(function() {
			if(this.value == "网站") {
				this.value= "";
			}
			$(this).removeClass("empty");
		}).blur(function() {
			if(this.value == "") {
				this.value= "网站";
				$(this).addClass("empty");
			}
		}); 
	}
	
	var comment = $("#comment");
	if(comment) {
		comment.focus(function() {
			if($(this).val() == "留言") {
				$(this).val("");
			}
			$(this).removeClass("empty");
		}).blur(function() {
			if($(this).val() == "") {
				$(this).val("留言");
				$(this).addClass("empty");
			}
		}); 
	}
	
	var commentForm = $("#commentForm");
	commentForm.submit(function() {
		if(this.author.value == "名字*") this.author.value = "";
		if(this.email.value == "邮箱*") this.email.value = "";
		if(this.url.value == "网站") this.url.value = "";
	});
	
});