
// FontSize control constants
var _intCurrentFontSize = 0;
var FS_FONT_SIZE_BUTTON_1_ID = "lnkFontSize1"
var FS_FONT_SIZE_BUTTON_2_ID = "lnkFontSize2"
var FS_FONT_SIZE_BUTTON_3_ID = "lnkFontSize3"
//var FS_AJAX_POST_URL = "/professional/post/setTextSize.aspx?size=";
var FS_AJAX_POST_URL = document.location.protocol + "//" + document.location.hostname + "/professional/post/setTextSize.aspx?size=";


// The "Site" object should contain all of the code that adds behavior to the various client side controls
var Site = {
   
	start: function(){ 	
		
		// Add Font Size button behavior    
	
	},

	changeFontSize: function(newSize) {
	
			var elemBody = jQuery('body');    
			
        	if(_intCurrentFontSize != newSize) {
				elemBody.removeClass('textsize1');
				elemBody.removeClass('textsize2');
				elemBody.removeClass('textsize3');
	        	elemBody.addClass('textsize' + newSize);
	        }
			
			// Set current size
			_intCurrentFontSize = newSize;
			createCookie('TextSize',_intCurrentFontSize,'365');
			// Send a request to the server to store the TextSize in the cookie
	        var url = FS_AJAX_POST_URL + _intCurrentFontSize;
	        new Ajax(url, { method: 'get' }).request();
	        
	} // End changeFontSize()
	,
	
	// Add the behaviors to the font-size control
	createFontSizer: function() {  
	    
	    $(FS_FONT_SIZE_BUTTON_1_ID).addEvent('click', function(event) { Site.changeFontSize(1); });
	    $(FS_FONT_SIZE_BUTTON_2_ID).addEvent('click', function(event) { Site.changeFontSize(2); });
	    $(FS_FONT_SIZE_BUTTON_3_ID).addEvent('click', function(event) { Site.changeFontSize(3); });
	    var thisSize=readCookie('TextSize');
	    
	    Site.changeFontSize(thisSize);
	} // End createFontSizer()
	
	
};

// Call the Site initialization function when the page loads
//window.addEvent('load', Site.start);

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function createCookie(name,value,days){
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
//	if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}