

function vaihdaIsoKuva(src,txt){
 	document.body.style.cursor="wait";
 
	if(document.getElementById('galleria_iso_kuva')){
		document.getElementById('galleria_iso_kuva').setAttribute('src',src);
		
		if(document.getElementById('galleria_iso_kuvateksti')){
		 	asetaTeksti(document.getElementById('galleria_iso_kuvateksti'),txt);
		}//end if
	}//end if

 	document.body.style.cursor="default";
}//end function


function haeKuva(tyyppi,id,suunta){
  	var param = 'tyyppi=' + tyyppi + '&id=' + id + '&suunta=' + suunta;
  	
  	teeAjaxKutsu('ajax/haeKuva.php',param,handleHaeKuva);
}//end function


function handleHaeKuva(){
  	if (xmlhttp.readyState == 4) {
        /* If the data was retrieved successfully */
   	    if (xmlhttp.status == 200){
            var xmlDocument = xmlhttp.responseXML;
            var kuvat = xmlDocument.getElementsByTagName('kuva');

			if(kuvat.length>0){
			  	for(i=0; i<kuvat.length; i++){
				  	var img = document.getElementById('kuvapalsta_kuva'  + (i+1));
				  	
				  	img.setAttribute('src',kuvat[i].getAttribute('polku'));
				}//end for
			}//end if
        }//end if
    }//end if
}//end function
	
	
function asetaTeksti(otus,arvo){
    if(IEselain){
        otus.innerText=arvo;
    }else{
        otus.textContent=arvo;
    }//end if
}//end if


function teeAjaxKutsu(ajaxFile,parametrit,handleFile){
	if (xmlhttp!=null && xmlhttp.readyState !=0 && xmlhttp.readyState !=4) {

	}else{
	    xmlhttp.open("POST", ajaxFile, true);

	    xmlhttp.onreadystatechange = handleFile;
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.send(parametrit);
 	} //end if
}//end function
	

