﻿$(document).ready(function() 
{
    
    var showWait = $("#showWait");
    var txtSite = $("#txtSite");
    txtSite.focus(function(){
        txtSite.css("color","#000000");
        if(this.value=="Please insert your Site"){
            this.value="";
        }
    }).blur(function(){
        txtSite.css("color","#666");
        if(this.value=="Please insert your Site" || this.value==""){
            this.value="Please insert your Site";
        }
    });    
              
                
     $("#postForm").submit(getSubmit); 
    
    function getSubmit(){
        //验证输入关键字
        var divError =$("#divError");
		divError.addClass("error");
        var txt = $.trim(txtSite.val());
        if(txt=="" || txt=="Please insert your Site"){
            txtSite.parent("td").append(divError);
            divError.text("Field can not be empty").show();
            txtSite.css("border","1px solid #FF0000");
            txtSite.focus();
            return false;
        }else if(txt.length<4){
            txtSite.parent("td").append(divError);
            divError.text("Field can not be too short").show();
            txtSite.css("border","1px solid #FF0000");
            txtSite.focus();
            return false;
        }else if(txt.lastIndexOf(".")!=txt.length-3 && txt.lastIndexOf(".")!=txt.length-4 && txt.lastIndexOf(".")!=txt.length-5){
            txtSite.parent("td").append(divError);
            divError.text("Site error format   (\".\")").show();
            txtSite.css("border","1px solid #FF0000");
            txtSite.focus();
            return false;
        }else if(txt.indexOf("/")!=-1){
            txtSite.parent("td").append(divError);
            divError.text("Site error format   (\"/\")").show();
            txtSite.css("border","1px solid #FF0000");
            txtSite.focus();
            return false;
        }else{
            divError.removeClass("error");
            divError.text("Site: Please insert your Site(model:www.easyseosolution.com)").show();
            txtSite.css("border","1px solid #bbbec0");
        }
        
        $("#postForm").attr("action","/tools/free-analysis-report.aspx");

        return true;
    }
    
    
    
});
