$(document).ready(function(){
						   
	$('select.selectbox').css('display','none');
	$('.customselect').css('display','block');
	
	$('.selectdropdown li').hover(function () {
		$(this).stop().css({'background-color' : '#ffffff'});}, function () { $(this).stop().css({'background-color' : '#edeff1'});
	});
	
	
	
	$('.customselect').each(function(){
	
		var currentSel = $(this);
		var currentValue = $(currentSel).prev().find('option:selected').attr('value');
		
		if(currentValue >=1 || currentValue =='' ){
			currentText = $(currentSel).prev().find('option:selected').text();
			$(currentSel).find('.button').text(currentText);
		} else {
			$(currentSel).find('li#first').hide();
			$(currentSel).find('li:first-child').hide();
		}
		
		$(currentSel).find('.button').click(function(){
			
			if( $(this).next().css('display') == 'none' ) {
				
				$('.selectdropdown').fadeOut(100);
				$(this).next().slideDown(200);
				$(this).addClass('selected');
				
				// CHECK IF ITS A MULTICOLUMN, ADD CLICK FUNCTION FOR THE DIFFERENT STRUCTURE
				if( $(currentSel).hasClass('locationselect')) {
					$(currentSel).find('li#first').click(function(){
						newValue = $(this).attr('class');
						newText = $(this).text();
						$(currentSel).prev().attr('value', newValue);
						$(this).parent().parent().parent().prev().text(newText);
						$(this).parent().parent().parent().fadeOut(100);
						$(currentSel).find('li#first').hide();
					});
					$(currentSel).find('li li').click(function(){
						newValue = $(this).attr('class');
						newText = $(this).text();
						$(currentSel).prev().attr('value', newValue);
						$(this).parent().parent().parent().parent().parent().prev().text(newText);
						$(this).parent().parent().parent().parent().parent().fadeOut(100);
						$(currentSel).find('li#first').show();
					});
				// OR IF ITS A REGULAR SINGLE LEVEL DROP DOWN, USE THIS CLICK FUNCTION
				} else {
					$(currentSel).find('li').click(function(){
						newValue = $(this).attr('class');
						newText = $(this).text();
						$(currentSel).prev().attr('value', newValue);
						$(this).parent().parent().parent().prev().text(newText);
						$(this).parent().parent().parent().fadeOut(100);
						$(currentSel).find('li:first-child').show();
					});
					$(currentSel).find('li:first-child').click(function(){
						newValue = $(this).attr('class');
						newText = $(this).text();
						$(currentSel).prev().attr('value', newValue);
						$(this).parent().parent().parent().prev().text(newText);
						$(this).parent().parent().parent().fadeOut(100);
						$(currentSel).find('li:first-child').hide();
					});
					
				}
				
				$(document.window || 'body').click( function() {
					if( $(currentSel).find('.selectdropdown').css('display') == 'block' ) {
						$(currentSel).find('.selectdropdown').fadeOut(100);
						$(currentSel).find('.button').removeClass('selected');
					} else { }
				});
				return false;
				
				
				$('.selectdropdown li').hover(function () {
					$(this).stop().css({'background-color' : '#ffffff'});}, function () { 
					$(this).stop().css({'background-color' : '#edeff1'});
				});
				
			} else {
				
				$(this).next().hide();
				$(this).removeClass('selected');
				
			}
		});
	});

});


