function toggleField(val) { var o = document.getElementById('lead-other'); var p = document.getElementById('lead-label'); (val == '40320')? o.style.display = 'block' : o.style.display = 'none'; (val == '40320')? p.style.display = 'block' : p.style.display = 'none'; }

var currentVal;
function popContent(boxVal) {
	if (currentVal != undefined) {
		document.getElementById("hidden-content-"+currentVal).style.visibility = "hidden";
	}
	document.getElementById("hidden-content-"+boxVal).style.visibility = "visible";
	currentVal = boxVal;
}
function closePop(boxVal) {
	document.getElementById("hidden-content-"+boxVal).style.visibility = "hidden";
}

function hideContent() {
	//document.getElementById("drop-shadow-bottom-inner").style.visibility = "hidden";
	new Effect.Move('content-box', {
		x: 0,
		y: 162,
		mode: 'absolute',
		duration: 0.5,
		afterFinish: function() {
			document.getElementById("hide-button").style.visibility = "hidden";
			document.getElementById("show-button").style.visibility = "visible";
			new Effect.Move('show-button', { x: 0, y: -18, mode: 'absolute', duration: 0.2 });
		}
	});
}

function showContent() {
	new Effect.Move('show-button', { x: 0, y: 0, mode: 'absolute', duration: 0.1 });
	document.getElementById("hide-button").style.visibility = "visible";
	document.getElementById("show-button").style.visibility = "hidden";
	new Effect.Move('content-box', {
		x: 0,
		y: 0,
		mode: 'absolute',
		duration: 0.5,
		afterFinish: function() {
			//document.getElementById("drop-shadow-bottom-inner").style.visibility = "visible";
		}
	});
}

function hideBigContent(boxId, moveY) {
	// moveY will be determined automatically if boxId is "long-content"
	if (boxId == "long-content") {
		moveY = bgHeight-30;
	}
	new Effect.Move(boxId, {
		x: 0,
		y: moveY,
		mode: 'relative',
		duration: 0.5,
		afterFinish: function() {
			document.getElementById("hide-button").style.visibility = "hidden";
			document.getElementById("show-button").style.visibility = "visible";
			new Effect.Move('show-button', { x: 0, y: -18, mode: 'relative', duration: 0.2 });
		}
	});
}

function showBigContent(boxId, moveY) {
	if (boxId == "long-content") {
		moveY = 0-(bgHeight-30);
	}
	new Effect.Move('show-button', { x: 0, y: 18, mode: 'relative', duration: 0.1 });
	document.getElementById("hide-button").style.visibility = "visible";
	document.getElementById("show-button").style.visibility = "hidden";
	new Effect.Move(boxId, {
		x: 0,
		y: moveY,
		mode: 'relative',
		duration: 0.5
	});
}

// Window Resizer
var originalBgWidth = 1680;
var originalBgHeight = 850;
var minResizedHeight = 472;
var bgRatio = originalBgWidth/originalBgHeight;
var headerHeight = 109;
var footerHeight = 118;
var theWidth;
var theHeight;
var bgHeight;

function getDimensions() {
	// window dimensions
	if (window.innerWidth)
		theWidth=window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		theWidth=document.documentElement.clientWidth;
	else if (document.body)
		theWidth=document.body.clientWidth;

	if (window.innerHeight)
		theHeight=window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		theHeight=document.documentElement.clientHeight;
	else if (document.body)
		theHeight=document.body.clientHeight;

	bgHeight = theHeight - (headerHeight+footerHeight);
	// bgHeight has a maximum of 850 pixels
	if (bgHeight > originalBgHeight) {
		bgHeight = originalBgHeight;
	}
	if (bgHeight < minResizedHeight) {
		bgHeight = minResizedHeight;
	}
}

function resizeContent() {
	document.getElementById("flash-holder-container").style.height = bgHeight+"px";
	document.getElementById("drop-shadow-bottom").style.top = bgHeight-11+"px";
	//calculate static image dimensions
	if (Math.round(theWidth/bgRatio) < bgHeight) {
		imgWidth = Math.round(bgHeight*bgRatio);
		imgHeight = bgHeight;
	} else if (Math.round(theWidth/bgRatio) > bgHeight) {
		imgWidth = theWidth;
		imgHeight = Math.round(theWidth/bgRatio);
	} else {
		imgWidth = theWidth;
		imgHeight = bgHeight;
	}

	// resize still image if used
	if (document.getElementById("content-img")) {
		document.getElementById("content-img").style.height = imgHeight+"px";
		document.getElementById("content-img").style.width = imgWidth+"px";
		// center image
		if (imgWidth > theWidth) {
			posLeft = Math.round((imgWidth-theWidth)/2);
			document.getElementById("content-img").style.left = "-"+posLeft+"px";
		} else {
			document.getElementById("content-img").style.left = "0px";
		}
		if (imgHeight > bgHeight) {
			posTop = Math.round((imgHeight-bgHeight)/2);
			document.getElementById("content-img").style.top = "-"+posTop+"px";
		} else {
			document.getElementById("content-img").style.top = "0px";
		}
	}

	// resize form if exists
	if (document.getElementById("long-content-container")) {
		document.getElementById("main-content-container").style.height = bgHeight-25+"px";
		document.getElementById("long-content-container").style.height = bgHeight-25+"px";
	}
	if (document.getElementById("scroll-box")) {
		document.getElementById("scroll-box").style.height = (bgHeight-162)+"px";
	}
	if (document.getElementById("thank-you-box")) {
		document.getElementById("thank-you-box").style.height = (bgHeight-125)+"px";
	}

	// reposition big content box if exists
	if (document.getElementById("med-content-middle") || document.getElementById("big-content-middle")) {
		posTop = Math.round((bgHeight-minResizedHeight)/2);
		document.getElementById("main-content-wrapper").style.top = posTop+"px";
	}
	// reposition big content show/hide box if exists
	if (document.getElementById("big-content-bottom")) {
		posTop = bgHeight-421;
		document.getElementById("main-content-wrapper").style.top = posTop+"px";
	}
}

window.onresize = function() {
	getDimensions();
	resizeContent();
};