/* Author: 

*/

$(document).ready(function(){

	// Style Switcher
	// Open and Close
	$('#ss-link').click(function(){
		if( $(this).hasClass('on') ){
			$(this).removeClass('on');
			$('#styleswitcher').slideUp('slow');
		} else {
			$(this).addClass('on');
			$('#styleswitcher').slideDown('slow');
		}
	});
	
	// Style Contact Form
	// Open and Close
	$('#contact-link').click(function(){
		if( $(this).hasClass('on') ){
			$(this).removeClass('on');
			$('#contact-form').slideUp('slow');
		} else {
			$(this).addClass('on');
			$('#contact-form').slideDown('slow');
			$('#contact-form input').first().focus();
		}
	});
	// Submit and show message
	/*
	$('#contact-form input[type=submit]').click(function(e){
		$('#contact-form div').slideUp('fast',function(){
			$('#contact-form .success').slideDown('slow');
		});
		e.preventDefault();
	});
	// Close message
	$('#contact-form .success .button').click(function(){
		$('#contact-form').slideUp('slow',function(){
			$('#contact-link').removeClass('on');
		});
	});
	*/
	

	// Events
	// Load Image
	if( $('#event').length ){
		var theImg = $('.preloader').data('mypath');
		$('<img />').attr('src',theImg).load(function(){
			$(this).insertAfter('#event .preloader').fadeIn('slow');
		});
	}

	// Must-Have Styles
	// Landing Page
	// Load Image
	if( $('#styles-intro').length ){
		var theImg = $('.preloader').data('mypath');
		$('<img id="styles-intro-background" />').attr('src',theImg).load(function(){
			$(this).insertAfter('#styles-intro .preloader').fadeIn('slow',function(){

				// Hover Effect
				$('#styles-intro a').hover(function(){
					$(this).animate({ opacity: 0}, 300);
				},function(){
					$(this).animate({ opacity: 1}, 100);
				});
			
			});
		});
	}

	// Store History
	// Load Image
	if( $('#history-content').length ){
		var theImg = $('.preloader').data('mypath');
		$('<img />').attr('src',theImg).load(function(){
			$(this).insertAfter('#history-content .preloader').fadeIn('slow');
		});
	}
	
	// Brands
	// Load Image
	if( $('#brand-profile').length ){
		var theImg = $('.preloader').data('mypath');
		$('<img id="brand-background" />').attr('src',theImg).load(function(){
			$(this).insertAfter('#brand-profile .preloader').fadeIn('slow',function(){
				$('#brand-profile .content').fadeIn('slow');
			});
		});
	}


	// E-Club Page
	// Load Image
	if( $('#e-club').length ){
		var theImg = $('.preloader').data('mypath');
		$('<img id="eclub-background" />').attr('src',theImg).load(function(){
			$(this).insertAfter('#e-club .preloader').fadeIn('slow',function(){
				$('#e-club .content').fadeIn('slow');
			});
		});
	}
	// Submit Button
	/*
	$('#eclub-form input[type=submit]').click(function(e){
		$('#eclub-form').fadeOut('fast',function(){
			$('#e-club .success').fadeIn('slow');
		});
		e.preventDefault();
	});
	*/

	// Paging Tooltip
	if( $(document).width() > 480 ){ // Only if on a big screen!!
		$('#prev-page').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			showBody: " - ", 
			extraClass: "page-preview-left", 
			fixPNG: true, 
			opacity: 0.95,
			top:-70,
			left:50
		});
		$('#next-page').tooltip({
			positionLeft: true,
			track: true, 
			delay: 0, 
			showURL: false, 
			showBody: " - ", 
			extraClass: "page-preview-right", 
			fixPNG: true, 
			opacity: 0.95,
			top:-70,
			left:-50
		});
	}
	
	//Map
	$('#map-link').click(function (e) {
		$.modal('<iframe src="'+this.href+'&output=embed"></iframe><p class="larger"><a target="_blank" href="'+this.href+'">View larger</a></p>');
		return false;
	});
	
	// Mobile Teaser
	showFull = $.cookie('showFull');
	if( $(document).width() <= 480 && showFull == undefined ){
		$('#mobile-teaser').show();
		$('#container').hide();
	}
	
	$('#close-teaser').click(function(){
		$('#container').show();
		$('#mobile-teaser').hide();
		$.cookie('showFull', 'true');
	});
	
	// Current Menu Items
	if($('body').is('parent-pageid-82')){
		$('li.must-have-styles').addClass('current-menu-item');
	}
	
	
	//Holiday Gift Guide
	$("#holiday-gift-guide ul li").hover(function(){
		$("div", this).stop().animate({bottom:"0px"},{queue:false,duration:200});
	}, function() {
		$("div", this).stop().animate({bottom:"-220px"},{queue:false,duration:200});
	});

	
});
