function autofitIframe(id) {
	if (document.all && document.getElementById) {
		parent.document.getElementById(id).style.height = this.document.body.offsetHeight + "px";
	} else if (document.getElementById) {
		parent.document.getElementById(id).style.height = this.document.body.scrollHeight + "px";
	}
}





// #####################################################################
// defines the browser DOM
// #####################################################################

userAgent = navigator.userAgent;
var NN=0;
var IE=0;
var DOM=0;
if (userAgent.search('MSIE')>=0) {
	IE=1;
} else {
	NN = 1; 
	if (parseInt(navigator.appVersion)>4) {
  		NN=0;IE=1;DOM=1;
	};
};


// #####################################################################
// MOUSE POSITION
// ####################################################################



// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position
        // reflects the position from the top/left of the screen the
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}


// #######################################################################################
// STANDARD FUNCTION FOR POPUP WINDOW
// #######################################################################################
function thisPopup(URL, left, top, width, height, scrollbars) {
	var standardSetting = 'toolbar=0, location=0, directories=0, status=0, scrollbars=' + scrollbars;
	var customSetting = 'menubar=0, resizable=1, width=' + width + ', height=' + height;
	var positioning = 'left=' + left + ', top =' + top;
	// create window
	closePopup();
	z_win = window.open(URL, 'myPopup', + '\'' + standardSetting + ', ' + customSetting + ', ' + positioning + '\'');
	z_win.focus();
}

// #######################################################################################
// CLOSES POPUP WINDOW IF ALREADY OPEN
// #######################################################################################
function closePopup() {
	if (window.z_win) {
		window.z_win.close();
	}
}

// #######################################################################################
// REFRESHES OPENER
// #######################################################################################
function refreshOpener(URL) {
	window.opener.location.href = URL;
}


// #######################################################################################
//VARIOUS POPUP WINDOW CALLERS
// #######################################################################################
function popupForm(URL, width, height) {
	thisPopup(URL, 100, 120, width, height, 1);
}

function openClubMemberForm() {
	left = 200;
	top = 120;
	width = 380;
	height = 430;
	scrollbars = 1;
	URL = "templates/snug_club_signup.php";
	thisPopup(URL, left, top, width, height, scrollbars);
}

function closeSnugClub() {
	self.close();
}



// #######################################################################################
// RESIZES WINDOW
// #######################################################################################
function resizeWindow(width, height) {
	window.resizeTo(width, height);
}







// #####################################################################
// makes a hidden div layer visible
// #####################################################################

var openDiv = '';

function showMe(div) {
	if (openDiv) {
		hideMe(openDiv);
	}
	openDiv = div;	
	if (DOM) {
		document.getElementById(div).style.visibility = 'visible';
		document.getElementById(div).style.display = 'block';
		document.getElementById(div).style.left = 150;
		document.getElementById(div).style.top = yMousePos - 40;
	} else if (IE) {
		document.all[div].style.visibility = 'visible';
		document.all[div].style.display = 'block';
		document.all[div].style.pixelLeft = 150;
		document.all[div].style.pixelTop = yMousePos - 40;
	} else if (NN) {
	    document.div.visibility = 'show';
		document.div.display = 'block';
		document.div.pixelLeft = 150;
		document.div.pixelTop = yMousePos - 40;
	}
} // end function

function showMeExtended(div, offsetleft, offsetTop) {
	if (openDiv) {
		hideMe(openDiv);
	}
	openDiv = div;	
	if (DOM) {
		document.getElementById(div).style.visibility = 'visible';
		document.getElementById(div).style.display = 'block';
		document.getElementById(div).style.left = xMousePos + offsetleft;
		document.getElementById(div).style.top = yMousePos - offsetTop;
	} else if (IE) {
		document.all[div].style.visibility = 'visible';
		document.all[div].style.display = 'block';
		document.all[div].style.pixelLeft = xMousePos + offsetleft;
		document.all[div].style.pixelTop = yMousePos - offsetTop;
	} else if (NN) {
	    document.div.visibility = 'show';
		document.div.display = 'block';
		document.div.pixelLeft = xMousePos + offsetleft;
		document.div.pixelTop = yMousePos - offsetTop;
	}
} // end function




