$(document).ready(function() {
	
    // Expand Panel
    $("#open").click(function(){
        $("div#panel").slideDown("slow");
	
    });
	
    // Collapse Panel
    $("#close").click(function(){
        $("div#panel").slideUp("slow");
    });
	
    // Switch buttons from "Log In | Register" to "Close Panel" on click
    $("#toggle a").click(function () {
        $("#toggle a").toggle();
    });

    $("#sendForm").click(function(){
        sendContactAjax("#wrapper #contactForm","#forms");        
        //"$.get('includes/contact.php', function(data){$('#forms').html(data)},'html')"
        setTimeout("$.get('includes/contact.php', function(data){$('#forms').html('<h2>Send Another Query</h2>'+data)},'html')", 2000);
    });

    $("#panel #sendContact").click(function(){
        sendContactAjax("#panel #contactForm","#contactFormDiv");
        setTimeout("slideUp()", 2000);
    });

    $("#sendQouteForm").click(function(){
        $.post("includes/qu.php",
            $("#qouteForm").serialize(),
            function(data){
                $("#forms").html(data);
            },
            "html");
        setTimeout("$.get('includes/qoute.php', function(data){$('#forms').html('<h2>Request Another Quote</h2>'+data)},'html')", 2000);
    });

    var options = {
        newsList: "#news",
        startDelay: 10,
        placeHolder1: " ",
        placeHolder2: "_"
    }
    $().newsTicker(options);
});

function slideUp(){
    $("div#panel").slideUp("slow");
    $("#toggle a").toggle();
}

function sendContactAjax(form,messageContainer){
    $.post("includes/cont.php",
        $(form).serialize(),
        function(data){
            $(messageContainer).html(data);
        },
        "html");
}