// JavaScript Document


/* ot tuk */


function hide() {
					document.getElementById('pre_text').style.display = "none";	
					document.getElementById('preview').style.display = "none";			 	
}

function page(m, xx){
	if(m!=''){
	document.getElementById('cur_page').value=m;
	document.getElementById(xx).submit();
	}
}

function search_country(y){
		//document.getElementById('search_input').value=y;
		//document.search_form.submit();
		//return;
	var check = document.getElementById('resultsWrapper');
	//if(check==null||check==undefined){//alert('nqma');
		//document.getElementById('search_input').value=y;
		//document.search_form.submit();
		//return;
	//}else{
		$.ajax({
		  type: 'POST',
		  url: 'http://www.kiwilanguages.es/es.html?jj',
		  data:  { search_input: y, jj : true },
		  success: function(data){
				//alert(data);
				document.getElementById('resultsWrapper').innerHTML = data;
			}
		});
	//}
}

function createRequestObject(){
	var request_;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_ = new XMLHttpRequest();
	}
	return request_;
}

var http_info = createRequestObject();

function add_pays(my_lang, course_subgroup, course_group, country_id){
	if(country_id!=''){
		if(document.getElementById('sc'+country_id).className=='deactive'){
			document.getElementById('sc'+country_id).className='';
		}else{
			document.getElementById('sc'+country_id).className='deactive';
		}
	}
	http_info.open('get', 'ajax_filter.php?my_lang='+my_lang+'&course_subgroup='+course_subgroup+'&course_group='+course_group+'&country_id='+country_id+'&z='+Math.random());
	http_info.onreadystatechange = info_handleInfo;
	http_info.send(null);
}

function info_handleInfo(){
	if(http_info.readyState == 4){
		var response = http_info.responseText;
		fullinfo=response.split('+-*');
		document.getElementById('cur_results').innerHTML = fullinfo[0];
	   	document.getElementById('xxx1').innerHTML = fullinfo[1];
	   
	}
}

var http_info2 = createRequestObject();

function add_pays2(my_lang, course_subgroup, country_id){
	if(country_id!=''){
		if(document.getElementById('sc'+country_id).className=='deactive'){
			document.getElementById('sc'+country_id).className='';
		}else{
			document.getElementById('sc'+country_id).className='deactive';
		}
	}
	http_info.open('get', 'ajax_filter2.php?my_lang='+my_lang+'&course_subgroup='+course_subgroup+'&country_id='+country_id+'&z='+Math.random());
	http_info.onreadystatechange = info_handleInfo2;
	http_info.send(null);
}

function info_handleInfo2(){
	if(http_info.readyState == 4){
		var response = http_info.responseText;
		fullinfo=response.split('+-*');
		document.getElementById('cur_results').innerHTML = fullinfo[0];
	   	document.getElementById('xxx1').innerHTML = fullinfo[1];
	   
	}
}

var http_change_sekect_1 = createRequestObject();

function change_select1(my_lang, sg){
	http_info.open('get', 'ajax_select1.php?my_lang='+my_lang+'&sg='+sg+'&z='+Math.random());
	http_info.onreadystatechange = info_handleInfo3;
	http_info.send(null);
}

function info_handleInfo3(){
	if(http_info.readyState == 4){
		var response = http_info.responseText;
		
		document.getElementById('select1').innerHTML = response;	   
	}
}

var http_change_sekect_2 = createRequestObject();

function change_select2(my_lang, cg){
	http_info.open('get', 'ajax_select2.php?my_lang='+my_lang+'&cg='+cg+'&z='+Math.random());
	http_info.onreadystatechange = info_handleInfo4;
	http_info.send(null);
}

function info_handleInfo4(){
	if(http_info.readyState == 4){
		var response = http_info.responseText;
		
		document.getElementById('select2').innerHTML = response;	   
	}
}

var http_change_sekect_3 = createRequestObject();

function change_select3(my_lang, c){
	http_info.open('get', 'ajax_select3.php?my_lang='+my_lang+'&c='+c+'&z='+Math.random());
	http_info.onreadystatechange = info_handleInfo5;
	http_info.send(null);
}

function info_handleInfo5(){
	if(http_info.readyState == 4){
		var response = http_info.responseText;
		
		document.getElementById('select3').innerHTML = response;	   
	}
}

var http_change_sekect_4 = createRequestObject();

function change_select4(my_lang, c, country){
	http_info.open('get', 'ajax_select4.php?my_lang='+my_lang+'&c='+c+'&country='+country+'&z='+Math.random());
	http_info.onreadystatechange = info_handleInfo6;
	http_info.send(null);
}

function info_handleInfo6(){
	if(http_info.readyState == 4){
		var response = http_info.responseText;
		
		document.getElementById('select4').innerHTML = response;	   
	}
}
