function initPage() {
	$("#custom").addClass("hidden");
	$("#toggleCustom").toggle(
		function() {
			$("#custom").slideDown("fast");
			$(this).text("取消定制");
		},
		function() {
			$("#custom #customRst").attr("value","").parent().slideUp("fast");
			$(this).text("定制");
		}
	);
	
	$("#longUrl").addClass("greyfy");
}
$(document).ready(initPage);

function initTextFields() {
		var $fields = $(".initText");
		$fields.bind("focus",fieldsFocus);
		$fields.bind("blur",fieldsBlur);
}
function fieldsFocus() {
	if ($(this).attr("id") == "longUrl") {
		$(this).removeClass("greyfy");
	}
	if (this.value == this.defaultValue) {
		this.value = "";
	}
	else {
		this.select();
	}
}
function fieldsBlur() {
	var re = /^\s+(\s)*$/;
	if (re.test(this.value) || this.value == "") {
		this.value = this.defaultValue;
		if ($(this).attr("id") == "longUrl") {
			$(this).addClass("greyfy");
		}
	}
}
$(document).ready(function(){
	if ($('#longUrl').val() == '输入要缩短的网址, 需包含"http://"') {
		initTextFields();
	}
});
function delUrl()
{
	$('.editForm > a').click(function(){
		var url = $(this).parent().parent().children('dl').children('dd').children('em').text();
		if (confirm('确定要删除 '+ url +' ？')) {
			return true;
		} else {
			return false;
		}
		});
}
$(document).ready(function(){delUrl();});