/*-----------------------------------------------------------------------------
Javascript Common Functions

author:    bubi blomer
website:   http://www.maal4.nl
-----------------------------------------------------------------------------*/

	function mediaRoation(){
	   if(nr >= but_ar.length){
	       nr = 0;
	   } else {
	       nr ++;
	   }
	   var but = but_ar[nr];
	  $(but).trigger('click');
	  //alert(nr);
	};
		    	
    nr = 0;
    
    but_ar = new Array('#media_1', '#media_2', '#media_3', '#media_4', '#media_5', '#media_6', '#media_7');
    
    cid = setInterval('mediaRoation()', 5000);


/* =Jquery
-----------------------------------------------------------------------------*/

$(document).ready(function() {

	//Media Rotation
	$('#media_1').click(function(){
		$(this).fadeIn('slow');
		$('#media_7').fadeOut('slow');
	});
	$('#media_2').click(function(){
		$(this).fadeIn('slow');
		$('#media_1').fadeOut('slow');
	});
	$('#media_3').click(function(){
		$(this).fadeIn('slow');
		$('#media_2').fadeOut('slow');
	});
	$('#media_4').click(function(){
		$(this).fadeIn('slow');
		$('#media_3').fadeOut('slow');
	});
	$('#media_5').click(function(){
		$(this).fadeIn('slow');
		$('#media_4').fadeOut('slow');
	});
	$('#media_6').click(function(){
		$(this).fadeIn('slow');
		$('#media_5').fadeOut('slow');
	});
	$('#media_7').click(function(){
		$(this).fadeIn('slow');
		$('#media_6').fadeOut('slow');
	});
        
    // Form Validation
	$('#emailSubscription').validate();
    
    // Clear email input on click
    $('#email').attr('value','enter email');
    $('#email').click(function(){
	$(this).attr('value','');
    });

	//Footer Positioning.    
    var currentWindowHeight = $(window).height();
    var currentWindowWidth = $(window).width();
    
    var leftFooterHeight = $('#leftFooter').height();
    var centerFooterHeight = $('#centerFooter').height();
    var rightFooterHeight = $('#rightFooter').height();
    
    var leftFooterWidth = $('#leftFooter').width();
    var centerFooterWidth = $('#centerFooter').width();
    var rightFooterWidth = $('#rightFooter').width();
    
    //Setting the Correct offset to Css
 		
	$('#leftFooter').css({ 'top': $(window).height() - leftFooterHeight, 'left': 0, 'z-index': 11 });
	$('#centerFooter').css({ 'top': $(window).height() - centerFooterHeight, 'left': ((currentWindowWidth / 2) - (centerFooterWidth / 2)), 'z-index': 11 });
	$('#rightFooter').css({ 'top': $(window).height() - rightFooterHeight, 'left': currentWindowWidth - rightFooterWidth, 'z-index': 11 });
	$('#footer').css({ 'width': currentWindowWidth, 'position': 'fixed', 'bottom': 0, 'left': 0 });
	
	$(window).resize(function(){
		var newWindowHeight = $(window).height();
		var newWindowWidth = $(window).width();
		var newScrollPosition = $(window).scrollTop();
		$('#leftFooter').css({ 'top': newWindowHeight - leftFooterHeight, 'left': 0, 'z-index': 11 });
		$('#centerFooter').css({ 'top': newWindowHeight - centerFooterHeight, 'left': ((newWindowWidth / 2) - (centerFooterWidth / 2)), 'z-index': 11 });
		$('#rightFooter').css({ 'top': newWindowHeight - rightFooterHeight, 'left': newWindowWidth - rightFooterWidth, 'z-index': 11 });
		$('#footer').css({ 'width': newWindowWidth, 'position': 'fixed', 'bottom': 0, 'left': 0 });
	});
			
	//show Footer
	$('#leftFooter, #centerFooter, #rightFooter, #footer').fadeIn('slow');
	
	//Add Extra space for last contentPost Div
	$('div.contentPost:last').css({'margin-bottom': 45});
	
	// Internet Explorer 6 Message	
	if($.browser.msie && $.browser.version == 6){
		
		$('#leftFooter, #centerFooter, #rightFooter, #footer').hide();
		
		/* $('#footerIE').css({ 'position': 'absolute', 'left': ((currentWindowWidth / 2) - (960 / 2) ) }); */
		
		$('#ie6Message').modal({
			close:(true),
			onOpen: function (dialog) {
				dialog.overlay.click(function(){
					$.modal.close();
				});
				dialog.overlay.fadeIn('slow', function () {
					dialog.container.slideDown('slow', function () {
						dialog.data.fadeIn('slow');
					});
				});
			}
		});
	};
        

}); // END DOCUMENT READY FUNCTION


