﻿
function fixImageUrls() {

    var image_site = 'http://www.rockypointstables.com'
    var imgs = $('div.page-htmlfrag').find('img');

    for (i = 0; i < imgs.length; i++) {
        // todo only run once.
        var oldurl = imgs.eq(i).attr('src');
        var newurl = image_site + oldurl;
        imgs.eq(i).attr('src', newurl);

    }
}

function isEmail(email) {
    var result = email.search(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,3})+$/);
    if (result > -1) { return true; } else { return false; }
}

function isValid() {
    if ($('.txtName').val() == '') {
        alert('Please enter your name.');
        $('.txtName').focus();
        return false;
    }
    if ($('.txtEmail').val() == '') {
        alert('Please enter an email address.');
        $('.txtEmail').focus();
        return false;
    }
    if (isEmail($('.txtEmail').val()) == false) {
        alert('Please enter a valid email address.');
        $('.txtEmail').select();
        return false;
    }
    if ($('.txtSubject').val() == '') {
        alert('Please enter a subject.');
        $('.txtSubject').focus();
        return false;
    }
    if ($('.txtMessage').val() == '') {
        alert('Please enter a message.');
        $('.txtMessage').focus();
        return false;
    }
    return true;
}
