$(document).ready(function() {

 // ----------------- sistema -----------------

 // Newsletter subscribe
    $("#FooterNews").submit(function(){
        var ser = $(this).serialize();  //produced above response
        jQuery.facebox({image: 'http://arquivocontemporaneo.com.br/img/icons/facebox-loader.gif'});
        $.post($(this).attr("action"), ser,
        function(response) {
                jQuery.facebox(response);
        });
        return false;
    });
 // Contato form
    $("#formContato").submit(function(){
        var ser = $(this).serialize();  //produced above response
        jQuery.facebox({image: 'http://arquivocontemporaneo.com.br/img/icons/facebox-loader.gif'});
        $.post($(this).attr("action"), ser,
        function(response) {
                jQuery.facebox(response);
        });
        return false;
    });
    $(".menuDesigner").each(function(){
        var liID = $(this).attr("id");
        var spanID = $("#produtosDesigner").html();
        if(liID == spanID)
            $(this).addClass("active");
    });
    $("#formMS").submit(function() {
        if ($("#nomeS").val() == "nome")
            $("#nomeS").val("");
        $("#formMS").validate();
        if($("#formMS").valid() == false) {
                return false;
        }
        if($("#nome").val() == "") {
                return false;
        }
    });
// Locação Form
    $("#devolucao").mask("99/99/9999",{placeholder:" "});
    $("#retirada").mask("99/99/9999",{placeholder:" "});

    $("#resetNumber").click(function(){
        var location = "http://arquivocontemporaneo.com.br/produtos/changeCat/" + $(this).attr("name");
        window.location.href = location;
    });
    $("#resetDesigner").click(function(){
        var location = "http://arquivocontemporaneo.com.br/produtos/resetFilterDesigner/" + $(this).attr("name");
        window.location.href = location;
    });
    $("#filterDesignerReset").click(function(){
        var location = $(this).attr("value");
        window.location.href = location;
    });
    $("#filterNumber").change(function(){
        var location = $(this).attr("value");

        window.location.href = location;
    });
    $("#filterDesigner").change(function(){
	if ($(this+'option:selected').html() == 'Todos'){
	    var location = $(this).attr("value");
	}
        else{
	    var designer = $(this).attr("value");
	    var location = "http://arquivocontemporaneo.com.br/produtos/filterDesigner/"+designer;
	}
        window.location.href = location;
    });
    $("#shareTwitter").click(function(event){
        event.preventDefault();
        newwindow=window.open($(this).attr("href"),'Compartilhar no Twitter','height=400,width=600');
	if (window.focus) {newwindow.focus()}
	return false;
    });
    $("#shareFacebook").click(function(event){
        event.preventDefault();
        newwindow=window.open($(this).attr("href"),'Compartilhar no Facebook','height=400,width=600');
	if (window.focus) {newwindow.focus()}
	return false;
    });
    $("#filterArquiteto").change(function(){
        var location = $(this).attr("value");
        window.location.href = location;
    });
    $("#filterTipo").change(function(){
        var location = $(this).attr("value");
        window.location.href = location;
    });
    $("#resetArquiteto").click(function(){
        var location = "http://arquivocontemporaneo.com.br/projetos/resetArquiteto/";
        window.location.href = location;
	return false;
    });
    $("#resetTipo").click(function(){
        var location = "http://arquivocontemporaneo.com.br/projetos/resetTipo/";
        window.location.href = location;
	return false;
    });
    $("#print").click(function(event){
        event.preventDefault();
        $(".produtos").printElement();
    });
    $("#printSelection").click(function(event){
        event.preventDefault();
        $("#selecao-lista").printElement();
    });

});
