/*! common actions for the jquery to do */
$(document).ready(function(){
    var contentwidth = $('#content').width();
    if(contentwidth == 725) {
        $('.about').columnize({
            columns: 2
        });
    }
    $('.last.column img').parent('div').prepend($('.last.column img'));

    $('#menu ul li ul').prev('a').click(function() {
        $('ul.children').slideToggle('slow');
        return false;
    });
    
    function imageresize() {
        var contentwidth = $('#content').width();
        if(contentwidth != 725) {
            $('#section').after($('#second-horizontal-menu'));
            $('#second-horizontal-menu').after($('#horizontal-menu'));
            $('#sidebar').append($('#menu ul li ul'));
            $('ul.children').css('padding', '10px 0 10px 0').css('margin-top', '10px');
        }
        else {
            $('#section').before($('#second-horizontal-menu'));
            $('#second-horizontal-menu').before($('#horizontal-menu'));
            $('ul.children').css('padding', '20px 0 10px 0');
        }
        
    }
    
    imageresize();

    $('#menu ul.children li.current_page_item, #menu ul.children li.current_page_parent').parent('ul').show();

    
    $(window).bind("resize", function(){//Adjusts image when browser resized
        imageresize();
    });

    $('.toggle-artist-news').click(function() {
        $('#artist-news').slideToggle();
        return false;
    });
	
	setInputField('email', 'Email Address');
	setInputField('firstname', 'First name');
	setInputField('surname', 'Surname');
	
	function setInputField($name, $text) {
		if($("#mail input[name=" + $name + "]").val() == "") {
			$("#mail input[name=" + $name + "]").val($text);
			$("#mail input[name=" + $name + "]").addClass('fade');
		}
		else if ($("#mail input[name=" + $name + "]").val() == $text) {
			$("#mail input[name=" + $name + "]").addClass('fade');
		}
		
		$("#mail input[name=" + $name + "]").focus(function() {
			if($(this).val() == $text) {
				$(this).val("");
				$("#mail input[name=" + $name + "]").removeClass('fade');
			}
		});
	}
});
