/* STANDARD TEMPLATE */
/* Javascript Triggers and Custom Functions
----------------------------------------------------------------------------- */


	$(document).ready(function() {
	
	
	});
	
	$(window).load(function() {

		if (section != "messageboard" && section != "checkout" ) {
		
			navigation();
		//	login();
			if (page == "index" || page == "news" || section == "about") readmore();
			tabs('removeEmptyTabs');
			paging();
			truncate();
			comments();
			markup();
			dropdown();
			
			// PLUGIN: CLIQUE FORMS (Adds text into input forms)
			$('#mailing_list_entry_email').cliqueForms({ placeholder: "Enter Your E-mail Address" });

			// PLUGIN: CLIQUE ACTIONS (Replaces submit buttons with text links)
			try { $('input[type=submit]').cliqueActions(); } catch (error) { alert('Error: Missing Clique Actions Plugin'); }

			// PLUGIN: PHOTO DOWNLOAD BLOCKER (Prevents photo downloads with overlayed gif)
			try { $('div.widget-photo.display img').photoDownloadBlocker(); } catch (error) { alert('Error: Missing Photo Download Blocker Plugin'); }

			// Exclusive Photos is the first tab, begin cycling
			if ( $('#photos').length > 0 && $('ul.tabs li:first-child a.tab').attr('href') == "#photos" ) {

				photoSlideshow();

				// PLUGIN: PHOTO DOWNLOAD BLOCKER (Prevents photo downloads with overlayed gif)
				try { $('div.widget-photo.slideshow img').photoDownloadBlocker(); } catch (error) { alert('Error: Missing Photo Download Blocker Plugin'); }

				if ($('#photos ul.photos > li[class!=last]').length > 0) {

					$('#photos div a, a#photos_back, a#photos_next').hover(

						function() {

							$('a#photos_back').show();
							$('a#photos_next').show();

						}, function() {

							$('a#photos_back').hide();
							$('a#photos_next').hide();

						}

					)

				}

			}
			
			cufon();

		}

	});
	

/* FUNCTION: ADD HOVER CLASS TO BONJOVI.COM DROPDOWN
----------------------------------------------------------------------------- */

	function dropdown() {

		$('#network ul > li:has(ul)').hover(

			function() {

				$(this).addClass('hover');

			},
			function() {

				$(this).removeClass('hover');

			}

		)

	}
	
	
/* FUNCTION: LOGIN PAGE PROMO
----------------------------------------------------------------------------- */

	function login() {
	
		if (page == "login") {
	
			// APPEND NOTE TO SIGN IN BUTTON
			$('div.widget-account.signin em.email').append(' *');
			$('div.widget-account.signin ul.actions').after('<small class="note">* You must now use your email address to sign in. Contact <a href="mailto:support@allaccesstoday.com" target="_blank">customer support</a> if you do not remember the email address on your account.</small>');
	
			// START PACKAGE TIER SLIDESHOW
			$('ul.tiers').before('<div id="paging">').cycle({
	
				fade: true,
				speed: 400,
				timeout: 9000,
				pager: '#paging',
				before: function() { if (window.console) console.log(this.src); }
	
			});
	
			// START UPSELL BENEFITS SLIDESHOW
			$('div#benefits ul').cycle({
	
				fade: true,
				speed: 400,
				timeout: 6000
	
			});
	
			// CUSTOM PAGING LINKS
			$('#paging a:nth-child(1)').livequery(function() { $(this).addClass('basic'); });
			$('#paging a:nth-child(1)').livequery(function() { $(this).text('Basic'); });
			$('#paging a:nth-child(2)').livequery(function() { $(this).addClass('deluxe'); });
			$('#paging a:nth-child(2)').livequery(function() { $(this).text('Deluxe'); });
			$('#paging a:nth-child(3)').livequery(function() { $(this).addClass('premier'); });
			$('#paging a:nth-child(3)').livequery(function() { $(this).text('Premier'); });
			
		}
		
	}
	
	
/* FUNCTION: CUFON
----------------------------------------------------------------------------- */

	function cufon() {

		var trade_gothic = [ 
		
			'#page-index div.widget-event ul.events li > strong', 
			'div#inquiry h3', 
			'div.prompt h3', 
			'div#answers h3', 
			'div.pane h3', 
			'#page-profile div.widget-profile.display div.group h4', 
			'div.widget-photo h4', 
			'#news ul.leads h4 a', 
			'div.widget-editorial ul.leads li div.story a.readmore', 
			'div.widget-editorial.display h4', 
			'#footer address strong', 
			'ul.tabs li a', 
			'div.widget-tag.display h3', 
			'div.widget-alert.added h3', 
			'body.section-legal div#content h3',
			'body.section-legal div#content h4', 
			'div.widget-account.modify h3', 
			'div.widget-account.modify h4', 
			'body.section-news ul.tabs li', 
			'div.widget-editorial h4', 
			'div.widget-event h3', 
			'div.widget-event h4', 
			'div#sidebar div.pane h3',
			'div.widget-tag.album h4',
			'#page-video div.widget-media.player h3',
			'#page-archive #content h4',
			'#optin h3'
			
			
		];

		Cufon.replace(trade_gothic, { fontFamily: 'Trade Gothic', hover: true });
		
		$(trade_gothic.toString()).css('visibility', 'visible');
				
	}
	
	
/* FUNCTION: MARKUP CHANGES
----------------------------------------------------------------------------- */


	function markup() {
	
		$('#page-index #features #photos a.browse').each(function() {
		
			$(this).attr('href', '/photos');
		
		});
		
		$('#page-news #sidebar div.widget-tag h3').after('<h4>Browse by year</h4>');
		$('#page-archive div.widget-tag h3').after('<h4>Browse by year</h4>');
		$('#page-news #sidebar div.widget-tag ul li:first-child').remove();
		$('#page-archive div.widget-tag ul li:first-child').remove();
	
	}
			
		
/* FUNCTION: SITE CHANGE ALERT
-----------------------------------------------------------------------------

	function overlay() {
				
		if ($.cookie('soulOverlay') != "false") {
	
			$('<div id="overlay"><a href="#">Welcome to our new website!</a></div>').appendTo('body');
			$('#overlay a').click(function() {
			
				$(this).parent().fadeOut(function() { $(this).remove(); });
				return false;
			
			});
			
			if (site_host.match('sparkart.net')) {
			
				// Dev Cookie
				$.cookie('soulOverlay', 'false', { domain: 'sparkart.net' });
				
			} else {
			
				// Live Cookie
				$.cookie('soulOverlay', 'false', { domain: 'jonbonjovisoulfoundation.org' });

			}

		}

	} */
