
	img_width = 890;
	padding_sides = 30;
	max_width = 1400;
	min_width = 980;

	$(document).ready(function(){
		
		setBackground();

		$(".first_level").mouseover(function(){

			width = $(this).width();
			pos = $(this).position();
			target = $(this).next();

			ul_with = target.width();
			
			target.css("margin-left",pos.left+"px");
			target.find("a").css("width",(ul_with-15)+"px");
						
			$(".sub_menu").hide();
			window.clearTimeout(timer);						

			$("#hider").show().mouseover(function(){
				time_hideMenu();
				$("#hider").hide();
			});


			target.show();
			target.find("a").mouseover(function(){
				window.clearTimeout(timer);						
			});
			target.find("a").mouseout(function(){
				time_hideMenu();					
			});
		});

	  // activate copy / download
		$("#small").mouseenter(function(){
			$(this).hide();
			$("#large").show();
		})
		$("#large").mouseleave(function(){
			$(this).hide();
			$("#small").show();
		})
		
		timer = window.setTimeout('hideMenu()', 10);

		
		setContent();



	});
	function time_hideMenu(){
		window.clearTimeout(timer);
		timer = window.setTimeout('hideMenu()', 500);
	}

	function hideMenu(){
		$(".sub_menu").hide();
	}

	$(window).resize(function() {
		setContent();
	});

	function setContent(){

	  // set vertical stuff
		nor_top = 210;
		min_top = 130;
		min_height = 570;
		bottom_dist = 54;
		bottom_width = 129;
		nor_height = min_height + (nor_top - min_top);
		

		win_height = $(window).height();				

		bottom = win_height - bottom_dist;
		min_bottom = min_height - bottom_dist - 14;
		nor_bottom = win_height - bottom_dist;

		if (win_height < min_height){
			$("#frames").css("padding-top", min_top+"px");
			$("#image_gal").css("top", min_top+"px");
			$("#html").css("top", min_top+"px");
			$("#copy_download").css("top", min_bottom+"px");
		}else if (win_height < nor_height){
			diff = Math.abs(nor_height - win_height);
			set = min_top + ((nor_height - min_height) - diff);
			set_bottom = win_height - bottom_dist;
			$("#frames").css("padding-top", set+"px");
			$("#image_gal").css("top", set+"px");
			$("#html").css("top", set+"px");
			$("#copy_download").css("top", set_bottom+"px");
		}else{
			$("#frames").css("padding-top",nor_top+"px");
			$("#image_gal").css("top", nor_top+"px");
			$("#html").css("top", nor_top+"px");
			$("#copy_download").css("top", nor_bottom+"px");
		}

	  // set horizontol stuff like gallery and video

		win_width = $(window).width();
		if (win_width < min_width){
			win_width  = min_width;
			center =  win_width / 2;												
		}else{
			center =  win_width / 2;
		}
		$('#image_gal').width(win_width - (padding_sides * 2));
		$('#html').width(win_width - (padding_sides * 2));
		$("#copy_download").css("left", (win_width - bottom_width - (padding_sides * 2))+"px");

		if ($('#image_gal').width() > max_width){
			$('#image_gal').width(max_width);			
		}							

		if ($('#html').width() > max_width){
			$('#html').width(max_width);			
		}	

		if (win_width > max_width){
			add_left = (win_width - max_width) / 2;
			$("#copy_download").css("left", (max_width - bottom_width - (padding_sides * 2) + add_left)+"px");		
		}	
	
		image_left = center - $('#image_gal').width() / 2;
		html_left = center - $('#html').width() / 2;
		$('#image_gal').css("left",image_left);
		$('#html').css("left",html_left);
		
		start = (($('#image_gal').width() / 2) - (img_width / 2));
		start_images = 0 - (img_width * 2) + start;											
		$('#images').css("left", start_images+"px");
		
		description_left = start + 50;
		$("#image_description").css("left", description_left+"px");

	}

	function setBackground(){

			var flashvars = {};
			flashvars.image = $("#bg").attr("title");
			var params = {};
				params.menu = "false";
				params.scale = "exactfit";
				params.wmode = "transparent";

			
			var rand = Math.random();
			swfobject.embedSWF(theme_url+"swf/bg.swf?r="+rand, "bg_flash", "100%", "100%", "9.0.0","", flashvars, params);
			/*
			str = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="swf/bg_test" align="middle">';
			str += '<param name="allowScriptAccess" value="sameDomain" />';
			str += '<param name="allowFullScreen" value="false" />';
			str += '<param name="movie" value="swf/bg.swf?image='+flashvars.image+'&r='+rand+'" /><param name="scale" value="exactfit" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="swf/bg.swf?image='+flashvars.image+'&r='+rand+'" quality="high" bgcolor="#ffffff" wmode="transparent" scale="exactfit" width="100%" height="100%" name="swf/bg_test" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
			str += '</object>';
			$("#bg_flash").html(str);
			*/

	}




