﻿var popup;
var modalWidth = '370px';
var maxModalWidth = '555px'; // flush to edge of stadium nav
var currentModalWidth;

function popUp() {

	if(arguments.length > 0) {
		popup = window.open(arguments[0] + '.aspx','popup','width=250,height=250,scrollbars=0');
		popup.focus();
	}
}

function openModalPopUp() {
	if(arguments.length > 0) {
		if(arguments[0].toLowerCase() == 'wherebuy!') {
			myLightbox.startModal({ url:arguments[0] + '.aspx', width:maxModalWidth, height:'325px', top:'150px', left:'150px', relativeTo:'homeContent', borderSize:'0', overlay:'no', chrome:'no' });
			currentModalWidth = maxModalWidth;
			return;
		}
		myLightbox.startModal({ url:arguments[0] + '.aspx', width:modalWidth, height:'325px', top:'150px', left:'150px', relativeTo:'homeContent', borderSize:'0', overlay:'no', chrome:'no' });
		currentModalWidth = modalWidth;
	}
}

function closeModalPopUp() { myLightbox.endModal(); }

function closePopUp() {
	if($('lightboxPage')) { closeModalPopUp(); } // TODO: close flash placeholder
	else { popup.close(); }
}

function flashPageLoader() {
	if(arguments.length > 0) {
		if(objBabyRuth) {
			objBabyRuth.pageLoader(arguments[0]);
		} else {
			document.getElementById('objBabyRuth').pageLoader(arguments[0]);
		}
	}
}

/* INDIVIDUAL POPUPS */
var header = document.getElementById('header');
var content = document.getElementById('content');
var text = document.getElementById('text');
var privacy = document.getElementById('privacy');

if(header && content && text) {
	content.style.display = 'none';
	window.onload = function() {
		content.style.display = '';
	};

	if(parent.document.getElementById('lightboxPage')) {
		header.style.display = 'none';
		content.style.width = parent.currentModalWidth;
		content.style.background = 'none';
		text.style.width = content.style.width;
		text.style.height = '305px';
		text.style.overflow = 'auto';
		text.style.marginTop = '20px';
		text.style.marginLeft = '0';
		if(privacy) { privacy.style.display = 'none'; }
	}

	if(window.name == 'popup') {
		text.style.overflow = 'auto';
		var scrollFix = 45;
		var h = parseInt(header.style.height.replace('px','')) + parseInt(text.style.marginTop.replace('px','')) + parseInt(text.style.height.replace('px','')) + scrollFix;
		window.resizeTo(parseInt(header.style.width.replace('px','')),h);
	}
}
