﻿/// <reference path="jquery-1.2.6-vsdoc.js"/>
/// <reference path="jQueryExtensions.js"/>

jQuery(document).ready(function() {
    jQuery.joinInputs("codpostal1", "codpostal2"),
    jQuery("#btnInstaller").click(function() {
    if (jQuery('#codpostal1').val() == "" || jQuery('#codpostal2').val() == "") {
        jQuery("#frmInstaller div.formErrors").hide("normal", function() {
        jQuery("#frmInstaller div.formErrors").html("Verifique se preencheu o campo de código postal correctamente").show("normal");
            });
            return false;
        }
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (jQuery('#email').val() != "" && !filter.test(jQuery('#email').val())) {
            jQuery("#frmInstaller div.formErrors").hide("normal", function() {
            jQuery("#frmInstaller div.formErrors").html("Verifique se preencheu o campo de e-mail correctamente").show("normal");
            });
            return false;
        }
        if (window.location.pathname == '/como/Default.aspx') {
            jQuery('#in_cp7_1').val(jQuery("#codpostal1").val());
            jQuery('#in_cp7_2').val(jQuery("#codpostal2").val());
            jQuery('.searchInstaladores .submit').click();
            window.location = '#searchInstaladores';
        } else {
            window.location = "/como/Default.aspx?code=XzX6F6#" + jQuery("#codpostal1").val() + "-" + jQuery("#codpostal2").val();
        }
        return false;
    });
});

