$(document).ready(function() {
	
	// due to ie7 problems with z-index and the dom-structure the overlay-div should be moved to body
	var overlay = $('#scr1').remove();
	$('body').append(overlay);
	
	var triggers = $("a.overlayInput").overlay({
		// some expose tweaks suitable for modal dialogs
		expose: {
			color: '#ddd',
			loadSpeed: 200,
			opacity: 0.9
		},
		
		top: 30,
		
		closeOnClick: true,
		
		// load contact form
		onBeforeLoad: function() { 
		    // grab wrapper element inside content 
		    var wrap = this.getContent().find("#contact_overlay_form");
		    
		    // load the page specified in the trigger
		    wrap.load(this.getTrigger().attr("href")+" .mailformplus_contactform");
		    
		    // get css
		    // <link rel="stylesheet" href="fileadmin/templates/mailformplus/kontakt_script.css" type="text/css" media="screen">
		    var cssIsLinked = false;
			$("link[rel='stylesheet']").each(function() {
				if ($(this).attr("href").indexOf("kontakt_script.css") != -1) {
					cssIsLinked = true;
				}
			});
			if (!cssIsLinked) {
				$('head').append('<link rel="stylesheet" href="fileadmin/templates/mailformplus/kontakt_script.css" type="text/css" media="screen">');
			}
		}
	});
});
