maintenanceReset= function(){
	$('input, select, textarea').removeClass();
}
maintenanceSend = function(form){
	$('input, select, textarea').removeClass();
	window['wok'] = 0;
	window['werr'] = '';
	window['wfoc'] = '';
    if(form.yacc.value == '' || form.yacc.value == 'account number'){
		window['wok'] = 1;
		window['werr'] += '\t- Your Account Number\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'yacc';
		}
		$('#yacc').removeClass('valid');
		$('#yacc').addClass('error');
	} else {
		$('#yacc').removeClass('error');
		$('#yacc').addClass('valid');
	}
	if(form.yfname.value == '' || form.yfname.value == 'first name'){
		window['wok'] = 1;
		window['werr'] += '\t- Your First Name\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'yfname';
		}
		$('#yfname').removeClass('valid');
		$('#yfname').addClass('error');
	} else {
		$('#yfname').removeClass('error');
		$('#yfname').addClass('valid');
	}
	if(form.ysname.value == '' || form.ysname.value == 'surname'){
		window['wok'] = 1;
		window['werr'] += '\t- Your Surname\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'ysname';
		}
		$('#ysname').removeClass('valid');
		$('#ysname').addClass('error');
	} else {
		$('#ysname').removeClass('error');
		$('#ysname').addClass('valid');
	}
    if(form.yadd1.value == '' || form.yadd1.value == 'first line of your address'){
		window['wok'] = 1;
		window['werr'] += '\t- The First Line of your Address\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'yadd1';
		}
		$('#yadd1').removeClass('valid');
		$('#yadd1').addClass('error');
	} else {
		$('#yadd1').removeClass('error');
		$('#yadd1').addClass('valid');
	}
    if(form.ypcode.value == '' || form.ypcode.value == 'postcode'){
		window['wok'] = 1;
		window['werr'] += '\t- Your Postcode\n';
		if(window['wfoc']==''){
			window['wfoc'] = 'ypcode';
		}
		$('#ypcode').removeClass('valid');
		$('#ypcode').addClass('error');
	} else {
		$('#ypcode').removeClass('error');
		$('#ypcode').addClass('valid');
	}
    var tel = /^[0-9 ]+$/;
    if(!tel.test(form.ytel.value)){
        window['wok'] = 1;
        window['werr'] += '\t- Your Contact Telephone Number\n';
        if(window['wfoc']==''){
            window['wfoc'] = 'ytel';
        }
        $('#ytel').removeClass('valid');
        $('#ytel').addClass('error');
    } else {
        $('#ytel').removeClass('error');
        $('#ytel').addClass('valid');
    }
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(!filter.test(form.yemail.value)){
        window['wok'] = 1;
        window['werr'] += '\t- Your Email Address\n';
        if(window['wfoc']==''){
            window['wfoc'] = 'yemail';
        }
        $('#yemail').removeClass('valid');
        $('#yemail').addClass('error');
    } else {
        $('#yemail').removeClass('error');
        $('#yemail').addClass('valid');
	}
    if(form.ymain.value == '' || form.ymain.value == 'Details of your request'){
    	window['wok'] = 1;
        window['werr'] += '\t- Details of your Maintenance Request\n';
        if(window['wfoc']==''){
            window['wfoc'] = 'ymain';
        }
        $('#ymain').removeClass('valid');
        $('#ymain').addClass('error');
    } else {
        $('#ymain').removeClass('error');
        $('#ymain').addClass('valid');
    }
	if(form.code.value == ''){
		window['wok'] = 1;
		window['werr'] += '\t- Security Check\n';
		if(window['wfoc'] == ''){
			window['wfoc'] = 'code';
		}
		$('#code').removeClass('valid');
		$('#code').addClass('error');
			if(window['wok']==1){
				alert('We encountered to following errors when to send your submission.\n\n'+window['werr']+'');
				eval('el("'+window['wfoc']+'").focus();');
			}
	} else {
		$.post('../../_rsc/chk.php',{code: form.code.value}, function(data){
																	  if(data == 'tpp_pass'){
																		  $('#code').removeClass('error');
																		  $('#code').addClass('valid');
																		if(window['wok']==1){
																			alert('We encountered to following errors when trying to send your submission.\n\n'+window['werr']+'');
																			eval('el("'+window['wfoc']+'").focus();');
																		} else {
																			$('#maintenance').fadeTo(100,0.01,function(){
																				$.post('../../_rsc/maintenancerequest.php',{
                                                                                	   yacc: el('yacc').value,
																					   yfn:  el('yfname').value,
																					   yln:  el('ysname').value,
																					   yadd1:el('yadd1').value,
																					   ypcode:el('ypcode').value,
																					   ytel: el('ytel').value,
																					   yem:  el('yemail').value,
																					   ydet: el('ymain').value,
																					   n: ((el('wnews').checked)?'Y':'N')
																					},function(data){
																					if(data=='tpp_pass'){
																						el('maintenance').innerHTML = '<h3>Submission Successful</h3><p>Thank you for your maintenance request - a member of our team will receive all your details shortly and will be in touch with any updates as required.</p>';
																						$('#maintenance').fadeTo(100,1);
																					} else {
																						el('image').src = '../../_img/securimage_show.php?sid=' + Math.random();
																						$('#maintenance').fadeTo('fast',1,function(){
																							alert(data);
																						});
																					}
																				}, "html");
																		   });
																		}
																	  } else {
																		  window['wok'] = 1;
																		  window['werr'] += '\t- Incorrect Security Code\n';
																		  if(window['wfoc'] == ''){
																			  window['wfoc'] = 'code';
																		  }
																		  el('image').src = '../../_img/securimage_show.php?sid=' + Math.random();
																		  $('#code').removeClass('valid');
																		  $('#code').addClass('error');
																		  	if(window['wok']==1){
																				alert('We encountered to following errors when trying to send your submission.\n\n'+window['werr']+'');
																				eval('el("'+window['wfoc']+'").focus();');
																			}
																	  }
																	  },"html");
	}
}
wCM = function(val){
	if(val=='SMS'){
		$('#ct1').slideUp('fast', function(){
											 $('#ct2').slideDown('fast');
											 });
	} else if(val=="Email") {
		$('#ct2').slideUp('fast', function(){
											 $('#ct1').slideDown('fast');
											 });
	} else {
		$('#ct2').slideUp('fast');
		$('#ct1').slideUp('fast');
	}
}
verAdd = function(val){
	if(val==true){
		el('padd1').value = el('yadd1').value;
		el('padd2').value = el('yadd2').value;
		el('padd3').value = el('yadd3').value;
		el('pstate').selectedIndex = el('ystate').selectedIndex;
		el('ppcode').value = el('ypcode').value;
	} else {
		el('padd1').value = 'address line 1';
		el('padd2').value = 'address line 2';
		el('padd3').value = 'address line 3';
		el('pstate').selectedIndex = 0;
		el('ppcode').value = 'postcode';
	}
}
