

// trim leading, trailing and multiple spaces from a string.
// Can't get my head around Regex so don't ask.
function trim(s) {
	s = s.replace(/(^\s*)|(\s*$)/gi,"");
	s = s.replace(/[ ]{2,}/gi," ");
	s = s.replace(/\n /,"\n");
	return s;
}

var jq = jQuery.noConflict();

jq(document).ready(function(){
	
	//if(document.location.href.indexOf("cmspagemode") < 0 && jq(".home_flash ol").length)
	//{
	//	jq(".home_flash ol").cycle({
	//		fx:     'fade', 
	//		speed:  'slow', 
	//		timeout: 4000
	//	});
	//}

	//if(document.location.href.indexOf("cmspagemode") < 0 && jq(".home_flash ul").length)
	{
		jq(".home_flash ul").cycle({
			fx:     'fade', 
			speed:  'slow', 
			timeout: 4000
		});
	}
  
	// truncate the headlines in case they're too long for that space ...
	var theChar = "";
	jq(".head_news ul.sf_newsList h2 a").each(function(){
		theChar = trim(jq(this).text());
		theChar.length > 45 ? jq(this).text(theChar.substring(0,45) + " [...]") : null;
	});
    jq(".head_news ul.sf_newsList").cycle({
		fx:     'fade', 
		speed:  'slow', 
		timeout: 3500,
		next:   '.head_news_next a', 
		prev:   '.head_news_prev a' 
	});
	
	if(document.location.href.indexOf("cmspagemode") < 0)
	{
		jq(".subnav ul").length > 0 ? jq(".subnav").show() : jq(".subnav").hide();
	}
	
	jq(".maincontent input:radio, .maincontent input:checkbox").addClass("tickbox");
	jq(".maincontent input:submit").hover(function(e){ jq(this).toggleClass("submitHover"); }, function(){ jq(this).toggleClass("submitHover"); });
 	jq(".formRowWrapper").hover(
			function(){ jq(this).addClass("formRowHover"); },
			function(){ jq(this).removeClass("formRowHover"); }
	);
	jq(".formRowWrapper input, .formRowWrapper textarea").focus( function(){ jq(this).parents(".formRowWrapper").addClass("formRowFocus"); } );
	jq(".formRowWrapper input, .formRowWrapper textarea").blur( function(){ jq(this).parents(".formRowWrapper").removeClass("formRowFocus"); } );

	jq(".footer ul li:last").addClass("rmLast");
 
});

