var i = 0.0;
var display = 0.0;
var browser=navigator.appName;
var imagecode = "";

function setTTSImageCode(thecode) {
	imagecode = thecode;
	document.getElementById("mainimagecontainer").innerHTML = imagecode;
	i=0;
}

function filter(x) 
{
	if(browser=="Microsoft Internet Explorer") {
	
		if(x == "dec" && (i <0 && i >= -0.15)) {
			i = -0.1;
		} else {
			if(x == "dec" && (i < 0.2 && i >= 0)) {
				i = -0.9;
			} else {
				if(x == "dec" && i > 0) {
					i = i - 0.1;
				} else {
					if(x == "inc" && i == -0.9) {
						i = 0.0;
					} else {			
						if(x == "inc" && i < -0.1) {
							i = i - 0.1;
						} else {			
							if(x == "inc" && i == -0.1) {
								i = 0.1;
							} else {
								i = i + 0.1;
							}
						}
					}
				}
			}
		}
			
		display = i;
		
		//This is dumb as hell to have to go backwards for IE	
		if (i >= -0.9 && i < -0.8)
			display = -0.1;
		if (i >= -0.8 && i < -0.7)
			display = -0.2;
		if (i >= -0.7 && i < -0.6)
			display = -0.3;
		if (i >= -0.6 && i < -0.5)
			display = -0.4;
		if (i >= -0.5 && i < -0.4)
			display = -0.5;
		if (i >= -0.4 && i < -0.3)
			display = -0.6;
		if (i >= -0.3 && i < -0.2)
			display = -0.7;
		if (i >= -0.2 && i < -0.1)
			display = -0.8;
		if (i >= -0.1 && i < 0) {
			display = -0.9;
			//i = 0.1;
		}
			
		//alert(i + ",  " + display);


	} else {
		
		if(x == "inc") {
			i += 0.1;
		}
	
		if(x == "dec") {
			i -= 0.1;
		}
	
		if(i < -0.9) {
			i = -0.9;
		}
					
		display = i;

	
	}

	if(x == "reset") {
		i = 0.0;
	}
	if(i > 0.9) {
		i = 0.9;
	}
	//document.getElementById("currentval").innerHTML = Math.round(display*100) +  "%";

	//document.getElementById("currentval").innerHTML = Math.round(i*10)/10;
	//alert(imagecode);

	document.getElementById("mainimagecontainer").innerHTML = imagecode;


	//"<img src=\"01-Barnard-150-4h.jpg\" id=\"mainimage\"/>"
	
	//<img src="<?php echo "/user_images/" . $id . "_images/" . $current_entry_date. "/" . $filelist[0];?>" width=<? if($imagewidths[0] >=600) { echo "600"; } else { echo $imagewidths[0]; } ?> id="mainimage" border="0">
	
	
	jsImageFX.doImage(document.getElementById("mainimage"), 'lighten(amount=' + i + ')');

}

