/*
 * 	Easy Slider 1.7 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
/*
 *	markup example for $("#slider").easySlider();
 *	
 * 	<div id="slider">
 *		<ul>
 *			<li><img src="images/01.jpg" alt="" /></li>
 *			<li><img src="images/02.jpg" alt="" /></li>
 *			<li><img src="images/03.jpg" alt="" /></li>
 *			<li><img src="images/04.jpg" alt="" /></li>
 *			<li><img src="images/05.jpg" alt="" /></li>
 *		</ul>
 *	</div>
 *
 */

(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {			
			prevId: 		'back',
			prevText: 		'Previous',
			nextId: 		'forward',	
			nextText: 		'Next',
			controlsShow:	true,
			controlsBefore:	'',
			controlsAfter:	'',	
			controlsFade:	true,
			firstId: 		'firstBtn',
			firstText: 		'First',
			firstShow:		false,
			lastId: 		'lastBtn',	
			lastText: 		'Last',
			lastShow:		false,				
			vertical:		false,
			speed: 			300,
			auto:			false,
			pause:			9000,
			continuous:		true, 
			numeric: 		false,
			numericId: 		'controls'
		}; 
		
		var options = $.extend(defaults, options);  
				
		this.each(function() {  
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("li", obj).width(); 
			var h = $("li", obj).height(); 
			var clickable = true;
			obj.width(w); 
			obj.height(h); 
			obj.css("overflow","hidden");
			var ts = s-1;
			var t = 0;
			$("ul", obj).css('width',s*w);			
			
			if(options.continuous){
				$("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));
				$("ul", obj).append($("ul li:nth-child(2)", obj).clone());
				$("ul", obj).css('width',(s+1)*w);
			};				
			
			if(!options.vertical) $("li", obj).css('float','left');
								
			if(options.controlsShow){
				var html = options.controlsBefore;				
				if(options.numeric){
					html += '<ol id="'+ options.numericId +'"></ol>';
				} else {
					if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';
					html += ' <div id="slider-controls"><span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';
					html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span></div>';
					if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';				
				};
				
				html += options.controlsAfter;						
				$(obj).after(html);										
			};
			
			if(options.numeric){									
				for(var i=0;i<s;i++){						
					$(document.createElement("li"))
						.attr('id',options.numericId + (i+1))
						.html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>')
						.appendTo($("#"+ options.numericId))
						.click(function(){							
							animate($("a",$(this)).attr('rel'),true);
						}); 												
				};							
			} else {
				$("a","#"+options.nextId).click(function(){		
					animate("next",true);
				});
				$("a","#"+options.prevId).click(function(){		
					animate("prev",true);			
				});	
				$("a","#"+options.firstId).click(function(){		
					animate("first",true);
				});				
				$("a","#"+options.lastId).click(function(){		
					animate("last",true);				
				});				
			};
			
			function setCurrent(i){
				i = parseInt(i)+1;
				$("li", "#" + options.numericId).removeClass("current");
				$("li#" + options.numericId + i).addClass("current");
			};
			
			function adjust(){
				if(t>ts) t=0;		
				if(t<0) t=ts;	
				if(!options.vertical) {
					$("ul",obj).css("margin-left",(t*w*-1));
				} else {
					$("ul",obj).css("margin-left",(t*h*-1));
				}
				clickable = true;
				if(options.numeric) setCurrent(t);
			};
			
			function animate(dir,clicked){
				if (clickable){
					clickable = false;
					var ot = t;				
					switch(dir){
						case "next":
							t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1;	
							$("img#forwardArrow").animate({ marginLeft: "5px"}, 200);
							break; 
						case "prev":
							t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1;
							$("img#backArrow").animate({ marginLeft: "-5px"}, 200);
							break; 
						case "first":
							t = 0;
							break; 
						case "last":
							t = ts;
							break; 
						default:
							t = dir;
							break; 
					};	
					var diff = Math.abs(ot-t);
					var speed = diff*options.speed;						
					if(!options.vertical) {
						p = (t*w*-1);
						$("ul",obj).animate(
							{ marginLeft: p }, 
							{ queue:false, duration:speed, complete:adjust }
						);				
					} else {
						p = (t*h*-1);
						$("ul",obj).animate(
							{ marginTop: p }, 
							{ queue:false, duration:speed, complete:adjust }
						);					
					};
					
					if(!options.continuous && options.controlsFade){					
						if(t==ts){
							$("a","#"+options.nextId).hide();
							$("a","#"+options.lastId).hide();
						} else {
							$("a","#"+options.nextId).show();
							$("a","#"+options.lastId).show();					
						};
						if(t==0){
							$("a","#"+options.prevId).hide();
							$("a","#"+options.firstId).hide();
						} else {
							$("a","#"+options.prevId).show();
							$("a","#"+options.firstId).show();
						};					
					};				
					
					if(clicked) clearTimeout(timeout),$("img#backArrow, img#forwardArrow").animate({ marginLeft: "0px"}, 20);;
					if(options.auto && dir=="next" && !clicked){;
						timeout = setTimeout(function(){
							animate("next",false);
				$("img#backArrow, img#forwardArrow").animate({ marginLeft: "0px"}, 20);
						},diff*options.speed+options.pause);
					};
			
				};
				
			};
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				$("img#backArrow, img#forwardArrow").animate({ marginLeft: "0px"}, 20);
				},options.pause);
			};		
			
			if(options.numeric) setCurrent(0);
		
			if(!options.continuous && options.controlsFade){					
				$("a","#"+options.prevId).hide();
				$("a","#"+options.firstId).hide();				
			};				
			
		});
	  
	};

})(jQuery);


/*
 * jQuery Tools 1.2.2 - The missing UI library for the Web
 * 
 * [tooltip, tooltip.slide, tooltip.dynamic]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Sun Jun 06 15:03:21 GMT 2010
 */
(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,e=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];e+=a.outerWidth()+c.offset[1];var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")e-=a/2;if(i=="left")e-=a;return{top:h,left:e}}function t(a,b){var c=this,h=a.add(c),e,i=0,j=0,m=a.attr("title"),q=n[b.effect],k,r=a.is(":input"),u=r&&a.is(":checkbox, :radio, select, :button"),
s=a.attr("type"),l=b.events[s]||b.events[r?u?"widget":"input":"def"];if(!q)throw'Nonexistent effect "'+b.effect+'"';l=l.split(/,\s*/);if(l.length!=2)throw"Tooltip: bad events configuration for "+s;a.bind(l[0],function(d){if(b.predelay){clearTimeout(i);j=setTimeout(function(){c.show(d)},b.predelay)}else c.show(d)}).bind(l[1],function(d){if(b.delay){clearTimeout(j);i=setTimeout(function(){c.hide(d)},b.delay)}else c.hide(d)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,
{show:function(d){if(!e){if(m)e=f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else if(b.tip)e=f(b.tip).eq(0);else{e=a.next();e.length||(e=a.parent().next())}if(!e.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;e.stop(true,true);var g=p(a,e,b);d=d||f.Event();d.type="onBeforeShow";h.trigger(d,[g]);if(d.isDefaultPrevented())return c;g=p(a,e,b);e.css({position:"absolute",top:g.top,left:g.left});k=true;q[0].call(c,function(){d.type="onShow";k="full";h.trigger(d)});
g=b.events.tooltip.split(/,\s*/);e.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&e.bind(g[1],function(o){o.relatedTarget!=a[0]&&a.trigger(l[1].split(" ")[0])});return c},hide:function(d){if(!e||!c.isShown())return c;d=d||f.Event();d.type="onBeforeHide";h.trigger(d);if(!d.isDefaultPrevented()){k=false;n[b.effect][1].call(c,function(){d.type="onHide";k=false;h.trigger(d)});return c}},isShown:function(d){return d?k=="full":k},getConf:function(){return b},
getTip:function(){return e},getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(d,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(o){f(c).bind(g,o);return c}})}f.tools=f.tools||{version:"1.2.2"};f.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",
tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){n[a]=[b,c]}};var n={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,
{},f.tools.tooltip.conf,a);if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new t(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);
(function(d){var i=d.tools.tooltip;d.extend(i.conf,{direction:"up",bounce:false,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!d.browser.msie});var e={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};i.addEffect("slide",function(g){var a=this.getConf(),f=this.getTip(),b=a.slideFade?{opacity:a.opacity}:{},c=e[a.direction]||e.up;b[c[1]]=c[0]+"="+a.slideOffset;a.slideFade&&f.css({opacity:0});f.show().animate(b,a.slideInSpeed,g)},function(g){var a=this.getConf(),f=a.slideOffset,
b=a.slideFade?{opacity:0}:{},c=e[a.direction]||e.up,h=""+c[0];if(a.bounce)h=h=="+"?"-":"+";b[c[1]]=h+"="+f;this.getTip().animate(b,a.slideOutSpeed,function(){d(this).hide();g.call()})})})(jQuery);
(function(g){function j(a){var c=g(window),d=c.width()+c.scrollLeft(),h=c.height()+c.scrollTop();return[a.offset().top<=c.scrollTop(),d<=a.offset().left+a.width(),h<=a.offset().top+a.height(),c.scrollLeft()>=a.offset().left]}function k(a){for(var c=a.length;c--;)if(a[c])return false;return true}var i=g.tools.tooltip;i.dynamic={conf:{classNames:"top right bottom left"}};g.fn.dynamic=function(a){if(typeof a=="number")a={speed:a};a=g.extend({},i.dynamic.conf,a);var c=a.classNames.split(/\s/),d;this.each(function(){var h=
g(this).tooltip().onBeforeShow(function(e,f){e=this.getTip();var b=this.getConf();d||(d=[b.position[0],b.position[1],b.offset[0],b.offset[1],g.extend({},b)]);g.extend(b,d[4]);b.position=[d[0],d[1]];b.offset=[d[2],d[3]];e.css({visibility:"hidden",position:"absolute",top:f.top,left:f.left}).show();f=j(e);if(!k(f)){if(f[2]){g.extend(b,a.top);b.position[0]="top";e.addClass(c[0])}if(f[3]){g.extend(b,a.right);b.position[1]="right";e.addClass(c[1])}if(f[0]){g.extend(b,a.bottom);b.position[0]="bottom";e.addClass(c[2])}if(f[1]){g.extend(b,
a.left);b.position[1]="left";e.addClass(c[3])}if(f[0]||f[2])b.offset[0]*=-1;if(f[1]||f[3])b.offset[1]*=-1}e.css({visibility:"visible"}).hide()});h.onBeforeShow(function(){var e=this.getConf();this.getTip();setTimeout(function(){e.position=[d[0],d[1]];e.offset=[d[2],d[3]]},0)});h.onHide(function(){var e=this.getTip();e.removeClass(a.classNames)});ret=h});return a.api?ret:this}})(jQuery);


// Cody's Custom Functions

      $(document).ready(function() {

         // Newsletter Signup Form    	
    	 $("a#toggleOpen").click(function(){
			$('#signup').stop().animate({ top: "487px"}, 200);
			$('#dropbox').stop().animate({ top: "0"}, 200);
			$(this).hide();		
			$('a#toggleClosed').show();			
		});
 
		 $("a#toggleClosed").click(function(){
			 $('#signup').stop().animate({ top: "-20px"}, 250);
			 $('#dropbox').stop().animate({ top: "-507px"}, 250);
			 $('a#toggleOpen').show();		
			 $(this).hide();			
         });

		// Change Location Box
    	$("a.edit").click(function(){
    		$("#navigation ul").animate({ top: "-60px"}, 700);
    		$("#locator").animate({ bottom: "0px"}, 700);
    		$(this).toggle();
    		$("a.close").toggle();
    	});
    	
    	$("a.close").click(function(){
    		$("#navigation ul").animate({ top: "0"}, 700);
    		$("#locator").animate({ bottom: "-60px"}, 700);
    		$(this).toggle();
    		$("a.edit").toggle();
    	});
       	
       	// When Querying Pages, hide all but first page
       	
       	$(".childPage").not(':eq(0)').css("display", "none");
       	$(".arrow").not(':eq(0)').css("display", "none");
       	
       	$("#expert").click(function(){
       		$(this).children('.arrow').show();
       		$("#beginner .arrow").hide();
       		$(".childPage:eq(0)").fadeOut("fast");
       		$(".childPage:eq(1)").fadeIn("slow");
       	});
       	
       	$("#beginner").click(function(){
       		$(this).children('.arrow').show();
       		$("#expert .arrow").hide();
       		$(".childPage:eq(1)").fadeOut("fast");
       		$(".childPage:eq(0)").fadeIn("slow");
       	});
       	
       	// Tooltip
       	
       	// initialize tooltip
		$(".define").tooltip({

 			  // tweak the position
		  offset: [10, 2],

		   // use the "slide" effect
		effect: 'slide'

		// add dynamic plugin with optional configuration for bottom edge
		}).dynamic({ bottom: { direction: 'down', bounce: true } });
       	
  
  		$('.tooltip').each(function() {
   			$(this).wrapInner("<div class='ttContent' />");
       		$(this).append("<div class='ttBottomArrow'></div>");
 		 });
		
		$('a.define').attr({onclick: "return false"});
	    		           
//Sliders and such

	$("#slider").easySlider({
		auto: true,
		continuous: true,
		numeric: false,
		prevId: 'prevBtn',
		prevText: 'Back',
		nextId: 'nextBtn',	
		nextText: 'Next'

	});
	
	$("#specials").easySlider({
		auto: true,
		continuous: true,
		numeric: false,
		prevId: 'prevSpecial',
		prevText: 'Back',
		nextId: 'nextSpecial',	
		nextText: 'Next',
		vertical: false,
		speed: 150

	});

	
	$('#slideshow').cycle({
		fx: 'fade',
		speed: 1500,
		timeout: 8500
	});
	
	$('#slideshow2').cycle({
		fx: 'fade',
		speed: 600,
		timeout: 3000
	});
     
	$('.blue').prepend('<span>Blue Sushi</span> ');
	$('.sake').prepend('<span>Sake Bombers Lounge</span> ');
	
	$("#state select").change(function() {
   		 $(this).parent('form').submit();
	});
	
	$('.button:even').addClass('odd');
	
	$('#commentCards a').click(function() {
		$('#commentCards').hide();
	});

	$('.commentCard').hide();

	$('a#generalInquiries').click(function() {
		$('#generalInquiriesCard').show();
	});
	
	$('a#donationRequest').click(function() {
		$('#donationRequestCard').show();
	});

	$('a#positiveExperience').click(function() {
		$('#positiveExperienceCard').show();
	});

	$('a#opportunityForImprovement').click(function() {
		$('#opportunityForImprovementCard').show();
	});

	$('a.back').click(function() {
		$('#commentCards').show();
		$('.commentCard').hide();
	});
	
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
	
	// Yeah, we've got scrolling Fade-In buttons
	$(window).scroll(function(){
		if($(window).scrollTop() <="350")
		$('#Top').fadeOut('slow');
		else
		$('#Top').fadeIn('slow');
	});
	
	$('#currentCity').change(function() {
		var newCity = $(this).val();
  		$('#LISTID').val(newCity);
	});
	
	$('#formLink').click(function() {
		$('#hiddenSection').css('display', 'block');
	});
	
	$('form#giftcards').submit(function(){
		var newValue = '';
		$('input.prePop').each(function(){
			var thisValue = $(this).val();
			newValue = newValue+' '+thisValue;
		});
		$('#customValue').val(newValue);
	});
	
	// Display Current City Location First
	
	var locCity = $('body').attr('id');
	if ( $('body.locations') ) {
		var $closeCity = $('div.'+locCity);
		$('div.cityLocations:first').before($closeCity.html());
		$closeCity.remove();
	}

});
      
	function sp_form_change() {
		var selectValue = $('#currentCity option:selected').val();
		if (selectValue == 'omaha') {
			$('form#mc-embedded-subscribe-form').attr('action','http://bluesushisakegrill.us1.list-manage1.com/subscribe/post?u=db9c070f883da39e78800c62f&id=da51f2949c');
			$('.hiddenGroup').attr('name','group[53][1]');
			$('.hiddenGroup').attr('id','mce-group[53]-53-0');
		} else if (selectValue == 'fortworth') {
			$('form#mc-embedded-subscribe-form').attr('action','http://bluesushisakegrill.us1.list-manage1.com/subscribe/post?u=db9c070f883da39e78800c62f&id=58d6fe24b5');
			$('.hiddenGroup').attr('name','group[57][1]');
			$('.hiddenGroup').attr('id','mce-group[57]-57-0');
		}

	}
	

