$(document).ready(function() {
	$("select").each(function() {
		styled_box = '<div class="select" id="'+$(this).attr('class')+'"><div>'+$(this).attr('value')+'</div><div class="options">';
		for(i=0; i<$(this).children().length; i++)
		{
			styled_box += '<div class="option">'+$($(this).children()[i]).html()+'</div>';
		}
		styled_box = '</div></div>';
		$(this).after(styled_box);
		$("select").hide();
		$(".select").show();
		$(".select .selected").click(function() {
			if($(this).parent().children(".options").css("display")=="none")
			{
				$(this).parent().children(".options").css("display","block");
				$(this).parent().css("border-bottom","none");
				$(this).html("Select One");
			}
			else
			{
				$(this).parent().children(".options").css("display","none");
				$(this).parent().css("border-bottom","1px solid #a1a1a4");
				$(this).html($("."+$(this).parent().attr("id")).children("option:selected").html());
			}
		});
		$(".option").click(function() {
			$(this).siblings(".option.selected").removeClass("selected");
			$(this).addClass("selected");
			$(this).parent().css("display","none");
			$(this).parent().parent().css("border-bottom","1px solid #a1a1a4");
			$("."+$(this).parent().parent().attr("id")).attr('value',$("."+$(this).parent().parent().attr("id")).children("option:contains('"+$(this).html()+"')").attr('value'));
			$(this).parent().siblings(".selected").html($(this).html());
		});
	});
});
