if (navigator.appVersion.match('MSIE 6.0')) {
  window.onresize=resizeBox;
  document.write('<style>.errbox {position: absolute; top: expression( ( ignoreMe = document.documentElement.scrollTop ) + \'px\' );}</style>');
}

function resizeBox() {
  var myWidth = document.documentElement.clientWidth;
  if (myWidth < 760 ) myWidth = 800;
  document.getElementById('errbox').style.left  = -myWidth/2 + 380
  document.getElementById('errbox').style.width = (myWidth-22) + 'px';
}

function valContact()
{
     $('div.errbox').hide('slow');
    var error     = new Array();
    var errorText = '';
    var i     = 0;
    var text  = '';
    var k     = document.getElementById('validate');
    if (!document.getElementById('Business_Name').value) {
        error[i++] = 'Business Name';
        highLight('Business_Name');
    } else {
        unHighLight('Business_Name');
    }
    if (!document.getElementById('Contact_Name').value) {
        error[i++] = 'Contact Name';
        highLight('Contact_Name');
    } else {
        unHighLight('Contact_Name');
    }
    if (!document.getElementById('Position').value) {
        error[i++] = 'Position';
        highLight('Position');
    } else {
        unHighLight('Position');
    }
    if (!document.getElementById('Email').value || !/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,}$/.test(document.getElementById('Email').value)) {
        error[i++] = 'Email';
        highLight('Email');
    } else {
        unHighLight('Email');
    }
    if (!document.getElementById('Phone').value || !/^[0-9 ]+$/.test(document.getElementById('Phone').value)) {
        error[i++] = 'Phone';
        highLight('Phone');
    } else {
        unHighLight('Phone');
    }
    if (!document.getElementById('Business_Sector').value) {
        error[i++] = 'Business Sector';
        highLight('Business_Sector');
    } else {
        unHighLight('Business_Sector');
    }
    if (!document.getElementById('Enquiry').value && document.getElementById('Form').value == 'contact') {
        error[i++] = 'Enquiry';
        highLight('Enquiry');
    } else if (document.getElementById('Form').value == 'contact') {
        unHighLight('Enquiry');
    }
    if (!document.getElementById('Security_Code').value || !/^[a-zA-Z0-9]{6}$/.test(document.getElementById('Security_Code').value)) {
        error[i++] = 'Security Code';
        highLight('Security_Code');
    } else {
        unHighLight('Security_Code');
    }
    if (error.length) {
        if (i > 1) {
            text = ' fields are';
        } else {
            text = ' field is';
        }

        errorText = 'The ' + error.join(', ') + text + ' filled improperly - please complete these fields';
    }
    if (document.getElementById('Form').value == 'sing_up' && document.getElementById('Terms').checked == false) {
        text = '';
        if (i) {
            text = ', also p';
        } else {
            text = ' P';
        }
        errorText += text + 'lease accept Terms and Conditions';
        i++;
    }
    k.innerHTML = errorText + '.';
    if (i) {
        if (navigator.appVersion.match('MSIE 6.0')) {
          resizeBox();
        }
        $('div.errbox').show('slow');
        return false;
    } else {
        return true;
    }
}

function highLight(id) {
    var form = document.getElementById(id);
    var div  = document.getElementById('div_' + id);

    form.style.borderColor = "#F6A2A2";
    div.style.color        = "#FF0000";
    div.style.borderColor  = "#FF0000";
}

function unHighLight(id) {
    var form = document.getElementById(id);
    var div  = document.getElementById('div_' + id);

    form.style.borderColor = "#AFAFAF";
    div.style.color = "#333333";
    div.style.borderColor = "#F6A2A2";
}