// JavaScript Document

function highlight(field)
{
	field.focus();
	field.select();

	return true;
}

function checkThis(theVal)
{
	if(theVal="your@email.com")
	{
		$("#emailSignup").attr("value", "");
	}
}
	
$("document").ready(function ()
{
	//Fill in hidden variables on form to block spam
	$(".anticatpcha").val("NoMoreSpamEnHere");
	
	$("#showContactForm").click(function ()
	{
		$("#contactUsForm2").hide();
		$("#contactUsForm").slideToggle();
	});
	$("#showDealerForm").click(function ()
	{
		$("#contactUsForm").hide();
		$("#contactUsForm2").slideToggle();
	});
		$('a[@href$="mp3"]').flash(
        { src: '/flash/singlemp3player.swf', height: 20, width: 100 },
        { version: 7 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.file = $this.attr('href');
            $this.before($.fn.flash.transform(htmlOptions));						
        }
    );

	$(".comingSoon").click(function() { $.prompt("Buy Notion Clothing Online, Coming Soon"); });
	function voteResponse(responseText, statusText)  
	{ 
		if(statusText == "success")
		{
			switch(responseText)
			{
				case "Thank You For Voting":
					$(".voteButton").css({'opacity':'0.2'});
					$(".voteButton").unbind('click');
				default:
					alert(responseText);
					break;
			}
		}
	}

	$(".voteButton").click(function()
	{
		var vId = $(this).attr("title");
		function callbackFunc(v,m)
		{
			if(v == "yes")
			{
				$.post("/includes/contest.php", { 'sentFrom': 'contest', 'vote': 'yes', 'cItem':vId }, voteResponse);
			}
		}
		$.prompt("You may only vote once, would you like your vote counted towards this picture?", { buttons:{ "Not Yet":"no","Yes, Cast My Vote!":"yes"},callback: callbackFunc });
	});
	$("#myspaceQ").click(function()
	{
		$.prompt("Copy and paste the code into your myspace profile and show this on your page.");
	});
	
	$("#companyFlash").flash({src: '../flash/slideshow2.swf',width: 272,height: 325,'flashvars': {galleryId: 14},wmode: 'transparent'});
	$("#homeLeftFlash").flash({src: '../flash/slideshow.swf',width: 420,height: 325,'flashvars': {galleryId: 13},wmode: 'transparent'});
	$("#homeRightFlash").flash({src: '../flash/slideshow2.swf',width: 272,height: 325,'flashvars': {galleryId: 17},wmode: 'transparent'});
	$("#flashTeamRight").flash({src: '../flash/slideshow2.swf',width: 272,height: 325,'flashvars': {galleryId: 19},wmode: 'transparent'});
	$("#contactFlashLeft").flash({src: '../flash/slideshow.swf',width: 420,height: 325,'flashvars': {galleryId: 18},wmode: 'transparent'});
	$("#eventsFlash").flash({src: '../flash/eventSlideshow.swf',width: 272,height: 325,'flashvars': {galleryId: $("#eventId").val()},wmode: 'transparent'});
	$("#articleFlash").flash({src: '../flash/eventSlideshow.swf',width: 272,height: 325,'flashvars': {galleryId: $("#articleId").val()},wmode: 'transparent'});
	$("#mediaFlash").flash({src: '../flash/mediaSlideshow.swf',width: 390,height: 325,'flashvars': {galleryId: $("#galleryId").val()},wmode: 'transparent'});
	
		function callbackFunc(v,m)
		{
			if(v == "yes")
			{
				if(m.children('#emailSignup').val() != "your@email.com")
				{
					window.location="http://visitor.constantcontact.com/d.jsp?m=1101893904862&p=oi&ea=" + m.children('#emailSignup').val();
				}
			}
		}
		
		$("#signUp").click(function()
		{
			$.prompt("<span style='color: #000'>Join Our Mailing List</span><br /><input type='text' id='emailSignup' style='width: 100%' value='your@email.com' onclick='checkThis(this.value)'>", { buttons:{ "Nevermind":"no","Sign Me Up":"yes"},callback: callbackFunc });	
		});
		$('a.adThumb').lightBox(); // Select all links in the page
		$('a.submissions').lightBox(); // Select all links in the page
//Family Sport Lists
		//Get Names
		$("#surfList").load("includes/getNames.php?sport=surf&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#surfList .linkItem"), function(i) {if($("#surfList .linkItem").size() > 4) {if(i>4){$(this).hide();}}});});
		$("#skateList").load("includes/getNames.php?sport=skate&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#skateList .linkItem"), function(i) {if($("#skateList .linkItem").size() > 4) {if(i>4){$(this).hide();}}});});
		$("#snowList").load("includes/getNames.php?sport=snow&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#snowList .linkItem"), function(i) {if($("#snowList .linkItem").size() > 4) {if(i>4){$(this).hide();}}});});
		$("#otherList").load("includes/getNames.php?sport=other&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#otherList .linkItem"), function(i) {if($("#otherList .linkItem").size() > 4) {if(i>4){$(this).hide();}}});});
		
		//Reload Random names if they click More
//		$("#moreSurf").livequery('click', function (event) { $("#surfList").load("includes/getNames.php?sport=surf&cachebuster=" + new Date().getTime()); });
		$("#moreSurf").livequery('click', function (event) { 
			if($("#surfList .linkItem").size() > 5)
			{
				$("#surfList .linkItem").show();
				$.each($("#surfList .linkItem"), function(i)
				{
					if(i<5)
					{
						$(this).remove();
					}
				});
				$.each($("#surfList .linkItem"), function(i) { if(i>4){$(this).hide();}});
			} else {
				//Reload All names
				$("#surfList").load("includes/getNames.php?sport=surf&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#surfList .linkItem"), function(i) { if(i>4){$(this).hide();}});});
			}
		});
		$("#moreSkate").livequery('click', function (event) { 
			if($("#moreSkate .linkItem").size() > 5)
			{
				$("#moreSkate .linkItem").show();
				$.each($("#moreSkate .linkItem"), function(i)
				{
					if(i<5)
					{
						$(this).remove();
					}
				});
				$.each($("#moreSkate .linkItem"), function(i) { if(i>4){$(this).hide();}});
			} else {
				//Reload All names
				$("#moreSkate").load("includes/getNames.php?sport=skate&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#moreSkate .linkItem"), function(i) { if(i>4){$(this).hide();}});});
			}
		});
		$("#moreSnow").livequery('click', function (event) { 
			if($("#moreSnow .linkItem").size() > 5)
			{
				$("#moreSnow .linkItem").show();
				$.each($("#moreSnow .linkItem"), function(i)
				{
					if(i<5)
					{
						$(this).remove();
					}
				});
				$.each($("#moreSnow .linkItem"), function(i) { if(i>4){$(this).hide();}});
			} else {
				//Reload All names
				$("#moreSnow").load("includes/getNames.php?sport=snow&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#moreSnow .linkItem"), function(i) { if(i>4){$(this).hide();}});});
			}
		});
		$("#moreOther").livequery('click', function (event) { 
			if($("#moreOther .linkItem").size() > 5)
			{
				$("#moreOther .linkItem").show();
				$.each($("#moreSnow .linkItem"), function(i)
				{
					if(i<5)
					{
						$(this).remove();
					}
				});
				$.each($("#moreOther .linkItem"), function(i) { if(i>4){$(this).hide();}});
			} else {
				//Reload All names
				$("#moreOther").load("includes/getNames.php?sport=other&cachebuster=" + new Date().getTime(),{limit: 25},function() {$.each($("#moreOther .linkItem"), function(i) { if(i>4){$(this).hide();}});});
			}
		});		
		//Hover Fade In Fade Out
		$(".surftd").hover(function(){$(".nameList").hide();$("#surfList").fadeIn();}, function(){return false;});
		$(".skatetd").hover(function(){$(".nameList").hide();$("#skateList").fadeIn();}, function(){return false;});
		$(".snowtd").hover(function(){$(".nameList").hide();$("#snowList").fadeIn();}, function(){return false;});
		$(".othertd").hover(function(){$(".nameList").hide();$("#otherList").fadeIn();}, function(){return false;});
		
		$(".teamSub").livequery('click', function()
		{
			$(".teamTable").hide(0);
			var id= $(this).attr('title');
			$("#otherBox").load("includes/getNames.php?sub_category=" + id + "&cachebuster=" + new Date().getTime());
			$("#otherBox").fadeIn('normal');
			return false;
		});
		
		$("#backToFamily").livequery('click', function()
		{
			$("#otherBox").hide(0);
			$(".teamTable").fadeIn('normal');
			return false;
		});
//EVENTS PAGE
	$("#eventTop").click(function()
	{
		if($("#events_clicker").html() == "Click for more details.")
		{
			$("#eventComments").hide();
			$("#eventList").animate({height: 80}, 700);
			$("#eventsRight").animate({height: 289}, 700);
			$("#events_clicker").html("Click for less details.");
			$("#eventDetails").fadeIn('slow');
		} else {
			$("#eventDetails").fadeOut('fast');
			$("#eventList").animate({height: 314}, 700);
			$("#eventsRight").animate({height: 60}, 700);
			$("#events_clicker").html("Click for more details.");
		}
	});
	$(".event_item").click(function()
	{
			$("#eventDetails").fadeOut('fast');
			$("#eventList").animate({height: 314}, 700);
			$("#eventsRight").animate({height: 60}, 700);
			$("#events_clicker").html("Click for more details.");
		var eId = $(this).attr('id');
		var eId = eId.substr(1);
		$("#theEventID").val(eId);
		$("#eventsFlash").html("");
		$("#eventsFlash").flash({src: '../flash/eventSlideshow.swf',width: 272,height: 325,'flashvars': {galleryId: eId},wmode: 'transparent'});
		$("#event_title").load("/getEvent.php", {id:eId, o:'title'});
		$("#event_when").load("/getEvent.php", {id:eId, o:'when'});
		$("#eventDetails").load("/getEvent.php", {id:eId, o:'description'});
		$(".commentInfo").load("/loadComments.php?type=event&id=" + eId);
	});
	
	
	
	
	
	
	
//Media Page
	$(".media_item").click(function()
	{
		var date = $(this).attr('id').split("_");
		var eId = date[0];
		var eGallery = date[1];
		$("#mediaFlash").html("");
		$("#mediaFlash").flash({src: '../flash/mediaSlideshow.swf',width: 390,height: 325,'flashvars': {galleryId: eId},wmode: 'transparent'});
		//$("#myspaceCode").html("test");
		$("#myspaceCode input").val('<object type=\"application/x-shockwave-flash\" allowScriptAccess=\"never\" allowNetworking=\"internal\" width=\"388\" height=\"325\" align=\"center\" data=\"http://www.notionclothing.com/flash/publicSlideshow.swf\"><PARAM NAME=\"FlashVars\" VALUE=\"galleryId=' + eId + '\"><param name=\"movie\" value=\"http://www.notionclothing.com/flash/publicSlideshow.swf\" /><param name=\"quality\" value=\"high\" /></object>');
		$(".commentInfo").load("/loadComments.php?type=main&id=" + eId);
	});
	$("#vComments").livequery('click', function()
	{
		var eId = $(this).attr('title');
		$("#mediaList").animate({height: 0}, 700);
		$("#mediaList").fadeOut(5);
		$(".commentInfo").fadeOut('fast');
		$("#mediaComments").animate({height: 355}, 700);
		$("#commentImage").attr("src", "/images/mediacomments2.gif");
		$("#backtomedia").fadeIn();
		$("#commentFormBox").load("commentForm.php?type=main&id=" + eId);
		$("#commentFormBox").fadeIn();
	});
	$("#eComments").livequery('click', function()
	{
		$("#events_clicker").html("Click for more details.");
		$("#eventDetails").fadeOut('fast');
		$("#eventList").animate({height: 314}, 5);
		$("#eventsRight").animate({height: 60}, 5);
		var eventId = $(this).attr('title');
		$("#eventList").animate({height: 0}, 700);
		$("#eventList").fadeOut(5);
		$("#eventComments").animate({height: 309}, 700);
		$("#commentImage").fadeIn('fast');
		$("#backtoevents").fadeIn();
		$("#commentFormBox").load("commentForm.php?type=event&id=" + eventId);
		$("#commentFormBox").fadeIn();
	});
	
	$("#commentImage").livequery('click', function()
	{
		$("#eventComments").hide();
		$("#backtoevents").hide();
		$("#commentFormBox").hide();
		$("#eventList").animate({height: 309}, 700);
		$("#eventList").fadeIn(5);
	});
	
	$("#backtomedia").livequery('click', function()
	{
		$("#mediaList").fadeIn(5);
		$("#commentFormBox").fadeOut('fast');
		$("#mediaList").animate({height: 278}, 700);
		$("#mediaComments").animate({height: 65}, 700);
		$(".commentInfo").fadeIn('fast');
		$("#commentImage").attr("src", "/images/mediacomments.gif");
		$("#backtomedia").hide();
	});
	
	//$("#commentForm")
	$("#step2").livequery('click', function()
	{
		$("#cForm2").hide(0);		   
		$("#captcha").show(0);
		Recaptcha.create("6Ld9vgEAAAAAAK5pMzBaEmTlrR89S_nriBa-FN2n",
		"scc", {
		   theme: 'custom',
		   lang: 'en',
		   custom_theme_widget: 'scc',
		   callback: Recaptcha.focus_response_field
		});
	});





	$(".news_item").click(function()
	{
		var eId = $(this).attr('id');
		var eId = eId.substr(1);
		window.location="/news-" + eId;
	});

	$(".download_item").click(function()
	{
		var eId = $(this).attr('id');
		var eId = eId.substr(1);
		window.location="/download-file-" + eId;
	});
	var htmlHolder = "";
	$("#joinContest").click(function()
	{
		htmlHolder = $("#contestRight").html();
		$("#contestRight").html("");
		$("#contestRight").append($("#entryForm").clone());
		$("#entryForm").attr("id", "entryForm2");
		//alert($("#contestRight").html());
		//$("#contestRight").html($("#entryForm").html());

		Recaptcha.create("6Ld9vgEAAAAAAK5pMzBaEmTlrR89S_nriBa-FN2n",
		"scc", {
		   theme: 'custom',
		   lang: 'en',
		   custom_theme_widget: 'scc',
		   callback: Recaptcha.focus_response_field
		});
		$("#contestForm").validate({messages: {email: {required: "", email: "<div style='color:red; text-align:center; margin-bottom: 8px'>Please us a valid e-mail address.</div>"}}});
		jQuery.validator.messages.required = "";
		$("#closeContest").click(function()
		{
			$("#contestRight").html(htmlHolder);
			$('a.submissions').lightBox(); //re-initialize it
		});
	});
	
	
	$("area").click(function ()
	{
		window.location='/store_locator_' + $(this).attr("alt");
	});
	
var options = {
        resizeLgImages:     true,
        displayNav:         false,
        handleUnsupported:  'remove',
        keysClose:          ['c', 27], // c or esc
        autoplayMovies:     false
    };

    Shadowbox.init(options);
	
	function sendFriend(v,m)
	{
		if(v == "yes")
		{	
			window.location="sendToFriend.php?sentFrom=ssssennndddToFrrriend&link=" + $("#curPage").val() + "&email1=" + m.children('#email1').val() + "&email2=" + m.children('#email2').val() + "&theEventID=" + $("#theEventID").val();
		}
	}
	
	$(".sendToFriend").click(function()
	{
		$.prompt("Your E-Mail: <input type='text' id='email1' name='email1' style='width: 100px' /><br /> Friend's E-Mail: <input type='text' id='email2' style='width: 100px' name='email2' value='' />", { buttons:{ "Nevermind":"no","Send To Friend":"yes"},callback: sendFriend });
	});

});

function popBioMedia(id)
{
	//$("#hiddenLink" + id).attr("href", "../ridermedialarge/" + id + ".jpg");
	$("#hiddenLink" + id).click();
}
function popMainMedia(id)
{
	/*
	$("#hiddenLink").attr("href", "../mainmedialarge/" + id + ".jpg");
	$("#hiddenLink").click();
	*/
	$("#hiddenLink" + id).click();

}
