$(document).ready(function() {
	
	// Default form field text using the title field
	$(".defaultText").focus(function(srcc)
	{
		if ($(this).val() == $(this)[0].title)
		{
			$(this).removeClass("defaultTextActive");
			$(this).val("");
		}
	});	
	$(".defaultText").blur(function()
	{
		if ($(this).val() == "")
		{
			$(this).addClass("defaultTextActive");
			$(this).val($(this)[0].title);
		}
	});	
	$(".defaultText").blur();        						
		
});

// Disable or Enable dialog buttons
function ButtonDialogState(sIDDialog,sLabel,bEnable){
 //    $(sIDDialog+" ~ .ui-dialog-buttonpane").children("button:contains('"+sLabel+"')").button((bEnable==true) ? "enable" : "disable" );//1.8.2
	 $(sIDDialog+" ~ .ui-dialog-buttonpane .ui-dialog-buttonset").children("button:contains('"+sLabel+"')").button((bEnable==true) ? "enable" : "disable" );//1.8.4
}

function flashRed(target) {
	$(target).animate({ borderTopColor: "#f00", borderLeftColor: "#f00", borderRightColor: "#f00", borderBottomColor: "#f00"}, 'fast').
					 animate({ borderTopColor: "#222", borderLeftColor: "#222", borderRightColor: "#222", borderBottomColor: "#222"}, 'fast').
					 animate({ borderTopColor: "#f00", borderLeftColor: "#f00", borderRightColor: "#f00", borderBottomColor: "#f00"}, 'fast').
					 animate({ borderTopColor: "#222", borderLeftColor: "#222", borderRightColor: "#222", borderBottomColor: "#222"}, 'fast').
					 animate({ borderTopColor: "#f00", borderLeftColor: "#f00", borderRightColor: "#f00", borderBottomColor: "#f00"}, 'fast').delay(1000).
					 animate({ borderTopColor: "#222", borderLeftColor: "#222", borderRightColor: "#222", borderBottomColor: "#222"}, 2000);					 
}

function secondsToTime(sec) {
	var hr = Math.floor(sec / 3600);
	var min = Math.floor((sec - (hr * 3600))/60);
	sec -= ((hr * 3600) + (min * 60));
	sec += ''; min += '';
	while (min.length < 2) {min = '0' + min;}
	while (sec.length < 2) {sec = '0' + sec;}
	hr = (hr)?hr+':':'';
	return hr + min + ':' + sec;
}	
