// JavaScript Document
//want $ to work with other libs
$(document).ready(noselect);

function noselect(){	
	// $(disableSelection(document.getElementById("imageflow")))
	if ( $("#imageflow").length > 0 ) {
		$(disableSelection("#imageflow"));
	}
};

$(document).ready(sidebar);

function sidebar(){
    //$("#sidebar1,#innercontent").equalizeCols(0);
};


//used by filter drop down 
$(document).ready(filterRedirect);
function filterRedirect(){

	$('#filter').change(function(){

		document.location.href=document.location.href.split('?')[0] + '?filter=' + encodeURIComponent($('#filter option:selected').val());
	 //have to do this to stop the post back which occurs
	 //return false;
 });

};

//
$(document).ready(redirectToStockistsSearch);
function redirectToStockistsSearch(){
  $('#stockistSearch').click(function(){
	//if($('#location option:selected').val()!='' && $('#location option:selected').val()!='Please select filter'){
  	  document.location.href = $('#searchFormRedirect').val() + "?location=" + encodeURIComponent($('#location option:selected').val());
	//}
	//else{
	//	alert("Please select location");
	//}
     }
  );
}

$(document).ready(alterTable);
function alterTable()
{
 $('span:contains("(not shown)")').hide();
 $('span:contains("optional")').hide();
 $('fieldset p:eq(2) input').after("<br />&nbsp;(optional - remember http://)<br /><br />");
 $('fieldset p:eq(1) input').after("<br />&nbsp;(Personalise your comments with a <a href=\"http://en.gravatar.com\" target=\"blank\" title=\"Get yourself a Gravatar\">Gravatar</a>)<br /><br />");

}

$.fn.slideFadeOut = function (speed,callback) {
	return this.animate({height: 'hide', opacity: 'hide'},speed,callback);
}
$.fn.slideFadeIn = function (speed,callback) {
	return this.animate({height: 'show', opacity: 'show'},speed,callback);
}


$(document).ready(serveAccord);

function flow(item)
{
	$("#"+item).slideFadeIn("slow");
}

function serveAccord()
{
	// Hide all divs bar first
	$("#services-content div:not(#item1)").hide();
	
	$("#service-list a").click(function() {
		//alert($(this).attr("rel"));
		var toShow = $(this).attr("rel");
		$("#services-content div").slideFadeOut("slow");
		setTimeout(function(){flow(toShow);},600);	
	});
}
