//Globals
	
var nw = 1000;	
var nh = 718;
var bgw = 1000;
var bgh = 667;

var nrt = nw/nh;
var bgrt = bgw/bgh;

$(document).ready(function(){
	
	jQuery.event.add(window, "load", resizeFrame);
	jQuery.event.add(window, "resize", resizeFrame);
	
	//setTimeout("checkPics()", 0);
	
	if($("#googlemaps").length > 0)
	{
		
		$("a.gmTabMuc").click(function(){
			$("#map").attr("src", "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&sll=48.194586,11.691513&sspn=0.08525,0.222988&ie=UTF8&hq=Ingram+Micro+Pan+Europe+GmbH&hnear=Heisenbergbogen+3,+Aschheim&ll=48.15211,11.68381&spn=0.006295,0.006295&iwloc=near&z=14&output=embed&q=Ingram+Micro+Pan+Europe+GmbH+Heisenbergbogen+3+85609+Dornach");
			$("a.gmTabMuc").attr("class", "gmTabMuc active");
			$("a.gmTabStr").attr("class", "gmTabStr");
			return false;
		});
		
		$("a.gmTabStr").click(function(){
			$("#map").attr("src", "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Europaring+20+D-94315+Straubing&sll=48.888311,12.60973&sspn=0.08409,0.222988&ie=UTF8&hq=&hnear=Europaring+20,+Ittling+94315+Straubing,+Bayern&z=14&ll=48.90048,12.66171&output=embed&iwloc=near");
			$("a.gmTabMuc").attr("class", "gmTabMuc");
			$("a.gmTabStr").attr("class", "gmTabStr active");
			return false;
		});
		
		setTimeout("checkMap()", 200);
	
	}
	
	if($(".fadeInOnPageLoad").length > 0)
	{
		$(".fadeInOnPageLoad").fadeIn('slow');
	}
	
	$(".buttonBox a").hover(
	function(){
		var src = $(this).find("img").attr("src");
		$(this).find("img").attr("src", src.substring(0, src.length-4) + "_h.png");
	}, 
	function(){
		var src = $(this).find("img").attr("src");
		
		$(this).find("img").attr("src", src.substring(0, src.length-6) + ".png");
	});
	
	if($("#contentDynamiteTeam").length > 0)
	{
		var html = "";
		html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"100%\" HEIGHT=\"100%\" id=\"flashDynamiteTeam\">\n";
		html += "<PARAM NAME=movie VALUE=\"\/tl_files\/flash\/dynamiteTeam.swf\">\n";
		html += "<PARAM NAME=quality VALUE=high>\n";
		html += "<PARAM NAME=bgcolor VALUE=#FFFFFF>\n";
		html += "<PARAM NAME=wmode VALUE=transparent>\n";
		html += "<PARAM NAME=scale VALUE=exactfit>\n"; 
		html += "<EMBED src=\"\/tl_files\/flash\/dynamiteTeam.swf\" scale=\"exactfit\" href=\"\/tl_files\/flash\/dynamiteTeam.swf\" quality=high bgcolor=#FFFFFF wmode=\"transparent\" WIDTH=\"100%\" HEIGHT=\"100%\" NAME=\"Dynamite Team\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>\n";
		$("#contentDynamiteTeam").html(html);
	}
	
	if($("#contentDynamite").length > 0)
	{
		var html = "";
		html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"100%\" HEIGHT=\"100%\" id=\"flashDynamiteAbout\">\n";
		html += "<PARAM NAME=movie VALUE=\"\/tl_files\/flash\/dynamiteAbout.swf\">\n";
		html += "<PARAM NAME=quality VALUE=high>\n";
		html += "<PARAM NAME=bgcolor VALUE=#FFFFFF>\n";
		html += "<PARAM NAME=wmode VALUE=transparent>\n";
		html += "<PARAM NAME=scale VALUE=exactfit>\n"; 
		html += "<EMBED src=\"\/tl_files\/flash\/dynamiteAbout.swf\" scale=\"exactfit\" href=\"\/tl_files\/flash\/dynamiteAbout.swf\" quality=high bgcolor=#FFFFFF wmode=\"transparent\" WIDTH=\"100%\" HEIGHT=\"100%\" NAME=\"Dynamite About\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>\n";
		$("#contentDynamite").html(html);
	}
	
	if($("#contentLeitfaden").length > 0)
	{
		var html = "";
		html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"100%\" HEIGHT=\"100%\" id=\"flashAusbildungLeitfaden\">\n";
		html += "<PARAM NAME=movie VALUE=\"\/tl_files\/flash\/leitfaden_bild.swf\">\n";
		html += "<PARAM NAME=quality VALUE=high>\n";
		html += "<PARAM NAME=bgcolor VALUE=#FFFFFF>\n";
		html += "<PARAM NAME=wmode VALUE=transparent>\n";
		html += "<PARAM NAME=scale VALUE=exactfit>\n"; 
		html += "<EMBED src=\"\/tl_files\/flash\/leitfaden_bild.swf\" scale=\"exactfit\" href=\"\/tl_files\/flash\/leitfaden_bild.swf\" quality=high bgcolor=#FFFFFF wmode=\"transparent\" WIDTH=\"100%\" HEIGHT=\"100%\" NAME=\"Ausbildung Leitfaden Bild\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>\n";
		$("#contentLeitfaden").html(html);
	}
	
	if($("#contentLeitfadenWort").length > 0)
	{
		var html = "";
		html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"100%\" HEIGHT=\"100%\" id=\"flashAusbildungLeitfadenWort\">\n";
		html += "<PARAM NAME=movie VALUE=\"\/tl_files\/flash\/leitfaden_wort.swf\">\n";
		html += "<PARAM NAME=quality VALUE=high>\n";
		html += "<PARAM NAME=bgcolor VALUE=#FFFFFF>\n";
		html += "<PARAM NAME=wmode VALUE=transparent>\n";
		html += "<PARAM NAME=scale VALUE=exactfit>\n"; 
		html += "<EMBED src=\"\/tl_files\/flash\/leitfaden_wort.swf\" scale=\"exactfit\" href=\"\/tl_files\/flash\/leitfaden_wort.swf\" quality=high bgcolor=#FFFFFF wmode=\"transparent\" WIDTH=\"100%\" HEIGHT=\"100%\" NAME=\"Ausbildung Leitfaden Wort\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>\n";
		$("#contentLeitfadenWort").html(html);
	}
	
	if($("#contentUeberIm").length > 0)
	{
		var html = "";
		html += "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"100%\" HEIGHT=\"100%\" id=\"flashUeberIm\">\n";
		html += "<PARAM NAME=movie VALUE=\"\/tl_files\/flash\/ueberIm.swf\">\n";
		html += "<PARAM NAME=quality VALUE=high>\n";
		html += "<PARAM NAME=bgcolor VALUE=#FFFFFF>\n";
		html += "<PARAM NAME=wmode VALUE=transparent>\n";
		html += "<PARAM NAME=scale VALUE=noorder>\n"; 
		html += "<EMBED src=\"\/tl_files\/flash\/ueberIm.swf\" scale=\"noorder\"href=\"\/tl_files\/flash\/ueberIm.swf\" quality=high bgcolor=#FFFFFF wmode=\"transparent\" WIDTH=\"100%\" HEIGHT=\"100%\" NAME=\"Ueber IM\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>\n";
		$("#contentUeberIm").html(html);
	}	

});

function checkMap()
{

	if($("#map").width() > "0")
	{
		$("a.gmTabMuc").click();
		return;
	}
	setTimeout("checkMap()", 200);
}

/*
function checkPics()
{
	
	if($("#bg_notebook").height() > "0" && $("#bg_image").height() > "0")
	{
		
		nh = $("#bg_notebook").height();
		nw = $("#bg_notebook").width();
		nrt = $("#bg_notebook").width()/$("#bg_notebook").height();
		bgh = $("#bg_image").height();
		bgw = $("#bg_image").width();
		bgrt = $("#bg_image").width()/$("#bg_image").height();
		
		resizeFrame();
		
		return;
	}
	
	setTimeout("checkPics()", 50);
}
*/

function resizeFrame() 
{
	var h = $(window).height();
	var w = $(window).width();	

	// Resize Background Image
	if(w/h >= bgrt)
	{
		$("#bg_image").width(w);
		$("#bg_image").height(bgh*(w/bgw));
		//$("#bg_image").css('margin-top',-($("#bg_image").height()-h)/2 + "px");
		$("#bg_image").css('margin-bottom', "0px");
		$("#bg_image").css('margin-left',"0px");
	} else {
		$("#bg_image").height(h);
		$("#bg_image").width(bgw*(h/bgh));
		//$("#bg_image").css('margin-left',-($("#bg_image").width()-w)/2 + "px");
		$("#bg_image").css('margin-bottom', "0px");
		$("#bg_image").css('margin-top',"0px");
	}
	
	// Resize Notebook Image
	if(w/h >= nrt)
	{
			
		$("#bg_notebook").height(h);
		$("#bg_notebook").width(nw*(h/nh));
		$("#bg_notebook").css('margin-left',-($("#bg_notebook").width()-w)/2 + "px");
		$("#bg_notebook").css('margin-top',"0px");
	} else {
		$("#bg_notebook").width(w);		
		$("#bg_notebook").height(nh*(w/nw));
		$("#bg_notebook").css('margin-top',-($("#bg_notebook").height()-h)/2 + "px");
		$("#bg_notebook").css('margin-left',"0px");
	}
	
	// Set Content Wrapper
	$("#main").css('top', (h/2-$("#bg_notebook").height()/2) + ($("#bg_notebook").height()/100)*6.3);
	$("#main").css('left', (w/2 - $("#bg_notebook").width()/2) + ($("#bg_notebook").width()/100)*11.7);
	
	$("#main").width(($("#bg_notebook").width()/100)*76.8);
	$("#main").height(($("#bg_notebook").height()/100)*61.5);
	
	// Set Rahmen Top Wrapper
	$("#rahmenTop").css('top', (h/2-$("#bg_notebook").height()/2) + ($("#bg_notebook").height()/100)*2);
	$("#rahmenTop").css('left', (w/2 - $("#bg_notebook").width()/2) + ($("#bg_notebook").width()/100)*11.7);
	
	$("#rahmenTop").width(($("#bg_notebook").width()/100)*76.8);
	$("#rahmenTop").height(($("#bg_notebook").height()/100)*4);
	
	// Display hidden Parts
	$("#bg_image").show();
	$("#bg_notebook").show();
	$("#main").show();
	$("#rahmenTop").show();
	
	// Set default font-size (em)
	$("body").css('font-size', Math.round(($("#main").height()/100)*3) + "px");
	
}




