function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
}

function sortLesson(city, category) {		
		
		var format = document.getElementById('lsn_format').value;
		if(format == 'list'){
		var status = document.getElementById('lsn_status').value;
		var wday = document.getElementById('lsn_wday').value;
		var shour = document.getElementById('lsn_shour').value;
		var ehour = document.getElementById('lsn_ehour').value;
		var strURL='http://hanasoo.com/group_call.php?cit='+encodeURI(city)+'&lct='+category+'&st='+status+'&wd='+wday+'&shr='+shour+'&ehr='+ehour;
		} else if(format == 'calendar'){
		
		var status = document.getElementById('lsn_status').value;
		var shour = document.getElementById('lsn_shour').value;
		var ehour = document.getElementById('lsn_ehour').value;
		
		var strURL='http://hanasoo.com/calendar_call.php?cit='+encodeURI(city)+'&lct='+category+'&st='+status+'&shr='+shour+'&ehr='+ehour;
		
		} else if(format == 'map'){
		
		var strURL='http://hanasoo.com/map_call.php?cit='+encodeURI(city);
		
		}
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if 'OK'
					if (req.status == 200) {						
						document.getElementById('group_ajax').innerHTML=req.responseText;
					}else{
						alert('There was a problem while using XMLHTTP:\\n' + req.statusText);
					}
				}else{
				document.getElementById('group_ajax').innerHTML = "<img src='http://hanasoo.com/img/img_loading.gif' width='16' height='16' style='margin: 100px 422px;'>";
				}
			}
			req.open('GET', strURL, true);
			req.send(null);
		}		
}

function getPage(nowpage,tcnt,city,category,status,shour,ehour) {

		var strURL="http://hanasoo.com/group_call.php?np="+nowpage+"&tc="+tcnt+"&cit="+encodeURI(city)+"&lct="+category+'&st='+status+"&shr="+shour+"&ehr="+ehour;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('group_ajax').innerHTML=req.responseText;
						
					} else {
						alert("There was a problem while using XMLHTTP:" + req.statusText);
					}
				}else{
				document.getElementById('group_ajax').innerHTML = "<img src='http://hanasoo.com/img/img_loading.gif' width='16' height='16' style='margin: 100px 422px;'>";
				}			
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
}

function getCalendar(cyear,cmonth,city,category,status,shour,ehour) {		
		
		var strURL='http://hanasoo.com/calendar_call.php?cy='+cyear+'&cm='+cmonth+'&cit='+encodeURI(city)+'&lct='+encodeURI(category)+'&st='+status+'&shr='+shour+'&ehr='+ehour;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if 'OK'
					if (req.status == 200) {						
						document.getElementById('group_ajax').innerHTML=req.responseText;
						tb_init('a.thickbox, area.thickbox, input.thickbox');						
					} else {
						alert('There was a problem while using XMLHTTP:' + req.statusText);
					}
				}else{
				document.getElementById('h_calendar_month').innerHTML = "<img src='http://hanasoo.com/img/img_loading.gif' width='16' height='16' style='margin:5px 0px 4px 0px;'>";
				}
			}
			req.open('GET', strURL, true);
			req.send(null);
		}		
}

function disableSelect(value) {
	if(value == 'list'){
	
	document.getElementById('lsn_status').disabled = false;
	document.getElementById('lsn_wday').disabled = false;
	document.getElementById('lsn_shour').disabled = false;
	document.getElementById('lsn_ehour').disabled = false;
		
	} else if(value == 'calendar'){
	
	document.getElementById('lsn_status').disabled = false;
	document.getElementById('lsn_wday').disabled = true;
	document.getElementById('lsn_wday').selectedIndex=0;
	document.getElementById('lsn_shour').disabled = false;
	document.getElementById('lsn_ehour').disabled = false;
	
	} else if(value == 'map'){
	
	document.getElementById('lsn_status').disabled = true;
	document.getElementById('lsn_status').selectedIndex=0;
	document.getElementById('lsn_wday').disabled = true;
	document.getElementById('lsn_wday').selectedIndex=0;
	document.getElementById('lsn_shour').disabled = true;
	document.getElementById('lsn_ehour').disabled = true;
	
	}
}

function setStartHour(hour) {
var shourvalue = document.getElementById('lsn_shour').value;
var shr;
var cnt = 0;
document.getElementById('lsn_shour').length = 0;

for (shr = 0; shr < hour; shr++) {
document.getElementById('lsn_shour').options[cnt] = new Option(shr + ':00', shr);
if (shr == shourvalue) {
document.getElementById('lsn_shour').options[cnt].selected = true;
}
cnt++;
}
}


function setEndHour(hour) {
var ehourvalue = document.getElementById('lsn_ehour').value;
var ehouroption;
var ehr;
var fromhour = ++hour;
var cnt = 0; 
document.getElementById('lsn_ehour').length = 0;
for (ehr = fromhour; ehr < 25; ehr++) {
document.getElementById('lsn_ehour').options[cnt] = new Option(ehr + ':00', ehr);
if (ehr == ehourvalue) {
document.getElementById('lsn_ehour').options[cnt].selected = true;
}
cnt++;
}
}