jQuery(document).ready(function() 
{
    // add bottom quotes for blockquotes
	jQuery("blockquote").append('<div class="quote_bottom"></div>');
	
	// sidebar: contact
	jQuery("#contact_form").hide();
	jQuery("#contact_form_toggle").click(function () {
		jQuery("#contact_form").slideToggle("fast");
	});

	// sidebox: links
	//jQuery(".side_box_links .sidebox_toggle_content").hide();
	jQuery(".side_box_links .sidebox_toggle").click(function () {
		jQuery(".side_box_links .sidebox_toggle_content").slideToggle("fast");
	});

    // sidebox: pages
	//jQuery(".side_box_pages .sidebox_toggle_content").hide();
	jQuery(".side_box_pages .sidebox_toggle").click(function () {
		jQuery(".side_box_pages .sidebox_toggle_content").slideToggle("fast");
	});
	
	// sidebox: events
	//jQuery(".side_box_events .sidebox_toggle_content").hide();
	jQuery(".side_box_events .sidebox_toggle").click(function () {
		jQuery(".side_box_events .sidebox_toggle_content").slideToggle("fast");
	});
	
	// sidebox: projects
	//jQuery(".side_box_projects .sidebox_toggle_content").hide();
	jQuery(".side_box_projects .sidebox_toggle").click(function () {
		jQuery(".side_box_projects .sidebox_toggle_content").slideToggle("fast");
	});

	// sidebox: review
	//jQuery(".side_box_review .sidebox_toggle_content").hide();
	jQuery(".side_box_review .sidebox_toggle").click(function () {
		jQuery(".side_box_review .sidebox_toggle_content").slideToggle("fast");
	});

	// sidebox: gallery
	//jQuery(".side_box_gallery .sidebox_toggle_content").hide();
	jQuery(".side_box_gallery .sidebox_toggle").click(function () {
		jQuery(".side_box_gallery .sidebox_toggle_content").slideToggle("fast");
	});

	// set lightbox link
	jQuery("a.mylightbox").lightBox({fixedNavigation:true});
	
	// set padding for every third item
	jQuery(".post_content .ngg-gallery-thumbnail-box").each(function( intIndex ){
		if( (intIndex + 1) % 3 == 0)
		{  
			//alert(jQuery(this).attr("id"));
			jQuery(this).css("margin", "0 0 5px 0");
		}
	});
	
	// mouseOver effect for icons
	jQuery(".subnav_frame_single").mouseover(function() 
	{
  		jQuery("img", this).css("opacity", 1.0);
	});
	
	jQuery(".subnav_frame_single").mouseout(function() 
	{
  		jQuery("img", this).css("opacity", 0.4);
	});
	
	
	// form validation
	jQuery("#contactform").validate();

	jQuery('#contactform').ajaxForm({ 
        dataType:  'json', 
        success:   processJson,
        beforeSubmit: function() { 
			//alert(jQuery("#captcha").val());
			//alert(jQuery("#validcaptcha").val());
			if(jQuery("#captcha").val() == jQuery("#validcaptcha").val()){ return true; }
			else{ alert("Falscher Sicherheitscode! - Wrong security code!"); return false; }
		}
    });
    
    jQuery('#contactform').submit(function() {
  		//jQuery("#contact_form").hide();
  		//return false;
	});

});

function processJson(data) { 
    //alert(data.message); 
    //jQuery('form :input').val("");
    jQuery("#contactform").hide();
    jQuery("#contact_form").html('<p class="form_return">'+ data.message +'</p>');
}
