Shadowbox.init();

$(document).ready(function(){
	
	$('.tips').tipTip();
		
	$('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
	
	$("#error_console").dialog('close');
	
});

function error_display(message, title, icon, callback) { // display an error popup, with onliy an OK button. This is different from teh confirmation_display function which can go either way. 
	$('#error_console').html('<span class="ui-icon ui-icon-'+icon+' picon"></span><p>'+message+'</p>').attr('title',title);
	// add and remove the classes depending on type of warning. 
	// set title. 
	$("#error_console").dialog({
			bgiframe: true,
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
					eval(callback);
					$(this).dialog('destroy');
				}
			}
		});
	$("#error_console").dialog('open');
}


function confirmation_display(message, title, icon, functionyes, functionno) { // confirm yes or no on certain actions. run functionyes or functionno depending on the client's response on the pop-up. 
	var yesorno = '';
	$('#error_console').html('<span class="ui-icon ui-icon-'+icon+' picon"></span><p>'+message+'</p>');
	// add and remove the classes depending on type of warning. 
	// set title. 
	$('#error_console').attr('title',title);
	$("#error_console").dialog({
			bgiframe: true,
			modal: true,
			buttons: {
				Yes: function() {
					$(this).dialog('close');
					eval(functionyes);
					$(this).dialog('destroy');
				},
				No: function() {
					$(this).dialog('close');
					eval(functionno);
					$(this).dialog('destroy');
				}
			}
		});
	
	$("#error_console").dialog('open');
	return yesorno;
}
