(function($) {
    $(function() {
	
		if ($('#rotator').length){
			init_rotator();
		}
	
		if ($('.scrollable').length){
			$(".scrollable").scrollable();
			$('.gallery-buttons a').click(function(){
				return false;
			});
		}
		
		if ($('.answer').length){
			$('.answer').hide();
			$('a.question').click(function(){
				$(this).parent('h4').next(".answer").css('height', 'auto');
				$(this).parent('h4').next(".answer").slideToggle('fast');
				
				return false;
			});
		}
		/*
		if ($('.imagery').length){
			$(function() {
			  $('#main-item img').load(function() {
			    $(this).fadeIn(); 
			  });
			  $(".scrollable .item a").click(function() {
			    var image = $(this).attr("rel");
			    $('#main-item img').stop().hide().attr('src', image);
			    return false;
			  });
			});
		}
		*/
		
		if ($('.imagery').length){
			$('#main-item').cycle({ 
				fx:     'fade', 
				speed:  'fast', 
				timeout: 2000, 
				next:   '#next-image', 
				prev:   '#prev-image' 
			});
		}
		
		if ($('.youtube').length){
			$(function() {
			  $('#main-item').load(function() {
			    $(this).fadeIn(); 
			  });
			  $(".scrollable .item a").click(function() {
			    var video = $(this).attr("rel");
			    $('#main-item object').stop().remove();
			    $('#main-item').html(video);
			    return false;
			  });
			});
		}
		
		if ($('#call-back-details').length){
			$('#call-back-details').show();
			$('#call-back-form').hide();
			$('#call-back-details a').click(function(){
				$('#call-back-details').hide();
				$('#call-back-form').fadeIn().show();
				return false;
			});
			
			$('#call-back-form a.close').click(function(){
				$('#call-back-form').hide();
				$('#call-back-details').fadeIn();
				return false;
			});
		}
		
		if ($('#club-tour-details').length){
			$('#call-tour-details').show();
			$('#club-tour-form').hide();
			$('#club-tour-details a').click(function(){
				$('#club-tour-details').hide();
				$('#club-tour-form').fadeIn();
				return false;
			});
			
			$('#club-tour-form a.close').click(function(){
				$('#club-tour-form').hide();
				$('#club-tour-details').fadeIn();
				return false;
			});
		}
		
		/*if ($('#corporatemembership-details').length){
			$('#corporatemembership-form').hide();
			$('#corporatemembership-details a').click(function(){
				$('#corporatemembership-details').hide();
				$('#corporatemembership-form').fadeIn();
				return false;
			});
		}*/
		
		if ($('body#location').length){
			
			$('#map-click').click(function(){
				$.scrollTo( '#map-head', 800 );
			});
			$('#luas-click').click(function(){
				$.scrollTo( '#luas', 800 );
			});
			$('#directions-click').click(function(){
				$.scrollTo( '#directions', 800 );
			});
			$('#foot-click').click(function(){
				$.scrollTo( '#directions', 800 );
			});
			$('#carpark-click').click(function(){
				$.scrollTo( '#carpark', 800 );
			});
			$('#dcc-click').click(function(){
				$.scrollTo( '#dcc', 800 );
			});
		}
		
		if ($('form').length){
			$('input.name').focus(function(){
				if($(this).attr("value") == "your firstname")
				{
					$(this).attr("value", "");
				}
			});
			$('input.name').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "your firstname");
				}
			});
			$('input.name').focus(function(){
				if($(this).attr("value") == "your surname")
				{
					$(this).attr("value", "");
				}
			});
			$('input.name').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "your surname");
				}
			});
			$('input.emailadd').focus(function(){
				if($(this).attr("value") == "your email")
				{
					$(this).attr("value", "");
				}
			});
			$('input.emailadd').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "your email");
				}
			});
			$('input.mobile').focus(function(){
				if($(this).attr("value") == "your mobile")
				{
					$(this).attr("value", "");
				}
			});
			$('input.mobile').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "your mobile");
				}
			});
			//Corporate
			$('input.position').focus(function(){
				if($(this).attr("value") == "position within company")
				{
					$(this).attr("value", "");
				}
			});
			$('input.position').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "position within company");
				}
			});
			
			$('input.co-name').focus(function(){
				if($(this).attr("value") == "company name")
				{
					$(this).attr("value", "");
				}
			});
			$('input.co-name').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "company name");
				}
			});
			$('textarea.co-address').focus(function(){
				if($(this).attr("value") == "company address")
				{
					$(this).attr("value", "");
				}
			});
			$('textarea.co-address').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "company address");
				}
			});
			
			$('input.contact-no').focus(function(){
				if($(this).attr("value") == "your contact number")
				{
					$(this).attr("value", "");
				}
			});
			$('input.contact-no').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "your contact number");
				}
			});
			$('input.bus_type').focus(function(){
				if($(this).attr("value") == "type of business")
				{
					$(this).attr("value", "");
				}
			});
			$('input.bus_type').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "type of business");
				}
			});
			
			$('input.no-employees').focus(function(){
				if($(this).attr("value") == "no. of employees")
				{
					$(this).attr("value", "");
				}
			});
			$('input.no-employees').blur(function(){
				if($(this).attr("value") == "")
				{
					$(this).attr("value", "no. of employees");
				}
			});
		}
		
		$('input.search-site').focus(function(){
			if($(this).attr("value") == "search site")
			{
				$(this).attr("value", "");
			}
		});
		
		$('input.search-site').blur(function(){
			if($(this).attr("value") == "")
			{
				$(this).attr("value", "search site");
			}
		});
    });

    $(window).bind("load", function() {

    });
})(jQuery);


