var menuItems = 0;

$(document).ready(function() {

	menuItems = $("#sitebar li").length;

	bgImageResize();
	$(window).bind("resize", function resizeWindow(e) { 
		bgImageResize(); 
	});

	if($.os.name == 'iphone'){
		$("body").attr("id", "smallVP").addClass("iPhone");
		imageResize();
	};
	if($(".spacerLine").length > 1){
		$(".spacerLine:last").css({
			border: "none",
			padding: 0
		});
	}
	$('.contentSingleWrap h1 a').hover(function(){
		$(this).closest('.contentSingleWrap').addClass('singleWrapOver');
	}, function(){
		$(this).closest('.contentSingleWrap').removeClass('singleWrapOver');
	});
	
		
});

function bgImageResize () {
	if($.os.name != 'iphone'){
		var windowWidth = $(window).width();
		var windowHeight = $(window).height();
		
		if(windowHeight < windowWidth){
			$("body").css({
				backgroundSize: windowWidth+"px "+windowWidth+"px"/*,
				backgroundPosition: "0px "+(windowWidth - windowHeight) / -2+"px"*/
 			});
		}else{
			//$("body").css("background-size", windowHeight+"px "+windowHeight+"px");
			$("body").css({
				backgroundSize: windowHeight+"px "+windowHeight+"px"/*,
				backgroundPosition: (windowHeight - windowWidth) / -2+"px 0px"*/
				});
		}
		$("body").removeAttr("id");
		if(windowWidth <= 820){
			$("body").attr("id", "smallVP");
			if(menuItems > 3){
				$("body#smallVP .contentWrap").attr("id", "menu3items");		
			}
		}else if(windowWidth <= 1150){
			$("body#smallVP .contentWrap").attr("id", "");
			$("body").attr("id", "middleVP");
		}else{
			$("body#smallVP .contentWrap").attr("id", "");
			$("body").attr("id", "bigVP");
		}
		imageResize();
	}
};
function imageResize () {
	$("img.alignnone.size-full").each(function(){			
		$(this).css({
			width: $(".contentWrap").width() - 40,
			height: 'auto'
		});
	});
//	$("img.size-medium").each(function(){	
//		$(this).css({
//			width: ($(".contentWrap").width() - 40) / 3,
//			height: 'auto'
//		});
//	});
}
