$(document).ready(function(){	
	
	// switch button
	$("#btn_cloud_1").toggle(
		function(){
			$("#tags ul").hide().addClass("alt").fadeIn("fast");
		},
		function(){
			$("#tags ul").hide().removeClass("alt").fadeIn("fast");
		}
	);
	
	// create a sort by alphabet button
	$("#btn_cloud_2").toggle(
		function(){
			$("#tags ul li").tsort({order:"asc"});
		},	
		function(){
			$("#tags ul li").tsort({order:"desc"});
		}		
		);	
	
	// create a sort by alphabet button	
	$("#btn_cloud_3").toggle(
		function(){
			$("#tags ul li").tsort({order:"desc",attr:"class"});
		},	
		function(){
			$("#tags ul li").tsort({order:"asc",attr:"class"});
		}		
		);
});


function set_tag(total_set,imo_id){
					
				   imo_perc = (total_set / total_imo)*100;
				   //alert(imo_perc);
					if (imo_perc <= 2) {
					$('#imo_'+imo_id).removeClass().addClass('tag1');
					} else if (imo_perc > 2 && imo_perc <= 10 ) {
					$('#imo_'+imo_id).removeClass().addClass('tag2');
					} else if (imo_perc > 10 && imo_perc <= 20 ) {
					$('#imo_'+imo_id).removeClass().addClass('tag3');
					} else if (imo_perc > 20 && imo_perc <= 50 ) {
					$('#imo_'+imo_id).removeClass().addClass('tag4');
					} else {
					$('#imo_'+imo_id).removeClass().addClass('tag5');
					}
	
	};
