$(function(){

	
	$('ul li:last-child, ol li:last-child').addClass('last');

	$('#nav li').hover(function() {
		$(this).children('ul').fadeIn(150);
		$(this).addClass('active');
	},
	function(){
		$(this).children('ul').fadeOut(150);
		$(this).removeClass('active');
	});
	
	
	
	pageHeight = $('.page').height();

	$('.sidebar').css('height', pageHeight);
	
	$('p.top').click(function() {
	
		$('html, body').animate({scrollTop:0}, 500);
	
	});
	
	/*
$('p.read-more a').html('Read more');
	
*/
	if (typeof(window.parent.parent.resizeFrame) == 'function')
		{
			var l = location.href;
			var p = l.indexOf('?height=');
			if (p == -1)
				p = l.indexOf('&height=');
			if (p != -1)
			{
				p += 8;
				var p2 = l.indexOf('&', p);
				if (p2 == -1)
					p2 = l.length;
				window.parent.parent.resizeFrame((l.substring(p, p2) - 0) + 'px', l.indexOf('scroll=0') == -1);
			}
		}
		
	$('#tech-a-feature ul.sub-menu').cycle({
		fx: 'fade',
		timeout: 4000,
		pager:  '#cycle-nav'
	});
	
	var i = 0;
	$("#tech-a-feature ul.sub-menu li").each(function() {
	   $(this).addClass("item"+(i++));
	  });
	  
	  
	$('#jobviteframe').load(function() {
        $('.jobs-page').addClass('loaded');
    });
    
    $('a.lightbox').colorbox();
	
});


$(window).scroll(function() {


	t = $('.side-nav').height();
	u = $('.page').height();
	
	v = $(document).scrollTop();
	w = $('.page').offset();
	x = w.top + 45;
	y = $(document).height();
	z = u + x - t;
	s = u + x;
	
	if (v > x && v < z) {
		
		$('.page').removeClass('fixed-bottom');
		$('.page').addClass('fixed');
		
		
	
	}
	
	else if (v > z && v < s) {
	
		$('.page').removeClass('fixed');
		$('.page').addClass('fixed-bottom');
	
	}
	
	else {
	
		$('.page').removeClass('fixed');
		$('.page').removeClass('fixed-bottom');
	
	}



});


