// Main javascript code

//if (navigator.appName == "Microsoft Internet Explorer"){
//document.write("<link rel=\"stylesheet\" href=\"main.css\" type=\"text/css\">);
//}
//
//else{
//document.write("<link rel=\"stylesheet\" href=\"netstyle.css\" type=\"text/css\">);
//}

function emailAddress(name,descrip)
		{
			emailE=('tb'+name+'@' + 'tbalert.org');
			document.write('<a href="mailto:' + emailE + '">' + descrip + '</a>');
		}
		
function emailAddressNoTB(name,descrip)
		{
			emailE=(name+'@' + 'tbalert.org');
			document.write('<a href="mailto:' + emailE + '">' + descrip + '</a>');
		}
		

function dpatax(theForm) 
		{
			var subj = "Reclaim gift aid"
			theForm.M_TBMail.value = document.iform.tbmail.checked;			
			theForm.M_TBTax.value = document.taxform.tbtax.checked;
			theForm.M_TBShare.value = document.iform.tbshare.checked;
			if (document.taxform.tbtax.checked) subj = subj + " Yes ";
			else subj = subj + " No ";
			if (document.taxform.tbtax.checked) theForm.cartId = " Don GA";
			if (document.iform.tbmail.checked) subj = subj + "/ No mail";
			if (document.iform.tbshare.checked) subj = subj + "/ No share";
			theForm.M_subject.value = subj;			
       }

function dpataxStaff(theForm) 
		{
			var subj = "Reclaim gift aid"
			theForm.M_TBMail.value = document.iform.tbmail.checked;			
			theForm.M_TBTax.value = document.taxform.tbtax.checked;
			theForm.M_TBShare.value = document.iform.tbshare.checked;
			if (document.iform.tbmail.checked) subj = subj + "/ No mail";
			if (document.iform.tbshare.checked) subj = subj + "/ No share";
			theForm.M_subject.value = subj;			
       }

function setTextSize(textPx)
{
	document.write("<style type=\"text/css\">");
	document.write(".pageText2 {font-size: ",textPx,"px;}");
	document.write("</style>");
}

// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = (document.cookie.substring(offset, end))
    }
  }
 // document.write("Cookie ",cookieValue," <br>");
  return cookieValue;
}
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  var spath = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
	spath = "; path=/";
	
  }
  document.cookie = name + "=" + (value) + expire + spath;
}

function readTextSize(){
	var textSize = readCookie("TBAlertTextSize"); 
	if (textSize==""){
		textSize=12;	
	}
	if (parseInt(textSize)==isNaN) {textSize = 12;}
	//document.write("Text size ",textSize,"<br>");
	//setTextSize(200);
	return textSize;
}

function writeTextSize(textSize){
	writeCookie("TBAlertTextSize",escape(textSize),36000);
}

function resizeText(delta){
	var currentTextSize = parseInt(readTextSize());
	//alert(currentTextSize);
    if (delta > 0) currentTextSize += delta;
 	if (delta < 0) currentTextSize += delta;
	if (currentTextSize > 500) currentTextSize = 500;
	if (currentTextSize < 6) currentTextSize = 6;
	//alert(currentTextSize);
	//setTextSize(currentTextSize);
	writeTextSize(currentTextSize.toString());
    window.location.reload();
}
