// navigation functions

function navOn(navName) {
	if (document.getElementById) {
		if (document.getElementById(navName).className != 'nav-select') {
			document.getElementById(navName).style.background = '#a28f7f';
		}
	}
}

function navOff(navName) {
	if (document.getElementById) {
		if (document.getElementById(navName).className != 'nav-select') {
			document.getElementById(navName).style.background = '#73563f';
		}
	}
}

function dnavSelect(navName) {
	if (document.getElementById) {
		document.getElementById(navName).className = 'dnav-select';
	}
}

function dnavOn(navName) {
	if (document.getElementById) {
		if (document.getElementById(navName).className != 'dnav-select') {
			document.getElementById(navName).style.background = '#ede9e6';
		}
	}
}

function dnavOff(navName) {
	if (document.getElementById) {
		if (document.getElementById(navName).className != 'dnav-select') {
			document.getElementById(navName).style.background = '#ffffff';
		}
	}
}

function showMenu(divName) {
	if (document.getElementById) {
		document.getElementById(divName).style.display = 'block';
	}
}

function hideMenu(divName) {
	if (document.getElementById) {
		document.getElementById(divName).style.display = 'none';
	}
}

// investor info change

function showInv1() {
	if (document.getElementById) {
		document.getElementById('inv-tab-l-a').style.color = '#000000';
		document.getElementById('inv-tab-r-a').style.color = '#cc3300';
		document.getElementById('inv-tab-l-p').style.borderTop = '4px solid #e44c16';
		document.getElementById('inv-tab-r-p').style.borderTop = '4px solid #c1b5aa';
		document.getElementById('inv-info1').style.display = 'block';
		document.getElementById('inv-info2').style.display = 'none';
	}
}

function showInv2() {
	if (document.getElementById) {
		document.getElementById('inv-tab-l-a').style.color = '#cc3300';
		document.getElementById('inv-tab-r-a').style.color = '#000000';
		document.getElementById('inv-tab-l-p').style.borderTop = '4px solid #c1b5aa';
		document.getElementById('inv-tab-r-p').style.borderTop = '4px solid #e44c16';
		document.getElementById('inv-info1').style.display = 'none';
		document.getElementById('inv-info2').style.display = 'block';
	}
}


// investor info callout change

function showInvCallout1() {
	if (document.getElementById) {
		document.getElementById('inv-call-tab-l-a').style.color = '#000000';
		document.getElementById('inv-call-tab-r-a').style.color = '#cc3300';
		document.getElementById('inv-call-info1').style.display = 'block';
		document.getElementById('inv-call-info2').style.display = 'none';
	}
}

function showInvCallout2() {
	if (document.getElementById) {
		document.getElementById('inv-call-tab-l-a').style.color = '#cc3300';
		document.getElementById('inv-call-tab-r-a').style.color = '#000000';
		document.getElementById('inv-call-info1').style.display = 'none';
		document.getElementById('inv-call-info2').style.display = 'block';
	}
}

// content tabs change

function showContent1() {
	if (document.getElementById) {
		document.getElementById('content-tab-l-a').style.color = '#000000';
		document.getElementById('content-tab-r-a').style.color = '#a28f7f';
		document.getElementById('content-tab-l-p').style.borderTop = '4px solid #e44c16';
		document.getElementById('content-tab-r-p').style.borderTop = '4px solid #c1b5aa';
		document.getElementById('content-info1').style.display = 'block';
		document.getElementById('content-info2').style.display = 'none';
	}
}

function showContent2() {
	if (document.getElementById) {
		document.getElementById('content-tab-l-a').style.color = '#a28f7f';
		document.getElementById('content-tab-r-a').style.color = '#000000';
		document.getElementById('content-tab-l-p').style.borderTop = '4px solid #c1b5aa';
		document.getElementById('content-tab-r-p').style.borderTop = '4px solid #e44c16';
		document.getElementById('content-info1').style.display = 'none';
		document.getElementById('content-info2').style.display = 'block';
	}
}

// dropdown select location change
function sel(Url) {
	if (Url) {
  	window.open(Url,"_blank");
  }
}

// open a popup window
function openwin(url,w,h,s) {
  var scrl;
	if (s) { scrl="scrollbars=yes,"; w = w+16; }
	else { scrl="scrollbars=no,"; }

	if (!w) w = 640;
	if (!h) h = 480;

	fenster = window.open(url,"_blank",scrl+"resizable=yes,width="+w+",height="+h+",screenX=50,screenY=50");
	fenster.focus();
}

// font change functions

function fontsizeup() {
  active = getActiveStyleSheet();
  setActiveStyleSheet('large');
  document.getElementById('u-reg').style.display = 'inline';
  document.getElementById('u-large').style.display = 'none';
}

function fontsizedown() {
  active = getActiveStyleSheet();
  setActiveStyleSheet('reg');
  document.getElementById('u-reg').style.display = 'none';
  document.getElementById('u-large').style.display = 'inline';
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  return ('reg');
}

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 expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
if (title == 'null') {
  title = getPreferredStyleSheet();
}

setActiveStyleSheet(title);

function getSubFlash() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="597" height="166" id="Sub_aim" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/flash/patient-stories/Sub_aim.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque"><embed src="/flash/patient-stories/Sub_aim.swf" quality="high" bgcolor="#ffffff" width="597" height="166" name="Sub_aim" align="middle" allowScriptAccess="sameDomain" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function getHomeFlash() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="597" height="248" id="twp_anim2" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/flash/home/twp_anim2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque"><embed src="/flash/home/twp_anim2.swf" quality="high" bgcolor="#ffffff" width="597" height="248" name="twp_anim2" align="middle" allowScriptAccess="sameDomain" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function getMapFlash() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="575" height="315" id="US_Corp_map" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/flash/home/US_Corp_map.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque"><embed src="/flash/home/US_Corp_map.swf" quality="high" bgcolor="#ffffff" width="575" height="315" name="US_Corp_map" align="middle" allowScriptAccess="sameDomain" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function openExternalLink(href, target) {
  var newwin = window.open('/util/exit-notice.shtml?url=' + encodeURIComponent(href) + '&target=' + encodeURIComponent(target),'openlink','width=330,height=190,screenX=100,screenY=100,top=100,left=100,resizable=yes,toolbar=no,scrollbars=no')
  newwin.focus();
}

function setupExternalLinks() {
  var links = document.getElementsByTagName('a');
  for (var i = links.length; i != 0; i--) {
    var a = links[i-1];
    if (!a.href) continue;

    if (a.href.indexOf('http') != -1 &&
            a.href.indexOf(window.location.hostname) == -1 &&
      !excludeUrl(a.href)
        ) {
      a.onclick = function() {
                openExternalLink(this.href, this.target);
                return false;
            }

    }
  }
}

var excludeUrls = Array();

function excludeUrl(url){
  for(var l = 0; l < excludeUrls.length; l++){
    if(url.indexOf(excludeUrls[l]) == 0){
      return true;
    }
  }

  return false;
}