$(function(){
  if ($("#phone").length > 0) {
		// Checks to make sure people enter a valid phone number.
		$("#phone").mask("(999) 999-9999");
	}

	// Begin home flash embed code.
	if($('#flash_container_home').length > 0) {
		var flashvars = {};
		var params = {
				allowscriptaccess: 'always',
				wmode: 'transparent',
				quality: 'high'
			};
		var attributes = {
				id: 'flash_container_home'
			};

		swfobject.embedSWF(
			"http://www.thesecrettowriting.com/HomePlayer.swf", 
			"flash_container_home", "920", "387", "9.0.0","xi/expressInstall.swf", 
			flashvars, params, attributes
			);
	} 
	// End home flash embed code.

	// Begin what makes us different flash embed code.
	if($('.what_makes_us_different').length > 0) {
		var flashvars = {
				theVIDEO: 'http://thesecrettowriting.com/videos/WhatDifferentiatesUs.flv'
			};
		var params = {
				allowscriptaccess: 'always',
				wmode: 'transparent',
				quality: 'high'
			};
		var attributes = {
				id: 'Flash'
			};

		swfobject.embedSWF(
			"http://www.thesecrettowriting.com/dev/singleplayer/SinglePlayer.swf", 
			"what_differentiates_us_flash", "545", "332", "9.0.0","xi/expressInstall.swf", 
			flashvars, params, attributes
			);
	} 
	// End what makes up different flash embed code.
	
	// Begin students flash embed code.
	if($('.students').length > 0) {
		var flashvars = {
				theVIDEO: 'http://thesecrettowriting.com/videos/Students.flv'
			};
		var params = {
				allowscriptaccess: 'always',
				wmode: 'transparent',
				quality: 'high'
			};
		var attributes = {
				id: 'Flash_Applicants'
			};

		swfobject.embedSWF(
			"http://www.thesecrettowriting.com/dev/singleplayer/SinglePlayer.swf", 
			"Flash_Applicants", "545", "332", "9.0.0","xi/expressInstall.swf", 
			flashvars, params, attributes
			);
	} 
	// End students flash embed code.
	
	// Begin applicants flash embed code.
	if($('.app').length > 0) {
		var flashvars = {
				theVIDEO: 'http://thesecrettowriting.com/videos/Applicant.flv'
			};
		var params = {
				allowscriptaccess: 'always',
				wmode: 'transparent',
				quality: 'high'
			};
		var attributes = {
				id: 'Flash_Applicants'
			};

		swfobject.embedSWF(
			"http://www.thesecrettowriting.com/dev/singleplayer/SinglePlayer.swf", 
			"Flash_Applicants", "545", "332", "9.0.0","xi/expressInstall.swf", 
			flashvars, params, attributes
			);
	} 
	// End applicants flash embed code.
	
});

function dimLightsOn(e) {
	if ($("#flash_container_home")) {
		$("#flash_container_home").addClass("flash_above");
		}
	if ($("#Flash_Applicants")) {
		$("#Flash_Applicants").addClass("flash_above");	
		}
	if ($("#Flash")) {
		$("#Flash").addClass("flash_above");	
		}
		
		
	$("#overlay").fadeIn("fast");
	
}

function dimLightsOff(e) {
	if ($("#flash_container_home")) {
		$("#flash_container_home").removeClass("flash_above");
		}
	if ($("#Flash_Applicants")) {
		$("#Flash_Applicants").removeClass("flash_above");
		}
	if ($("#Flash")) {
		$("#Flash").removeClass("flash_above");
		}
	
	$("#overlay").fadeOut("fast");
}

$('#header .book').click(function() {
  $('#bookOverlya[style="display: none;"]').removeAttr('style');
  $('#bookOverlay').addClass('open');
  return false;
});

$('#bookOverlay .close_btn').click(function() {
  $('#bookOverlay').removeClass('open');
});

$('.home_page #bookOverlay .close_btn').click(function(){
  $('#bookOverlay').fadeOut();
});

function callPopUp(e) {
  $('#bookOverlay').fadeIn();
}


