// <![CDATA[
$(document).ready(function() {
						   
/* main menu with submenus /**/
$('#nav>li').each(function(){
	//var id_text = $(this).attr('code');
	//var name_text = $(this).find('item').text();
	//alert($(this).attr('class'));
	//alert($(this).text());
	
	$(this).hover(
		function () {
			$(this).addClass('sfhover');
		},
		function () {
			$(this).removeClass('sfhover');
		}
	);
});

/*
$("#nav>li:first").addClass("first");
$("#nav>li:last").addClass("last");
/**/

$('#nav>li:has(ul)>a:first-child').each(function(){
	//alert($(this).text());
	$(this).addClass('mainfoldericon');
});
						   
/* scrollers /**
	$("div.scrollable").scrollable({
		vertical: true, 
		size: 1,
		loop: true
	}).mousewheel().circular().autoscroll({
		autoplay: true,
		autopause: true,
		interval: 7000,
		api: true
	}); 
/**/
	
	
/* scrollers /**/
	//.mousewheel(400)
	$("#flowpanes").scrollable({
		size:1,
		circular: true
	}).autoscroll({
		autoplay:true,
		autopause:true,
		interval:7000
	});
/**/

/* table row color strips /**/
	$('table.sortable tbody tr:not([th]):nth-child(odd)').addClass('odd');
	$('table.sortable tbody tr:not([th]):nth-child(even)').addClass('even');
/**/

/* overlays /**/
	$("*[rel^=#]").overlay();
	window.loadOverlay = function(overlayName) { 
		$(overlayName).overlay({
			mask: {
				color: '#fff',
				// load mask a little faster
				loadSpeed: 200,
				opacity: 0.4
			},
			fixed: false,
			closeOnClick: true,
			closeOnEsc: true,
			load: true/**/
		});  
	};
	window.closeOverlay = function (overlayName){
		$(overlayName).overlay().close();
	}

/**/

/* flash files /**/
	$('div[class^=flash]').each(function(index) {
		//alert($(this).attr('id'));
		//alert($(this).attr('title'));
		flashembed($(this).attr('id'), {
			src: $(this).attr('title'), 
			//bgcolor: 'transparent',
			wmode: 'transparent',
			version: [7, 0]
		});

	});

	/*
	//w 200 h 200
	flashembed("pigs", {
		src: "_files/flash/pigs.swf", 
		wmode: 'transparent',
		version: [7, 0]
	});
	//w 745 h 150
	flashembed("van", {
		src: "_files/flash/van.swf", 
		wmode: 'transparent',
		version: [7, 0]
	});
/**/

/* buttons /**/
	$('.button').hover(
		function() {
			//$(this).children('img')[0].src = $(this).children('img')[0].src.replace(/\.png$/, '-over.png');
			
			//alert($(this).css('marginTop'));
			//alert(   $(this).children('img').width()   );
			
			$(this).children('img').width(   $(this).children('img').width()  +10   );
			$(this).children('img').height(  $(this).children('img').height() +10   );
			
			$(this).children('img').css('padding-top', (parseInt($(this).children('img').css('padding-top').replace('px', ''))-5)+'px');
			$(this).children('img').css('padding-bottom', (parseInt($(this).children('img').css('padding-bottom').replace('px', ''))-5)+'px');
			$(this).children('img').css('padding-left', (parseInt($(this).children('img').css('padding-left').replace('px', ''))-5)+'px');
			$(this).children('img').css('padding-right', (parseInt($(this).children('img').css('padding-right').replace('px', ''))-5)+'px');
			/**/
			$(this).addClass('hover');
			
		},
		function() {
			//$(this).children('img')[0].src = $(this).children('img')[0].src.replace(/-over\.png$/, '.png');

			$(this).children('img').width(   $(this).children('img').width()  -10   );
			$(this).children('img').height(  $(this).children('img').height() -10   );
			
			$(this).children('img').css('padding-top', (parseInt($(this).children('img').css('padding-top').replace('px', ''))+5)+'px');
			$(this).children('img').css('padding-bottom', (parseInt($(this).children('img').css('padding-bottom').replace('px', ''))+5)+'px');
			$(this).children('img').css('padding-left', (parseInt($(this).children('img').css('padding-left').replace('px', ''))+5)+'px');
			$(this).children('img').css('padding-right', (parseInt($(this).children('img').css('padding-right').replace('px', ''))+5)+'px');
			$(this).removeClass('hover');
		}
	);
/**/

/* shopping form stuff /**/
$('.shop #size').change(function() {
	var value = $(this).val();
	if( value.search("{p") != -1) {
		var start_position = parseInt( value.search("{p") )+2;
		var end_position = parseInt( value.search("}") );
		value = value.slice(start_position, end_position);
		var new_price = parseInt( $(".shop .adjusted_price").attr('title') );
		new_price = parseInt( new_price + parseInt(value) );
		
		$(".shop .price").css('text-decoration', 'line-through');
		$(".shop .price").css('color', '#ccc');
		$(".shop .adjusted_price").html('Adjusted Price: <strong>$' + new_price + '</strong><br />');
	} else {
		$(".shop .price").css('text-decoration', 'none');
		$(".shop .price").css('color', '#8e1f11');
		$(".shop .adjusted_price").html(' <br />');
	}
	
	if ($(this).val() == 'X-Large') {
		// do this
		//alert('X-Large');
	}
	if ($(this).val() == 'somethingelse') {
		// do that
	}
});
/**/

/*
bubbalous.com
bubbalouscatering.com
local linked urls "/"
alert(window.location.href);
/**/
/* no-lightbox /**/
	$('a[href$=bubbalous.com/], a[href$=bubbalous.com], a[href$=bubbalouscatering.com/], a[href$=bubbalouscatering.com/]')
	.filter("[href^=http://bubbalous], [href^=http://www.bubbalous]")
	.add('a[href=/]').each(function(index) {
		
		$(this).attr('href', ($(this).attr('href') + '#no-lightbox') );
		
	});


});

/* OUTSIDE DOCUMENT READY /**/

/* Google Analytics for bubbalous.com /**/
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1892705-14']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
/**/

//--><!]]>
