/*
 *	Author: <jef.collier@salientlink.com>
 */

jQuery.noConflict();

//Accordion Magick
jQuery(document).ready(function() {
	jQuery('.accordion .wrapper').hide();
	jQuery('.accordion h2 a.active').parent().next('.wrapper').slideDown('slow');
	jQuery('.accordion h2 a').click(function(){
		if(jQuery(this).hasClass('active')){
			jQuery(this).removeClass('active').parent().next('.wrapper').slideUp('slow');
		} else {
			jQuery(this).addClass('active').parent().next('.wrapper').slideDown('slow');	
		}
		return false;
	});
});
 
//ColorBox
jQuery(document).ready(function() {
	//About Lightboxes
	jQuery('.about a.more').colorbox({
		inline:true, 
		width:"1024px"
	});
	//Concert Lightboxes
	jQuery('.concert a.more').colorbox({
		inline:true, 
		width:"1024px"
	});
	//Concert Lightboxes
	jQuery('#icons li a.newsletter').colorbox({
		inline:true, 
		width:"300px"
	});
	//This gets rid of the scroll bars on the page, but prevents users from reading big lightbox bios.
	jQuery('body.page-template-concerts-php').bind('cbox_open', function(){ 
		jQuery('html').css({overflow:'hidden'}); 
	}).bind('cbox_closed', function(){ 
		jQuery('html').css({overflow:'auto'}); 
	}); 
	//Un-used iframe scroll hack for modals
	//jQuery(".iframe").colorbox({width:"80%", height:"80%", iframe:true}); 
});

//Style Hacks
jQuery(document).ready(function() {
	//Hiding the Newsletter Atribute Notice!
	jQuery('#wpfes_newsletter h6').hide();
	//Recalculating #Footer to fake "sticky"
	setInterval("fixFooter()",1000);
});

//Newsletter Validation Hacks
jQuery(document).ready(function() {
	var regMail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var defaultVal = jQuery('#newsletter_signup input#wpfes_email').val();
	jQuery('#newsletter_signup #wpfes_newsletter form').submit(function() {
		if (jQuery('input#wpfes_email').val() == defaultVal || jQuery('input#wpfes_email').val() == 'E-mail' || jQuery('input#wpfes_email').val() == '' ) {
			jQuery('#wpfes_newsletter h6').text('Please enter an email address').show().fadeOut(2000);
			return false;
		} else {
			if(!regMail.test(jQuery('input#wpfes_email').val())){
				jQuery('#wpfes_newsletter h6').text('Please provide a valid email!').show().fadeOut(2000);
				return false;
			} else {
				//jQuery('#wpfes_newsletter h6').text('Everything looks valid.').show().fadeOut(2000);
				return true;
			}
		}
	});
});

function fixFooter(){
	var cHt = jQuery('#container').height();
	if(cHt < 720){
		jQuery('#footer').css({
			"width":"100%",
			"position":"fixed",
			"bottom":"0"
		});
	} else {
		jQuery('#footer').css({
			"width":"100%",
			"position":"relative"
		});
	}
}
