//Functions needed for fbc2011 Theme
//alert('debug');
try {
	Cufon.replace('.menu a');
	Cufon.replace('h2, h1.wholesale, h1.wedding, ul.contentCategory2 a', {
		hover: true
	});
} catch (err) {

}

function toggleMe(a){
  var e=document.getElementById(a);
  //if(!e)return true;
  if(e.style.display=="none"){
	e.style.display="block"
  } else {
	e.style.display="none"
  }
  //return true;
}

jQuery.noConflict();

jQuery(document).ready(function($) {  	
	
	$(function() {
		
		if (jQuery.ui) {
			//dateFormat: 'DD, d MM, yy'
			$("#datepicker").datepicker({ dateFormat: 'd/m/yy', beforeShowDay: checkClowanceDays, buttonImage: "http://www.flowersbyclowance.co.uk/templates/fbc2011/images/calendar.gif", buttonImageOnly: true, showOn: "button", constrainInput: true,
            buttonText: 'Select...' });

				natDays = [
					"August 29, 2011 00:00:00",
					"December 26, 2011 00:00:00"
				];		
				
			function nationalDays(date) {

				for (i = 0; i < natDays.length; i++) {
				    var holiday = new Date(natDays[i]);
					
					if ((date.getFullYear() == holiday.getFullYear()) && (date.getMonth() == holiday.getMonth()) &&
						(date.getDate() == holiday.getDate())) {
						return [false, ''];
					}
				}	
			  return [true, ''];
			}

			// Function used to display valid delivery dates to the end user
			// First of all, ensure dates prior to today (inclusive) are disabled.
			function checkClowanceDays(date) {

				// if date in the past (or today) - that's no good for delivery
				var todayDay = new Date();
				todayDay.setHours(0,0,0,0);
				if (date <= todayDay) {
					return [false, ''];
				}
				
				// tomorrow is only good before 8 o'clock
				var newTodayDay = new Date();
				if (((date.getDate() - 1) == newTodayDay.getDate()) && (newTodayDay.getHours() > 8) &&
					(date.getMonth() == newTodayDay.getMonth())) {
					return [false, ''];
				}
				
				//sending for a monday is also not really possible at the moment
				if (date.getDay() == '1') {
					return [false, ''];
				}
				
				// saturday is a no go unless they've selected saturday postage
				if (document.getElementById('shipmethodType').value.toLowerCase().substring(0, 2) == 'sa') {
					if (date.getDay() == '6') {
						return [true, ''];
					} else {
						return [false, ''];
					}
				}
				
				// finally weekends AND bank/clowance holidays are no good
				var noWeekend = $.datepicker.noWeekends(date);
				if (noWeekend[0]) {
					return nationalDays(date);
				} else {
					return noWeekend;
				}
			}
		} // end the big jquery ui if statment

	})
  
	$(function(){
		try {
			$('#slides').slides({
				preload: true,
				preloadImage: 'templates/fbc2011/images/slideshow/loading.gif',
				play: 5000,
				pause: 0,
				hoverPause: false,
				effect: 'fade',
				crossfade: true,
				fadeSpeed: 500,
				generateNextPrev: false,
				generatePagination: false
			});		
		} catch (e) {
			//not home or content page
		}
	});	
	
	$(function() {
	
		$('li.topMenu').hover(function() { //mouse in
			if ($(this).is(':animated')){
				return false;
			} else {
				$(this).animate({ paddingTop: '10px' },200);
			}
		}, function() { //mouse out
			$(this).animate({ paddingTop: 0 }, 200);
		});	
	
	});
	
	jQuery(".jqPullDown").hide();
	  //toggle the componenet with class msg_body
	  jQuery("#openJqPullDownHeading").click(function()
	  {
		jQuery(".jqPullDown").slideToggle(500);
	  });
	

	
});
