$.fn.clearfocus = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};

function doSifr(){
	$.sifr({
		path: '/images/project-elements/',
		save: true
	});

	$('h2').sifr({ font: 'headlines' });
	$('h3').sifr({ font: 'headlines' });
}

$(document).ready(function(){

	$("a").focus(function() {
		$(this).blur();
	});

	//doSifr();

	Cufon.now();
	Cufon.replace('h2');
	Cufon.replace('h3');

	$('select.directjump').change(function () {
		window.location.href = $(this).val();
	});

	$("p#socialmediaopener a").click(function () {
		reference = this;
		$("div#socialmedia").slideToggle("slow", function () {
			if($("div#socialmedia").is(":hidden")){
				$(reference).css("background-image" , "url('/images/project-elements/social-media-open-inactive.png')");
			}else{
				$(reference).css("background-image" , "url('/images/project-elements/social-media-open-active.png')");
			}
		});
	});

	$('<p id="facebook"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.meurer-palazis.de&amp;layout=standard&amp;show_faces=true&amp;width=380&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:80px;" allowTransparency="true"></iframe></p>').appendTo("div#socialmediacontainer");
});

function contactform(){
  // Hide forms
  $( 'form.contactform' ).hide().end();

  // Processing
  $( 'form.contactform' ).find( 'ol.blockstyle>li>label' ).not( '.nogx' ).each( function( i ){
    var labelContent = this.innerHTML;


    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );

    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = "";
    this.appendChild( labelSpan );
  } ).end();

  // Show forms
  $( 'form.contactform' ).show().end();
}
