$(function(){
	
	$('a.linker').append('<img src="/inc/images/mach20_camera.png" style="float: left; margin-top: 3px; margin-right: 3px;" height="14" />');
	
	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  

    $("ul.topnav li span").click(function() { //When trigger is clicked...  
	        //Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
        $(this).parent().hover(function() {  
        }, function(){  
            $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up  
        });  
        //Following events are applied to the trigger (Hover events for the trigger)  
        }).hover(function() {  
            $(this).addClass("subhover"); //On hover over, add class "subhover"  
        }, function(){  //On Hover Out  
            $(this).removeClass("subhover"); //On hover out, remove class "subhover"  
    });
	
	$('#btn_request').click(function(){
		
		var reqField = 0;
		$.each($('#frm_collect input[class~="req"]'), function(i,v){
			if($(this).val().length == 0){
				$('label[for='+$(this).attr('id')+']').addClass('bold');
				reqField++;
			}
		});
		
		if(reqField != 0){
			alert('Please complete the required fields');
			return false;
		}

		$.ajax({
			url: '/inc/cfc/actions.cfc?method=requestForm',
			data: $('#frm_collect').serialize(),
			success: function(){
				$('#frm_collect')[0].reset();
				alert('Thanks for your request. A mach20autos representative will contact you shortly.');
			}
		})
		return false;
	})
})
