$(document).ready(function() {
  function filterPath(string) {
  return string
 .replace(/^\//,'')
 .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
 .replace(/\/$/,'');
  }
  var locationPath = filterPath(location.pathname);
  $('a[href*=#]').each(function() {
 var thisPath = filterPath(this.pathname) || locationPath;
 if (  locationPath == thisPath
 && (location.hostname == this.hostname || !this.hostname)
 && this.hash.replace(/#/,'') ) {
   var $target = $(this.hash), target = this.hash;
   if (target) {
  var targetOffset = $target.offset().top;
  $(this).click(function(event) {
    event.preventDefault();
    $('html, body').animate({scrollTop: targetOffset}, 1100, function() {
   location.hash = target;
    });
  });
   }
 }
  });
});

//skin to use for lightbox
Shadowbox.loadSkin('shadowbox-skin', 'includes/misc/');

$(window).load(function(){
	var options = {        	
		overlayOpacity: 0.8,
		resizeDuration: .40,
		fadeDuration: .25,
		continuous: true
  };
  
	Shadowbox.init(options);
});

//clear form fields
$(function() {
	$.fn.clearInput = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	
	$('#search').clearInput();
	$('#email').clearInput();
	$('#password').clearInput();	
});

$f('musicPlayer', 'includes/flash/flowplayer-3.1.1.swf', {
   
    plugins: { 
        controls: { 
            fullscreen: false, 
            height: 30 
        } 
    }, 
 
    clip: { 
        autoPlay: false, 
 
        // optional: when playback starts close the first audio playback 
        onBeforeBegin: function() { 
            $f('musicPlayer').close(); 
        } 
    } 
 
});

//pop up window for music player
$(document).ready( function() {
   
    $('A[rel="external"]').click( function() {
        window.open( $(this).attr('href'), '', 'width=625,height=100' );
        return false;
    });
   
});

//cufon stuff
Cufon.replace('.h1BG h1', { fontFamily: 'Printhouse' });
Cufon.replace('h2', { fontFamily: 'Cleanhouse', hover: true });
Cufon.replace('.h3BG h3', { fontFamily: 'Printhouse' });
