function ajaxme() {
	CSBfleXcroll('mycustomscroll2');
	CSBfleXcroll('mycustomscroll4');
	updatecheckboxesbag();
	
	$$('.overlay_item_bagit').addEvent('mouseenter', function(){
			$('overlay_bag_gear_overlay').setStyles({
    		display:'block',
    		opacity: 0});
		new Fx.Style($('overlay_bag_gear_overlay'), 'opacity', {duration: 500}).start(0,1);
		});
		$$('.overlay_item_bagit').addEvent('mouseleave', function(){
		$('overlay_bag_gear_overlay').setStyles({
    		
    		opacity: 1});
		new Fx.Style($('overlay_bag_gear_overlay'), 'opacity', {duration: 500, 
					 onComplete: function() {
						 $('overlay_bag_gear_overlay').setStyles({
			    		display:'none'
    					});
					 }
					 }).start(1,0);
		});
	
	
	var score = $$('#star_score img');
	score.each(function(element) {
	element.addEvent('click', function(){
									   
			for (var i = 1; i<=score.length; i++)
			{
				var newimg = $('rating_'+i).src;
				newimg = newimg.replace('_on','_off');
				$('rating_'+i).src = newimg;
			}
			
			for (var i = 1; i<=(element.id.replace('rating_','')); i++)
			{
				var newimg = $('rating_'+i).src;
				newimg = newimg.replace('_off','_on');
				$('rating_'+i).src = newimg;
			}
			
			
			$('rating_score').value = element.id.replace('rating_','');
			
		});
	
		
	});
	
	$('submit_comment').addEvent('click', function(e) {
	e = new Event(e).stop();
	url = "component.aspx?mode=addcomm&auth="+ $('input_name').value;
	url = url + "&authcity=" + $('input_city').value;
	url = url + "&authstate=" + $('input_state').value;
	url = url + "&rating=" + $('rating_score').value;
	url = url + "&comment=" + $('input_comments').value;
	url = url + "&component=" + $('input_component').value;
	url = url + "&category=" + $('input_comment_type').value;
	validatecomments();
	
});

	
}

var url;

var validatecomments = function() {
	var formpass = true;
	if ($('input_name').value == '' || $('input_name').value == ' ' || $('input_name').value.match(/^  +/) ) {
		$('input_name').style.border = '1px solid red';
		formpass= false;
	}
	
	else {
		$('input_name').style.border = '1px solid #666666';
	}
	
	if ($('input_city').value == '' || $('input_city').value == ' ' || $('input_city').value.match(/^  +/) ) {
		$('input_city').style.border = '1px solid red';
		formpass= false;
	}
	
	else {
		$('input_city').style.border = '1px solid #666666';
	}
	
	
	if ($('input_comments').value == '' || $('input_comments').value == ' ' || $('input_comments').value.match(/^  +/) || checkMaxLength() ) {
		$('input_comments').style.border = '1px solid red';
		formpass = false;
	}
	
	else {
		$('input_comments').style.border = '1px solid #666666';
	}
	
	if ($('input_comment_type').value == 'null') {
		$('input_comment_type').style.border = '2px solid red';
		$('category_error').style.left = '120px';
		$('category_error').style.top = '-5px';
		formpass = false;
	}
	
	else {
		$('input_comment_type').style.border = '2px solid #666666';
		$('category_error').style.left = '-9999px';
	}
	
/*	if(checkMaxLength) {
		$('input_comments').style.border = '1px solid red';
		formpass = false;
	}*/
	
	if (formpass != false) {
	new Ajax(url, {
		method: 'POST',
		update: $('comment_section')
	}).request();
	
	track('systembuilder_submit_'+$('input_component').value);
	}
}

function checkMaxLength() {
	var maxLength = 500;
	var currentLength = $('input_comments').value.length;
	if (currentLength > maxLength) {
		return true;
	} else {
		return false;
	};
}
