/**
 * @author chardcastle
 */

if(junk == null){
	var junk = {};
};
junk.estimator={
	wasteImgPath: "/tpl/anyjunk/images/volumeEstimator/volumes/wasteSizes/",
	truckImgPath: "/tpl/anyjunk/images/volumeEstimator/volumes/trucks/",
	defaultSelected:"l", // lower case L
	init: function(){
		junk.estimator.addEvents();
	},
	addEvents: function(){
		junk.estimator.addMyFunctionsToEvent("a");
		junk.estimator.addMyFunctionsToEvent("b");
		junk.estimator.addMyFunctionsToEvent("c");
		junk.estimator.addMyFunctionsToEvent("d");
		junk.estimator.addMyFunctionsToEvent("e");
		junk.estimator.addMyFunctionsToEvent("f");
		junk.estimator.addMyFunctionsToEvent("g");
		junk.estimator.addMyFunctionsToEvent("h");
		junk.estimator.addMyFunctionsToEvent("i");
		junk.estimator.addMyFunctionsToEvent("j");
		junk.estimator.addMyFunctionsToEvent("k");
		junk.estimator.addMyFunctionsToEvent("l");
		junk.estimator.addMyFunctionsToEvent("m");
	},
	addMyFunctionsToEvent: function(id){
		var element = $(id);
		element.addEvent("mouseenter",junk.estimator[id]);
		element.addEvent("mouseleave",junk.estimator.reset[id]);
		if(!element){alert("element not set");}	
	},
	clearDefaultSelect: function(){
		if($(junk.estimator.defaultSelected).hasClass("selected")){
			$(junk.estimator.defaultSelected).addClass("notSelected");			
			$(junk.estimator.defaultSelected).removeClass("selected");
			$(junk.estimator.defaultSelected+"Inner").addClass("notSelectedInner");			
			$(junk.estimator.defaultSelected+"Inner").removeClass("selectedInner");			
		}
	},
	addSelected: function(id){
		if(id != junk.estimator.defaultSelected){
			junk.estimator.clearDefaultSelect();
		}
		$(id).addClass("selected");	
		$(id).removeClass("notSelected");
		$(id+"Inner").addClass("selectedInner");		
		$(id+"Inner").removeClass("notSelectedInner");	
	},
	removeSelected: function(id){						
		$(id).addClass("notSelected");
		$(id).removeClass("selected");
		$(id+"Inner").addClass("notSelectedInner");	
		$(id+"Inner").removeClass("selectedInner");				
	},
	updateTruckCaption: function(message){
		$("truckDesc").innerHTML = message;
	},
	a: function(){
		junk.estimator.updatePictures("a.jpg");	
		junk.estimator.addSelected("a");
		junk.estimator.updateTruckCaption("Min Charge");
	},
	b: function(){
		junk.estimator.updatePictures("b.jpg");	
		junk.estimator.addSelected("b");
		junk.estimator.updateTruckCaption("1/8 Truckload");
	},	
	c: function(){
		junk.estimator.updatePictures("c.jpg");	
		junk.estimator.addSelected("c");
		junk.estimator.updateTruckCaption("1/6 Truckload");
	},
	d: function(){
		junk.estimator.updatePictures("d.jpg");	
		junk.estimator.addSelected("d");
		junk.estimator.updateTruckCaption("1/4 Truckload");
	},
	e: function(){
		junk.estimator.updatePictures("e.jpg");
		junk.estimator.addSelected("e");
		junk.estimator.updateTruckCaption("1/3 Truckload");
	},	
	f: function(){
		junk.estimator.updatePictures("f.jpg");
		junk.estimator.addSelected("f");
		junk.estimator.updateTruckCaption("3/8 Truckload");
	},	
	g: function(){
		junk.estimator.updatePictures("g.jpg");
		junk.estimator.addSelected("g");
		junk.estimator.updateTruckCaption("1/2 Truckload");
	},	
	h: function(){
		junk.estimator.updatePictures("h.jpg");
		junk.estimator.addSelected("h");
		junk.estimator.updateTruckCaption("5/8 Truckload");
	},	
	i: function(){
		junk.estimator.updatePictures("i.jpg");
		junk.estimator.addSelected("i");
		junk.estimator.updateTruckCaption("2/3 Truckload");
	},	
	j: function(){
		junk.estimator.updatePictures("j.jpg");
		junk.estimator.addSelected("j");
		junk.estimator.updateTruckCaption("3/4 Truckload");
	},	
	k: function(){
		junk.estimator.updatePictures("k.jpg");
		junk.estimator.addSelected("k");
		junk.estimator.updateTruckCaption("5/6 Truckload");
	},	
	l: function(){
		junk.estimator.updatePictures("l.jpg");
		junk.estimator.addSelected("l");
		junk.estimator.updateTruckCaption("7/8 Truckload");
	},	
	m: function(){
		junk.estimator.updatePictures("m.jpg");
		junk.estimator.addSelected("m");
		junk.estimator.updateTruckCaption("Full Load");
	},										
	updatePictures: function(imageId){
		$("wasteImage").src = junk.estimator.wasteImgPath+imageId;
		$("truckImage").src = junk.estimator.truckImgPath+imageId;
	}
};
junk.estimator.reset = {
	a: function(){
		junk.estimator.removeSelected("a");
	},
	b: function(){
		junk.estimator.removeSelected("b");
	},
	c: function(){
		junk.estimator.removeSelected("c");
	},
	d: function(){
		junk.estimator.removeSelected("d");
	},
	e: function(){
		junk.estimator.removeSelected("e");
	},
	f: function(){
		junk.estimator.removeSelected("f");
	},
	g: function(){
		junk.estimator.removeSelected("g");
	},
	h: function(){
		junk.estimator.removeSelected("h");
	},
	i: function(){
		junk.estimator.removeSelected("i");
	},
	j: function(){
		junk.estimator.removeSelected("j");
	},
	k: function(){
		junk.estimator.removeSelected("k");
	},
	l: function(){
		junk.estimator.removeSelected("l");
	},
	m: function(){
		junk.estimator.removeSelected("m");
	}	
}
