jQuery(document).ready(function() {
	// get the origianl size of body
	var original_body_font_size = jQuery('body').css('font-size');
	original_body_font_size = parseFloat(original_body_font_size, 10);
	var current_body_font_size = original_body_font_size;
	
	jQuery('#resetFontSize').click(function () {
		// reset the font size
		current_body_font_size = original_body_font_size;
		jQuery('body').css('font-size', current_body_font_size);
		
		// resize the followingelements
		stretch('.zMenu');
		stretchV('.zSection2');
	});
	
	jQuery('#increaseFontSize').click(function () {
		// increase the body font size by 10%
		current_body_font_size = current_body_font_size * 1.10;
		jQuery('body').css('font-size', current_body_font_size);
		
		// resize the following elements
		stretch('.zMenu');
		stretchV('.zSection2');
	});
	
	jQuery('#decreaseFontSize').click(function () {
		// decrease the body font size by 10%
		current_body_font_size = current_body_font_size / 1.10;
		jQuery('body').css('font-size', current_body_font_size);
		
		// resize the following elements
		stretch('.zMenu');
		stretchV('.zSection2');
	});
	
	// initialize
	stretch('.zMenu');
	stretchV('.zSection2');
});

/*
 * stretch a background-image in teh vertical axis only
 */
function stretchV(selector) {
	var height = jQuery(selector).height();
	var img_height = jQuery(selector).find('.zBackground img').height();
	var img_width = jQuery(selector).find('.zBackground img').width();

	jQuery(selector).find('.zBackground img').height(height);
	jQuery(selector).find('.zBackground img').width(img_width);
}

/*
 * stretch a background-image in both axis
 */
function stretch(selector) {
	var width = jQuery(selector).width();
	var height = jQuery(selector).height();
	
	jQuery(selector).find('.zBackground img').width(width);
	jQuery(selector).find('.zBackground img').height(height);
}
