// JavaScript Document

/*  ListArticles  */
$(document).ready( function() {
	/*  Footer Bottom  */ /*Leave me at the end*/
	footerbottom();
	$(window).resize( function() {
		footerbottom();				
	});
	$('.iPadNavigation').accordion({
		active: 3,
		//animated: 'bounceslide',
		//event: 'mouseover',
		changestart: function(event, ui) {
			var activeClass = ui.newHeader.attr('id');
			$('.iPadView img').animate({
				opacity: 0
			}, {queue:false, duration:400}).removeClass('active');
			$('.iPadView img.' + activeClass ).animate({
				opacity: 1
			}, {queue:false, duration:400}).addClass('active');
        }
	});
	
	/*browserfix*/
	 if($.browser.msie){
      $(".Article table td:nth-child(2)").css({
		"background":"url(/images/project/arrow.png) 13px 8px no-repeat #66B1E3",
		width:"5px",
		position:"relative",
		borderLeft:"1px solid #59a2d3",
		borderBottom:"1px solid #59a2d3"
		});
	  $(".Article table tbody ").css({
		borderTop:"1px solid #BDD7E8"
		});
	 
   }
   
$('.btnKontakt').click(function()
	{
		$('#contactForm').css('display','block');
	});

});




/*Navigation*/
$(function(){
        $('.naviMain_Navigation').superfish({
                delay: 500,
                autoArrows: false,
                dropShadows: false
        });
});

function footerbottom() {
	if($('#cmsEditor').length == 0)
	{
		var heightPage = $('#page').attr('clientHeight');
		var heightContent = $('#content').attr('clientHeight');
		var heightHtml = $('html').attr('clientHeight');
		if ( heightPage < heightHtml) {
			$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
		}
		else {
			$('#content').removeAttr('style');
			var heightPage = $('#page').attr('clientHeight');
			var heightContent = $('#content').attr('clientHeight');
			var heightHtml = $('html').attr('clientHeight');
			if ( heightPage < heightHtml) {
				$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
			}
		}
	}
	else
	{
		var heightPage = $('#page').attr('clientHeight');
		var heightContent = $('#content').attr('clientHeight');
		var heightHtml = ($('html').attr('clientHeight')-70);
		if ( heightPage < heightHtml) {
			$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
		}
		else {
			$('#content').removeAttr('style');
			var heightPage = $('#page').attr('clientHeight');
			var heightContent = $('#content').attr('clientHeight');
			var heightHtml = ($('html').attr('clientHeight')-70);
			if ( heightPage < heightHtml) {
				$('#content').attr('style','min-height:'+(heightHtml-(heightPage-heightContent+1))+'px');
			}
		}
	}
}
/****browse button style****/
(function($) {
    
    $.fn.filestyle = function(options) {
                
        /* TODO: This should not override CSS. */
        var settings = {
            width : 250
        };
                
        if(options) {
            $.extend(settings, options);
        };
                        
        return this.each(function() {
            
            var self = this;
            var wrapper = $("<div>")
                            .css({
                                "width": settings.imagewidth + "px",
                                "height": settings.imageheight + "px",
                                "background": "url(" + settings.image + ") 0 0 no-repeat",
                                "background-position": "right",
                                "display": "inline",
                                "position": "absolute",
                                "overflow": "hidden"
                            });
                            
            var filename = $('<input class="file">')
                             .addClass($(self).attr("class"))
                             .css({
                                 "display": "inline",
                                 "width": settings.width + "px"
                             });

            $(self).before(filename);
            $(self).wrap(wrapper);

            $(self).css({
                        "position": "relative",
                        "height": settings.imageheight + "px",
                        "width": settings.width + "px",
                        "display": "inline",
                        "cursor": "pointer",
                        "opacity": "0.0"
                    });

            if ($.browser.mozilla) {
                if (/Win/.test(navigator.platform)) {
                    $(self).css("margin-left", "-142px");                    
                } else {
                    $(self).css("margin-left", "-168px");                    
                };
            } else {
                $(self).css("margin-left", settings.imagewidth - settings.width + "px");                
            };

            $(self).bind("change", function() {
                filename.val($(self).val());
            });
      
        });
        

    };
	
    
})(jQuery);

