function resetFields(whichform) {
	for(var i=0; i<whichform.elements.length; i++) {
		var element = whichform.elements[i];
		if (element.type == "submit" || element.type == "radio" || element.type == "checkbox" || element.type == "textarea") continue; 
		if (!element.defaultValue) continue;
		element.onfocus = function(){
			if(this.value == this.defaultValue) {
				this.value = "";
			}
		}
		element.onblur = function(){
			if (element.parentNode.id = "donateForm") {
				setDonateParameter();
			}
			
			if(this.value == "") {
				this.value = this.defaultValue;
			}
		}
	}
}

function setDonateParameter(){
		var donateLinks = document.getElementById("donateForm").getElementsByTagName("a");	
		var donateValue = document.getElementById("donateForm").getElementsByTagName("input")[0].value;	
		for(i=0; i<donateLinks.length; i++) {				
			donateLinks[i].href = donateLinks[i].href + "&initialValue=" + donateValue;
		}	
}

function prepareForms() {
	for(var i=0; i<document.forms.length; i++){
		var thisform = document.forms[i];
		resetFields(thisform);
	}
}

jQuery(document).ready(function() {
	prepareForms();
	label2value();	
/*	$('body#blog a.blog-login').click(function() {
		var dialog = $("<div id='dialog'></div>").insertAfter('#footer');
		$(dialog).dialog({ resizable: false, modal: true, width: 460, height: 330, overlay: { opacity: 0.5, background: "black" } });
		$('.ui-dialog-titlebar-close').click(function() { $('#footer').remove(dialog); });
		$(dialog).html('<iframe src="/blog/login/" id="login"></iframe>');
		return false;
	});*/
});