function ucfirst (str) {
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}

var $_GET = {};

document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
    function decode(s) {
        return decodeURIComponent(s.split("+").join(" "));
    }

    $_GET[decode(arguments[1])] = decode(arguments[2]);
});

if(typeof(Cufon)!= 'undefined')
{
	Cufon.replace('h3' );
	Cufon.replace('h4' );
	Cufon.replace('h5' );
	Cufon.replace('h6' );
	Cufon.replace('#main-content blockquote' );
	Cufon.replace('#do-teaser h6' ); 
	Cufon.replace('#do-teaser p' );
	Cufon.replace('.item-name ' );
}
//Cufon.replace('#nav a', {
	//hover: true});	
//begin beautiful jquery
		$(document).ready(function() {	
			$(".replace-input").click(function()
			{
				$(this).toggleClass('selected');
				var newval = $(this).attr('tag');
				if($(this).hasClass('selected'))
				{
					$(this).parent().children('.replace-all').removeClass('selected').children('input').val('');
					$(this).children('input').val(newval);
				}else{
					$(this).children('input').val('');
				}
				SubmitSearch();
			});
			
			$(".replace-all").click(function()
			{
				$(this).toggleClass('selected');
				var newval = 'All';
				if($(this).hasClass('selected'))
				{
					$(this).parent().children('.selected').removeClass('selected').children('input').val('');
					$(this).toggleClass('selected');
					$(this).children('input').val(newval);
				}else{
					$(this).children('input').val('');
				}
				SubmitSearch();
			});
		
			function SubmitSearch()
			{
				//gather all my inputs
				$("form").submit();
			};

			$("#debug").click(SubmitSearch);
		
		
		//image fader for header 
		
			$('#teaser').innerfade({
				animationtype: 'fade',
				speed: 750,
				timeout: 6000,
				containerheight: '225px'
			});
			$('#contact-imgs').innerfade({
				animationtype: 'fade',
				speed: 750,
				timeout: 6000,
				containerheight: '225px'
			});
			
			
		//PIKACHOOOOOOOOOSE
		$("#inventory-images").PikaChoose({show_prev_next:false});
		
		//View Perma Link
		$("#perma a").hover(function() {
			$(this).prev("em").animate({opacity: "show", left: "-185"}, "slow");
		}, function() {
			$(this).prev("em").animate({opacity: "hide"}, "fast");
		});
		
		if(typeof($_GET["mess"])!="undefined")
		{
			alert($_GET["mess"]);
			//$('body').append('<a id="fancyme" href="#fancyme">'+$_GET["m"]+'</a>');
			//$('#fancyme').fancybox();
			//setTimeout("$('#fancyme').trigger('click')",1000);
		}
		
		//form fields prefills and clears
		$('#contact-form').find(':input[type!=hidden]').each(function()
		{
			var defaultText = $(this).attr('name').substr(8);
			defaultText = ucfirst(defaultText);
			$(this).attr('value',defaultText);
			$(this).bind('focus',function()
			{
				$(this).attr('value','');
			});
			$(this).bind('blur',function()
			{
				if($(this).val() == "")
				{
					$(this).attr('value',defaultText);
				}
			});
		});
				
	});//Close Function


