SIV.addHandlers({	

	
	mailEnquiry : function(success, data) {
		$('#SubmitEnquiry').show();
		$('.enquiryLoader').hide();
		if(success){
			
			$('#makeEnquiryForm').html('<div class="form-thanks vag">Thank you.</div><div class="form-comment">Our team will review your enquiry and get back to you within 48 hours.</div>');
		
		}else{
			$('#enquiry-' + data.error).addClass('error').focus();
			
		}
	},
	mailCallback : function(success, data) {
		$('#SubmitCallback').show();
		$('.enquiryLoader').hide();
		if(success){
			
			$('#callbackForm').html('<div class="form-thanks vag">Thank you.</div><div class="form-comment">Our team will review your enquiry and get back to you within 48 hours.</div>');
		
		}else{
			$('#callback-' + data.error).addClass('error').focus();
			
		}
	},
	register : function(success, data) {
		$('#send-register-button').show();
		$('#load-register').hide();
		if(success){
			
			$('#registerForm').html('<div class="form-thanks vag">Thank you.</div><div class="form-comment">We will endevour to keep you up to date with the latest goings on from the SIV events team.</div>');
		
		}else{
			$('#register-' + data.error).addClass('error');
			
		}
	}
})


$(function() {
	
	/*$('select.blueSelect').each(function(){
		var select = $(this);

		var selectBoxContainer = $('<div>',{
			width		: select.outerWidth(),
			className	: 'bluezSelect',
			html		: '<div class="selectBox"></div>'
		});
	
		var dropDown = $('<ul>',{className:'dropDown'});
		var selectBox = selectBoxContainer.find('.selectBox');
	
		// Looping though the options of the original select element
	
		select.find('option').each(function(i){
			var option = $(this);
	
			if(i==select.attr('selectedIndex')){
				selectBox.html(option.text());
			}
	
			// As of jQuery 1.4.3 we can access HTML5
			// data attributes with the data() method.
	
			if(option.data('skip')){
				return true;
			}
	
			// Creating a dropdown item according to the
			// data-icon and data-html-text HTML5 attributes:
	
			var li = $('<li>',{
				html:	option.data('html-text')
			});
	
			li.click(function(){
	
				selectBox.html(option.text());
				dropDown.trigger('hide');
	
				// When a click occurs, we are also reflecting
				// the change on the original select element:
				select.val(option.val());
	
				return false;
			});
	
			dropDown.append(li);
		});
	
		selectBoxContainer.append(dropDown.hide());
		select.hide().after(selectBoxContainer);
	
		// Binding custom show and hide events on the dropDown:
	
		dropDown.bind('show',function(){
	
			if(dropDown.is(':animated')){
				return false;
			}
	
			selectBox.addClass('expanded');
			dropDown.slideDown('fast');
	
		}).bind('hide',function(){
	
			if(dropDown.is(':animated')){
				return false;
			}
	
			selectBox.removeClass('expanded');
			dropDown.slideUp('fast');
	
		}).bind('toggle',function(){
			if(selectBox.hasClass('expanded')){
				dropDown.trigger('hide');
			}
			else dropDown.trigger('show');
		});
	
		selectBox.click(function(){
			dropDown.trigger('toggle');
			
		});
	
		// If we click anywhere on the page, while the
		// dropdown is shown, it is going to be hidden:
	
		$(document).click(function(){
			dropDown.trigger('hide');
		});

	})*/
	
	//$('select').sbCustomSelect();
	
	
	
	
	
	$('#xcontainer').click(function(){
		closeSplash();
		
	})
	$('#splash-continue-link').click(function(){
		closeSplash();
		return false;
	})
	$('#splash-promo-link').click(function(){
		closeSplash();
	})
	
	$('#hotel-input').datepicker({dateFormat:'dd/mm/yy',minDate: new Date() });
	
	$('#hotel-search').click(function(){
		dateVar = $('#hotel-input').val();
		dateArr = dateVar.split("/");
		dateArr[0] = dateArr[0] - 2;
		dateVar = dateArr[2]+"-"+dateArr[1]+"-"+dateArr[0];
		window.open('https://www.thebookingbutton.co.uk/property_groups/SheffieldAccom?start_date=' + dateVar); 
		return false;
	})
	
	
	var menuId;
	$('#menu .multiMenu').hover(function(){
		menuId = $(this).getId();
		
		if($(this).hasClass('active')){
			$('#subMenu-' + menuId).hide();
			$(this).removeClass('active');
		}else{
			$('#menu .active').removeClass('active');
			$('#menu .mainSubMenu').hide();
			$('#subMenu-' + menuId).show();
			$(this).addClass('active');
		}
		
	}, function(){})
	
	$(document).click(function(){
		$('#menu .active').removeClass('active');
		$('#menu .mainSubMenu').hide();
	})
	
	$('#SubmitEnquiry').click(function(){
		$(this).hide();
		$('.enquiryLoader').show();
		SIV.ajaxCall({
				url: '/ajax/enquiry/submitEnquiry',
				form: 'makeEnquiryForm',
				handler: 'mailEnquiry'
			});
		return false;
		
		
	});
	
	$('#SubmitCallback').click(function(){
		$(this).hide();
		$('.enquiryLoader').show();
		SIV.ajaxCall({
				url: '/ajax/enquiry/submitCallback',
				form: 'callbackForm',
				handler: 'mailCallback'
			});
		return false;
		
		
	});
	
	
	if($('#pageImageSelect li').length > 0){
		
		var features = new Array();
	
		var numFeatures = 0;
	
		$('#page-scroll-feature .select-image').each(function(){
			features[numFeatures] = $(this).getId();
			numFeatures++;
		})
		
		selectedFeature = 0;
		
		var featureScroll = setInterval(function () {
			if(selectedFeature == (numFeatures -1)){
				selectedFeature = 0;
			}else{
				selectedFeature++;
			}
			$('#page-scroll-feature a').removeClass('active');
			$('#page-scroll-feature #select-image-' + features[selectedFeature]).addClass('active');
			$('#page-images li').hide();
			$('#page-images #page-image-' + features[selectedFeature]).show();
			
		},5000)
		
		$('#page-scroll-feature .select-image').click(function(){
			$('#page-scroll-feature a').removeClass('active');
			$(this).addClass('active');
			featureid = $(this).getId();	
			clearInterval(featureScroll);
			$('#page-images li').hide();
			$('#page-images #page-image-' + featureid).show();
			return false;
		});
	
	}
	
	$('.makeEnquiry').click(function(){
		if($('#callback').hasClass('active')){
			$('#callbackForm').slideUp();
			$('#callback').removeClass('active');
		}
		if($(this).hasClass('active')){
			$('.makeEnquiry').removeClass('active');
			$('#makeEnquiryForm').slideUp();
			
		}else{
			$('.makeEnquiry').addClass('active');
			$.scrollTo($('#bottomEnquiryContainer'),'100000');
			$('#makeEnquiryForm').slideDown();
		}
		
		return false;
		
	})
	
	$('.makeCallback').click(function(){
		if($('.makeEnquiry').hasClass('active')){
			$('.makeEnquiry').removeClass('active');
			$('#makeEnquiryForm').slideUp();
		}
		if($('.makeCallback').hasClass('active')){
			$('.makeCallback').removeClass('active');
			$('#callbackForm').slideUp();
			
		}else{
			$('.makeCallback').addClass('active');
			$.scrollTo($('#bottomEnquiryContainer'),'100000');
			$('#callbackForm').slideDown();
		}
		
		return false;
	})
	
	 $('input, textarea').placeholder();
	 
	 $('.form-submit').click(function(){
	 	
		$(this).parent('form').submit();
		return false;
	 })
	 
	 $('#show-advanced-search').click(function(){
	 	$('#advanced-search').slideToggle();
		$(this).toggleClass('active');
		return false;
	 })
	 
	 $('#venue-find-search').click(function(){
	 	$('#find-room-form').submit();
		return false;
	 })
	$('#register-link').colorbox({width:"710px", inline:true, href:"#registerForm", overlayClose:false, onComplete:function(){
	}});
	
	$('#send-register').click(function(){
		$(this).parent('div').hide();
		$('#load-register').show();
		$('#registerForm input').removeClass('error');	
		SIV.ajaxCall({
			url: '/ajax/social/register',
			form: 'registerForm',
			handler: 'register'
		});
	})
	
})
function closeSplash(){
	$('#modal-overlay').hide();
	$('#popup').hide();
}

