//global functions and items initialised on document load



//global functions
function initTableHighlights() {
	$(".highlight .row input:enabled, .highlight .row select:enabled, .highlight .row textarea:enabled").focus(function () {
		$(this).parents(".row").toggleClass("rowHighlight");
	});
	$(".highlight .row input:enabled, .highlight .row select:enabled, .highlight .row textarea:enabled").blur(function () {
		$(this).parents(".row").toggleClass("rowHighlight");
	});			
}

function initTabs() {
	$(".tabWrapper > ul").tabs();
}

function initErrorMsg() {
	$(".error").effect("highlight", {}, 1000);	
}

function initTextArea() {
	$("textarea").growfield();
	//noticed double posts and wiered extra characters
}

function initRotate() {
	$('.rotateMe').cycle({
		fx: 'fade',
		timeout: 6000,
		pause: 1,
		sync: 0
	});
	//if($.browser.msie && parseInt($.browser.version) == 6) {
     	$('.rotateMeTwitter').cycle({
			fx: 'fade',
			timeout: 6000,
			pause: 1,
			sync: 0
		});	
	/*} else {
		$('.rotateMeTwitter').cycle({
			fx: 'scrollLeft',
			timeout: 6000,
			pause: 1,
			sync: 0,
			height: 40
		});	
	}*/
}

function initMenu() {
	var path = location.pathname.substring(1).toLowerCase();
	var def = path.indexOf('default.aspx');
	if (def != -1) path = path.substring(0, def);
	if (path != "") {
		$('#menu a[@href$="' + path + '"]').addClass('down').parents('li').children('a').addClass('down');
		$('#subMenu a[@href$="' + path + '"]').addClass('down');
	} else {
		$('#menu li:first a').addClass('down');	
	}
}

function initSearch() {
	$(".searchBox").focus(function() {
		if (this.value == "Search") {
			this.value = "";
			$(this).toggleClass("searchFade");
		};						   
	});
	$(".searchBox").blur(function() {
		if (this.value == "") {
			this.value = "Search";
			$(this).toggleClass("searchFade");
		};						   
	});
}

//document load
$(document).ready(function() {
	//initTableHighlights();
	//initTabs();
	initErrorMsg();
	//initTextArea();
	initMenu();
	initRotate();
	initSearch();
	
});


