<!--

function fillSelectList(xmlhttp){
	
	if (xmlhttp.readyState==4 && xmlhttp.status==200){
		objects=JSON.parse(xmlhttp.responseText);
		select=document.getElementById('StationSelect');
		for(id in objects){
			select.add(new Option(objects[id].station_name,objects[id].station_id),null);
		}
	}
}

function fillTable(table,objects,column_ids){
	rowIndex=1
	clearTable(table,rowIndex);
	for(id in objects){
		table.insertRow(rowIndex);
		table.rows[rowIndex].id=id;
		for(i in column_ids)
			table.rows[rowIndex].insertCell(column_ids[i]);		
		for(field in objects[id]){
			cellIndex=column_ids[field]
			if(cellIndex!=null)
				table.rows[rowIndex].cells[cellIndex].innerHTML=objects[id][field];
		}
		rowIndex=rowIndex+1;
	}
}
function sendAjaxRequest(url,callback_function){
	var xmlhttp;
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
		callback_function(xmlhttp);
	};		
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function sendAjaxPostRequest(url,data_section_id, callback_function){
	params="";
	section=document.getElementById(data_section_id);
	inputFields=section.getElementsByTagName("INPUT");
	textAreaFields=section.getElementsByTagName("TEXTAREA");
	for (i=0;i<inputFields.length;i++){
		el=inputFields[i];
		params+=el.name+"="+el.value+"&";
	}
	for (i=0;i<textAreaFields.length;i++){		
		el=textAreaFields[i];
		params+=el.name+"="+el.value+"&";
	}
	
	params=params.substring(0,params.length-1);
	var xmlhttp;
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
		callback_function(xmlhttp);
	};
	
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.send(params);
	
}

function setHtmlValuesFromJsonObjects(objects){
	for(tmp in objects){
		element=document.getElementById(tmp);
		if(element!=null){
			if(element.type=="text" || element.type=="textarea" || element.type=="hidden")
				element.value=objects[tmp];
			else
				element.innerHTML=objects[tmp];
		}
	}
}

-->
