name0='';
email0='';
phone0='';
zip0='';
content0='';

function wsfytpCheckSubmit(){
    c1=false;
    c2=false;
    c3=false;
    c4=false;
    c5=false;
    c6=false;

    name = document.getElementById("wsfytpName").value;  if(name=="Your Name:")name=''; else if(name==name0+": Please enter your name.") name=name0;
    email = document.getElementById("wsfytpEmail").value; if(email=="Email Address:")email='';else if(email==email0+": Please enter your email.") email=email0;
    phone = document.getElementById("wsfytpPhone").value; if(phone=="Your Phone:")phone=''; else if(phone==phone0+": phone number please.") phone=phone0;
    zip = document.getElementById("wsfytpZip").value; if(zip=="Case Location:")zip=''; else if(zip==zip0+": case location please.") zip=zip0;
    content = document.getElementById("wsfytpMessage").value; if(content=="Reason for Contact:")content=''; else if(content==content0+": case location please.") content=content0;

    var errs=new Array("Please provide your name.",
        "Please provide a valid email address.",
        "Please provide your area code and phone number.",
        "Please provide location of your case.",
        "Please provide more details regarding your inquiry.",
        "Please check agree box below.");


    var ver = getInternetExplorerVersion();
    if(navigator.userAgent.match("MSIE")){
        if (zip.length<2) {
            zip0=zip; zip1=zip0+": case location please.";
            document.getElementById("wsfytpZip").setAttribute("value", zip1);
            document.getElementById("wsfytpZip").setAttribute("style", "color: red;");
            document.getElementById("wsfytpZip").setAttribute("onfocus","if ((this.value==zip0)||(this.value==': case location please.')||(this.value==zip1)||(this.value=='Case Location:')) {this.value=zip0; this.style.color = 'black'; };");
        } else {
            c1 = true;
        }

        if((name.length<2)){
            name0=name; //if(name=='liqname') name0='';
            name1=name0+": your name please.";
            document.getElementById("wsfytpName").setAttribute("value", "Please enter your name.");
            document.getElementById("wsfytpName").setAttribute("style", "color: red;");
            document.getElementById("wsfytpName").setAttribute("onfocus","if ((this.value=='Please enter your name.')||(this.value=='Your Name:')) {this.value=name0; this.style.color = 'black'; };");
        } else {
            c2 = true;
        }
        if((email.length<7)){
            email0=email; email1=email0+": valid email address.";
            document.getElementById("wsfytpEmail").setAttribute("value", email1);
            document.getElementById("wsfytpEmail").setAttribute("style", "color: red;");
            document.getElementById("wsfytpEmail").setAttribute("onfocus","if ((this.value==email0)||(this.value==': valid email address.')||(this.value==email1)||(this.value=='Email Address:')) {this.value=email0; this.style.color = 'black'; };");
        } else {
            c3 = true;
        }

        if(phone.length<7){
            phone0=phone;phone1=phone0+": phone number please.";
            document.getElementById("wsfytpPhone").setAttribute("value", phone1);
            document.getElementById("wsfytpPhone").setAttribute("style", "color: red;");
            document.getElementById("wsfytpPhone").setAttribute("onfocus","if ((this.value==phone0)||(this.value==': phone number please.')||(this.value==phone1)||(this.value=='Your Phone:')) {this.value=phone0; this.style.color = 'black'; };");
        }else{
            c4 = true;
        }
        if (!gObj("agreeterm").checked){
            setHtml('er6',errs[5]);
            document.getElementById("er6").style.color ="red";
            show('er6','block');
        }else{
            c6 = true;
            setHtml('er6','');
            hide('er6');
        }

        if(content.length<10){
            content0=content; content1=content0+": please provide more details.";
            document.getElementById("wsfytpMessage").setAttribute("value", content1);
            document.getElementById("wsfytpMessage").setAttribute("style", "color: red;");
            document.getElementById("wsfytpMessage").setAttribute("onfocus","if ((this.value==content0)||(this.value==': please provide more details.')||(this.value==content1)||(this.value=='Reason for Contact:')) {this.value=content0; this.style.color = 'black'; };");
        }else{
            c5 = true;
        }


    }else{
        if(zip.length<2){
            zip0=zip;
            document.getElementById("wsfytpZip").value = zip0+": case location please.";
            document.getElementById("wsfytpZip").style.color = "red";
            document.getElementById("wsfytpZip").onfocus=function(){if ((this.value==zip0+': case location please.')||(this.value=='Case Location:')) {this.value=zip0; this.style.color = 'black'; }}
        } else {
            c1 = true;
        }
        if((name.length<2) || (name=="Your Name:")){
            name0=name;
            document.getElementById("wsfytpName").value = name0+": Please enter your name.";
            document.getElementById("wsfytpName").style.color = "red";
            document.getElementById("wsfytpName").onfocus=function(){if ((this.value==name0+': Please enter your name.')||(this.value=='Your Name:')) {this.value=name0; this.style.color = 'black'; }}
        } else {
            c2 = true;
        }

        if(phone.length<7){
            phone0=phone;
            document.getElementById("wsfytpPhone").value = phone0+": phone number please.";
            document.getElementById("wsfytpPhone").style.color ="red";
            document.getElementById("wsfytpPhone").onfocus=function(){if ((this.value==phone0+': phone number please.')||(this.value=='Your Phone:')) {this.value=phone0; this.style.color = 'black'; }}
        }else{
            c4 = true;
        }

        if(email.length<3){
            email0=email;
            document.getElementById("wsfytpEmail").value = email0+": valid email address.";
            document.getElementById("wsfytpEmail").style.color ="red";
            document.getElementById("wsfytpEmail").onfocus=function(){if ((this.value==email0+': valid email address.')||(this.value=='Email Address:')) {this.value=email0; this.style.color = 'black'; }}
        }else{
            c3 = true;
        }

        if(content.length<10){
            content0=content;
            document.getElementById("wsfytpMessage").value = content0+": please provide more details.";
            document.getElementById("wsfytpMessage").style.color ="red";
            document.getElementById("wsfytpMessage").onfocus=function(){if ((this.value==content0+': please provide more details.')||(this.value=='Reason for Contact:')) {this.value=content0; this.style.color = 'black'; }}
        }else{
            c5 = true;
        }

        if (!gObj("agreeterm").checked){
            setHtml('er6',errs[5]);
            document.getElementById("er6").style.color ="red";
            show('er6','block');
        }else{
            c6 = true;
            setHtml('er6','');
            hide('er6');
        }
    }
    if(c1 && c2 && c3 && c4 && c5 && c6){
        return true;
    }else{
        return false;
    }
}

function getInternetExplorerVersion(){
    var rv = -1;
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}

function hide(el){
    var elem=document.getElementById(el);
    if (elem===null || elem===undefined) elem=el;
    elem.style.display='none';
}
function setHtml(el,html){
    var elem=document.getElementById(el);
    elem.innerHTML=html;
}

function show(el,how){
    var elem=document.getElementById(el);
    if (elem===null || elem===undefined) elem=el;
    elem.style.display=how;
}

function gObj(obj){var theObj;if(document.all){if(typeof obj=="string"){return document.all(obj);}else{return obj.style;}}if(document.getElementById){if(typeof obj=="string"){return document.getElementById(obj);}else{return obj.style;}}return null;}
                            /**
 * Created by longmeng on 7/15/14.
 */



function loadScript(url, callback){

    var script = document.createElement("script")
    script.type = "text/javascript";

    if (script.readyState){  //IE
        script.onreadystatechange = function(){
            if (script.readyState == "loaded" ||
                    script.readyState == "complete"){
                script.onreadystatechange = null;
                callback();
            }
        };
    } else {  //Others
        script.onload = function(){
            callback();
        };
    }

    script.src = url;
    document.getElementsByTagName("head")[0].appendChild(script);
}



 //model ====
 // Get the modal
window.onload = function(){  
var modal = document.getElementById('myModal');

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on the button, open the modal 
btn.onclick = function() {
    loadScript("https://www.google.com/recaptcha/api.js", function(){
    });

    modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
};
