function displayLightBoxMsg(strConfirmationMsg, pIntWidth, pIntHeight)
{
	intWidth = 600; // Default...
	intHeight = 220; // Default...
	if(arguments.length >= 3)
	{
		intWidth = pIntWidth;
		intHeight = pIntHeight;
	}
	Lightbox.showBoxByAJAX('/ajax/displayLightBoxMsg.cfm?strConfirmationMsg=' + encodeURIComponent(strConfirmationMsg), intWidth, intHeight);
}

function displayVideoPlayer(CTM_ID, CTM_FilePath , pIntWidth, pIntHeight)
{
	intWidth = 600; // Default...
	intHeight = 220; // Default...
	if(arguments.length >= 4)
	{
		intWidth = pIntWidth;
		intHeight = pIntHeight;
	}
	Lightbox.showBoxByAJAX('/ajax/displayVideoPlayer.cfm?CTM_ID=' + CTM_ID + '&CTM_FilePath=' + CTM_FilePath + '&intWidth=' + intWidth + '&intHeight=' + intHeight, intWidth, intHeight);
}

function displayVideoPlayer08(FilePath , pIntWidth, pIntHeight)
{
	intWidth = 419; // Default...
	intHeight = 236; // Default...
	if(arguments.length >= 3)
	{
		intWidth = pIntWidth;
		intHeight = pIntHeight;
	}
	Lightbox.showBoxByAJAX('/ajax/displayVideoPlayer08.cfm?FilePath=' + FilePath + '&intWidth=' + intWidth + '&intHeight=' + intHeight, intWidth, intHeight);
}

function emailThisPageToAFriend(strPageURL, strRedirect)
{	intWidth = 600;
	intHeight = 470;
	Lightbox.showBoxByAJAX('/ajax/emailThisPageToAFriend.cfm?strPageURL=' + strPageURL + '&strRedirect=' + strRedirect, intWidth, intHeight);
	$("box").setStyle({
		background: '#FFFFFF',
		border: '2px solid #000000'
	});
	$("close").setStyle({
		display:'block'
	});
}

// Function used under the 'Email to a Friend' section uder my Account...
function validateEmailToAFriendForm()
{
	objForm = document.frmEmail;
	blnError = false;
	strErrorMsg = '';
	if(objForm.strMyEmail.value == '')
	{
		strErrorMsg += '\nPlease enter your email address';
		blnError = true;
	}
	else if(!_CF_checkEmail(objForm.strMyEmail.value, true))
	{
		strErrorMsg += '\nPlease enter a valid email address';
		blnError = true;
	}
	
	if(objForm.txtMessage.value == '')
	{
		strErrorMsg += '\nPlease enter a message';
		blnError = true;
	}
	if(objForm.strFriendsName.value == '')
	{
		strErrorMsg += "\nPlease enter your friend's name";
		blnError = true;
	}
	if(objForm.strFriendsEmail.value == '')
	{
		strErrorMsg += "\nPlease enter your friend's email address";
		blnError = true;
	}
	/* - Removed email validation since it fails when multiple email addresses are entered - Victor - August 11, 2008
	else if(!_CF_checkEmail(objForm.strFriendsEmail.value, true))
	{
		strErrorMsg += '\nPlease enter a valid email address';
		blnError = true;
	}												
	*/
	if(blnError)
	{
		alert(strErrorMsg);
	}
	else
	{
		/* Submit the form...*/
		objForm.submit();
	}	
}

/* Helper functions stollen from the cfform.js file */											
function _CF_checkregex(object_value, regexPattern, required)
{
	if( required )
	{
		if( object_value.length == 0 )
		{
			return false;
		}
	}else{
		if( object_value.length == 0 )
		{
			return true;
		}
	}

	return regexPattern.test(object_value);
}

function _CF_checkEmail(object_value, required)
{
	//trim whitespace before we validate
	object_value = object_value.replace(/^\s+/,'').replace(/\s+$/,'');
	return _CF_checkregex(object_value, /^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$/, required);
}

/* AJAX function used to display judging panel...*/
function judgingPanel()
{	
	intWidth = 697;		// Default
	intHeight = 572;	// Default
	Lightbox.showBoxByAJAX('/ajax/anteUpJudgingPanel.cfm', intWidth, intHeight);
	$("box").setStyle({
		background: 'none',
		border: 'none'
	});
	$("close").setStyle({
		display:'none'
	});
}

/* AJAX function used to display leaderboards...*/
function leaderboard()
{	
	intWidth = 434;		// Default
	intHeight = 380;	// Default
	Lightbox.showBoxByAJAX('/ajax/anteUpLeaderboard.cfm', intWidth, intHeight);
	$("box").setStyle({
		background: 'none',
		border: 'none'
	});
	$("close").setStyle({
		display:'none'
	});
}

/* AJAX function used to display contestant bio...*/
function bio(ctb_id)
{
	intWidth = 697;		// Default
	intHeight = 572;	// Default
	Lightbox.showBoxByAJAX('/ajax/anteUpBio.cfm?ctb_id=' + ctb_id, intWidth, intHeight);
	$("box").setStyle({
		background: 'none',
		border: 'none'
	});
	$("close").setStyle({
		display:'none'
	});
}

/* AJAX function used to display voting box */
function anteUpVote(ctb_id)
{
	intWidth = 697;		// Default
	intHeight = 572;	// Default
	Lightbox.showBoxByAJAX('/ajax/anteUpVote.cfm?ctb_id=' + ctb_id, intWidth, intHeight);
	$("box").setStyle({
		background: 'none',
		border: 'none'
	});
	$("close").setStyle({
		display:'none'
	});
}
function submitAnteUpVote(result){
	$('voteBtn').src = '/resource/image/spinner.gif';
	if(result){
		var url = '/ajax/anteUpVoteThankYou.cfm';
		var params = 'email=' + $F('email') + '&ctb_id=' + $F('ctb_id') + '&captcha=' + $F('captcha');
		var ajax = new Ajax.Updater({success: 'voteInformation'},url,{method: 'get', parameters: params, evalScripts: true});
	}else{
		$('voteBtn').src = '/resource/mike-and-ike-ca/image/button/vote.png';	
	}
}