﻿function fsubmit_onclick() {
    var rest = "no";
    var ease = "no";
    var inter = "no";
    var use = "no";
    var txt1 = document.form1.txtfname.value;
    var txt2 = document.form1.txtlname.value;
    var ema = document.form1.txtEmail.value;
    var cbo = document.form1.cboBox.value;

    if (comboValidator(cbo) == false) {
        form1.cboBox.focus();
        return false;
    }
    if (textboxValidator(txt1) == false) {
        form1.txtfname.focus();
        return (false);
    }

    if (textboxValidator(txt2) == false) {
        form1.txtlname.focus();
        return (false);
    }

    if (emailvalidator(ema) == false) {
        form1.txtEmail.focus();
        return false
    }
    for (x = 0; x < 4; x++) {
        if (document.form1.restime[x].checked == true) {
            rest = "yes";
            break;
        }
    }
    if (rest == "no") {
        window.alert("Please check a radio button from each category!");
        return false;
    }

    for (x = 0; x < 4; x++) {
        if (document.form1.ease[x].checked == true) {
            ease = "yes";
            break;
        }
    }
    if (ease == "no") {
        window.alert("Please check a radio button from each category!");
        return false;
    }

    for (x = 0; x < 4; x++) {
        if (document.form1.interactive[x].checked == true) {
            inter = "yes";
            break;
        }
    }
    if (inter == "no") {
        window.alert("Please check a radio button from each category!");
        return false;
    }

    for (x = 0; x < 4; x++) {
        if (document.form1.useful[x].checked == true) {
            use = "yes";
            break;
        }
    }
    if (use == "no") {
        window.alert("Please check a radio button from each category!");
        return false;
    }

    return true;
}
//checking textbox
function textboxValidator(str) {
    if (str == "" || str == " ") {
        alert("Please fill in the textbox field.");
        return false;
    }
    return true;
}

//checking Combobox
function comboValidator(cbovalue) {

    if (cbovalue == "null") {
        alert("Please choose suffix selection !");
        return false;
    }
    return true;
}

//checking email
function emailvalidator(str) {

    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)


    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr - 1) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr - 1) {
        alert("Invalid E-mail ID")
        return false
    }
    //string.indexOf(searchstring, start)
    // checking @ after @ again
    if (str.indexOf(at, (lat + 1)) > lat) {
        alert("Invalid E-mail ID")
        return false
    }
    // checking . after . again
    if (str.indexOf(dot, (dot + 1)) > dot) {
        alert("Invalid E-mail ID")
        return false
    }

    //   .@ or @.
    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        alert("Invalid E-mail ID")
        return false
    }

    //looking for blank space inside email
    if (str.indexOf(" ") != -1) {
        alert("Invalid E-mail ID")
        return false;
    }
    return true;
}
//checking radio butotn
function validateRadioBtn() {
}
//checking textArea field
function validateTextArea(strvalue) {
    if (strvalue.length == 0) {
        alert("Please fill in the text Area.");
        return false;
    }
}
//checking checkbox field
function validateCheckBox(strvalue) {
    if (strvalue == "yes") {
        alert("Please check at box..");
        return false;
    }
}
//moving picture
var x = 0;
var y = 0;
var clearId;
function MoveImage() {

    document.getElementById("divcenter").style.left = x + "px";
    document.getElementById("divcenter").style.top = y + "px";
    x += 5;

    if (x == 1000) {
        x = -300
        y += 50;
        if (y > 250) {
            y = 0;
        }
    }
}
function GetWithTimer() {
    clearId = setInterval("MoveImage();", 10)
}
function SearchSite() 
{     
document.location.href='http://www.scottonwriting.net/sowBlog/SearchResults.htm? cx=010199128167657050181%3Aztmz7aqoddc&cof=FORID%3A11&ie=UTF-8&q=' +  
 
document.getElementById('q').value + '&sa=Search'; 
}


