var urlstr = "http://hanasoo.com/";
var urlstr = "http://localhost/hanasoo/";

function sortLesson(city, language) {		
		
		var format = document.getElementById('grp_format').value;
		if(format == 'list'){
		var wday = document.getElementById('grp_wday').value;
		var shour = document.getElementById('grp_shour').value;
		var ehour = document.getElementById('grp_ehour').value;
		var strURL=urlstr+'group_list.php?cit='+encodeURI(city)+'&lang='+language+'&wd='+wday+'&shr='+shour+'&ehr='+ehour;
		} else if(format == 'calendar'){
		var shour = document.getElementById('grp_shour').value;
		var ehour = document.getElementById('grp_ehour').value;
		
		var strURL=urlstr+'group_calendar.php?cit='+encodeURI(city)+'&lang='+language+'&shr='+shour+'&ehr='+ehour;
		
		} else if(format == 'map'){
		
		var strURL=urlstr+'group_map.php?cit='+encodeURI(city)+'&lang='+language;
		
		}
		
		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=urlstr+'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,language) {
		var shour = document.getElementById('grp_shour').value;
		var ehour = document.getElementById('grp_ehour').value;

		var strURL=urlstr+"group_list.php?np="+nowpage+"&tc="+tcnt+"&cit="+encodeURI(city)+"&lang="+language+"&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_inner').innerHTML = "<img src=urlstr+'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,language,shour,ehour) {		
		
		var strURL=urlstr+'calendar_call.php?cy='+cyear+'&cm='+cmonth+'&cit='+encodeURI(city)+'&lang='+encodeURI(language)+'&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=urlstr+'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('grp_wday').disabled = false;
	document.getElementById('grp_shour').disabled = false;
	document.getElementById('grp_ehour').disabled = false;
		
	} else if(value == 'calendar'){
	document.getElementById('grp_wday').disabled = true;
	document.getElementById('grp_wday').selectedIndex=0;
	document.getElementById('grp_shour').disabled = false;
	document.getElementById('grp_ehour').disabled = false;
	
	} else if(value == 'map'){
	document.getElementById('grp_wday').disabled = true;
	document.getElementById('grp_wday').selectedIndex=0;
	document.getElementById('grp_shour').disabled = true;
	document.getElementById('grp_ehour').disabled = true;
	
	}
}

function setStartHour(hour) {
var shourvalue = document.getElementById('grp_shour').value;
var shr;
var cnt = 0;
document.getElementById('grp_shour').length = 0;

for (shr = 0; shr < hour; shr++) {
document.getElementById('grp_shour').options[cnt] = new Option(shr + ':00', shr);
if (shr == shourvalue) {
document.getElementById('grp_shour').options[cnt].selected = true;
}
cnt++;
}
}


function setEndHour(hour) {
var ehourvalue = document.getElementById('grp_ehour').value;
var ehouroption;
var ehr;
var fromhour = ++hour;
var cnt = 0; 
document.getElementById('grp_ehour').length = 0;
for (ehr = fromhour; ehr < 25; ehr++) {
document.getElementById('grp_ehour').options[cnt] = new Option(ehr + ':00', ehr);
if (ehr == ehourvalue) {
document.getElementById('grp_ehour').options[cnt].selected = true;
}
cnt++;
}
}
