jQuery.noConflict();

jQuery(window).unbind("resize");
jQuery(window).bind("resize", setSubmenuHeight);

overlayFading = false;

function setSubmenuHeight() {
	var submenu = jQuery('div#submenu');
	var flashHeight = jQuery('div#flashbox');
	var docuGesamt = jQuery(document).height();
	var gesamt = jQuery(window).height();
	
	//submenu.height(gesamt-230);
	flashHeight.height(docuGesamt);
	//console.log('resize', jQuery(this).height());
	//console.log('subSize', submenu.height());
}


function setMenuPosition() {
	var menuLeftBox = jQuery('div#mainmenu_left');
	var menuRightBox = jQuery('div#mainmenu_right');
	var itemLeft = jQuery('div#linksAktiv');
	var itemRight = jQuery('div#rechtsAktiv');


	if (menuLeftBox.height()) {
        var heightValue = 142
        if (jQuery('#red_dot.start')) heightValue += jQuery('#red_dot.start').height()+45;
        menuLeftBox.css('top', heightValue-menuLeftBox.height());
    }
	if (menuRightBox.height()) {menuRightBox.css('top', 142-menuRightBox.height());}

	var obenLinksNeu, obenRechtsNeu, obenLinksOffset, obenRechtsOffset;
	
	if (itemLeft.height()) {
		obenLinksOffset = document.getElementById('linksAktiv').offsetTop;
		obenLinksNeu = 142-obenLinksOffset-15;
		jQuery(menuLeftBox.css('top',obenLinksNeu));
	}	
		
	if (itemRight.height()) {	
		obenRechtsOffset = document.getElementById('rechtsAktiv').offsetTop;
		obenRechtsNeu = 142-obenRechtsOffset-15;
		jQuery(menuRightBox.css('top',obenRechtsNeu));
	}
}


jQuery(document).ready(function(){

	var conBox = jQuery('div#contentbox');
	var conImg = jQuery('div#content img');
	var conText = jQuery('div#content_overlay');
	var logoBox = jQuery('div#logobox');
	var logoImg = jQuery('div#logobox img');
	var subMenu = jQuery('div#submenu');
	var subMenuBox = jQuery('div#submenubox');
	var conSlide = jQuery('div.rgsgcontent');
	var conVimeo = jQuery('div#vimeobox');
	var projectName = jQuery('div#projektname');
	var textOverlay = jQuery('div#content_overlay_big');
	var textOverlayBox = jQuery('div#content_overlay_big_box');
	
	setSubmenuHeight();
	setMenuPosition();


	/// SUBMENU ///

	if (conBox.width() > 690) {
		// subMenuBox.hide();
		// subMenu.height(subMenuBox.height()+17);
		subMenuBox.animate({opacity: 1.0}, 3000).animate({opacity: 'hide'}, 'slow');

		subMenu.hover(function() {
			subMenuBox.animate({
                		opacity: 'show'
	        	}, 'normal');
        	}, function() {
			subMenuBox.animate({
        	        	opacity: 'hide'
        		}, 'normal');
	        });		
	}
	
	
	
	/// PROJEKTBESCHREIBUNG ///
	
	if ((conImg.width() > 460) || (conSlide.width() > 460) || (conVimeo.width() > 460)) {
		conText.animate({opacity: 1.0}, 3000).animate({opacity: 'hide'}, 'slow');

		conBox.hover(function() {
			conText.animate({
        	        	opacity: 'show'
        		}, 'normal');
	        }, function() {
			conText.animate({
                		opacity: 'hide'
	        	}, 'normal');
        	});

		projectName.hover(function() {
			conText.animate({
        	        	opacity: 'show'
        		}, 'normal');
	        }, function() {
			conText.animate({
                		opacity: 'hide'
	        	}, 'normal');
        	});

	}

	/// CONTENT-TEXT-OVERLAY ///

	if (overlayFading==true) {
		
		textOverlayBox.animate({opacity: 1.0}, 6000).animate({opacity: 'hide'}, 'slow');
	
		textOverlay.hover(function() {
			textOverlayBox.animate({
	               		opacity: 'show'
	        	}, 'normal');
	       	}, function() {
			textOverlayBox.animate({
	       	        	opacity: 'hide'
	       		}, 'normal');
	        });		
	}	

	 
	/// LOGO-HOVER /// 

	/*
	logoImg.hide();	 

	logoBox.hover(function() {
		logoImg.animate({
                	opacity: 'show'
        	}, 'fast');
        }, function() {
		logoImg.animate({
                	opacity: 'hide'
        	}, 'fast');
        });
	*/


	/// SONSTIGES ///

	jQuery.ifixpng('img/pixel.gif');
	jQuery('img[@src$=.png]').ifixpng(); 
	
	jQuery('#bg_start').width('100%').height('100%');
	
});
