function highlight(element) {
	document.getElementById(element.id).style.backgroundColor="#CCFF66";
}

function dehighlight(element) {
	document.getElementById(element.id).style.backgroundColor="#FFFFFF";
}

function huge_pic(img,imgdiv,w,h,title,kerroin,path,zoom) {
	//alert(zoom);

	//if imagediv already exista, click causes div to close
if(document.getElementById("zoom_div_"+imgdiv)) {

	//alert("ikkuna is already open");
	close_zoom("zoom_div_"+imgdiv);
	close_zoom("holder_div_"+imgdiv);
	return;
	}

		TJPzoomamount=kerroin;

		//create div to hold zoomable image
		var akkuna=document.createElement("div");

		akkuna.style.width=w+"px";
		akkuna.style.height=h+"px";
		akkuna.setAttribute("id","zoom_div_"+imgdiv);
		akkuna.id="zoom_div_"+imgdiv;
		akkuna.style.backgroundColor="white";
		akkuna.style.borderColor="white";
		akkuna.style.border="solid 10px #C0C0C0";


		//create image inside the div
		var kuva=document.createElement('img');

		kuva.setAttribute("id","zoom_kuva_"+imgdiv);
		kuva.setAttribute("title","Click to close / klikkaa sulkeaksesi");
		kuva.id="zoom_kuva_"+imgdiv;
		//kuva.setAttribute('src','admin/upload/'+img); 
		kuva.setAttribute('src',path+img); 
		
		kuva.setAttribute('onclick','close_zoom("'+imgdiv+'")'); 
		if(navigator.userAgent.indexOf('MSIE')>-1) {
			kuva.onclick=function() {
				close_zoom("'+imgdiv+'");
			}
		}
		
		kuva.style.width=w;
		kuva.style.height=h;

		if(zoom==true) { kuva.setAttribute('onmouseover',"TJPzoom(this,\"admin/upload/original/"+img+"\")"); }
		//kuva.setAttribute('onmouseover',"TJPzoom(this,path+img)");

		//create div to hold iframe
		var holder=document.createElement("div");
		holder.setAttribute("id","holder_div_"+imgdiv);
		holder.id="holder_div_"+imgdiv;
		holder.style.width=(w+10)+"px";
		holder.style.height=(h+10)+"px";
		holder.style.position="absolute";
	


		//create a iframe behind the actual div :)
		var isoakkuna=document.createElement("iframe");
		
		isoakkuna.width=(w+10)+"px";
		isoakkuna.height=(h+10)+"px";
;
		//isoakkuna.style.border="yes";

		//kokeillaan suurennosta...
		/*
		isoakkuna.style.width="10px";
		isoakkuna.style.height="10px";
		*/

		isoakkuna.setAttribute("id","isoakkuna_div_"+imgdiv);
		isoakkuna.setAttribute("name","isoakkuna_div_"+imgdiv);
		isoakkuna.id="isoakkuna_div_"+imgdiv;
		isoakkuna.name="isoakkuna_div_"+imgdiv;

		/*
		isoakkuna.style.backgroundColor="white";
		isoakkuna.style.borderColor="white";
		
		
		isoakkuna.style.display="block";
		isoakkuna.style.background="#E1EA64";
		*/

		if(zoom==true) { 
			if(navigator.userAgent.indexOf('MSIE')>-1) {
				kuva.onmouseover=function() {TJPzoom(this,"admin/upload/original/"+img);}
				// kuva.onmouseover=function() {TJPzoom(this,path+img);}
			}
		}



		akkuna.style.position="absolute";
		akkuna.style.display="block";
		akkuna.style.background="#C0C0C0";

		// need to circumvent IE "feature"
		//this addition here is causing curious IE behaviour
		// no zoom at all?
		document.getElementById('body').appendChild(holder);
		document.getElementById(holder.id).appendChild(isoakkuna);
		position_center(holder.id);
		


		// original solution...
		document.getElementById('body').appendChild(akkuna);
		
		//isoakkuna.appendChild(akkuna);
		

		//create closelink
		var linktext = document.createTextNode("sulje x");
		var linkimg =document.createElement("img");
		linkimg.setAttribute('src','images/close.gif');
		linkimg.setAttribute('border','0');
		//linkimg.style.cssFloat="right";
		linkimg.style.marginTop="-10px";
		linkimg.style.marginLeft=(w-42)+"px";
		linkimg.style.position="absolute";

		var closelink=document.createElement('a');
		closelink.style.borderColor="#FFFFFF";
		closelink.setAttribute('href','javascript:void(0)');
		closelink.setAttribute('onclick','close_zoom("'+imgdiv+'")');
		

		if(navigator.userAgent.indexOf('MSIE')>-1) {
			closelink.onclick=function() {
				close_zoom(imgdiv);
			}
		}

		closelink.appendChild(linkimg);
		//isoakkuna.appendChild(akkuna);
		akkuna.appendChild(closelink);
		akkuna.appendChild(kuva);

		//kokeillaan...
		//suurennos(akkuna.id,w,h);

		position_center(akkuna.id);


}

/************************************************************************************/
function suurennos(element,toWidth,toHeight) {
		//alert(element+" "+toWidth+" "+toHeight); //ok
		//find the element in the document
		var elm=document.getElementById(element);

        //get the actual width of the element
        var actualWidth = parseInt(elm.style.width);
		var actualHeight = parseInt(elm.style.height);

       //calculate the change between the actual element
       //width and the final width
       var change     = toWidth-actualWidth;
		var changeH     = toHeight-actualHeight;

      //we add 10px to actual width
      var add=actualWidth+10;
	  var addH=actualHeight+10;
      elm.style.width  = add+'px';
	  elm.style.height  = addH+'px';

      //we wrap the changeWidth to pass it to the settimeout
      function innerChangeWidth() {
          suurennos(element,toWidth,toHeight);
		  //position center to viewport at every go...
		  position_center(elm.id);
      }
      //if the actual width and the final width difference
      // is superior to 0, we still need to improve the width
      if(change>0){
        var timer = setTimeout(innerChangeWidth,20);
      }
      //else we clear the timeout and stop the function.
      else {
        clearTimeout(timer);
        return true;
     }
}

/************************************************************************************/

function position_center(div) {

	if( document.getElementById ) {
		// Get a reference to divTest and measure its width and height.
		//alert(div);
		var div = document.getElementById (div);
		var divWidth = div.offsetWidth ? div.offsetWidth : div.style.width ? parseInt( div.style.width ) : 0;
		var divHeight = div.offsetHeight ? div.offsetHeight :  div.style.height ? parseInt( div.style.height ) : 0;
		
		// Calculating setX and setX so the div will be centered in the viewport.
		var setX = ( getViewportWidth() - divWidth ) / 2;
		var setY = ( getViewportHeight() - divHeight ) / 2;

		//take vertical scroll into account
		if(document.documentElement.scrollTop>0) {
		//alert(document.documentElement.scrollTop);
		var setY = (( getViewportHeight() + (document.documentElement.scrollTop*2))- divHeight ) / 2;
		}
		
		// If setX or setY have become smaller than 0, make them 0.
		if( setX < 0 ) setX = 0;
		if( setY < 0 ) setY = 0;


		
		// Position the div in the center of the page and make it visible.
		div.style.left = setX + "px";
		div.style.top = setY + "px";
		div.style.visibility = "visible";
	}
}

/************************************************************************************/


function getViewportWidth() {
	var width = 0;
	if( document.documentElement && document.documentElement.clientWidth ) {
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth ) {
		width = document.body.clientWidth;
	}
	else if( window.innerWidth ) {
		width = window.innerWidth - 18;
	}
	return width;
}

function getViewportHeight () {
	var height = 0;
	if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) {
		height = document.body.clientHeight;
	}
	else if( window.innerHeight ) {
		height = window.innerHeight - 18;
	}
	return height;
}
/************************************************************************************/

function close_zoom(item) {
//alert(item);
el=document.getElementById("zoom_div_"+item);
el.parentNode.removeChild(el);

el=document.getElementById("holder_div_"+item);
el.parentNode.removeChild(el);
}

/************************************************************************************/
<!-- 
//Browser Support Code
function ajaxFunction(id,action){
	//alert(id);
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//document.myForm.time.value = ajaxRequest.responseText;
		}
	}
	var age = document.getElementById('tarjous_'+id).value;

	//var cat = document.getElementById('category_'+id).value;

	//make checkbox.checked=true/false depending on what we chose

	var queryString = "?oid=" + id + "&action=" + action+ "&quantity="+quantity;
	ajaxRequest.open("GET", "" + queryString, true);
	ajaxRequest.send(null); 
}


