$(document).ready(function(){
    $('.home .sifr-quote').before('<img src="/media/images/img-quote-start-white.gif" class="quote-start" width="23" height="16" />');
    $('.home .sifr-quote').after('<img src="/media/images/img-quote-end-white.gif" class="quote-end" width="23" height="16" />');
    $('.project .sifr-quote,.service .sifr-quote').before('<img src="/media/images/img-quote-start-blue.gif" class="quote-start" width="23" height="16" />');
    $('.project .sifr-quote,.service .sifr-quote').after('<img src="/media/images/img-quote-end-blue.gif" class="quote-end" width="23" height="16" />');
	
	$('.portfolio .callout').hover(function() {
		$(this).addClass('selected');
	}, function(){
		$(this).removeClass('selected');
	});
	
	// Hide noscript tagged elements
	$('.noscript').hide();
	
	// Show map and location form
	$('.contact-us form').show();
	$('.contact-us #map-canvas').show();
	
	// Map location box click to clear
	$('#fromAddress').focus(function(){
		if (this.value == 'your postcode') {
			this.value = '';
		}
	});
	
	// Map location box click to clear
	$('#fromAddress').blur(function(){
		if (this.value == '') {
			this.value = 'your postcode';
		}
	});
	
	// Email box click to clear
	$('#frm-email').focus(function(){
		if (this.value == 'your email address') {
			this.value = '';
		}
	});
	
	// Email box click to clear
	$('#frm-email').blur(function(){
		if (this.value == '') {
			this.value = 'your email address';
		}
	});
	
	// Mobile box click to clear
	$('#frm-mobile').focus(function(){
		if (this.value == 'your mobile number') {
			this.value = '';
		}
	});
	
	// Mobile box click to clear
	$('#frm-mobile').blur(function(){
		if (this.value == '') {
			this.value = 'your mobile number';
		}
	});

	$('.portfolio .callout').click(function() {
		window.location = $(this).find("a:first").attr("href");
	});
	
	$('form.doSelectable label, form.doSelectable input').each(function() {
		$(this).hide();																				   
	});
	
	$('form.doSelectable select').each(function() {
		
		var selectableHTML = '<div class="doSelectable"><p>' + $(this).children('option:first').html() + '</p><ul>';
		$(this).children('option').each(function() {
			if($(this).val() != '')
			{
				selectableHTML = selectableHTML + '<li><a href="' + $(this).val() + '">' + $(this).html() + '</a></li>';
			}
		});				
		selectableHTML = selectableHTML + '</ul></div>';
		
		$(this).replaceWith(selectableHTML);
		
		bindClickActions();
		
	});
	
});

function bindClickActions()
{
	
	$('div.doSelectable').click(function() {
		$(this).children('ul').slideToggle('fast');
	});

	$('div.doSelectable').bind("mouseleave",function() {
		$(this).children('ul').slideUp('fast');
	});
	
}

