﻿// JavaScript Document

$(document).ready(function() {

						   
	/*					   
	$("#topMenu ul li:last-child").css("margin-right", "0");
	$("#footerLegal ul li:last-child").css("margin-right", "0").css("border-right", "0");
	
	$("#topMenu ul li ul li").hover(
	  function () {
		  //alert("here");
		$(this).parent().parent().children("a").addClass("hover");
	  }, 
	  function () {
		$(this).parent().parent().children("a").removeClass("hover");
	  }
	);
	
	
	*/
	
	$('div#v65-productSpecs').before('<a id="more">Read More</a>');

	$('#v65-relatedProducts').before( $('div#v65-productAddToCart') );
	
	$('#v65-relatedProducts').before( $('div.v65-socialMediaBar') );
	
	
	
	// WRAP the HIDDEN FIELDS in HRs
	$('a#more').after('<hr class="beginHidden">');
	$('hr.dotted').after('<hr class="endHidden">');
	
	// HIDE ALL CONTENT BETWEEN HRs
	$('hr.beginHidden').each(function(){
		var $set = $();
		var nxt = this.nextSibling;
		while(nxt) {
			if(!$(nxt).is('hr.endHidden')) {
				$set.push(nxt);
				nxt = nxt.nextSibling;
			} else break;
		} 
		$set.wrapAll('<div class="hidden" />');
	});
	
	
	$('a#more').click(function(){
		
		$('div.hidden').slideToggle();
		
		if ($('a#more').text() == "Read More") {
			$('a#more').text("Read Less");
		} else {
			$('a#more').text("Read More");
		}
	});
	
	$('div#v65-productAddToCart form').removeAttr("class");
	
	$('div.v65-productAddToCartQuantity input').remove();
	
	var quantityDropDown = '<select name="Quantity" id="Quantity"><option selected="selected" value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="20">20</option><option value="25">25</option><option value="30">30</option><option value="40">40</option><option value="50">50</option><option value="75">75</option><option value="100">100</option></select>';
	
	$('div.v65-productAddToCartQuantity').append(quantityDropDown);	
	
	$('div.v65-productAddToCartButton button').remove();
	
	var theButtons = '<input name="submit" type="submit" id="submit" class="muniBtn" value="add to cart"/><a href="../../Bottle-Shop" class="muniBtn">Continue Shopping</a>';
	
	$('div.v65-productAddToCartButton').append(theButtons);
	
	
	$('div#v65-productDescription').after( $('div#v65-relatedProducts') );
	
	$('div#v65-relatedProducts h3').text('MORE MUNI');
	
	$('div#v65-relatedProducts h3').wrap('<div id="moreTitle"></div>');
	
	
	/* CART */
	
	$('div#v65-cartCheckOutCoupons form input').attr('value', 'Have a Coupon?');
	
	$('div#v65-cartCheckOutCoupons form input').attr('style', '');
	
	$('div#v65-cartCheckOutCoupons form input').focus(function() {
		if ( $(this).attr('value') == 'Have a Coupon?') {
			$(this).attr('value', '');
		}
	});
	
	$('div#v65-cartCheckOutCoupons form input').blur(function() {
		if ( $(this).attr('value') == "" ) {
			$(this).attr('value', 'Have a Coupon?');
		}
	});
	
	$('div#v65-cartCheckOutCoupons form button span').text('Use It');
	
	$('div#v65-cartCheckOutCoupons form').after('<hr style="clear:both;" />');
	
	$('.v65-cartItemAmount button').text('update');
	
	$('.v65-product5up').append('<style>.v65-clear {display:none;}</style>');
	
	$('#v65-checkoutSecure img').attr('src', 'assets/images/lock.jpg');
	
	var zoneName = ($('div#leftMenu h3').text());
	if ( zoneName == " About Us " || zoneName == " Photos " || zoneName ==" Members ") {
		//alert("about");
		$('div#pageContent').css('width', '655px');
	}
	
	
	$('#v65-CalendarTable td').hover(function(e) {
		
		
		
		
		
		
    });
	
	$('#v65-CalendarTable td').hover(
		function() {
			
			var month = $('#v65-CalendarNav h2').html();
			var day = $(this).children(".v65-CalendarDay").html();
			var date = month.replace(" ",(" "+day+", "));
			
			if ( $(this).is(".v65-CalendarOffMonthDays") ){
				//nada	
			} else {
				$(this).prepend("<a class='reserve' href='http://www.yougoteric.com/clients/mw/resiform/?date=" + date + "'>Reserve</a>");
				//alert(date);
	
				$("a.reserve").fancybox({
					'type'	: 'iframe',
					'width'	: 500,
					'height': 540
				});
				
			}
			
		},
		function() {
			$(this).children("a.reserve").remove();
			
		}
	);
	
	
	
	$("#homeBanner").cycle({
		containerResize: 1,
		before:onBefore
	});
	
	function onBefore() {
		var newHeight = $(this).height();
		//alert (newHeight);		
		$("#homeBanner").animate({
			height: newHeight
		}, "fast");
	}
	
	
	
});
