$.noConflict();
jQuery(document).ready(function($){
	$("input, textarea").focus(function(){
		if($(this).attr('title') == $(this).val())
			$(this).val('');
		
	}).blur(function(){
		if($(this).val() == '')
			$(this).val($(this).attr('title'));
	});
	
	/*
	$("textarea").focus(function(){
		if($(this).attr('title') == $(this).html())
			$(this).html('');
	}).blur(function(){
		if($(this).html() == '')
			$(this).html($(this).attr('title'));
	});
	*/
	$(".hover-buttons").hover(function(){
		$(this).find('img').toggle();
	},function(){
		$(this).find('img').toggle();
	});
	
	phonei = 0;
	$('.phone').each(function(){
		$(this).attr('id','phone'+(phonei++));
		listenForDigit($(this).attr('id'));
	});
});

function debug($msg) {
	if (window.console && window.console.log)
		window.console.log($msg);
}
	
function cleanDialog(id)
{
	// clean form data
	jQuery('#'+id+'-dialog input, #'+id+'-dialog textarea').each(function(){
		jQuery(this).val(jQuery(this).attr('title'));
	});
	jQuery('#'+id+'-dialog select').each(function(){
		document.getElementById(this.id).selectedIndex = 0;
	});
	
	// reset form colour
	jQuery("#"+id+"-form .required").css({'background-color':'#D2D3D5',color: '#808080'}).attr('disabled','');

	// restore the submit button
	jQuery("#submit-"+id).css({visibility: 'visible'});

	// claer the status
	jQuery("#"+id+"-status").html('');
	
	jQuery('#'+id+'-dialog .buttons-up').show();
	jQuery('#'+id+'-dialog .buttons-over').hide();
}
