// A utility function that returns true if a string contains only
// whitespace characters
function isblank(s) {
    for (var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// This is a function that performs form verification.  It will be
// invoked from the onSubmit() event handler.  The handler should return
// whatever value this function returns.
function verify(f) {
    var msg;
    var empty_fields = " ";
    var error = 0;

    nameof    = f.name; // select the form element of interest
    email     = f.email;
    question  = f.question;

    // Look at the name to see if it is blank
    if ((nameof.value == null) || (nameof.value == "") || isblank(nameof.value)) {
        empty_fields = "\n          Name";
        error = 1;
    }
    if ((email.value == null) || (email.value == "") || isblank(email.value)) {
        empty_fields += "\n          E-mail";
        error = 1;
    }
    if ((question.value == null) || (question.value == "") || isblank(question.value)) {
        empty_fields += "\n          Question";
        error = 1;
    }

    if (error == 0) {
        return true;  //submit form OK and exit function
    } else {
        msg = "_____________________________________________________________\n\n";
        msg += "The form was not submitted because of the following error(s).\n";
        msg += "Please correct these error(s) and re-submit.\n";
        msg += "_____________________________________________________________\n\n";
        msg += "- The following required field(s) are empty: " + empty_fields + "\n\n";
    }
    alert(msg);
    return false;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,'scrollbars=yes,width=470,height=450');
  return false;
}

/* Google && Overture conversion tracking */
var gc_imageObject;
var cc_imageObject;
function go_tracking() {
    /* Google Code for PURCHASE Conversion Page */
    gc_imageObject = new Image();
    gc_imageObject.src = "http://www.googleadservices.com/pagead/conversion/1072335750/?value=1&label=PURCHASE&script=0";

    /* Overture Services Inc. 07/15/2003 */
    var cc_tagVersion = "1.0";
    var cc_accountID = "2017759714";
    var cc_marketID = "0";
    var cc_protocol = "http";
    var cc_subdomain = "convctr";
    if (location.protocol == "https:") {
        cc_protocol = "https";
        cc_subdomain = "convctrs";
    }
    var cc_queryStr = "?" + "ver=" + cc_tagVersion + "&aID=" + cc_accountID + "&mkt=" + cc_marketID +"&ref=" + escape(document.referrer);
    var cc_imageUrl = cc_protocol + "://" + cc_subdomain + ".overture.com/images/cc/cc.gif" + cc_queryStr;
    cc_imageObject = new Image();
    cc_imageObject.src = cc_imageUrl;
}

var fv_imageObject = null;
function addfav() {
    if (window.external) {
        window.external.AddFavorite('http://homeworktutoring.com', 'HomeworkTutoring.com for all your Math, Statistics, Physics, Chemistry, Programming, Economics, Electronics, English and Foreign Languages assignments');
        if (fv_imageObject == null) {
            fv_imageObject = new Image();
            fv_imageObject.src = "http://homeworktutoring.com/cgi-bin/counter/addfav.php?isadd=1";
        }
    }
}

var position = 0;
var initmsg = null;
var outmsg  = null;
function outmsg_ticker() {
    if (outmsg == null) {
        if (document.getElementById("outmsg") == null) {
            setTimeout("outmsg_ticker()", 10);
            return;
        }
        outmsg = document.getElementById("outmsg");
        initmsg = "We will reply within 12 hours of receiving your homework problem. All you need to do is select the department (subject). Send your questions/problems including your deadline by email or fax.";
    }

    //var msg = initmsg.substring(position, initmsg.length - position);
    //if (msg.length < 79) {
    //    msg += " " + initmsg;
    //}
    //outmsg.innerHTML = msg.replace(" ", "&nbsp;");
    //position = (position == initmsg.length - 1) ? 0 : position + 1;
    var msg = initmsg;
    for (i = 0; i <= (82 / msg.length) + 1; i++) {
        msg += " " + msg;
        outmsg.innerHTML = "<nobr>" + msg.substring(position, position + 82).replace(" ", "&nbsp;") + "</nobr>";
    }
    position = (position == msg.length - 1) ? 0 : position + 1;
    setTimeout("outmsg_ticker()", 200);
} 
outmsg_ticker();