var curFontSize = 14;
var fontModifier = 2;
var maxFont = 16;
var minFont = 12;

//function ts(trgt, act) {
//    if (document.getElementById) {
//        storyBody = document.getElementById(trgt);
//      if (storyBody) {
//        if (act === 1) {
//            curFontSize += fontModifier;
//            curFontSize = Math.min(curFontSize, 1.4);
//        } else if (act === 0) {
//            curFontSize -= fontModifier;
//            curFontSize = Math.max(curFontSize, 1);
//        }
//
//        storyBody.style.fontSize = curFontSize + "em";
//	    }
//    }
//	
//    // set cookie with font size
//    var expdate = new Date();
//    FixCookieDate (expdate);
//    expdate.setTime (expdate.getTime() + (672*60*60*1000)); // 4 weeks
//    SetCookie("userfontc",curFontSize,expdate);
//   
//    return(false);
//}

function getCookieVal(offset, target) {
	var fontSize = document.cookie.indexOf (";", offset);
	//alert('fontSize1 ' + fontSize);
	var test = unescape(document.cookie.substring(offset, fontSize));
	//alert('test ' + test);
	if (fontSize == -1) {
	  fontSize = document.cookie.length;
	}
	else {
    fontSize = curFontSize;
  }

	//alert('fontSize ' + fontSize);
	
	jQuery('#' + target).css({'font-size': fontSize});
  jQuery('#' + target + ' p').css({'font-size': fontSize});
  jQuery('#' + target + ' p a').css({'font-size': fontSize});
	
	return (false);//unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)  {
		date.setTime (date.getTime() - skew);
	}
}

function SetCookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

function ts(target, action) {
  if ($(target)) {
    var currentSize = $(target).getStyle('font-size');
    //alert('currentSize ' + currentSize);
    if (currentSize) {
      var fontSize = parseInt(currentSize);
      var fontChange = (action == '1' ? fontModifier : -fontModifier );
      
      //alert('fontSize ' + fontSize + ' fontChange ' + fontChange);
      fontSize = fontSize + fontChange;
      
      if (fontSize > maxFont)
        return;
      if (fontSize < minFont)
        return;
      
      jQuery('#' + target).css({'font-size': fontSize});
      jQuery('#' + target + ' p').css({'font-size': fontSize});
      jQuery('#' + target + ' p a').css({'font-size': fontSize});
      
      // set cookie with font size
      var expdate = new Date();
      FixCookieDate (expdate);
      expdate.setTime (expdate.getTime() + (672*60*60*1000)); // 4 weeks
      SetCookie("userfontc",fontSize,expdate);
    }
  }
  return(false);
}

//getCookieVal('userfontc', 'content-area');