// 2011.06.18
// Grendelfly - A Division of SC&G Technology Solutions
//
// Requires JQuery: jquery-1.4.2.min.js

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}


function fSet_Font_Size(dir){
	
	if(dir == 'up'){txt_unt = 2}else if(dir == 'dwn'){txt_unt = -2};
	
	$('#idMd h1,#idMd h2,#idMd h3,#idMd h4,#idMd p,#idMd li').each( function(i,x){
		var g_sze = $(x).css('font-size').replace(/\D/g,'');
		var n_sze = Number(g_sze) + Number(txt_unt);
		var n_lht = Number(n_sze) + 6;
		$(x).css({'font-size':n_sze+'px','line-height':n_lht+'px'});		
		});

		// Set Cookie
		var txt_sze = getCookie('txt_sze');
			if(txt_sze == null){txt_sze = 0;};
		var n_txt_sze = Number(txt_sze) + Number(txt_unt)
		setCookie('txt_sze',n_txt_sze,365);
	
	};
	
function fSet_Font_Size_0(){
	
	var txt_sze = getCookie('txt_sze');
	$('#idMd h1,#idMd h2,#idMd h3,#idMd h4,#idMd p,#idMd li').each( function(i,x){
		var g_sze = $(x).css('font-size').replace(/\D/g,'');
		var n_sze = Number(g_sze) + Number(txt_sze);
		var n_lht = Number(n_sze) + 6;
		$(x).css({'font-size':n_sze+'px','line-height':n_lht+'px'});		
		});	
	}; 


$(function(){
		   
$(document).ready(function() {

fSet_Font_Size_0();

// External Links - Open in new window
// Ancor tags with class of 'ext'

	$('a.ext').each(function(){
		$(this)
		.attr({'target':'_blank'})
		.attr({'title':'Opens New Window'})
		.css({'padding-right':'12px','background':'url(/img/ico/ico-window-sm-gry.gif) right no-repeat'})
		;
	});

// Header Link function
	$('#idHd')
	.css({'cursor':'pointer'})
	.click( function(){
		window.location.assign('/');
		});

// Text Sizer

//	fSet_Font_Size();
	$('#text_size img').click( function(){
		var g_id = $(this).attr('id');
		if(g_id=='txt_sml'){fSet_Font_Size('dwn');}else if(g_id=='txt_lrg'){fSet_Font_Size('up');};
		});



}); // $(document).ready(function()
}); // $(function()


