// onload will process an array we can push any functions to that we want
var old = window.onload; // catch any existing onload calls 1st
window.onload = function () {
  if (old) { // execute existing onloads
    old();
  };
  for (var ii = 0; arguments.callee.actions.length > ii; ii++) {
    arguments.callee.actions[ii]();
  };
};
window.onload.actions = [];

function fixLinks()
{
	if (!document.getElementsByTagName) return null;
	var server = document.location.hostname;
	var anchors = document.getElementsByTagName("a");
	var id, href, title;
	for(var i=0; i < anchors.length; i++){
	if(!anchors[i].href) continue;
		href = anchors[i].href;
		title = anchors[i].title;
		id = anchors[i].id;
		if(href.indexOf(server) == -1){ // Href is not a file on my server
			if(href.indexOf("javascript:") == -1){ // Href is not a javascript call
				if(!anchors[i].onclick){ // Href does not have an onclick event
					if(href.indexOf("mailto:") == -1){ // Href is not a mailto:
						if((href.indexOf("http://") != -1) || (href.indexOf("https://") != -1)){ // Href is not relative (for Safari)
							anchors[i].setAttribute("target","_blank");
							//anchors[i].setAttribute("href","#");
							anchors[i].setAttribute("title",title + " [This Link Will Open in a New Window]");
						}
					}
				}
			}
		}
	}
	
	//DO THE SAME FOR FORMS

	var forms = document.getElementsByTagName("form");
	for(var i=0; i < forms.length; i++){
	if(!forms[i].href) continue;
		href = forms[i].href;
		title = forms[i].title;
		id = forms[i].id;
		if(href.indexOf(server) == -1){ // Href is not a file on my server
			if((href.indexOf("http://") != -1) || (href.indexOf("https://") != -1)){ // Href is not relative (for Safari)
				forms[i].setAttribute("target","_blank");
			}
		}
	}
	return null;
}
window.onload.actions.push(fixLinks);




myInterval = 0;
providerHeight = 0;
openedHeight = 150;
openingInterval = 30;
openingStep = 2;

function toggleProvider(button){
	providerOpen(button);
	return false;
}


function providerOpen(button){
	myInterval = window.setInterval(providerExpand,openingInterval);
	openingStep = 2;
	$('t_provider').style.display = "block";
	button.onclick = function(){
		providerClose(this);
		return false;
	}
}

function providerClose(button){
	myInterval = window.setInterval(providerCondense,openingInterval);
	openingStep = 2;
	button.onclick = function(){
		providerOpen(this);
		return false;
	}
}

function providerExpand(){
	if ((openedHeight - providerHeight) < (openingStep*3)) openingStep -= 3; else  openingStep+= 3;
	providerHeight += openingStep;
	if (providerHeight > openedHeight) {
		providerHeight = openedHeight;
		window.clearInterval(myInterval);
	}
	$('t_provider').style.height = providerHeight+'px';
}

function providerCondense(){
	if ((providerHeight) < (openingStep*(-3))) openingStep -= 3; else  openingStep+= 3;
	providerHeight -= openingStep;
	if (providerHeight < 1) {
		providerHeight = 1;
		window.clearInterval(myInterval);
		$('t_provider').style.display = "none";
	}
	$('t_provider').style.height = providerHeight+'px';
}