$(document).ready(function(){
	//$(".search").focus(function(){if($(this).attr("value") == "Search..." || $(this).attr("value") == "Search..."){$(this).attr("value","");}});
	//$(".findLocalPostcode").focus(function(){if($(this).attr("value") == "Please insert your postcode" || $(this).attr("value") == "Please insert your postcode"){$(this).attr("value","");}});
	//$(".searchCMS").focus(function(){if($(this).attr("value") == "Keyword Search..." || $(this).attr("value") != ""){$(this).attr("value","");}});
	//$(".searchNews").focus(function(){if($(this).attr("value") == "Search Articles..." || $(this).attr("value") != "Search Articles..."){$(this).attr("value","");}});
	
	// clear input.text on focus, if still in default
    $("input.search, input.searchCMS, input.findLocalPostcode, input.searchNews").focus(function() {

      if($(this).val()==$(this).attr("defaultValue")) {
        $(this).val("");
      }
    });

    // if field is empty afterward, add text again
    $("input.search, input.searchCMS, input.findLocalPostcode, input.searchNews").blur(function() {
      if($(this).val()=="") {
        $(this).val($(this).attr("defaultValue"));
      }
    });
	
	$("img.rotator").show();
	
	$(".no-js").hide();
	$(".js").show();
	
	$(".banner").hide();
	
	
	$('#homeBannerImages') .cycle({ 
		fx:     'fade', 
	    speed:   1500, 
	    timeout: 7000, 
	    pager:  '#homeBannerImagesNav' 
	});
	
	
	$(".successStoriesTicker1").cycle({
		fx:     'scrollVert',
		prev:   '#prev1', 
	    next:   '#next1', 
	    after:   onAfter1,
	    speed:   1500, 
	    timeout: 7000,
	    delay:   -2000
	});
	
	$(".successStoriesTicker2").cycle({
		fx:     'scrollVert',
		prev:   '#prev2', 
	    next:   '#next2', 
	    after:   onAfter2,
	    speed:   1500, 
	    timeout: 7000
	});
	
	$('.jsDropdown').sSelect();
});

function onAfter1(curr, next, opts) {
	var index = opts.currSlide;
	$('#prev1')[index == 0 ? 'hide' : 'show']();
	$('#next1')[index == opts.slideCount - 1 ? 'hide' : 'show']();
} 

function onAfter2(curr, next, opts) {
	var index = opts.currSlide;
	$('#prev2')[index == 0 ? 'hide' : 'show']();
	$('#next2')[index == opts.slideCount - 1 ? 'hide' : 'show']();
} 

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}
