$(document).ready(function() {

	// hide confirm and error boxes after 3 seconds
	setTimeout ( "hideConfirmBoxes()", 5000 );
	setTimeout ( "hideErrorBoxes()", 5000 );
	
	// flash video for the landing page
	$('#landing1_flash_video').flash({ src: 'bin/flash/LandingPage.swf', height:360, width:480});
	$('#webinar_flash_video').flash({ src: 'bin/flash/WebinarPage.swf', height:360, width:480});
	$('#webinar2_flash_video').flash({ src: '/bin/flash/Webinar2Page.swf', height:480, width:640});
	$('#demo_flash_video').flash({ src: 'bin/flash/DemoPage.swf', height:811, width:971});
	
	// supposed to fix .png transparency in IE 6
	$('body').supersleight({shim: 'http://www.textcastlive.com/scripts/x.gif'});
	
	// for the top nav2
	$("#topnav li").hover(function() { //Hover over event on list item
		// show our rollover
		var navItem = $(this).find("a").attr('class').substring(0, 6);
		$('.' + navItem).addClass(navItem + '_on');
		$(this).find("div").show(); //Show the subnav
	} , function() { //on hover out...
		// remove our rollover
		var navItem = $(this).find("a").attr('class').substring(0, 6);
		$('.' + navItem).removeClass(navItem + '_on');
		$(this).find("div").hide(); //Hide the subnav
	});
	
	// auto tab for the phone number fields
	$('input[name=area]').autotab({ target: 'pre', maxlength: 3, format: 'numeric' });
	$('input[name=pre]').autotab({ target: 'post', maxlength: 3, format: 'numeric', previous: 'area' });
	$('input[name=post]').autotab({ previous: 'pre', maxlength: 4, format: 'numeric' });
	
	// to submit the demo form
	$('#demo_sub').click(function(){
		$('#demoForm').submit();
		return false;
	});
	
	// to submit the login form
	$('#submit_form_login').click(function(){
		$('#frmLogin').submit();
		return false;
	});

	// Gordon added for step 3
	$("#orderSubmitButton").click(function () { document.frmRegistration.submit(); });	
	
	// do stuff for our label text fields when they get focus
	$('.lblTxt').focus(function (){
		// if the value of the input is the same as the title then we want to 
		// turn the text black, remove the italics, and clear out the value
		if ($(this).val() == $(this).attr('title')){
			$(this).
				val(''). // clear out the text
				removeClass('text-italic'). // remove the italics font style
				removeClass('text-lightgrey'). // remove the grey text style
				addClass('text-black'); // add the black text style
		}
	});
	
	// do stuff for our label text fields when they lose focus
	$('.lblTxt').blur(function (){
		// if the value of the input is the same as the title then we want to 
		// turn the text black, remove the italics, and clear out the value
		if ($(this).val() == ''){
			$(this).
				removeClass('text-black'). // remove the black text style
				addClass('text-italic'). // add the italic font style
				addClass('text-lightgrey'). // add the grey text style
				val($(this).attr('title')); // set the value to the same as the title
		}
	});

	
	// for the rotating banner
	setTimeout ( "displayBanner(0)", 2000 );
});
function hideConfirmBoxes(){
	$('.confirm').slideUp('slow');
	$('.confirm_sm').slideUp('slow');
}
function hideErrorBoxes(){
	$('.error').slideUp('slow');
	$('.error_sm').slideUp('slow');
}
function displayBanner(bannerIndex){
	var banners = new Array();
	banners[0] = '17% of people will forward a good text coupon to friends... it\'s viral!';
	banners[1] = 'Over 95% of all text messages are read within 15 minutes of when they are received.';
	banners[2] = 'More than 20% of people will respond to a text coupon... wow!';
	banners[3] = 'U.S. mobile users now send/receive more texts than phone calls.';
	$('#textPopup').fadeOut('slow', function(){
		$('#textPopup_text').text(banners[bannerIndex]);
		$('#textPopup').fadeIn('slow', function(){
			bannerIndex++;
			if (bannerIndex == banners.length){
				bannerIndex = 0;
			}
			setTimeout ( "displayBanner("+bannerIndex+")", 5000 );
		});
	});
}