// JavaScript Document
document.domain='lacasting.com'; // required for functions to work across sub domains

/*
Note:
SAFARI requires a doctype in the iframe content page to return height correctly
-works with //DTD HTML 4.01 Transitional
*/


function getWindowHeight() { // this is the parent height
var windowHeight=0;
if (typeof(window.innerHeight)=='number'){
windowHeight=window.innerHeight;}
else {
if (document.documentElement && document.documentElement.clientHeight){
windowHeight=document.documentElement.clientHeight;}
else {
if (document.body && document.body.clientHeight){
windowHeight=document.body.clientHeight;}
}}
return windowHeight;
}

function setFooter(){
if (document.getElementById){
	var footerElement=document.getElementById('footer');
	footerElement.style.visibility='hidden';
var windowHeight=getWindowHeight();
if (windowHeight>0){
var contentHeight=document.getElementById('content').offsetHeight;

var footerHeight=footerElement.offsetHeight;
if (windowHeight-(contentHeight+footerHeight)>=0){
footerElement.style.position='relative';
footerElement.style.top=(windowHeight-(contentHeight+footerHeight))+'px';}
else {
footerElement.style.position='static';}
}}
footerElement.style.visibility='visible';
}

function resizeCaller() {

// document.defaultIframeWidth='780px';
document.defaultIframeHeight='75%';
resizeIframe('ifrm');
}

function getIframeHeight(iframeid){ // this is the iframe content height
var iCurrframe=document.getElementById(iframeid);
var iCurrHeight;

if (iCurrframe.contentDocument && iCurrframe.contentDocument.body.offsetHeight){ //NS6, MOZ, FF, SAFARI
iCurrHeight=iCurrframe.contentDocument.body.offsetHeight+10+'px';}
else if (iCurrframe.Document && iCurrframe.Document.body.scrollHeight){ //IE5+
iCurrHeight=iCurrframe.Document.body.scrollHeight+10+'px';}
else{
iCurrHeight=document.defaultIframeHeight;} // IF RESIZE FAILS

return iCurrHeight;
}


function resizeIframe(iframeid){
var iCurrframe=document.getElementById(iframeid);
var iCurrHeight=getIframeHeight(iframeid);

//iCurrframe.style.width=document.defaultIframeWidth;
iCurrframe.style.height=iCurrHeight;



if (iCurrframe.addEventListener){
iCurrframe.addEventListener("load", readjustIframe, false);}
else if (iCurrframe.attachEvent){
iCurrframe.detachEvent("onload", readjustIframe); // Bug fix line
iCurrframe.attachEvent("onload", readjustIframe);}

setFooter(); // REQUIRES DIV ID=content & DIV ID=footer
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt;
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement;
if (iframeroot){
resizeIframe(iframeroot.id);}
}

function loadintoIframe(iframeid, url){ // USE INSTEAD OF location.href
if (document.getElementById){
document.getElementById(iframeid).src=url;}
}

if (window.addEventListener){
window.addEventListener("load", resizeCaller, false);
window.addEventListener("resize", setFooter, false);}
else if (window.attachEvent){
window.attachEvent("onload", resizeCaller);
window.attachEvent("onresize", setFooter);}
else{
window.onload=resizeCaller;

window.onresize=setFooter;}


// the following requires textresizedetector.js be included as well
function init()  {
var iBase = TextResizeDetector.addEventListener(onFontResize,null);
//alert("The base font size = " + iBase);
}
function onFontResize(e,args) {
resizeCaller();
/*var msg = "\nThe base font size in pixels: " + args[0].iBase;
msg +="\nThe current font size in pixels: " + args[0].iSize;
msg += "\nThe change in pixels from the last size:" + args[0].iDelta;
alert(msg);*/
}
//id of element to check for and insert control
TextResizeDetector.TARGET_ELEMENT_ID = 'content';
//function to call once TextResizeDetector has init'd
TextResizeDetector.USER_INIT_FUNC = init;




function NewWindow(mypage, myname, w, h, sc, r, m, t, st) {
var winl = 0;
var wint = 0; //(screen.height - h) / 2
props = '';
props += 'top='+wint+',';
props += 'left='+winl+',';
props += 'width='+w+',';
props += 'height='+h+',';
props += 'scrollbars='+sc+',';
props += 'resizable='+r+',';
props += 'menubar='+m+',';
props += 'toolbar='+t+',';
props += 'status='+st+',';
win = window.open(mypage, myname, props)
win.focus(); // always force window into focus
}



