function thisNull(str) {
    if (str == null) {
        return '';
    }
    else {
        return str;
    }
}
function sendEmail() {
	var name = thisNull($('#name').val());
	var email = thisNull($('#email').val());
	var phone = thisNull($('#phone').val());
	var message = thisNull($('#message').val());
	var btn = 1;			
    if (name == '' && email == '' && message == '') {
        alert('Name, email and message are required.');
    }
    else {
        $.ajax({ type: 'POST',
            url: 'contact.cfm',
            data: {
                name: name,
                email: email,
                phone: phone,
                message: message,
                btn: btn
            },
            dataType: 'html',
            success: function (html) {
               $('#dialog').dialog('close').remove();
               alert('Message sent!');
            }		            
        });
    }
}
function contactWindow() {
    $('#container').append('<div id="dialog"></div>');
	$('#dialog').html('').load('contact.cfm').dialog({ title: 'Contact Us', buttons: { Cancel: function () { $(this).dialog('close'); }, Send: function () { sendEmail() } }, height:450, width:350, autoOpen: true, modal: true, resizable: false, close: function (event, ui) { $(this).html(''); $(this).dialog('destroy'); $('#dialog').remove(); } });
}
$(document).ready(function() {
	$('#contact_bar img').hover(function() {$(this).animate({"opacity": ".5"}, "normal");}, function() {$(this).animate({"opacity": "1"}, "normal");});
	$('#logo_table td img').hover(function() {$(this).animate({"opacity": ".5"}, "normal");}, function() {$(this).animate({"opacity": "1"}, "normal");});
});
