Event.observe(window,'load',function(){

var btn = $('send_btn');

Event.observe(btn, 'click', function(event){

btn.disable();

var required = $('contact-form').getElementsByClassName('inputreq');

required.each(function(thisInput){

var id = thisInput.identify();

var req = " *";

if(!$(id).next('span.req_err'))
new Insertion.After($(id),'<span class="req_err"></span>');

if($(id).present() == false){
$(id).next('span.req_err').update(req);
$A
}else{
$(id).next('span.req_err').remove();
}
});

var arr = $A($('contact-form').getElementsByClassName('req_err'));

if(arr == 0)
{
var sss = "email_send.php";

new Ajax.Request(sss, 
{
method: 'post', 
parameters: $('contact-form').serialize(true),
onSuccess : function(resp)
{

if (resp.responseText.match("notvalid"))
{
alert('Sorry the validation code is incorrect. Please try again!');

$('valid').clear();
$('valid').focus();
}
else if (resp.responseText.match("error"))
{
if($('top_err')){
$('top_err').remove();

}else{
alert('Sorry an error occurred, please try again later!');

}
}
else if (resp.responseText.match("success"))
{
if($('top_err')){
$('top_err').remove();

}

if($('top_msg')){
$('top_msg').remove();

}else{
alert('Your email has been successfully sent. A PC Seafoods representative will be in contact with you within 48hrs.');
}
$('contact-form').reset();

}
else
{
alert(resp.responseText);
}
}
});
}

event.stop();

btn.enable();
}, false);

Event.observe('newVal', 'click', function(evt){

new Ajax.Request('new_captcha.php', 
{
method: 'get', 
onSuccess : function(res)
{
$('captimg').update(res.responseText);
}
});
});

});
