/**** Javascript for John Varvatos ******/

//everything happens after the page loads
$(function(){
	
	//blog
	$('#s').click(function() {
		if( $(this).val() == 'Search' ) {
			$(this).val('');
		}
		$(this).animate({'backgroundColor':'#555'});
	});
	$('#s').blur(function() {
		if( $(this).val() == '' ) {
			$(this).val('Search');
		}
		$(this).animate({'backgroundColor':'#333'});
	});
	
	if( $('body').hasClass('.jvs-funhouse') ) {
		$('.jvs-funhouse a').each(function() {
			var href = $(this).attr('href');
			href = href.replace('http://johnvarvatos.pod1ecommerce.com/','http://www.johnvarvatos.com/');
			$(this).attr('href', href);
		});
	};
	
	//Png fix for ie6 only
	if( jQuery.browser.msie ) {
		if( jQuery.browser.version == 6.0 ) {
			//supersleight.init();
		}
	}
	
	//Footer External Links
	$('#vimeo, #facebook').click(function() {
		window.open( $(this).attr('href') );
        	return false;							   
	});
	
	//Newsletter Popup Box
	/*$('#modal').jqm({ajax:'@href',ajaxText:'loading...',trigger:'#sign-up',overlay:75});
	$('#sign-up').click(function() {
		$('#modal').addClass('newsletter-box');
		return false;
	});*/
	
	$('a#close-modal').livequery('click',function() {
		$('#modal').jqmHide();
		$('#modal').removeClass('newsletter-box');
		return false;
	});
	
	//Tooltips
	$('.tooltip a').tooltip({ track: true, delay: 0, showURL: false, showBody: " - ", fade: 250, fixPN: true });
	
	//Lightbox
	$('#celeb-nav a, #press-content a').lightBox({imageLoading: 'http://johnvarvatos.pod1ecommerce.com/wp-content/themes/jv/images/lightbox-ico-loading.gif', imageBtnPrev: 'http://johnvarvatos.pod1ecommerce.com/wp-content/themes/jv/images/lightbox-btn-prev.gif', imageBtnNext: 'http://johnvarvatos.pod1ecommerce.com/wp-content/themes/jv/images/lightbox-btn-next.gif' });
	
	//Accordion on press releases
	$('#press-accordion').accordion({ autoHeight: false, collapsible: true, active: false });
	$('#press-releases a.header').append('<div class="clear"> </div>');
	
	//Change download text for press-release page
	if( $('body').attr('id') == 'press-releases' ) {
		$('ul.wam_ul a').empty().html('Download PDF')
	}
		
	/*$('#campaigns #container, #campaigns #footer-container').css({opacity: '0.4'});
	$('#campaigns #container, #campaigns #footer-container').hover(function() {
		$(this).animate({opacity: '1'});
	}, function() {
		$(this).animate({opacity: '0.4'});
	});*/
	
	//header
	$('li.nav-collections, #sub-nav-collections').hover(function() {
		if( $('#nav').css('padding-bottom') != '20px' ) {
			$('#nav').css('padding-bottom', '20px');
		}
		if( $('body').hasClass('the-world-of') ) {
			$('#sub-nav-world').hide();
		}
		$('#sub-nav-collections').show();
	},
	function() {
		if( !$('body').hasClass('the-world-of') && !$('body').hasClass('collections') ) {
			$('#nav').css('padding-bottom', '0');
		}
		if( $('body').hasClass('the-world-of') ) {
			$('#sub-nav-world').show();
		}
		if( !$('body').hasClass('collections') ) {
			$('#sub-nav-collections').hide();
		}
	});
	
	$('#nav-world, #sub-nav-world').hover(function() {
		if( $('#nav').css('padding-bottom') != '20px' ) {
			$('#nav').css('padding-bottom', '20px');
		}
		if( !$('#sub-nav-collections').is(':hidden') ) {
			$('#sub-nav-collections').hide();
		}
		$('#sub-nav-world').show();
	},
	function() {
		if( !$('body').hasClass('the-world-of') && !$('body').hasClass('collections') ) {
			$('#nav').css('padding-bottom', '0');
		}
		if( $('body').hasClass('collections') ) {
			$('#sub-nav-collections').show();
		}
		if( !$('body').hasClass('the-world-of') ) {
			$('#sub-nav-world').hide();
		}
	});
		
});