// JavaScript  -  Styleswitcher
function check(){
HTMLLinkElement.getAttribute("rel").indexOf("style") !=-1
HTMLListElement.getAttribute("title")
HTMLLinkElement.getAttribute("rel").indexOf("alt") !=-1
}
 
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() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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();
setActiveStyleSheet(title);

// End Styleswitcher






// JavaScript  -  External Windows Document

function TJKpop(){ // v1.0 | www.TJKDesign.com
  var e = document.getElementById('wrapper');
  if (e){
    var a=e.getElementsByTagName('a');

    for (var i=0;i<a.length;i++){
		
    if (a[i].getAttribute('href') != null && a[i].getAttribute('href').indexOf("http://") >= 0 && a[i].getAttribute('href').toUpperCase().indexOf(document.domain.toUpperCase()) == -1){

        a[i].className+=a[i].className?' outlink':'outlink';
        a[i].title+=' (opens in new window)';
				var rand = Math.round((Math.random() * 10000));
				a[i].onclick=function(){newWin=window.open(this.href,rand);if(window.focus){newWin.focus()} return false;}
        a[i].onkeypress=function(){newWin=window.open(this.href,rand);if(window.focus){newWin.focus()} return false;}
      }
    }
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(function(){if(document.getElementById) TJKpop();});

// End External Windows Document


// JavaScript  -  PDF Documents Windows


function TJKpopAppPdf(){ 

if(document.getElementById("wrapper"))    {
     var zA=document.getElementById("wrapper").getElementsByTagName("a");
	for (var i=0;i<zA.length;i++){
	// if the type value contains "application/pdf" or if the href value contains "PDF" or if the file is in a "PDF" folder then we have a winner
  if (zA[i].getAttribute("href") != null && zA[i].getAttribute("href").toUpperCase().indexOf(".PDF") >= 0){
		zA[i].title+=" (opens in new window)";
		zA[i].className+=zA[i].className?" pdfFile":"pdfFile";
		// This spawns multiple windows, but works fine with popup blockers
		// zA[i].target="_blank";
		// This opens a unique window and brings it in front of the opener each time the user clicks on the link
		// Note that the new window opens without a toolbar. This is to avoid further conusion for the visitor 
		zA[i].onclick=function() {newWin=window.open(this.href,"TJKWin");if( window.focus){newWin.focus()} return false;}
		zA[i].onkeypress=function() {newWin=window.open(this.href,"TJKWin");if( window.focus){newWin.focus()} return false;}
		}
	}
}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
var isOpera = false;
var agt = navigator.userAgent.toLowerCase();
if(agt.indexOf("opera") > 0) isOpera = true;

if(!isOpera)
	addLoadEvent(function(){if(document.getElementById) TJKpopAppPdf();});

// End PDF Documents Windows