// Name of the cookie to be set and read
var COOKIE_NAME = 'fontsize';

//Cookie options
var OPTIONS = { path: '/' };

// Name of the element whose font-size should be changed
var ELEMENT_NAME = '#MainContent';

// Name of the element containing three fontsize links (small/medium/large)
var LINK_PARENT = '.fontsize';


function setFontsize(value) {
	jQuery.cookie(COOKIE_NAME,value, OPTIONS );
	jQuery(ELEMENT_NAME).css('font-size', value);
}

jQuery(function() {
	
	
	/* Font size switching */
	
	var fs = jQuery.cookie(COOKIE_NAME);
	
	if(fs == null) {
		fs = '1em';
	}	
	
	jQuery(ELEMENT_NAME).css('font-size', fs);	
	
	jQuery(LINK_PARENT + ' a').eq(0).click( function() {
		setFontsize('1em');
	});
	
	jQuery(LINK_PARENT + ' a').eq(1).click( function() {
		setFontsize('1.2em');
	});
	
	jQuery(LINK_PARENT + ' a').eq(2).click( function() {
		setFontsize('1.3em');
	});
	
	
	
	/* Column height */
	
	jQuery('.twoColumnGroup').each(function(){
		var overallHeight = jQuery(this).height();
		jQuery(this).children('.column').each(function(){ 		
		 	jQuery(this).height(overallHeight + 'px');
		 });
	 });
	
	jQuery('.news-image').each(function(){
		var parent_height = jQuery(this).height();
		var img = jQuery(this).find('img').first();
		var image_height = img.height();
		if (image_height) {
			var top_margin = (parent_height - image_height)/2;  
			img.css( 'margin-top' , top_margin);
			jQuery(this).css('border', '1px solid #CCCCCC');			
		}
	});
	jQuery('.news-single-img').each(function(){
		var parent_height = jQuery(this).height();
		var img = jQuery(this).find('img').first();
		var image_height = img.height();
		if (image_height) {
			var top_margin = (parent_height - image_height)/2;  
			img.css( 'margin-top' , top_margin);
			jQuery(this).css('border', '1px solid #CCCCCC');			
		}
	});
	
	
	
});



