function qlOpen()
{
	$('#ql-on').fadeOut('slow');
	$('#menu-container').fadeOut(100, function()
	{
		$('#ql-close').fadeIn('slow');
		$('#ql-main').fadeIn('slow');
		$('#quicklinks-container').animate({
			"height": "379"
		}, 300);
		$('#logo-title img').animate({"marginTop": "229"}, 300);
	});
	return false;
}

function qlClose()
{
	$('#ql-close').fadeOut('slow');
	$('#ql-main').fadeOut(100, function()
	{
		$('#quicklinks-container').animate({
			"height": "173"
		}, 300);
		$('#logo-title img').animate({"marginTop": "23"}, 300);
		$('#ql-on').fadeIn('slow');
		$('#menu-container').fadeIn('slow');
	});
	return false;
}
function reqWin(desktopURL,alternateWidth,alternateHeight,noScrollbars,resizable,winName) { if ((alternateWidth && self.screen.availWidth * 0.8 < alternateWidth) || (alternateHeight && self.screen.availHeight * 0.8 < alternateHeight)) { noScrollbars = false; alternateWidth = Math.min(alternateWidth, self.screen.availWidth * 0.8); alternateHeight = Math.min(alternateHeight, self.screen.availHeight * 0.8); } else noScrollbars = typeof(noScrollbars) != "undefined" && noScrollbars == true; window.open(desktopURL, (winName ? winName : 'requested_popup'), 'toolbar=no,location=no,status=no,menubar=no,scrollbars=' + (noScrollbars ? 'no' : 'yes') + ',width=' + (alternateWidth ? alternateWidth : 480) + ',height=' + (alternateHeight ? alternateHeight : 220) + ',resizable=' + (resizable ? 'yes' : 'no') ); return false; }

function openLiveStream(url)
{
	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
		url = 'http://decatur.mediaserve.com:1935/live/livestream/playlist.m3u8';
	reqWin(url,660,500,0,1,'live_stream');
	return false;
}

function openArchiveStream(service)
{
	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
		url = 'http://decatur.mediaserve.com:1935/archive/mp4:' + service + '.f4v/playlist.m3u8';
	else
		url = '/media/archive_player.php?service=' + service;
	reqWin(url,660,500,0,1,'ondemand_stream');
	return false;
}

function formatAmount(e, field)
{
	var key;
	if (document.all) {
		key=e.keyCode;
	} else {
		key=e.which;
		if (key==13) //return pressed
			return;
		}
		if ((key==37)||(key==39)) //left or right arrow
			return;
		temp=field.value.replace(/[^0-9]/g,"");
		temp=temp.replace(/^0+/,"");
		while (temp.length<3)
			temp="0"+temp;
		if (field.value.search(/-/)!=-1)
			temp="-"+temp;
		field.value=temp.substr(0,temp.length-2)+"."+temp.substr(temp.length-2);
}
function checkMandatory ()
{
    if (!document.form.cost1.value && !document.form.cost2.value && !document.form.cost3.value)
    {
        alert('You must enter an amount into at least one of the three amount fields.');
        document.form.cost1.focus();
        return false;
    }
    if (document.form.cost1.value == 0 && document.form.cost2.value == 0 && document.form.cost3.value == 0)
    {
        alert('You must enter a non-zero amount into at least one of the three amount fields.');
        document.form.cost1.focus();
        return false;
    }
    else if (!document.form.first_name.value)
    {
        alert('You must enter your first name.');
        document.form.first_name.focus();
        return false;
    }
	else if (!document.form.last_name.value)
	{
		alert('You must enter your last name.');
		document.form.last_name.focus();
		return false;
	}
	else if (!document.form.address.value)
	{
		alert('You must enter your billing address.');
		document.form.address.focus();
		return false;
	}
	else if (!document.form.city.value)
	{
		alert('You must enter your billing address city.');
		document.form.city.focus();
		return false;
	}
	else if (!document.form.state.value)
	{
		alert('You must enter your billing address state.');
		document.form.state.focus();
		return false;
	}
	else if (!document.form.zip.value)
	{
		alert('You must enter your billing address zip code.');
		document.form.zip.focus();
		return false;
	}
	else if (!document.form.country.value)
	{
		alert('You must enter your billing address country.');
		document.form.country.focus();
		return false;
	}
	else if (!document.form.phone.value)
	{
		alert('You must enter your phone number.');
		document.form.phone.focus();
		return false;
	}
	else if (!document.form.email.value)
	{
		alert('You must enter your email address.');
		document.form.email.focus();
		return false;
	}
	else if (!document.form.ccnum.value)
	{
		alert('You must enter your credit card number.');
		document.form.ccnum.focus();
		return false;
	}
	else if (!document.form.cvv2_number.value)
	{
		alert('You must enter your credit card CID number.');
		document.form.cvv2_number.focus();
		return false;
	}
	else if (document.form.ccmo.selectedIndex == 0)
	{
		alert('You must enter your credit card expiration month.');
		document.form.ccmo.focus();
		return false;
	}
	else if (document.form.ccyr.selectedIndex == 0)
	{
		alert('You must enter your credit card expiration year.');
		document.form.ccyr.focus();
		return false;
	}

	if (document.form.cost1.value && ! document.form.cost1.value == 0)
	{
		document.form.elements['c1B'].value = document.form.elements['c1A'].value;
	}

	if (document.form.cost2.value && ! document.form.cost2.value == 0)
	{
		document.form.elements['c2B'].value = document.form.elements['c2A'].value;
	}

	if (document.form.cost3.value && ! document.form.cost3.value == 0)
	{
		document.form.elements['c3B'].value = document.form.elements['c3A'].value;
	}
}


