//	set some variables
var revealed = 0;
var max_rate = 40;
var current_rate = 0;
var deceleration = 5;
var frame_rate = 100;
var delay_time = (1 / frame_rate) * 1000;

var list_el;
var container_el;

var list_width;
var list_height;
var list_top;

var interval_id;

var clicked = false;
var rolled_down = false;

function loader(get_switch) {
	if(get_switch == '') {
		drop_down('drop_down_list', 'list_container');
	}
}

function move_down() {
	//	go go super lister
	if(revealed == 0) {
		list_el.style.visibility = "visible";
	}
	
	//	grab the current speed
	current_rate = (list_height - revealed) / deceleration;
	if(current_rate > max_rate) {
		current_rate = max_rate;
	}
	revealed += current_rate;
	
	//	reveal the clip
	clip_revealed = list_height - revealed;
	list_el.style.clip = "rect(" + clip_revealed + "px 370px " + list_height + "px 0px)";
	
	//	feed the clip down
	list_el.style.top = list_top - clip_revealed + "px";
	
	//	push the content down
	container_el.style.paddingBottom = revealed + "px";
	
	//	stop the train wreck
	if(current_rate < 0.01) {
		clearInterval(interval_id);
		rolled_down = true;
		clicked = false;
	}
}

function move_up() {
	//	grab the current speed
	current_rate = revealed / deceleration;
	if(current_rate > max_rate) {
		current_rate = max_rate;
	}
	revealed -= current_rate;
	
	//	reveal the clip
	clip_revealed = list_height - revealed;
	list_el.style.clip = "rect(" + clip_revealed + "px 370px " + list_height + "px 0px)";
	
	//	feed the clip down
	list_el.style.top = list_top - clip_revealed + "px";
	
	//	push the content down
	container_el.style.paddingBottom = revealed + "px";
	
	//	stop the train wreck
	if(current_rate < 0.01) {
		list_el.style.visibility = "hidden";
		revealed = 0;
		rolled_down = false;
		clicked = false;
		list_el.style.top = list_top;
		clearInterval(interval_id);
	}
}

function drop_down(list_id, container_id) {
	if(clicked == false && rolled_down == false) {
		//	grab the object
		list_el = document.getElementById(list_id);
		container_el = document.getElementById(container_id);
		
		//	grab some values
		list_width = list_el.offsetWidth;
		list_height = list_el.offsetHeight;
		list_top = list_el.offsetTop;
		
		//	animation
		interval_id = setInterval("move_down()", delay_time);
		
		//	protect from re-firing
		clicked = true;
	}
	if(clicked == false && rolled_down == true) {
		//	animation
		interval_id = setInterval("move_up()", delay_time);
		
		//	protect from re-firing
		clicked = true;
	}
}