$(document).ready(function(){
  
	$('#flashcontent').mousedown(function(e){

		var center=parseInt($(this).width()/2);
		if(e.pageX< center+480 &&  e.pageX>center+400 && e.pageY>220 && e.pageY <292 )
		{
			loadform();
		}
		else if(e.pageX< center+480 &&  e.pageX>center+400 && e.pageY>118 && e.pageY <191 )
		{
			closeform();
		}
		else if(e.pageX< center+418 &&  e.pageX>center+307 && e.pageY>156 && e.pageY <250 )
		{
			closeform();
		}
		else if(e.pageX< center+415 &&  e.pageX>center+344 && e.pageY>87 && e.pageY <148 )
		{
			closeform();
		}
	});

	
if(triggerReg)
{
	loadform();
}
else
{
	  // jQuery swfobject plugin
	  // http://jquery.thewikies.com/swfobject/
	$('#flashcontent').flash(
		      {
		    	  swf: 'http://assets.cdn.gamigo.com/img/otl_images/index-3.swf',
		          width: "100%",
		          height: 840,
		          scale: 'noscale',
		          play: true,
		          allowScriptAccess: "always",
		          params: {
		    	  wmode: "opaque",
		          allowScriptAccess: "always"
		          }/*,
		          flashvars: {
					name1: 'jQuery',
					name2: 'SWFObject',
					name3: 'Plugin'
				  }*/
		      }
		  );
}
if($('#flashcontent').find('object').length==0)
{
	// Wenn Flash nicht verfügbar ist, wird die Reg geladen.
	loadform();
}

  
  // change target + title attribute on links with rel="external"
  // to open in new window
  $('a[rel="external"]').attr({
    target: "_blank", 
    title: "Opens in a new window"
  });
  
});


// function to be called when opening the form
// #form = layer around the form iframe (background)
// #formbody = layer containing the iframe to the form itself
function loadform(){
  $('#form').show('fast', function() {
    // complete, now:
    $('#formbody').fadeIn('fast');
  });
  /*
  // outdated stuff, when not using easing animations,
  // does same as above, but without animation.
  $('#form').removeClass();
  $('#form').addClass("vis");
  $('#formbody').removeClass();
  $('#formbody').addClass("vis");
  */
}


// function to be called when closing the form
// #form = layer around the form iframe (background)
// #formbody = layer containing the iframe to the form itself
function closeform(){   
	$('#formbody,#form').hide();

  /*
  // outdated stuff, when not using easing animations,
  // does same as above, but without animation.
  $('#form').removeClass();
  $('#form').addClass("inv");
  
  $('#formbody').removeClass();
  $('#formbody').addClass("inv");
  */
}
