jQuery.noConflict();
jQuery(document).ready(function(){
    if(jQuery.browser.msie && jQuery.browser.version < 7){
        jQuery('head').append('<link rel="stylesheet" href="css/styles.ie6.css" type="text/css" />');
        jQuery('head').append('<link rel="stylesheet" href="css/dvdstyles.ie6.css" type="text/css" />');
    }
    
//    var dateVar = jQuery('.dateVar').attr('value');
//    alert(dateVar);
//    jQuery('.tout > h3 > a > em, .bones > h3 > a > em').text("Updated " +  dateVar);
    
    if(jQuery('#graphicHeader').length)
    {
        jQuery('#sideColumn').removeClass('td'); 
        jQuery('#sideColumn').addClass('td with-header');
    }
    
    if(jQuery('.videoColumn').length){
     jQuery('#content').removeClass('table');
     jQuery('#content').addClass('table media');
     jQuery('#content > div').removeClass('tr');
    }
    
    if(jQuery('p.contact').length){
     jQuery('#graphicHeader').remove(); 
     jQuery('h1').addClass('contact');
     jQuery('#sideColumn').removeClass('td with-header'); 
     jQuery('#sideColumn').addClass('td'); 
     }
     
    if(jQuery('.overlay').length){
     jQuery('body').removeClass('subpage');
     jQuery('body').addClass('index');
     }
    
	// ===== PNGs: Fix transparency for IE 6 ====================
	jQuery('img[src$=.png],.tout h3,.png').ifixpng();
	
	// ===== FOOTER: Add Mouseover FXs ====================
	jQuery('#footer li.tout a').hover(function() {
		jQuery(this).children('img.arrow').animate({ left:'+=15' }, { duration: 300, easing: 'easeOutBounce'});
	}, function() {
		jQuery(this).children('img.arrow').animate({ left:'-=15' }, { duration: 300, easing: 'easeOutBounce'});          
	});
	
	jQuery('#footer li.tour li a').hover(function() {
		jQuery(this).animate({ backgroundPosition:'12px 8px' }, { duration: 300, easing: 'easeOutBounce'});
		jQuery(this).children('b.date').animate({ paddingLeft: '+=8' }, { duration: 300, easing: 'easeOutBounce'});
	}, function() {
		jQuery(this).animate({ backgroundPosition:'0px 8px' }, { duration: 300, easing: 'easeOutBounce'});
		jQuery(this).children('b.date').animate({ paddingLeft: '-=8' }, { duration: 300, easing: 'easeOutBounce'});       
	});
	
	// ===== HEADER: Add Events to PhilFan / Login form =========================
	if(jQuery('#philfan').length){
	    jQuery('#philfan ul.loggedIn').show();
		jQuery('#philfan ul.form input[name="username"]').focus(function(){
			if(this.value==this.defaultValue) this.value = "";								
		}).blur(function(){
			if (this.value=="") this.value = this.defaultValue;
		}).bind("keypress",keypress);
		jQuery('#philfan ul.form input[name="password"]').focus(function(){
			if(this.type=='text') jQuery(this).replaceWith('<input type="password" name="password" value="" />');
			jQuery('#philfan ul.form input[name="password"]').focus().bind("keypress",keypress);
		});
		jQuery('#philfan ul.form input[name="ctl00$PhilLoginControl1$btnSubmit"]').click(function(){
		    jQuery('#philfan').animate({ 'marginTop':'-118px' }, 750, 'easeInQuad',
		        function(){
		            jQuery('#philfan ul.form').hide();
		            jQuery('#philfan ul.btns').show();
		            jQuery('#philfan ul.loggedIn').show();
		            }
	            ).animate({ 'marginTop':'0px' }, 750, 'easeOutQuad');
		     keypress('submit') });
		jQuery('#btnLogout').click(function(){
		    jQuery('#philfan').animate({ 'marginTop':'-118px' }, 750, 'easeInQuad',
		        function(){
		        jQuery('#philfan ul.form').hide();
		        jQuery('#philfan ul.loggedIn').hide();
		        jQuery('#philfan ul.btns').show();
		        }
	        ).animate({ 'marginTop':'0px' }, 750, 'easeOutQuad');
		   
		 keypress('submit') });
	
		// ===== HEADER: Add Animation to Switch To/From Login Form =========================
		//jQuery('#btnLogin').click(function(){
		//	jQuery('#philfan').animate({ 'marginTop':'-118px' }, 750, 'easeInQuad',
		//		function(){
		//			jQuery('#philfan ul.btns').hide();
		//			jQuery('#philfan ul.form').show();
		//		}
		//	).animate({ 'marginTop':'0px' }, 750, 'easeOutQuad');
		//	return false;
		//});
	
		jQuery('#btnClear').click(function(){
			jQuery('#philfan').animate({ 'marginTop':'-118px' }, 750, 'easeInQuad',
				function(){
					jQuery('#philfan ul.btns').show();
					jQuery('#philfan ul.form').hide();
					jQuery('#philfan ul.form input').val('').blur();
				}
			).animate({ 'marginTop':'0px' }, 750, 'easeOutQuad');
			return false;
		});
	};
	
	function keypress(e){
		if (e.keyCode == 13 || e == 'submit'){
			jQuery.post("login.asp", { 
				username: jQuery('#philfan input:text').val(),
				password: jQuery('#philfan input:password').val()
			},
			function(data){
				alert("Data Loaded: " + data);
			});
		}
	};
	
	// ===== FOOTER: Carousel - Partners/Logos ====================
	jQuery('#logos').simpleCarousel({
		'pagination':false,
		'autostart':true,
		'pause':4000
	});
	
	// ===== INDEX: Carousel - Photo Gallery =========================
	jQuery('#indexGallery').simpleCarousel({
		'showNextPrev':false,
		'autostart':true
	});
	
	// ===== FAQs: Accordion List =========================
	if(jQuery('#AccordionList').length){
		jQuery('#AccordionList').accordion({
			header: "dt",
			active: false,
			alwaysOpen: false,
			autoheight: false,
			selectedClass: 'active'
		});
	};
	
	// ===== CONTACT: Obfuscate Email Against Spam =========================
	jQuery('#mainContent span.mailme').mailme();
	
	// ===== GALLERY: Hover on Link for Image Preview =========================
	var inlineGallery = jQuery('#AccordionList.inlineGalleryPreview li a');
	if(inlineGallery.length){
		inlineGallery.imgPreview({
			containerID: 'inlineGalleryPreview',
			imgCSS: { width:212, height:142 },
			//onShow: function(link){
			//	jQuery('img', this).stop().css({opacity:0});
			//},
			//onLoad: function(){
			//	jQuery(this).animate({opacity:1}, 300);
			//},
			srcAttr: 'rel'
		});
	};
	
	// ===== IE6/CSS: Fix padding-top if there is a graphic header =====
	if(jQuery.browser.msie && jQuery.browser.version < 7){
		if(jQuery('#graphicHeader').height() > 0)
			jQuery('#mainContent').css('paddingTop','229px');
	}
});

// ===== MooTools =====
window.addEvent('domready', function() {
	
	// mootools code
	
});
