function resetFields(whichform) {

	var url = window.location.href;

	if(url.indexOf("do=send")<0) {

		for (var i=0; i<whichform.elements.length; i++) {
			var element = whichform.elements[i];

			if(element.type == "submit") continue;
			if(element.type == "radio") continue;
			if(element.type == "checkbox") continue;
			if(!element.defaultValue) continue;

			element.onfocus = function() {
				if(this.value == this.defaultValue) this.value = "";
			}
			element.onblur = function() {
				if(this.value == "") this.value = this.defaultValue;
			}
		}
	}
}

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

function defeatFocusRects() {
	a = document.getElementsByTagName("a");
	al = a.length;
	while(al--) {
		a[al].onfocus = function() {
			this.blur();
		}
	}
}
$(document).ready(function() {
	
	$("a[@href^=http]").each(
	   function(){
		  if(this.href.indexOf(location.hostname) == -1) { 
	      $(this).attr('target', '_blank');
	    }
	});
	
	$("a[href$=pdf]").each(
	   function(){
	      $(this).attr('target', '_blank');
	});
	
	prepareForms();
	defeatFocusRects();
	
	$('#tagselection').change(function(){
		$('#tags').submit();
	});
	$('#plzselection').change(function(){
		$('#plz').submit();
	});
	$('#bubbles').removeClass("h");
	$('#bubbles').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'random',
		containerheight: '135px'
	});

	$(".addressblock_basic .add").toggle(
		function () {
			$(this).parent().addClass("full");
		},
		function () {
			$(this).parent().removeClass("full");
		}
	);

	$("#submit").hover(
		function () {
			$(this).addClass("hover");
		}, 
		function () {
			$(this).removeClass("hover");
		}
	);

});
