// JavaScript Document
// Code runs after DOM has loaded

//$(document).ready(function() {

$(window).load(function() { 

	/*
	$("a.fancyiframe").fancybox({			
			
			//options
			'type' : 'iframe',
			'hideOnOverlayClick' : false,
			'width' : '80%',
			'height' : '80%',
			'titlePosition' 		: 'inside',			
			'onClosed' : function() { $('a').eq(0).focus(); }   // Firefox mouse scroll wheel fix, without this, the mouse wheel stops working after the light box is closed
			
	});
	*/
	

	function setPageHeight() {
		//This functions calculates and sets the height for the page div
		
		contentHeight = $('#content').height()			
		$('#page').height(contentHeight);				
		
		wrapHeight = $('#page-wrap').height() - $('#footer-wrap').height();
		if ((wrapHeight - $('#header').height()) < contentHeight)
		{
			wrapHeight = $('#content').height() + $('#header').height();
		}
		
		$('#page').height(wrapHeight);
	}
	
	/*
	function pixelFix() {
		// This function fixes the 1px alignment bug for centered backgrounds
		// If the viewport is an odd width, the page is shifted to the left by 1px to fix the misalignment
			
		if ($(window).width() % 2 == 1) {
			$('html').css('margin-left', '-1px');
		} else {
			$('html').css('margin-left', '0px');
		}
	}	
	*/
	
		
	setPageHeight();
	$(window).bind('resize', setPageHeight);  // reset #page height whenever the window is resized
	
	
	
	// remove bottom border on last blog post
	$('#mainContent .post-wrap:last, #mainContent .search-wrap:last').css('border-bottom', 'none');
	
	//pixelFix();
	//$(window).bind('resize', pixelFix);  // fix 1px alignment bug when window is resized.

	$('#access .menu-header ul ul li').css('border-right', 'none');
	$('#sideBar ul li:last-child').css("border-bottom", "none");
	$('#socialNetwork ul li:last-child').css("border-bottom", "none");
	
	// center main menu
	/*
	menuWidth = $('ul.menu').width();
	leftMargin = Math.round((900 - menuWidth) / 2);	
	console.log(leftMargin);
	*/
	
	//$('ul.menu').css('margin-left', leftMargin);
	$('#socialNetwork li.twitter-item').prepend('<img src="/images/icon-twitter.png" alt="twitter"  /> ');	
	$('#socialNetwork li.blog').prepend('<img src="/images/blogger.png" alt="blog"  /> ');
			
	
});
