// =========================================================================================
// FlashAPI
// 
// Ryan Taylor
// October 16, 2006
// 
// API for communicating back and forth between the browser, JavaScript, and Flash.
// =========================================================================================
// 
// +          +          +          +          +          +          +          +          +
// 
// =========================================================================================

// Reference to the flash object.
var objFlash = document.getElementById('swf_file');

// =====================================================================================
// CHAT FUNCTIONS
// =====================================================================================

// LaunchChat
// 
// Called from Flash.
// This is a hack to make ExternalInterface calls work with Flash Player 9 in Firefox.
function LaunchChat()
{
	// Set a timeout to give the returned success boolean a chance to return to Flash before 
	// stealing the focus from Flash with the new popup window.
	window.setTimeout("OpenChatWindow()", 200);
	
	// Return 'true' indicating that the call was a success.
	return true;
}

// OpenChatWindow
// 
// Opens a new live chat window.
function OpenChatWindow()
{
	// Open the new live chat window.
	window.open('http://server.iad.liveperson.net/hc/16732026/?cmd=file&file=visitorWantsToChat&site=16732026&referrer='+escape(document.location),'chat16732026','width=472,height=320');return false;
}

// =====================================================================================
// REGULAR EXPRESSION FUNCTIONS
// =====================================================================================

// ValidatePhone
// 
// ##########
// ###-###-####
// ###.###.####
// 
// Tests a phone number against the formats shown above.
function ValidatePhone(strInput)
{
	// The regular expression to test the input against.
	var objRegExp_1 = /^\d{3}(\-|\.)\d{3}(\-|\.)\d{4}/;
	var objRegExp_2 = /^\d{10}/;
	
	// Return the test results.
	return objRegExp_1.test(strInput) || objRegExp_2.test(strInput);
}

// ValidateEmail
// 
// X#@X#.XX
// X#@X#.XXX
// 
// Tests an email address against the formats shown above.
function ValidateEmail(strInput)
{
	// The regular expression to test the input against.
	//var objRegExp = /^\w+(@)\w+(\.){1}[a-z]{2,3}$/;
	var objRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\.\-])+\.)+([a-zA-Z0-9]{2,4})$/;
	
	// Return the test results.
	return objRegExp.test(strInput);
}

// ValidateData
// 
// #-#-####
// #/#/####
// #.#.####
// ##-##-####
// ##/##/####
// ##.##.####
// 
// Teets a date against the formats shown above.
function ValidateData(strInput)
{
	// The regular expression to test the input against.
	var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
	
	// Return the test results.
	return objRegExp.test(strInput);
}
