jQuery.noConflict();

jQuery(document).ready(function() {
	jQuery('.slideshow').cycle({
		fx: 'scrollDown',
		requeOnImageNotLoaded: true
	});

	// Begining FAQ Scroll To Function
	jQuery('a').click(function() {
		// Gets ID which stores text to search for
		var getId = jQuery(this).attr('id');
		if (getId) {
			// Searches for test in a h5 element then creates an anchor point to go to
			jQuery('h5:contains('+ getId +')').addClass("scrollHere");

			// Scrolls to above anchor point
			jQuery('html').animate({scrollTop: jQuery('.scrollHere').offset().top}, 3000);

			// Removes anchor point to avoid multiple scroll to points
			jQuery('.scrollHere').removeClass("scrollHere");
		}
	});

	jQuery("label img").live("click", function() {
		// Selects form element when thumbnail clicked
		jQuery("#" + jQuery(this).parents("label").attr("for")).click();

		// Reset any thumbnails set as selected
		jQuery("label div").each(function() {
			jQuery(this).addClass("imgNotSelect").removeClass("imgSelect");
		});

		// Get Reference Id then show as selected
		var getRef = "#" + jQuery(this).parents("label").attr("for");
		jQuery(getRef + "_S").addClass("imgSelect").removeClass("imgNotSelect");

		// Gets data from alt tag of thumbnail
		var coolVar = jQuery(this).attr("alt");

		// Takes out the sizes between the two brackets
		var coolVar2 = coolVar.match("{(.*)}");

		// Performs an Explode equivalent to seperate sizes
		var partsArray = coolVar2[1].split(" ");

		// Sets up list of size options then replaces old list
		var newForm = "<div id='sizes'>";
		jQuery.each(partsArray, function(intIndex, objValue) {
			var objText = objValue;
			if (objValue == "N/A") {
				var objText = "One Size Fits Most";
				var objAuto = "checked";
			}
			newForm += "<div class='sizeOpt'><input type='radio' value='" + objValue + "' name='submit[size]' " + objAuto + " id='" + objValue + "'><label for='" + objValue +"'>" + objText +"</label></div>";
		});
		jQuery("#sizes").replaceWith("<div id='sizes'>" + newForm + "</div>");
	});

	jQuery("#changeForm").change(function() {
		// Get value of newly selected option
		var newOpt = jQuery("#changeForm").val();
		if (newOpt == "DD") {
			jQuery(".CC").fadeOut("slow");
			jQuery(".DL").fadeIn("slow");
		}
		if (newOpt == "CH") {
			jQuery(".CC").fadeOut("slow");
			jQuery(".DL").fadeIn("slow");
		}
		if (newOpt == "CC") {
			jQuery(".CC").fadeIn("slow");
			jQuery(".DL").fadeIn("slow");
		}
		if (newOpt == "CP") {
			jQuery(".CC").fadeIn("slow");
			jQuery(".DL").fadeOut("slow");
		}
	});

	// Setup styling for tables as columns
	jQuery(".tablevertical td:nth-child(odd)").css("background", "#f8e8f2");
	jQuery(".tablevertical td:nth-child(even)").css("background", "#faecf5");
	jQuery(".tablevertical td:first-child").css("background", "#f1d7e7");

	// Setup styling for tables as rows
	jQuery(".tablehorizontal tr:odd").css("background", "#f8e8f2");
	jQuery(".tablehorizontal tr:even").css("background", "#faecf5");
	jQuery(".tablehorizontal tr:first-child").css("background", "#f1d7e7");
});

