$(document).ready(function() {
	// top navigation drop-down menus
	$(".subnav-menu-item").hover(
		function () {
			$(this).children(".subnav-menu-link").css("margin-bottom","-6px");
			$(this).children(".subnav-menu-link").css("z-index","101");
			$(this).children(".subnav-menu-link").css("color","#a284a8");
			$(this).children(".tertnav").css("display","block");
		},
		function () {
			$(this).children(".subnav-menu-link").css("margin-bottom","0px");
			$(this).children(".subnav-menu-link").css("z-index","99");
			$(this).children(".subnav-menu-link").css("color","#946b8d");
			$(this).children( ".tertnav").css("display","none");
	});
	
	// calendar panel tabs
	$( "#cal-tabs" ).tabs();
	
		
	// testimonial panel
	var myTabs = $('#quote-tabs').tabs();
	myTabs.tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 7000);
	$('#quote-tabs').mouseover(function(){
		$(this).tabs('rotate', 0, false);
	});
	
	$('#quote-tabs').mouseout(function(){
		$(this).tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 7000);
	});

	$("#quote-tabs .ui-tabs-panel").each(function(i){
		var totalSize = $("#quote-tabs .ui-tabs-panel").size() - 1;
		if (i != totalSize) {
			next = i + 2;
			$(".nav", this).append("<a href='#' class='next-tab mover' rel='" + next + "'>Next</a>");
		}
		if (i != 0) {
			prev = i;
			$(".nav", this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'>Previous</a>");
		}
	});
	$(".next-tab, .prev-tab").click(function() {
		myTabs.tabs("select", $(this).attr("rel"));
		return false;
    });
    
    // Martini Speaks
	var mySpokenTabs = $('#spoken-tabs').tabs();
	mySpokenTabs.tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 7000);
	$('#spoken-tabs').mouseover(function(){
		$(this).tabs('rotate', 0, false);
	});
	
	$('#spoken-tabs').mouseout(function(){
		$(this).tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 7000);
	});

	$("#spoken-tabs .ui-tabs-panel").each(function(i){
		var totalSize = $("#spoken-tabs .ui-tabs-panel").size() - 1;
		if (i != totalSize) {
			next = i + 2;
			$(".nav", this).append("<a href='#' class='next-tab-spoken mover' rel='" + next + "'>Next</a>");
		}
		if (i != 0) {
			prev = i;
			$(".nav", this).append("<a href='#' class='prev-tab-spoken mover' rel='" + prev + "'>Previous</a>");
		}
	});
	$(".next-tab-spoken, .prev-tab-spoken").click(function() {
		mySpokenTabs.tabs("select", $(this).attr("rel"));
		return false;
    });
	
	// He Said / She Said
	var myTheysaidTabs = $('#theysaid-tabs').tabs();
	myTheysaidTabs.tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 7000);
	$('#theysaid-tabs').mouseover(function(){
		$(this).tabs('rotate', 0, false);
	});
	
	$('#theysaid-tabs').mouseout(function(){
		$(this).tabs({fx:{opacity: 'toggle'}}).tabs('rotate', 7000);
	});

	$("#theysaid-tabs .ui-tabs-panel").each(function(i){
		var totalSize = $("#theysaid-tabs .ui-tabs-panel").size() - 1;
		if (i != totalSize) {
			next = i + 2;
			$(".nav", this).append("<a href='#' class='next-tab-theysaid mover' rel='" + next + "'>Next</a>");
		}
		if (i != 0) {
			prev = i;
			$(".nav", this).append("<a href='#' class='prev-tab-theysaid mover' rel='" + prev + "'>Previous</a>");
		}
	});
	$(".next-tab-theysaid, .prev-tab-theysaid").click(function() {
		myTheysaidTabs.tabs("select", $(this).attr("rel"));
		return false;
    });
    
    // header banners
	$('.banners a:gt(0)').hide();
	setInterval(function(){
		$('.banners a:first-child').fadeOut().next().fadeIn().end().appendTo('.banners');
	}, 3000);
	
	// header NOW button
	$("a[rel^='prettyPhoto']").prettyPhoto({
		allow_resize: false,
		social_tools: false,
		deeplinking: false,
		iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no" scrolling="no"></iframe>',

	});
});

function clearField(fieldName,defaultValue) {
     if(fieldName.value == defaultValue) {
          fieldName.value = ""
     }
}
