jQuery(InitSite);

var baseurl="http://www.hillingtonsquare.co.uk/";

function getFullHost() {
    var full = window.location.toString();
    return full.substring(0, full.lastIndexOf("/"));
} 

function InitSite()
{
	
	$(".youtube").fancybox({
		'titleShow' : false,
		'type' : 'swf',
		'modal' : false,
		'overlayOpacity' : 0.7,
		'overlayColor' : 'black'		
	});
	
	$("#pictures .frame a").fancybox({'titleShow': true, 'overlayOpacity' : 0.7});
	$(".fancybox").fancybox({'overlayOpacity' : 0.7});
	
	Cufon.now();
	Cufon.replace(".cufon, #nav li, .topstrip",{hover: {color: '#cc0000'}, fontFamily: 'Franklin Gothic Heavy'});
	
	setTimeout(
		function()
		{
			Cufon.refresh("#nav li");
		}
		,1000
	);
	
	if($("#thumbs").size())
	{
		var gallery = $('#thumbs').galleriffic({
			delay:                     3000, // in milliseconds
			numThumbs:                 7, // The number of thumbnails to show page
			preloadAhead:              40, // Set to -1 to preload all images
			enableTopPager:            false,
			enableBottomPager:         true,
			imageContainerSel:         '#slideshow', // The CSS selector for the element within which the main slideshow image should be rendered
			controlsContainerSel:      '#controls', // The CSS selector for the element within which the slideshow controls should be rendered
			captionContainerSel:       '#caption', // The CSS selector for the element within which the captions should be rendered
			loadingContainerSel:       '#loading', // The CSS selector for the element within which should be shown when an image is loading
			playLinkText:              "<img class='icon' src='"+baseurl+"assets/img/play.png' alt='Play' />",
			pauseLinkText:             "<img class='icon' src='"+baseurl+"assets/img/pause.png' alt='Pause' />",
			prevLinkText:              "<img class='icon' src='"+baseurl+"assets/img/previous.png' alt='Previous' />",
			nextLinkText:              "<img class='icon' src='"+baseurl+"assets/img/next.png' alt='Next' />"
		});
	}
	
	$("#contactform").submit(
		function(e)
		{
			e.preventDefault();
			
			var errors=0;
			
			if(!$("#name").val().length || !$("#address").val().length || !$("#contactdetails").val().length || !$("#idea").val().length)
				errors++;
			
			if(errors)
			{
				if(!$("#formerrors").size())
				{
					$("#submitp").before("<p class='hidden' id='formerrors'>Please ensure all fields are filled in before proceeding.</p>");
					$("#formerrors").slideDown();
				}
				else
					$("#formerrors").fadeOut(200).fadeIn(200);
			}
			else
			{
				$(this).unbind('submit').submit();
			}

		}
	);
}

