// JavaScript Document
function SearchForm(actualSelect,language,specialization,country,level,city,target,lenght,intensity,accomodation,refr_status) {

	var url = "http://"+location.hostname+"/"+"inc/ajax/search_form.php";
	var params = "actualSelect="+actualSelect+"&language="+language+"&specialization="+specialization+"&country="+country+"&level="+level+"&city="+city+"&target="+target+"&lenght="+lenght+"&intensity="+intensity+"&accomodation="+accomodation;
	//alert(params);
	
	//iba ked nejde o refresh status
	if ( refr_status == undefined ){
	   document.getElementById('ajax_show_res_arrows').src = "http://www.drbubo.com/images/body/ajax_anim_showres.gif";
           document.getElementById('ajax_show_res_arrows_r').src = "http://www.drbubo.com/images/body/ajax_anim_showres_r.gif";
      }
      else {
         document.getElementById('ajax_show_res_arrows').src = "http://www.drbubo.com/images/body/ajax_anim_showres_blank.gif";
         document.getElementById('ajax_show_res_arrows_r').src = "http://www.drbubo.com/images/body/ajax_anim_showres_blank.gif";
      }
      http.open("GET", url+"?"+params, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-Type", "text/html; charset=windows-1250");
    http.onreadystatechange = handleResponseSearchForm;
    http.send(null);
    document.getElementById('div_all_results').innerHTML = '<span style="font-size:10px;">generujem...</span>';	
    document.getElementById('div_all_cities').innerHTML = '';	
    document.getElementById('div_all_schools').innerHTML = '';
    document.getElementById('select_srch_language').style.Color = '#cccccc';	
    document.getElementById('select_srch_language').disabled = true;	
    document.getElementById('select_srch_specialization').style.Color = '#cccccc';	
    document.getElementById('select_srch_specialization').disabled = true;	
    document.getElementById('select_srch_country').style.Color = '#cccccc';	
    document.getElementById('select_srch_country').disabled = true;	
    document.getElementById('select_srch_level').style.Color = '#cccccc';	
    document.getElementById('select_srch_level').disabled = true;	
    document.getElementById('select_srch_city').style.Color = '#cccccc';	
    document.getElementById('select_srch_city').disabled = true;	
    document.getElementById('select_srch_target').style.Color = '#cccccc';	
    document.getElementById('select_srch_target').disabled = true;	
    document.getElementById('select_srch_lenght').style.Color = '#cccccc';	
    document.getElementById('select_srch_lenght').disabled = true;	
    document.getElementById('select_srch_intensity').style.Color = '#cccccc';	
    document.getElementById('select_srch_intensity').disabled = true;	
    document.getElementById('select_srch_accomodation').style.Color = '#cccccc';	
    document.getElementById('select_srch_accomodation').disabled = true;	
}

function handleResponseSearchForm() {
	
    if(http.readyState == 4){
        if(http.status == 200 && http.responseText != '') {
            var response = http.responseText;
            var update = new Array();

            if(response.indexOf('|' != -1)) {
                update = response.split('|');
				//alert(update[1]);
                document.getElementById('div_srch_language').innerHTML = update[1];
                document.getElementById('div_srch_specialization').innerHTML = update[2];
                document.getElementById('div_srch_country').innerHTML = update[3];
                document.getElementById('div_srch_level').innerHTML = update[4];
                document.getElementById('div_srch_city').innerHTML = update[5];
                document.getElementById('div_srch_target').innerHTML = update[6];
                document.getElementById('div_srch_lenght').innerHTML = update[7];
                document.getElementById('div_srch_intensity').innerHTML = update[8];
                document.getElementById('div_srch_accomodation').innerHTML = update[12];
                document.getElementById('div_all_results').innerHTML = update[9];
                document.getElementById('div_all_cities').innerHTML = update[10];
                document.getElementById('div_all_schools').innerHTML = update[11];
                document.getElementById('div_date').innerHTML = update[13];
                
                eval(update[14]);
            }
        }
    }
}

function waitForSearchForm() {
  if(!document.getElementById('select_srch_intensity').complete) {
    setTimeout('waitForSearchForm()',10);
  }
}



function SearchProgress(cID,uID,lenght,startDate,term,level,accomodation) {
	
	var url = "http://"+location.hostname+"/"+"inc/ajax/search_progress.php";
	var params = "cID="+cID+"&uID="+uID+"&lenght="+lenght+"&startDate="+startDate+"&term="+term+"&level="+level+"&accomodation="+accomodation;
	http.open("GET", url+"?"+params, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-Type", "text/html; charset=windows-1250");
    http.onreadystatechange = handleResponseSearchProgress;
    http.send(null);	
}

function handleResponseSearchProgress() {
	
    if(http.readyState == 4){
        if(http.status == 200 && http.responseText != '') {
            var response = http.responseText;
            var update = new Array();

            if(response.indexOf('|' != -1)) {
                update = response.split('|');
				location.href='school.php?step=2&src=search&sID='+update[1];
            }
        }
    }
}

