var g_invalidName = "";
var g_invalidEmail = "";
var g_whereRequire = "";
var g_thanks = "";

function showContactForm()
{
    var offsetWidth = 603;
    var innerWidth  = 0;
    
    if (parseInt(self.innerWidth)) {
        innerWidth = self.innerWidth;
    }
    else {
        innerWidth = document.documentElement.clientWidth;
    }

    $("err_msg").innerHTML = "&nbsp;";
    $("frm_contact").reset();
    $("contact_form").style.left = ((innerWidth-offsetWidth)/2)+"px";
    Effect.Appear("contact_form", {duration:0.5, afterFinish: function(){$("name").focus();}});
}

function hideContactForm()
{
    Effect.Fade("contact_form", {duration:0.5});
}

function sendContactForm()
{
    $("err_msg").innerHTML = "&nbsp;";
    
    if ($("email").value == "" || $("email").value.indexOf("@") == -1 || $("email").value.indexOf(".") == -1 ) {
        $("err_msg").innerHTML = g_invalidEmail;
        $("email").focus();
        return;
    }
	if ($("where").value == "")
	{
        $("err_msg").innerHTML = g_whereRequire;
        return;
	}
    
    new Ajax.Request("/app/actions/sendContactForm.php", { 
						asynchronous: true, 
						method: "post", 
						parameters: $("frm_contact").serialize(),
						onSuccess: function(request){
							Effect.Fade("contact_form", {duration:0.5});
                        }});
}