function init() {
	document.getElementById('contactform').onsubmit=function() {
		document.getElementById('contactform').target = 'upload_target';
		document.getElementById('contactsub').disabled = true;
	}

}

   $(document).ready(function(){
	
		$('#workreq').hide();
   		$("#date").datepicker({showOn: 'button', buttonImage: '/wil2/images/calendar.gif', buttonImageOnly: true});

		$("#date").focus(function(){
			if (this.value == 'mm/dd/yyyy') {
				this.value = '';
			}	
			$(this).css('color', '#222');
		}).blur(function() {
			if (this.value == '') {
				this.value = 'mm/dd/yyyy';
				$(this).css('color', '#999');
			}
		});
		
		$("#validTel").focus(function(){
			if (this.value == '(xxx) xxx-xxxx') {
				this.value = '';
			}	
			$(this).css('color', '#222');
		}).blur(function() {
			if (this.value == '') {
				this.value = '(xxx) xxx-xxxx';
				$(this).css('color', '#999');
			}
		});
		
		$('#requesttype').change(function() {
			if ($("#requesttype option:selected").val() == "workreq") {
				$('#workreq').slideDown();
			} else {
				$('#workreq').slideUp();
			}
		});

		$('.tablink').click(function() {
			$(this).prev().slideToggle();
		});
		
		$('#contactsub').click(function() {
			var clear = 0;
			if($('#validName').val() == "") {
				$('.namelabel').css('color', '#cc0000');
			} else {
				$('.namelabel').css('color', '#000000');
				clear++;
			}
			if($('#validEmail').val() == "") {
				$('.emaillabel').css('color', '#cc0000');
			} else {
				$('.emaillabel').css('color', '#000000');
				clear++;
			}
			if($('#validDomain').val() == "" || $('#validDomain').val() == "http://") {
				$('.domainlabel').css('color', '#cc0000');
			} else {
				$('.domainlabel').css('color', '#000000');
				clear++;
			}
			if($('#validTel').val() == "" || $('#validTel').val() == "(xxx) xxx-xxxx") {
				$('.phonelabel').css('color', '#cc0000');
			} else {
				$('.phonelabel').css('color', '#000000');
				clear++;
			}
			if($('#requesttype').val() == "") {
				$('.naturelabel').css('color', '#cc0000');
			} else {
				$('.naturelabel').css('color', '#000000');
				clear++;
			}
			if (clear == 5) {
				$(this).hide();
				$('#formresult').show();
				return true;
			} else {
				return false;
			}
		});
		
		init();
		
	});