$(document).ready(function() {
	switch (strPageID.toLowerCase()) {
		case "homev2" :
			swfobject.embedSWF(	"/_flash/video.swf", 
								"homepage_video", 
								"366", 
								"245", 
								"9.0.0", 
								"/_js/_swfobject/expressInstall.swf", 
								{
									imagefile: strHomeImage, 
									videofile: strHomeVideo
								}, 
								{menu: "false", wmode: "transparent", base: "_flash/"});
			break;
	}
	
	// global city show function for special module type
	
	$("#cities_show_all").click(function() {
		$(".cities").css("height", "auto");
		$(".cities").css("overflow-y", "visible");
		
		$("#cities_show_all").hide();
		$("#cities_not_listed").show();
	});

	// global show/hide past/current cities
	$("a.cities_list_show_toggle").click(function() { 
		var objElement		= $(".cities_list ul li.hidden:first");
		
		if ((objElement) && ($(objElement).css("display") != "none")) {
			$(".cities_list ul li.hidden")
				.fadeOut(function() { 
					$(".cities_list ul li.current")
						.fadeIn();
					$("a.cities_list_show_toggle").html("Show Past Events");
				});
		} else {
			$(".cities_list ul li.current")
				.fadeOut(function() { 
					$(".cities_list ul li.hidden")
						.fadeIn();
					$("a.cities_list_show_toggle").html("Hide Past Events");
				});
		}
	});
	
	$('div.discount-modal-bg, div.discount-modal').bind('click', function(){
		$('div.discount-modal-bg')
			.css('display', 'none');

		$('div.discount-modal')
			.css('display', 'none');
	});

	$('a.group-pricing').bind('click', function(){
		$('div.discount-modal-bg')
			.css('opacity', 0.5)
			.height( $('body').height() )
			.css('display', 'block');

		$('div.discount-modal')
			.css('display', 'block');

		return false;
	});
	
	// global search button
	$("#search_button_link").click(function() {
		$("#frmSearch").submit();
	});

	switch (strPageID.toLowerCase()) {
		case "homev2" :
			sIFR.replace(eightTrack, {
			  selector: '.sifr_header h2', 
			  wmode: 'transparent', 
			  fitExactly: 'false', 
			  forceSingleLine: 'true',  
			  selectable: 'false', 
			  offsetLeft: 5, 
			  css: {
				'.sIFR-root': { 'color': '#474749', 'letter-spacing': '-0.5' }
			  }
			});
			break;
			
		case "champions" :
			var txtTooltip		= 	"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">" + 
									"<tr>" +
									"<td class=\"c-tl\">&nbsp;</td>" + 
									"<td class=\"c-tr\">&nbsp;</td>" + 
									"</tr><tr>" + 
									"<td class=\"c-m-l\">" + 
									"<div class=\"c-m-l-t\">" + 
									"<img src=\"/_content/ttf.php?fsize=22&text=[NAME]&trans=true\" alt=\"\" />" + 
									"<div class=\"cms_content cms_content_xxsmall\" id=\"tooltip_data\"></div>" + 
									"</div>" + 
									"</td>" + 
									"<td class=\"c-m-r\">&nbsp;</td>" + 
									"</tr><tr>" + 
									"<td class=\"c-bl\">&nbsp;</td>" + 
									"<td class=\"c-br\">&nbsp;</td>" + 
									"</tr>" + 
									"</table>";
			$('.champion_rollover').simpletip({
				onShow: function() {
					this.update(generateTooltip(txtTooltip, this.getParent()[0].name, this.getParent()[0].rel));
				}, 
				showEffect: 'none', 
				content: generateTooltip(txtTooltip, $(this).attr('name'), $(this).attr('rel')), 
				fixed: false, 
				offset: [15, 0]
			});
			break;
			
		case "champions_detail" :
			sIFR.replace(eightTrack, {
			  selector: 'ul.athlete_header li h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 5, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#ffffff', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.header_dynamic h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 10, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.quicknav_left h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 20, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			break;

		case "calendar_athlete" :
			sIFR.replace(eightTrack, {
			  selector: '.header_dynamic h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 10, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.quicknav_left h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 2, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			break;
			
		case "contact" :
			$("#btnSubmit").click(function() {
				$("#frmContact").submit();
			});
			break;
			
		case "slog" :
			sIFR.replace(eightTrack, {
			  selector: 'ul.athlete_header li h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 5, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#ffffff', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			$("#slogger_quickjump_button").click(function() {
				if ($(".slogger_quickjump").css("display") == "block") {
					$(".slogger_quickjump").hide("slow");
					$("#slogger_quickjump_image").attr("src", "/_images/_elements/_headers/slogger_jump.jpg");
				} else {
					$(".slogger_quickjump").show("slow");
					$("#slogger_quickjump_image").attr("src", "/_images/_elements/_headers/slogger_jump_o.jpg");
				}
			});
			break;

		case "slog_athlete" :
			sIFR.replace(eightTrack, {
			  selector: 'ul.athlete_header li h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 5, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#ffffff', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.header_dynamic_426 h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 10, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.quicknav_left h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 20, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			break;
			
		case "slog_category" :
			sIFR.replace(eightTrack, {
			  selector: 'ul.athlete_header li h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 5, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#ffffff', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.header_dynamic_426 h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 10, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			$("#btnSubmit").click(function() {
				$("#frmComment").submit();
			});
			$("#strName").focus(function() {
				if ($("#strName").val() == 'Name') {
					$("#strName").val('');
					$("#strName").css("fontStyle", "normal");
					$("#strName").css("color", "#484848");
				}
			});
			$("#strName").blur(function() {
				if ($("#strName").val() == '') {
					$("#strName").val('Name');
					$("#strName").css("fontStyle", "italic");
					$("#strName").css("color", "#ccd0d1");
				}
			});
			$("#txtComments").focus(function() {
				if ($("#txtComments").val() == 'Comments') {
					$("#txtComments").val('');
					$("#txtComments").css("fontStyle", "normal");
					$("#txtComments").css("color", "#484848");
				}
			});
			$("#txtComments").blur(function() {
				if ($("#txtComments").val() == '') {
					$("#txtComments").val('Comments');
					$("#txtComments").css("fontStyle", "italic");
					$("#txtComments").css("color", "#ccd0d1");
				}
			});
			$("#topics_show_all").click(function() {
				$("ul.topics_left").css("height", "auto");
				$("ul.topics_left").css("overflow-y", "visible");
				
				$("#topics_show_all").hide();
			});
			break;

		case "slog_detail" :
			sIFR.replace(eightTrack, {
			  selector: 'ul.athlete_header li h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 5, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#ffffff', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.header_dynamic h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 10, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.quicknav_left h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 20, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			$("#btnSubmit").click(function() {
				$("#frmComment").submit();
			});
			$("#strName").focus(function() {
				if ($("#strName").val() == 'Name') {
					$("#strName").val('');
					$("#strName").css("fontStyle", "normal");
					$("#strName").css("color", "#484848");
				}
			});
			$("#strName").blur(function() {
				if ($("#strName").val() == '') {
					$("#strName").val('Name');
					$("#strName").css("fontStyle", "italic");
					$("#strName").css("color", "#ccd0d1");
				}
			});
			$("#txtComments").focus(function() {
				if ($("#txtComments").val() == 'Comments') {
					$("#txtComments").val('');
					$("#txtComments").css("fontStyle", "normal");
					$("#txtComments").css("color", "#484848");
				}
			});
			$("#txtComments").blur(function() {
				if ($("#txtComments").val() == '') {
					$("#txtComments").val('Comments');
					$("#txtComments").css("fontStyle", "italic");
					$("#txtComments").css("color", "#ccd0d1");
				}
			});
			break;

		case "store_detail" :
			sIFR.replace(eightTrack, {
			  selector: '.header_dynamic h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 10, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			break;
			
		case "testimonials" : 
			$("#btnSubmit").click(function() {
				var strErrorMessage		= '';
				var boolErrorFound		= false;
				
				if (($("#strFirstName").val() == '') || ($("#strFirstName").val() == "First Name")) {
					strErrorMessage		+=	' - Please enter your first name.\n';
					boolErrorFound		= true;
				}
				if (($("#strLastName").val() == '') || ($("#strLastName").val() == "Last Name")) {
					strErrorMessage		+=	' - Please enter your last name.\n';
					boolErrorFound		= true;
				}
				if (($("#strCity").val() == '') || ($("#strCity").val() == "City")) {
					strErrorMessage		+=	' - Please enter your city.\n';
					boolErrorFound		= true;
				}
				if (($("#txtTestimonial").val() == '') || ($("#txtTestimonial").val() == "Testify!")) {
					strErrorMessage		+=	' - Please enter your testimonial.\n';
					boolErrorFound		= true;
				}
				
				if (boolErrorFound) {
					alert('Some errors were found while trying to process your order.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
					return false;
				} else {
					return true;
				}
			});
			// focus events
			$("#strFirstName").focus(function() { if ($(this).val() == "First Name") $(this).val(""); });
			$("#strLastName").focus(function() { if ($(this).val() == "Last Name") $(this).val(""); });
			$("#strCity").focus(function() { if ($(this).val() == "City") $(this).val(""); });
			$("#txtTestimonial").focus(function() { if ($(this).val() == "Testify!") $(this).val(""); });
			
			// blur events
			$("#strFirstName").blur(function() { if ($(this).val() == "") $(this).val("First Name"); });
			$("#strLastName").blur(function() { if ($(this).val() == "") $(this).val("Last Name"); });
			$("#strCity").blur(function() { if ($(this).val() == "") $(this).val("City"); });
			$("#txtTestimonial").blur(function() { if ($(this).val() == "") $(this).val("Testify!"); });
			break;
			
		case "gallery" :
			$('.gallery_tooltip').simpletip({
				onBeforeShow: function() {
					this.hide();
				}, 
				onShow: function() {
					this.update(this.getParent()[0].rel);
				}, 
				showEffect: 'none', 
				content: $(this).attr('rel'), 
				fixed: false, 
				offset: [15, 0]
			});
			$('.gallery_tooltip').click(function() {
				window.location		= $(this).attr('href');
			});
			break;
			
		case "gallery_detail" :
			sIFR.replace(eightTrack, {
			  selector: '#gallery h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			sIFR.replace(eightTrack, {
			  selector: '.quicknav_left h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetLeft: 25, 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1', 'background-color': '#ffffff' }
			  }
			});
			$('.gallery_photo_button').simpletip({
				onBeforeShow: function() {
					this.hide();
				}, 
				onShow: function() {
					if (this.getParent()[0].title != "") {
						this.update(this.getParent()[0].title);
					} else {
						this.update("");
						this.hide();
					}
				}, 
				showEffect: 'none', 
				content: $(this).attr('title'), 
				fixed: false, 
				offset: [15, 0]
			});
			$('.gallery_video_button').simpletip({
				onBeforeShow: function() {
					this.hide();
				}, 
				onShow: function() {
					if (this.getParent()[0].title != "") {
						this.update(this.getParent()[0].title);
					} else {
						this.update("");
						this.hide();
					}
				}, 
				showEffect: 'none', 
				content: $(this).attr('title'), 
				fixed: false, 
				offset: [15, 0]
			});
			$('.gallery_photo_button').click(function() {
				var strPhotoID			= this.id;
				var arrPhotoInfo		= strPhotoID.split('|');
				var strCaptionText		= this.title;
				
				if (arrPhotoInfo[1] != null) {
					var strPhotoType	= arrPhotoInfo[0];
					var intPhotoID		= arrPhotoInfo[1];

					$('#large_image').attr('src', '');
					
					$('#large_image').hide();
					$('#gallery_large_caption').hide();
					$('#loading_overlay').show();
					
					scrollTo(0, 345);
					
					window.location.hash		= "#" + intPhotoID;
					
					$('#large_image').attr('src', '/_content/_get-image.php?type=' + strPhotoType + '&id=' + intPhotoID);
					$('#caption_text').html(strCaptionText);
					
					$('#large_image').load(function() {
						$('#loading_overlay').hide();
						$('#large_image').show();
						
						if ($('#caption_text').html().length > 0) {
							$('#gallery_large_caption').show();
						}
					});
				}
			});
			$('.gallery_video_button').click(function() {
				var strVideoID			= this.id;
				var arrVideoInfo		= strVideoID.split('|');
				var strCaptionText		= this.title;
				
				if (arrVideoInfo[1] != null) {
					var strVideoType	= arrVideoInfo[0];
					var intVideoID		= arrVideoInfo[1];

					scrollTo(0, 345);

					window.location.hash		= "#" + intVideoID;
					window.fraVideoFrame.location.href = "/_content/_get-video.php?type=" + strVideoType + "&id=" + intVideoID;
					$('#caption_text').html(strCaptionText);
				}
			});
			
			var strLocationHash			= window.location.hash;
			
			if (strLocationHash.length > 0) {
				var intMediaID			= strLocationHash.replace('#', '');
						
				switch (strGalleryMedia) {
					case "photos" :
						$('#large_image').attr('src', '');
						
						$('#large_image').hide();
						$('#gallery_large_caption').hide();
						$('#loading_overlay').show();

						$('#large_image').attr('src', '/_content/_get-image.php?type=' + strGalleryType + '&id=' + intMediaID);
						$('#caption_text').html('');

						$('#large_image').load(function() {
							$('#loading_overlay').hide();
							$('#large_image').show();
							
							if ($('#caption_text').html().length > 0) {
								$('#gallery_large_caption').show();
							}
						});
						break;
						
					case "videos" :
						window.fraVideoFrame.location.href = "/_content/_get-video.php?type=" + strGalleryType + "&id=" + intMediaID;
						$('#caption_text').html('');
						break;
				}
			}
			
			if (strGalleryMedia == "videos") {
				window.fraVideoFrame.location.href = "/_content/_get-video.php?type=" + strGalleryType + "&id=" + intFirstVideoID;
			}
			break;
			
		case "landing_home" :
			isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
			if (!jQuery.support.opacity) {
				if (isIE6) {
					$("#upgrade").show();
				}
			}
			swfobject.embedSWF(	"/_flash/athlete_ticker.swf", 
								"athletes_flash", 
								"570", 
								"209", 
								"9.0.0", 
								"/_js/_swfobject/expressInstall.swf", 
								{
								}, 
								{menu: "false", wmode: "window", base: ""});
			break;

		case "landing_detail" :
			Shadowbox.init();
			break;

		case "landing_signup_extended" :
			Shadowbox.init();
			
			$(".checkbox").click(function() {
				var strRelID		= $(this).attr("rel");
				var objImageObject	= $(this).children("img");
				var intCurVal		= parseInt($("#" + strRelID).val());
				
				if (intCurVal) {
					$("#" + strRelID).val("0");
					objImageObject.attr("src", "/_images/_buttons/input_check_off.png");
				} else {
					$("#" + strRelID).val("1");
					objImageObject.attr("src", "/_images/_buttons/input_check_on.png");
				}
			});
			$(".checkbox_label").click(function() {
				var strTitleID		= $(this).attr("title");
				var objAnchorObject	= $("a[rel=" + strTitleID + "]");
				var objImageObject	= $(objAnchorObject).children("img");
				var intCurVal		= parseInt($("#" + strTitleID).val());
				
				if (intCurVal) {
					$("#" + strTitleID).val("0");
					objImageObject.attr("src", "/_images/_buttons/input_check_off.png");
				} else {
					$("#" + strTitleID).val("1");
					objImageObject.attr("src", "/_images/_buttons/input_check_on.png");
				}
			});
			$("#intSessionID").change(function() {
				calculateTotalDue();
			});
			$("#strPromoCode").change(function() {
				obtainPromoDiscount($(this).val());
			});
			$("#btnSubmit").click(function() {
				if (!boolAJAXActive) {
					var strErrorMessage		= '';
					var boolErrorFound		= false;
					
					/*if ($("#strFirstName").val() == '') {
						strErrorMessage		+=	' - Please enter the first registrant\'s first name.\n';
						boolErrorFound		= true;
						errorClass("#strFirstName", true);
					} else {
						errorClass("#strFirstName", false);
					}
					if ($("#strLastName").val() == '') {
						strErrorMessage		+=	' - Please enter the first registrant\'s last name.\n';
						boolErrorFound		= true;
						errorClass("#strLastName", true);
					} else {
						errorClass("#strLastName", false);
					}
					if ($("#strEmail").val() == '') {
						strErrorMessage		+=	' - Please enter the first registrant\'s e-mail address.\n';
						boolErrorFound		= true;
						errorClass("#strEmail", true);
					} else {
						var strEmail		= $("#strEmail").val();
						var boolEmailValid	= false;
						
						if (strEmail.indexOf('@') > -1) {
							intAtPosition	= strEmail.indexOf('@');
							if (strEmail.indexOf('.', intAtPosition) > -1) {
								boolEmailValid	= true;
							}
						}
						
						if (!boolEmailValid) {
							strErrorMessage		+=	' - Please enter a valid e-mail address for the first registrant.\n';
							boolErrorFound		= true;
							errorClass("#strEmail", true);
						} else {
							errorClass("#strEmail", false);
						}
					}
					if ($("#strPhone").val() == '') {
						strErrorMessage		+=	' - Please enter the first registrant\'s phone number.\n';
						boolErrorFound		= true;
						errorClass("#strPhone", true);
					} else {
						errorClass("#strPhone", false);
					}
					if ($("#intSessionID").val() == '0') {
						strErrorMessage		+=	' - Please select a session time.\n';
						boolErrorFound		= true;
						errorClass("#intSessionID", true);
					} else {
						errorClass("#intSessionID", false);
					}*/
					
					// payment
					if ($("#strCardholderName").val() == '') {
						strErrorMessage		+=	' - Please enter the cardholder\'s full name.\n';
						boolErrorFound		= true;
						errorClass("#strCardholderName", true);
					} else {
						errorClass("#strCardholderName", false);
					}
					if ($("#strCardNumber").val() == '') {
						strErrorMessage		+=	' - Please enter the credit card number you will be using.\n';
						boolErrorFound		= true;
						errorClass("#strCardNumber", true);
					} else {
						errorClass("#strCardNumber", false);
					}
					if ($("#strCVVCode").val() == '') {
						strErrorMessage		+=	' - Please enter the 3 or 4 digit verification code from your credit card.  This is usually found on the back of the card near the magnetic strip.\n';
						boolErrorFound		= true;
						errorClass("#strCVVCode", true);
					} else {
						errorClass("#strCVVCode", false);
					}
					if ($("#strBillingAddress").val() == '') {
						strErrorMessage		+=	' - Please enter the billing address for the credit card you are using.\n';
						boolErrorFound		= true;
						errorClass("#strBillingAddress", true);
					} else {
						errorClass("#strBillingAddress", false);
					}
					if ($("#strBillingCity").val() == '') {
						strErrorMessage		+=	' - Please enter the billing city for the credit card you are using.\n';
						boolErrorFound		= true;
						errorClass("#strBillingCity", true);
					} else {
						errorClass("#strBillingCity", false);
					}
					if ($("#strBillingZIP").val() == '') {
						strErrorMessage		+=	' - Please enter the billing ZIP for the credit card you are using.\n';
						boolErrorFound		= true;
						errorClass("#strBillingZIP", true);
					} else {
						errorClass("#strBillingZIP", false);
					}
					
					if (!boolErrorFound) {
						if (parseInt($("#intRegistrantCount").val()) > 1) {
							if (confirm('You are about to register and pay for ' + parseInt($("#intRegistrantCount").val()) + ' participants.  This is going to be a total of $' + (getTotal() - getDiscount() - getBulkDiscount()) + '.  Are you sure you want to proceed?\n\nPress [OK] to continue, or [CANCEL] to abort.')) {
								if (parseInt($("#intRegistrantCount").val()) < 10) {
									for (var intCounter = (parseInt($("#intRegistrantCount").val()) + 1); intCounter <= 10; intCounter++) { 
										$("#strRegFirstName_" + intCounter).val("");
										$("#strRegLastName_" + intCounter).val("");
										$("#strRegAge_" + intCounter).val("");
										$("#strRegEmail_" + intCounter).val("");
										$("#strRegPhone_" + intCounter).val("");
										$("#strRegTeam_" + intCounter).val("");
										
										if (boolShirtsEnabled) {
											$("#strRegShirtSize_" + intCounter).val("");
										}
									}
								}
	
								$("#lyrButton").hide();
								$("#lyrLoader").show();
								$("#frmSignup").submit();
							}
						} else {
							$("#lyrButton").hide();
							$("#lyrLoader").show();
							$("#frmSignup").submit();
						}
					} else {
						alert('Some errors were found while trying to process your order.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
					}
				} else {
					alert('Please wait for the promo code lookup to finish before attempting to process your order.');	
				}
			});
			
			$("#strFirstName").blur(function() {
				$("#strRegFirstName_1").val($("#strFirstName").val());
				calculateTotalDue();
			});
			$("#strLastName").blur(function() {
				$("#strRegLastName_1").val($("#strLastName").val());
			});
			$("#strAge").blur(function() {
				$("#strRegAge_1").val($("#strAge").val());
			});
			$("#strRegFirstName_1").blur(function() {
				$("#strFirstName").val($("#strRegFirstName_1").val());
			});
			$("#strRegLastName_1").blur(function() {
				$("#strLastName").val($("#strRegLastName_1").val());
			});
			$("#strRegAge_1").blur(function() {
				$("#strAge").val($("#strRegAge_1").val());
			});
			$("#intRegistrantCount").change(function() {
				var intRegCount		= parseInt($("#intRegistrantCount").val());

				// hide all
				for (var intCounter = 2; intCounter <= 10; intCounter++) {
					$("#lyrRegistrant_" + intCounter).hide();	
				}
				
				if (intRegCount <= 10) {
					for (var intCounter = 2; intCounter <= intRegCount; intCounter++) {
						$("#lyrRegistrant_" + intCounter).show();
					}
				}
				
				obtainPromoDiscount($("#strPromoCode").val());
				calculateTotalDue();
			});
			
			$(".registrant_input").change(function() {
				calculateTotalDue();
			});
			
			// initially calculate total due on page load
			calculateTotalDue();
			
			if ($("#strPromoCode").val() != "") {
				obtainPromoDiscount($("#strPromoCode").val());
			}
			break;
			
		case "store_register" :
			$("#btnSubmit").click(function() {
				var strErrorMessage		= '';
				var boolErrorFound		= false;
				
				if ($("#strFirstName").val() == '') {
					strErrorMessage		+=	' - Please enter your first name.\n';
					boolErrorFound		= true;
				}
				if ($("#strLastName").val() == '') {
					strErrorMessage		+=	' - Please enter your last name.\n';
					boolErrorFound		= true;
				}
				if ($("#strDOB").val() == '') {
					strErrorMessage		+=	' - Please enter your date of birth.\n';
					boolErrorFound		= true;
				}
				if ($("#strAddress").val() == '') {
					strErrorMessage		+=	' - Please enter your mailing address.\n';
					boolErrorFound		= true;
				}
				if ($("#strCity").val() == '') {
					strErrorMessage		+=	' - Please enter your city.\n';
					boolErrorFound		= true;
				}
				if ($("#strState").val() == '') {
					strErrorMessage		+=	' - Please enter your state or province.\n';
					boolErrorFound		= true;
				}
				if ($("#strPostCode").val() == '') {
					strErrorMessage		+=	' - Please enter your postal code.\n';
					boolErrorFound		= true;
				}
				if ($("#strPhone").val() == '') {
					strErrorMessage		+=	' - Please enter your phone number.\n';
					boolErrorFound		= true;
				}
				if ($("#strEmail").val() == '') {
					strErrorMessage		+=	' - Please enter your e-mail address.\n';
					boolErrorFound		= true;
				} else {
					var strEmail		= $("#strEmail").val();
					var boolEmailValid	= false;
					
					if (strEmail.indexOf('@') > -1) {
						intAtPosition	= strEmail.indexOf('@');
						if (strEmail.indexOf('.', intAtPosition) > -1) {
							boolEmailValid	= true;
						}
					}
					
					if (!boolEmailValid) {
						strErrorMessage		+=	' - Please enter a valid e-mail address.\n';
						boolErrorFound		= true;
					}
				}
				if ($("#strPassword").val() == '') {
					strErrorMessage		+=	' - Please enter your password.\n';
					boolErrorFound		= true;
				} else {
					if ($("#strPasswordV").val() == '') {
						strErrorMessage		+=	' - Please enter your password again in the Confirm Password box.\n';
						boolErrorFound		= true;
					} else {
						if ($("#strPassword").val() != $("#strPasswordV").val()) {
							$("#strPassword").val("");
							$("#strPasswordV").val("");
							
							strErrorMessage		+=	' - Your passwords do not match.  Please enter them again.\n';
							boolErrorFound		= true;
						}
					}
				}
				
				if (!boolErrorFound) {
					$("#frmRegister").submit();
				} else {
					alert('Some errors were found while trying to process your registration.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
				}
			});
			break;

		case "store_guest" :
			$("#btnSubmit").click(function() {
				var strErrorMessage		= '';
				var boolErrorFound		= false;
				
				if ($("#strFirstName").val() == '') {
					strErrorMessage		+=	' - Please enter your first name.\n';
					boolErrorFound		= true;
				}
				if ($("#strLastName").val() == '') {
					strErrorMessage		+=	' - Please enter your last name.\n';
					boolErrorFound		= true;
				}
				if ($("#strAddress").val() == '') {
					strErrorMessage		+=	' - Please enter your mailing address.\n';
					boolErrorFound		= true;
				}
				if ($("#strCity").val() == '') {
					strErrorMessage		+=	' - Please enter your city.\n';
					boolErrorFound		= true;
				}
				if ($("#strState").val() == '') {
					strErrorMessage		+=	' - Please enter your state or province.\n';
					boolErrorFound		= true;
				}
				if ($("#strPostCode").val() == '') {
					strErrorMessage		+=	' - Please enter your postal code.\n';
					boolErrorFound		= true;
				}
				if ($("#strPhone").val() == '') {
					strErrorMessage		+=	' - Please enter your phone number.\n';
					boolErrorFound		= true;
				}
				if ($("#strEmail").val() == '') {
					strErrorMessage		+=	' - Please enter your e-mail address.\n';
					boolErrorFound		= true;
				} else {
					var strEmail		= $("#strEmail").val();
					var boolEmailValid	= false;
					
					if (strEmail.indexOf('@') > -1) {
						intAtPosition	= strEmail.indexOf('@');
						if (strEmail.indexOf('.', intAtPosition) > -1) {
							boolEmailValid	= true;
						}
					}
					
					if (!boolEmailValid) {
						strErrorMessage		+=	' - Please enter a valid e-mail address.\n';
						boolErrorFound		= true;
					}
				}
				
				if (!boolErrorFound) {
					$("#frmRegister").submit();
				} else {
					alert('Some errors were found while trying to save your shipping information.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
				}
			});
			break;

		case "store_account" :
			$("#btnSubmit").click(function() {
				var strErrorMessage		= '';
				var boolErrorFound		= false;
				
				if ($("#strFirstName").val() == '') {
					strErrorMessage		+=	' - Please enter your first name.\n';
					boolErrorFound		= true;
				}
				if ($("#strLastName").val() == '') {
					strErrorMessage		+=	' - Please enter your last name.\n';
					boolErrorFound		= true;
				}
				if ($("#strDOB").val() == '') {
					strErrorMessage		+=	' - Please enter your date of birth.\n';
					boolErrorFound		= true;
				}
				if ($("#strAddress").val() == '') {
					strErrorMessage		+=	' - Please enter your mailing address.\n';
					boolErrorFound		= true;
				}
				if ($("#strCity").val() == '') {
					strErrorMessage		+=	' - Please enter your city.\n';
					boolErrorFound		= true;
				}
				if ($("#strState").val() == '') {
					strErrorMessage		+=	' - Please enter your state or province.\n';
					boolErrorFound		= true;
				}
				if ($("#strPostCode").val() == '') {
					strErrorMessage		+=	' - Please enter your postal code.\n';
					boolErrorFound		= true;
				}
				if ($("#strPhone").val() == '') {
					strErrorMessage		+=	' - Please enter your phone number.\n';
					boolErrorFound		= true;
				}
				if ($("#strEmail").val() == '') {
					strErrorMessage		+=	' - Please enter your e-mail address.\n';
					boolErrorFound		= true;
				} else {
					var strEmail		= $("#strEmail").val();
					var boolEmailValid	= false;
					
					if (strEmail.indexOf('@') > -1) {
						intAtPosition	= strEmail.indexOf('@');
						if (strEmail.indexOf('.', intAtPosition) > -1) {
							boolEmailValid	= true;
						}
					}
					
					if (!boolEmailValid) {
						strErrorMessage		+=	' - Please enter a valid e-mail address.\n';
						boolErrorFound		= true;
					}
				}
				if ($("#strPassword").val() != '') {
					if ($("#strPasswordV").val() == '') {
						strErrorMessage		+=	' - Please enter your password again in the Confirm Password box.\n';
						boolErrorFound		= true;
					} else {
						if ($("#strPassword").val() != $("#strPasswordV").val()) {
							$("#strPassword").val("");
							$("#strPasswordV").val("");
							
							strErrorMessage		+=	' - Your passwords do not match.  Please enter them again.\n';
							boolErrorFound		= true;
						}
					}
				}
				
				if (!boolErrorFound) {
					$("#frmAccount").submit();
				} else {
					alert('Some errors were found while trying to update your account.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
				}
			});
			break;
			
		case "store_login" :
			$("#btnLogin").click(function() {
				var strErrorMessage		= '';
				var boolErrorFound		= false;
				
				if ($("#strEmail").val() == '') {
					strErrorMessage		+=	' - Please enter your e-mail address.\n';
					boolErrorFound		= true;
				} else {
					var strEmail		= $("#strEmail").val();
					var boolEmailValid	= false;
					
					if (strEmail.indexOf('@') > -1) {
						intAtPosition	= strEmail.indexOf('@');
						if (strEmail.indexOf('.', intAtPosition) > -1) {
							boolEmailValid	= true;
						}
					}
					
					if (!boolEmailValid) {
						strErrorMessage		+=	' - Please enter a valid e-mail address.\n';
						boolErrorFound		= true;
					}
				}
				if ($("#strPassword").val() == '') {
					strErrorMessage		+=	' - Please enter your password.\n';
					boolErrorFound		= true;
				}
				
				if (!boolErrorFound) {
					$("#frmLogin").submit();
				} else {
					alert('Some errors were found while trying to log you in.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
				}
			});
			break;

		case "store_checkout" :
			$("#btnAuthorize").click(function() {
				var strErrorMessage		= '';
				var boolErrorFound		= false;
				
				if ($("#strCardholderName").val() == '') {
					strErrorMessage		+=	' - Please enter the cardholder\'s name.\n';
					boolErrorFound		= true;
				}
				if ($("#strCardNumber").val() == '') {
					strErrorMessage		+=	' - Please enter your credit card number.\n';
					boolErrorFound		= true;
				}
				if ($("#strCardCVV").val() == '') {
					strErrorMessage		+=	' - Please enter your credit card\'s CVV (security) code.\n';
					boolErrorFound		= true;
				}
				
				if (!boolErrorFound) {
					$("#lyrButtons").hide();
					$("#lyrWait").show();
					$("#frmCheckout").submit();
				} else {
					alert('Some errors were found while trying to process this transaction.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
				}
			});
			break;
			
		case "store_category" :
			sIFR.replace(eightTrack, {
			  selector: '.category_header h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1' }
			  }
			});
			break;
			
		case "store_search" :
			sIFR.replace(eightTrack, {
			  selector: '.category_header h1', 
			  wmode: 'transparent', 
			  fitExactly: 'true', 
			  forceSingleLine: 'true', 
			  selectable: 'false', 
			  offsetTop: 2, 
			  css: {
				'.sIFR-root': { 'color': '#484848', 'letter-spacing': '-1' }
			  }
			});
			break;
			
	}
	
	if( $('#auto_enter_contact').length > 0 )
	{
		$('#auto_enter_contact').change(function(){
			if( $('#auto_enter_contact').is(':checked') )
			{
				$('input.input_email_val').val( $('#strEmail').val() );
				$('input.input_phone_val').val( $('#strPhone').val() );
			}
		});
		
		$('#strEmail').change(function(){
			if($('#auto_enter_contact').is(':checked'))
			{
				$('input.input_email_val').val( $('#strEmail').val() );
			}
		});
		
		$('#strPhone').change(function(){
			if($('#auto_enter_contact').is(':checked'))
			{
				$('input.input_phone_val').val( $('#strPhone').val() );
			}
		});
	}
	
	$('a.email-add').live('click', function(){
		var container = $(this).closest('div');
		var new_container = container.clone();
		container
			.after(new_container);
		new_container.
				find('input').val('');
		sync_fields();
		return false;
	});
	
	$('a.email-delete').live('click', function(){
		var container = $(this).closest('div');
		if( $('.email-container').length > 1 )
		{
			container.remove();
		}
		else
		{
			container.find('input').val('');
		}
		sync_fields();
		return false;
	});
	
	function sync_fields()
	{
		var counter = 0;
		$('div.email-container').each(function(){
			counter++;
			$(this).find('input[type="text"]').attr('name', 'strEmail'+counter);
			$(this).find('input[type="hidden"]').attr('name', 'strName'+counter);
		});
	}

	$('div.email-container input[type="text"]').live('change', function(){
		$(this).parent().find('input[type="hidden"]').val( $(this).val() );
	});

	if($("#btnSubmitStep2").length > 0)
	{
			$("#btnSubmitStep2").click(function() {
				if (!boolAJAXActive) {
					var strErrorMessage		= '';
					var boolErrorFound		= false;
					if( !$("#chkUndecided").is(':checked') )
					{
						if ($("#strFirstName").val() == '') {
							strErrorMessage		+=	' - Please enter the first registrant\'s first name.\n';
							boolErrorFound		= true;
							errorClass("#strFirstName", true);
						} else {
							errorClass("#strFirstName", false);
						}
						if ($("#strLastName").val() == '') {
							strErrorMessage		+=	' - Please enter the first registrant\'s last name.\n';
							boolErrorFound		= true;
							errorClass("#strLastName", true);
						} else {
							errorClass("#strLastName", false);
						}
						if ($("#strEmail").val() == '') {
							strErrorMessage		+=	' - Please enter the first registrant\'s e-mail address.\n';
							boolErrorFound		= true;
							errorClass("#strEmail", true);
						} else {
							var strEmail		= $("#strEmail").val();
							var boolEmailValid	= false;
							
							if (strEmail.indexOf('@') > -1) {
								intAtPosition	= strEmail.indexOf('@');
								if (strEmail.indexOf('.', intAtPosition) > -1) {
									boolEmailValid	= true;
								}
							}
							
							if (!boolEmailValid) {
								strErrorMessage		+=	' - Please enter a valid e-mail address for the first registrant.\n';
								boolErrorFound		= true;
								errorClass("#strEmail", true);
							} else {
								errorClass("#strEmail", false);
							}
						}
						if ($("#strPhone").val() == '') {
							strErrorMessage		+=	' - Please enter the first registrant\'s phone number.\n';
							boolErrorFound		= true;
							errorClass("#strPhone", true);
						} else {
							errorClass("#strPhone", false);
						}
					}
					
					if (boolErrorFound) {
						alert('Some errors were found while trying to process your order.  Please correct the items listed below, and then try again.\n\n' + strErrorMessage);
					}
					else
					{
						$("#btnSubmitStep2").closest('form').submit();
					}
				} else {
					alert('Please wait for the promo code lookup to finish before attempting to process your order.');	
				}
			});
	
	}
	
});

function generateTooltip(txtRawHTML, strTitle, strCaption) {
	txtRawHTML		= txtRawHTML.replace("[NAME]", strTitle);
	txtRawHTML		= txtRawHTML.replace("id=\"tooltip_data\">", "id=\"tooltip_data\">" + strCaption);
	
	return txtRawHTML;
}

function calculateTotalDue() {
	var intRegCount		= parseInt($("#intRegistrantCount").val());
	var dblTotal		= 0.00;
	var intCurSession	= $("#intSessionID").val();
	var intRegCounter	= 1;
	var dblSessionPrice	= parseFloat(arrSessions[intCurSession]);
	var intChildCounter	= 1;
	var discountpromo = $('#discountpromo').val();

	if(intRegCount > 1 && discountpromo == 1)
	{
		$(".promo_code_container").css('display', 'none');
	}
	else
	{
		$(".promo_code_container").css('display', 'block');
	}

	// update price-per-person
	if (intCurSession != "") {
		$("#lyrPrice").html("$" + arrSessions[intCurSession]);
	} else {
		$("#lyrPrice").html("n/a");
	}

	// add default first registration
	if (boolShirtsEnabled) {
		if ($("#strShirtSize").val().length > 0) {
			dblTotal			+= (dblSessionPrice + dblShirtPrice);
		} else {
			dblTotal			+= dblSessionPrice;
		}
	} else {
		dblTotal			+= dblSessionPrice;
	}


	if (intRegCount > 1) {
		for (var intCounter = 2; intCounter <= intRegCount; intCounter++) {
				if (boolShirtsEnabled) {
					dblTotal	+= dblSessionPrice + dblShirtPrice;
				} else {
					dblTotal	+= dblSessionPrice;
				}
				intRegCounter++;
		}
	}

	// adjust counter
	if (intRegCounter > intRegCount) {
		intRegCounter	= intRegCount;	
	}

	// calculate bulk discount
	dblBulkDiscountEach			= 0;
	dblBulkDiscount				= 0;

	if(arrChildDiscounts.length > 0 && arrChildDiscounts[intRegCount-1] && arrChildDiscounts[intRegCount-1].amount)
	{
		$('#lyrPrice').text( '$'+$.currency(parseFloat(arrChildDiscounts[intRegCount-1].amount)) );
	}

	if (arrChildDiscounts.length) {
		
		for (var intCounter = 1; intCounter <= intRegCounter; intCounter++) {
			for (var intDiscountCounter = 0; intDiscountCounter < arrChildDiscounts.length; intDiscountCounter++) {
				//alert(parseInt(arrChildDiscounts[intDiscountCounter].num)+":::"+intCounter+arrChildDiscounts[intRegCount-1].amount);
				//if ((parseInt(arrChildDiscounts[intDiscountCounter].num) == intCounter) && (parseFloat(arrChildDiscounts[intDiscountCounter].amount) > 0) && (parseFloat(dblSessionPrice) > parseFloat(arrChildDiscounts[intDiscountCounter].amount))) {


				if ((parseInt(arrChildDiscounts[intDiscountCounter].num) == intCounter) && (parseFloat(arrChildDiscounts[intDiscountCounter].amount) > 0) && (parseFloat(dblSessionPrice) > parseFloat(arrChildDiscounts[intRegCount-1].amount))) {
					dblBulkDiscount			= parseFloat(dblBulkDiscount) + (parseFloat(dblSessionPrice) - parseFloat(arrChildDiscounts[intRegCount-1].amount));
					//dblBulkDiscount			= parseFloat(dblBulkDiscount) + (parseFloat(dblSessionPrice) - parseFloat(arrChildDiscounts[intDiscountCounter].amount));
					dblBulkDiscountEach		= 0;
				}
			}
		}
	}
 
        //alert(dblDiscount +":::"+dblBulkDiscount);
	
	if ((dblDiscount > 0) || (dblBulkDiscount > 0)) {
		if ((dblDiscount > 0) && (dblBulkDiscount > 0)) {
			switch (intDiscountType) {
				case 1 :
				case 2 :
					dblTotal			-= (parseFloat(dblDiscount) + parseFloat(dblBulkDiscount));
					$("#lyrPromoCode").html("(including $" + $.currency((parseFloat(dblDiscount) + parseFloat(dblBulkDiscount)), {s: ",", d: ".", c: 2}) + " discount)");
					break;
					
				case 3 :
				case 4 :
					dblTotal			-= ((parseFloat(dblDiscountEach) * intRegCounter) + parseFloat(dblBulkDiscount));
					if ((dblBulkDiscount > 0) && (dblBulkDiscountEach == 0)) {
						$("#lyrPromoCode").html("(including $" + $.currency((parseFloat(dblDiscount) + parseFloat(dblBulkDiscount)), {s: ",", d: ".", c: 2}) + " off)");
					} else {
						$("#lyrPromoCode").html("(including $" + $.currency((parseFloat(dblDiscountEach) + parseFloat(dblBulkDiscountEach)), {s: ",", d: ".", c: 2}) + " off each registrant)");
					}
					break;
			}
		} else if ((dblDiscount > 0) && (dblBulkDiscount == 0)) {
			switch (intDiscountType) {
				case 1 :
				case 2 :
					dblTotal			-= dblDiscount;
					$("#lyrPromoCode").html("(including $" + $.currency(dblDiscount, {s: ",", d: ".", c: 2}) + " discount)");
					break;
					
				case 3 :
				case 4 :
					if ((dblDiscount > 0) && (dblDiscountEach == 0)) {
						dblTotal			-= dblDiscount;
						$("#lyrPromoCode").html("(including $" + $.currency(parseFloat(dblDiscount), {s: ",", d: ".", c: 2}) + " off)");
					} else {
						//alert(dblDiscountEach);
						if($("#strPromoCode").val()!=''){
							dblTotal			-= (dblDiscountEach * intRegCounter);
							
							//edited by rocky @ 12 jan, 2012
							newdiscountedprice=parseFloat($("#spanAPrice").text())-dblDiscountEach;
							if(newdiscountedprice)
								$("#lyrTotalDue2").html('$'+newdiscountedprice);
								
							dblDiscountEach+=parseFloat($("#spanSavePrice").text());
													
							var totalSaving=parseFloat(dblDiscountEach)*intRegCount;
							$("#strSavePrice").val('$'+totalSaving);
							$("#lyrPromoCode").html("(For a Total Savings of $"+ totalSaving +" <br/> including $" + $.currency(dblDiscountEach, {s: ",", d: ".", c: 2}) + " off each registrant)");
						}
						else{
							//edited by rocky 17 jan, 2012 
							newdiscountedprice=parseFloat($("#spanAPrice").text());
							if(newdiscountedprice)
								$("#lyrTotalDue2").html('$'+newdiscountedprice);
							dblDiscountEach=parseFloat($("#spanSavePrice").text());
							var totalSaving=parseFloat(dblDiscountEach)*intRegCount;
							$("#strSavePrice").val('$'+totalSaving);
							$("#lyrPromoCode").html("(For a Total Savings of $"+ totalSaving +" <br/> including $" + $.currency(dblDiscountEach, {s: ",", d: ".", c: 2}) + " off each registrant)");
						}
						//$("#lyrPromoCode").append("<br>(And $" + totalSaving + " as total savings)");
					}
					break;
			}
		} else if ((dblDiscount == 0) && (dblBulkDiscount > 0)) {
			dblTotal			-= dblBulkDiscount;
			
			if (dblBulkDiscountEach == 0) {
				$("#lyrPromoCode").html("(including $" + $.currency(dblBulkDiscount, {s: ",", d: ".", c: 2}) + " off)");
			} else {
				$("#lyrPromoCode").html("(including $" + $.currency(dblBulkDiscountEach, {s: ",", d: ".", c: 2}) + " off each registrant)");
			}
		}
	} else {
		$("#lyrPromoCode").html("");
		
		//edited by rocky 17 jan, 2012 
		newdiscountedprice=parseFloat($("#spanAPrice").text());
		if(newdiscountedprice)
			$("#lyrTotalDue2").html('$'+newdiscountedprice);
		dblDiscountEach=parseFloat($("#spanSavePrice").text());
		var totalSaving=parseFloat(dblDiscountEach)*intRegCount;
		$("#strSavePrice").val('$'+totalSaving);
		$("#lyrPromoCode").html("(For a Total Savings of $"+ totalSaving +" <br/> including $" + $.currency(dblDiscountEach, {s: ",", d: ".", c: 2}) + " off each registrant)");
	}
	
	
	
	$("#lyrTotalDue").html("$" + $.currency(dblTotal, {s: ",", d: ".", c: 2}) + "  (" + intRegCounter + " registrants)");
	//$("#lyrTotalDue2").html("$" + $.currency(dblTotal, {s: ",", d: ".", c: 2}));
}

function getActualNumRegistrants() {
	var intRegCount		= parseInt($("#intRegistrantCount").val());
	
	return intRegCount;
}

function resetMarquee() {
	$(".marquee_text div").css("left", "-0px");
}

function getTotal() {
	var dblTotal		= 0.00;
	var intCurSession	= $("#intSessionID").val();
	var intRegCounter	= 1;
	var dblSessionPrice	= parseFloat(arrSessions[intCurSession]);

	if (boolShirtsEnabled) {
		var strFieldName;
		
		for (var intCounter = 1; intCounter <= parseInt($("#intRegistrantCount").val()); intCounter++) {
			// calculate shirt price, if a shirt is requested
			if (intCounter == 1) {
				strFieldName		= "strShirtSize";
			} else {
				strFieldName		= "strRegShirtSize_" + intCounter;
			}
			if ($("#" + strFieldName).val().length > 0) {
				dblTotal			+= (dblSessionPrice + dblShirtPrice);
			} else {
				dblTotal			+= dblSessionPrice;
			}
		}
	} else {
		dblTotal			+= dblSessionPrice;
		dblTotal			= (dblTotal * parseInt($("#intRegistrantCount").val()));
	}
	
	return dblTotal;
}

function getBulkDiscount() { 
	var intCurSession		= $("#intSessionID").val();
	var dblSessionPrice		= parseFloat(arrSessions[intCurSession]);
	var dblReturnAmount		= 0;
	var intRegCount         = parseInt($("#intRegistrantCount").val());
	
	if (arrChildDiscounts.length) {
		for (var intCounter = 1; intCounter <= parseInt($("#intRegistrantCount").val()); intCounter++) {
			for (var intDiscountCounter = 0; intDiscountCounter < arrChildDiscounts.length; intDiscountCounter++) {
				if ((parseInt(arrChildDiscounts[intDiscountCounter].num) == intCounter) && (parseFloat(dblSessionPrice) > parseFloat(arrChildDiscounts[intRegCount-1].amount))) {
					dblReturnAmount			= parseFloat(dblReturnAmount) + (parseFloat(dblSessionPrice) - parseFloat(arrChildDiscounts[intRegCount-1].amount));
				//if ((parseInt(arrChildDiscounts[intDiscountCounter].num) == intCounter) && (dblSessionPrice > parseFloat(arrChildDiscounts[intDiscountCounter].amount))) {
					//dblReturnAmount			= parseFloat(dblReturnAmount) + (dblSessionPrice - parseFloat(arrChildDiscounts[intDiscountCounter].amount));
				}
			}
		}
	}
	
	return dblReturnAmount;
}

function getDiscount() {
	var dblReturnAmount			= 0;
	
	if (intDiscountType > -1) {
		switch (intDiscountType) {
			case 1 :
			case 2 :
			case 3 :
				dblReturnAmount		= dblDiscount;
				break;
				
			case 31 :
			case 4 :
				dblReturnAmount		= (dblDiscountEach * getActualNumRegistrants());
				break;
		}
	}
	
	return dblReturnAmount;
}

function obtainPromoDiscount(strCurPromoCode) {
	//alert(strCurPromoCode);
	if(!strCurPromoCode)
	{
		
	}
	else if (strCurPromoCode == "") {
		boolAJAXActive		= false;
		dblDiscount			= 0.00;
		dblDiscountEach		= 0.00;
		intDiscounType		= -1;
		calculateTotalDue();
		
		$("#strPromoCode").val("");
		
		if (dblBulkDiscount == 0) {
			$("#lyrPromoCode").html("");
		} else {
			if (dblBulkDiscountEach == 0) {
				$("#lyrPromoCode").html("(including $" + $.currency(dblBulkDiscount, {s: ",", d: ".", c: 2}) + " off)");
				//added by rocky @ 12 jan, 2012
				//$("#strSavePrice").val($("#strSavePrice").val()+dblBulkDiscount);
			} else {
				$("#lyrPromoCode").html("(including $" + $.currency(dblBulkDiscountEach, {s: ",", d: ".", c: 2}) + " off each registrant)");
				//added by rocky @ 12 jan, 2012
			
				//$("#strSavePrice").val($("#strSavePrice").val()+ (dblBulkDiscount*$("#intRegistrantCount").val()));
			}
		}
	} else {
		boolAJAXActive		= true;
		dblDiscount			= 0.00;
		dblDiscountEach		= 0.00;
		intDiscountType		= -1;
		$("#lyrPromoCode").html("Looking up promo code, please wait...");
		
		$.get(	"/_content/_code-lookup.php", 
				{
					code: strCurPromoCode, 
					key: $("#key").val(), 
					total: getTotal(), 
					numreg: getActualNumRegistrants(), 
					sid: $("#intSessionID").val()
				}, 
				function(txtData) {
					boolAJAXActive	= false;
					var objJSON		= eval(txtData);
					
					if (objJSON.success) {
						dblDiscount			= parseFloat(objJSON.amount);
						dblDiscountEach		= parseFloat(objJSON.amounteach);
						intDiscountType		= parseInt(objJSON.type);
						calculateTotalDue();
					} else {
						dblDiscount			= 0.00;
						dblDiscountEach		= 0.00;
						intDiscountType		= -1;
						calculateTotalDue();
						
						$("#strPromoCode").val("");
						
						if (dblBulkDiscount == 0) {
							$("#lyrPromoCode").html("");
						} else {
							if (dblBulkDiscountEach == 0) {
								$("#lyrPromoCode").html("(including $" + $.currency(dblBulkDiscount, {s: ",", d: ".", c: 2}) + " off)");
								//added by rocky @ 12 jan, 2012
								//$("#strSavePrice").val($("#strSavePrice").val()+dblBulkDiscount);
							} else {
								$("#lyrPromoCode").html("(including $" + $.currency(dblBulkDiscountEach, {s: ",", d: ".", c: 2}) + " off each registrant)");
								$("input#strSavePrice").val("1");
								//added by rocky @ 12 jan, 2012
								//$("#strSavePrice").val($("#strSavePrice").val()+ (dblBulkDiscount*$("#intRegistrantCount").val()));
							}
						}
	
						alert("Sorry, but that promotional code is not valid.");
					}
				}, 
				"json");
	}
}

function errorClass(strElementID, boolAddClass) {
	var objElement		= $(strElementID).parent("div");
	
	if(!$(objElement).attr("class"))
	{
		alert(strElementID);
	}
	
	var arrClasses		= $(objElement).attr("class").split(" ");
	var strClassSuffix	= "_red";
	var strCurClass		= "";
	
	if (arrClasses.length >= 1) {
		strCurClass			= arrClasses[0];
		
		switch (boolAddClass) {
			case true : 
				if (arrClasses.length > 1) {
					if (!$(objElement).hasClass(strCurClass + strClassSuffix)) {
						$(objElement).addClass(strCurClass + strClassSuffix);
					}
				} else {
					$(objElement).addClass(strCurClass + strClassSuffix);
				}
				break;
				
			case false : 
				if ($(objElement).hasClass(strCurClass + strClassSuffix)) {
					$(objElement).removeClass(strCurClass + strClassSuffix);
				}
				break;
		}
	}
}

