//Global Variables
PortalPath = "/Portals/4";

// Forms and Page Elements Handling
jQuery(document).ready(function() {
	if (jQuery("#LoginForm").length > 0) {
		jQuery("#LoginForm").wrapInner('<form action="https://oss.ticketmaster.com/cgi/request.cgi" method="post" name="formLogin" id="formLogin" onSubmit="return validSubmit(this)"></form>');
	}
	
	
	
	
	
	
	imgIds = [];
	
	var imgNumberTotal = jQuery(".eventPhotos").length;
	
	for (var i = 0; i < imgNumberTotal; i++) {
			imgIds.push(jQuery(".eventPhotos").eq(i).attr("id"));
	}
	
	for (var i = 0; i < imgIds.length; i++) {
		var imgNumber = jQuery(".eventPhotos").eq(i).children().length;
		jQuery("#" + imgIds[i]).after("<div class='eventsTabs' id='slidetabs" + imgIds[i] + "'></div>");

		

		for (j = 0; j < imgNumber; j++) {
			jQuery("div#slidetabs" + imgIds[i]).append("<a href='javascript:;'></a>");
		};
		
		

		jQuery("#slidetabs" + imgIds[i]).tabs(".eventPhotos#" + imgIds[i] + " > div", {
			effect: "fade",
			fadeOutSpeed: "slow",
			clickable: true,
			rotate: true
		}).slideshow();
		
		/* slideshowPlayTimeoutID = setTimeout(function() {
			jQuery(".eventsTabs#slidetabs" + imgIds[i]).data("slideshow").play();
		}, 3000); */
		jQuery(".eventsTabs#slidetabs" + imgIds[i]).delay(2000).data("slideshow").play();
		
		jQuery("a.stopSlideshow.buttonSt" + imgIds[i]).click(function() {
			//clearTimeout(slideshowPlayTimeoutID);
			jQuery(this).css("display", "none");
			jQuery("a.playSlideshow").css("display", "block");
			jQuery(this).parent().parent().parent().find("div.eventsTabs").data("slideshow").stop();
		});

		jQuery("a.playSlideshow.buttonPl" + imgIds[i]).click(function() {
			jQuery("a.stopSlideshow").css("display", "block");
			jQuery(this).css("display", "none");
			jQuery(this).parent().parent().parent().find("div.eventsTabs").data("slideshow").play();
		});
		
		
	};

	jQuery("a[rel]").overlay({
		mask: '#000000',
		effect: 'apple'
	});
	
	jQuery("a[rel]").overlay({
		mask: '#000000',
		effect: 'apple'
	});
});



// Custom Functions
function validSubmit(form) {
	var iAcctId = form.iAcctId.value;
	var iPIN = stripBlanks(form.iPIN.value);

	form.iAcctId.value = iAcctId;
	form.iPIN.value = iPIN;

	if(iAcctId == '') {
		alert("You must enter a valid Account ID");
		return false;
	}
	else if(iAcctId == 'Enter your Account ID') {
		alert("You must enter a valid Account ID");
		return false;
	}
	else if(iPIN == '') {
		alert("You must enter a valid password");
		return false;
	}
	return true;
}
