// <![CDATA[
$(document).ready(function() {

/* main menu with submenus /**/
$('ul.menu>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('hover');
		},
		function () {
			$(this).removeClass('hover');
		}
	);
});

/* toggle 2nd level submenus /**/
$('ul.menu>li>ul>li:has(ul)').each(function(){
	//alert($(this).text());
	$(this).hover(
		function () {
			$(this).children("ul").css("visibility", "visible");
		},
		function () {
			$(this).children("ul").css("visibility", "hidden");
		}
	);
});
/* just used for Meiners Catering /**/
/*
$('ul.menu>li:has(ul)').each(function(){
	$(this).hover(
		function () {
			$(this).children('ul').css('position', 'relative');
		},
		function () {
			$(this).children('ul').css('position', 'absolute');
		}
	);
});
/**/
$('.menu_header ul.menu li').each(function(){
	$(this).append('<div class="color"></div>');
});
$('.menu_header ul.menu>li').each(function(i){
	$(this).children('.color').addClass('color' + (i+1)%5);
	$(this).attr( 'data-color-index', (i+1)%5 );
});
$('.menu_header ul.menu>li>ul>li').each(function(i){
	$(this).children('.color').addClass('color' + (i+1)%5);
	$(this).attr( 'data-color-index', (i+1)%5 );
});

url_page_name = window.location.href.split("/");
url_page_name = url_page_name[url_page_name.length-2];
var colors = ['#9C4B9C', '#9C493B', '#8F8E58', '#B38F3E', '#677E3A'];
$('.menu_header ul.menu li:not(:has(ul))').each(function(){
	
	link_page_name = $(this).children("a").attr('href').split("/");
	//$(this).children("a").attr( 'data-link-page-name', link_page_name[link_page_name.length-2] );
	link_page_name = link_page_name[link_page_name.length-2];

	if( link_page_name == url_page_name ) {
		$('.main-color').css('background-color', colors[ parseInt( $(this).attr( 'data-color-index') ) ] );
	}

	
	$(this).hover(
		function () {
			//$(this).children("ul").css("visibility", "visible");
			//$(this).children('.color').width(0);
			$(this).children('.color').animate({
				width: '100'
			}, 500);
			
		},
		function () {
			//$(this).children("ul").css("visibility", "hidden");
			//$(this).children('.color').width(0);
			$(this).children('.color').animate({
				width: '0'
			}, 500);
		}
	);
});

/* Meiners Contact Form /**/
/*
$('#cid_12 .form-sub-label-container').delay(800).css('color', 'red');
//.append('<br />dsds');
/**/

/**/

/*
$("ul.menu>li:first").addClass("first");
$("ul.menu>li:last").addClass("last");
/**/

$('ul.menu>li:has(ul)>a:first-child').each(function(){
	$(this).addClass('main-folder-icon');
});

$('ul.menu>li:has(ul)>ul>li:has(ul)>a:first-child').each(function(){
	$(this).addClass('subfolder-icon');
});

/*
montage=window.location.href.split("/");
simple=montage.length-2;
alert(montage[simple])
$('.main-color').css('background-color', '#8F8E58');

/**/



/* 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({
		mask: {
			color: '#fff',
			// load mask a little faster
			loadSpeed: 200,
			opacity: 0.4
		},
		fixed: false,
		closeOnClick: true,
		closeOnEsc: true,
		load: false
	});
/**/

/* 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: [8, 0]
		});

	});

/**/

/* remove last dash wordpress in footer menu /**/
$(".menu-item:last").html(
	$(".menu-item:last").html().replace(/<\/a> - /i, "</a>")
);
/**/

/* scrollbars /**/
$(function(){
	$('#content').jScrollPane({showArrows:true, scrollbarWidth:16, scrollbarMargin:0, arrowSize:16});
});
/**/

});

/* OUTSIDE DOCUMENT READY /**/



//<!-- Begin
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=no,width=800,height=600,left = 240,top = 100');");
}
// End -->



/* Google Analytics for Meiner's Catering /**/

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1892705-13']);
_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);
})();

/**/

//--><!]]>
