/*
Title: Utility Javascript
Author: designkitchen, inc.
*/
//for IE
var ie = document.all?true:false;
var ieversion;
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
}

// This is used to open links in external windows. The HTML syntax is as follows:
// <a href="document.html" rel="external">external link</a>
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function placeFooter() {
	var viewportHeight = document.viewport.getHeight();
	var swooshwrapHeight = $('swooshwrap').getHeight();
	var footerwrapHeight = $('footerwrap').getHeight();
	if ((swooshwrapHeight + footerwrapHeight) < viewportHeight) {
		if (Prototype.Browser.IE && navigator.userAgent.indexOf('MSIE 6') > -1) {
			$('maincontainer').setStyle( { height: (viewportHeight - footerwrapHeight) + 'px' } );
		}
		else {
			$('maincontainer').setStyle( { minHeight: (viewportHeight - footerwrapHeight) + 'px' } );
		}
	}
}
Event.observe(window, 'resize', placeFooter);
document.observe("dom:loaded", placeFooter);

// function sizeFrame() {
// 	if(!ie) {
// 		if(document.getElementById("maincontainer") && window.scrollMaxY > 0) {
// 			document.getElementById("maincontainer").style.height=getHeight()+"px";
// 		}
// 	}
// 	else if (ieversion == "7") {
// 		document.getElementById("maincontainer").style.height=getHeight()+"px";
// 	}
// 	if(document.getElementById("footerwrap"))
// 		document.getElementById("footerwrap").style.visibility="visible";
// }
// window.onload = sizeFrame;
// function getHeight(){
// 	if (window.innerHeight && window.scrollMaxY) {// Firefox
// 		yWithScroll = window.innerHeight + window.scrollMaxY+60;
// 	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
// 		yWithScroll = document.getElementById("content").offsetHeight + document.getElementById("content").offsetLeft;
// 		if(yWithScroll < 400)
// 			yWithScroll = document.body.clientHeight-38;
// 		else
// 			yWithScroll = document.getElementById("content").offsetHeight + document.getElementById("content").offsetLeft + 150;
// 	}
// 	return yWithScroll;		
// }
function open_window(url,w,h) {
       var status_string = "resizable=yes,location=no,status=no,toolbar=no,scrollbars=no,width="+w+",height="+h;
       open(url, "_blank", status_string);
}
