/* JavaScript Document */
/* Autor:	Damjan Gataric
			damjan.gataric@etondigital.com
			EtonDIGITAL
*/

$(document).ready(function() {

	//main navigation
	$('#mainNav ul ul ul').each(function() {
		if ($(this).children('li').length<2) {
			$(this).append('<li style="padding: 0 0 8px; font-size: 0; line-height: 0;">&nbsp;</li>');
		}	
	});
	$('#mainNav ul ul').each(function() {
		$(this).children('li:first').addClass('first');
	});
	$('#mainNav ul ul').each(function() {
		$(this).children('li:last').addClass('last');
	});
	
	$('#mainNav ul li.parent').hover(
		function(){    
        $(this).children('a').addClass('hover');
        $('ul:first',this).stop().css({height: 'auto', overflow:'', paddingTop: '5px'}).slideDown(250);    
    	}, 
		function(){       
        $('ul:first',this).stop().slideUp(150, function() {$(this).parent('li').children('a').removeClass('hover');}).css({height:'auto'});
    });
	
	$('#mainNav>ul>li.parent>a').click(function() { return false; });
	
	
	//services tabs
	if ($('#hp-services').length>0) {
		$('#hp-services ul').kwicks({max: 224, duration: 300, easing: 'easeOutQuad', complete: 'callback'});
		$('#hp-services a').hover(
			function() { $(this).children('span').animate({'height':'70px'}, 300, function() { $(this).siblings('small').fadeIn(300); }); },
			function() { $(this).children('small').hide(); $(this).children('span').animate({'height':'43px'}, 300); }
		);
	}
	
	
	//breadcrumb cleaner
//	$('#breadcrumb a[href$="/submenu/458"]').remove();
//	$('#breadcrumb a[href$="/submenu/378"]').remove();
//	$('#breadcrumb a[href$="/submenu/570"]').remove();
//	$('#breadcrumb a[href$="/submenu/580"]').remove();
//	$('#breadcrumb a[href$="/submenu/576"]').remove();
	
	
	//CSS
	$('#footerNav>ul:last').css('margin',0);

});




function getWindowHeight() {
    var windowHeight = 0;
    if (typeof(window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}
function getContainerHeight() {
    var containerHeight = 0;
    containerHeight = document.getElementById('container').offsetHeight;
    return containerHeight;
}
function getFooterHeight() {
    var footerHeight = 0;
    footerHeight = document.getElementById('footer').offsetHeight;
    return footerHeight;
}
function setContainerHeight() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        var containerHeight = getContainerHeight();
        var footerHeight = getFooterHeight();
        if (windowHeight > containerHeight+footerHeight+216) {
            document.getElementById('container').style.height = (windowHeight-footerHeight-216)+'px';
        }
    }
}
window.onload = function() {    
    if (document.getElementById('container')) { setContainerHeight(); }
}
window.onresize = function() {
    if (document.getElementById('container')) { setContainerHeight(); }
}
