/*********************** Cookies Name ************************** 
Name:				Function:
------------------------------------
text 	= 	Font Size
cookie 	= 	Linear Version
***************************************************************/ 

var elems = null
var sizes = new Array()
var currSizes = new Array()

var defaultFontSize = 100;
if (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.match("MSIE 6.0")=="MSIE 6.0") { 
 defaultFontSize = 95; }
var currentFontSize = defaultFontSize;
$(document).ready(function(){
	//$('p[align=right]').css('text-align','right');
	//$('p[align=left]').css('text-align','right');
	//$('p[align=center]').css('text-align','center');

/******************** Text Size Cookie *************************/
	if (Get_Cookie('text')){
		setFontSize(Get_Cookie('text'));
	}	
	else{
		setFontSize(100);
	}
/***************************************************************/

/************************ Tsz King *****************************/
	$("#decreaseFont").click(function() {
		changeFontSize(-1);
	});
	$("#defaultFont").click(function() {
		revertStyles();
	});
	$("#increaseFont").click(function() {
		changeFontSize(1);
	});
/***************************************************************/	
})


/*********************** Change font-size **********************/


function revertStyles(){
	currentFontSize = defaultFontSize;
	changeFontSize(0);
	//Delete_Cookie( 'text', '/', location.host );
}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 10);
	if(currentFontSize > 120){
		currentFontSize = 120;
	}else if(currentFontSize < 80){
		currentFontSize = 80;
	}
	createCookie('text',currentFontSize);
	setFontSize(currentFontSize);
};
/***************************************************************/



/********************** Linear Version **************************/
function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('content_text') : document.all('content_text');

     if (Get_Cookie('cookie')=="Standard" || Get_Cookie('cookie')==null){
            	document.body.style.fontSize = fontSize + '%';
	} else {
                document.body.style.fontSize = '130%';
	}
};
/***************************************************************/



/********************* Cookie Settings *************************/
function createCookie(name,value,days) {
 if (days != null) {
 var date = new Date();
 date.setTime(date.getTime()+(days*24*60*60*1000));
 var expires = "; expires="+date.toGMTString();
 }
 else expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}

		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return null;
	}
}
/***************************************************************/


