sdiak = "áäčďéěíĺžňóô öŕúů üýřÁÄČĎÉĚÍĹźŇÓÔ ÖŔÚŮ ÜÝŘ"; 
bdiak = "aacdeeillnoo orstuu uyrzAACDEEILLNOO ORSTUU UYRZ"; 
function bezdiak(s) 
{ 
	tx = ""; 
	txt = s; 
	for(p = 0; p < txt.length; p++) 
	{ 
		if (sdiak.indexOf(txt.charAt(p)) != -1) 
		{ 
			tx += bdiak.charAt(sdiak.indexOf(txt.charAt(p))); 
		} 
		else tx += txt.charAt(p); 
	} 
	return tx; 
} 

var stat = 'cz';
function check_form(){
	if ( document.getElementById('name_f').value.length == 0 ) {
		alert('Vyplňte prosím jméno.');
		return false;
	}

	if ( document.getElementById('typ_zadani_polohy_vyctem').checked && !document.getElementById('aspon_neco')) {
		alert('Vyberte prosím město');
		return false;
	}
	if ( document.getElementById('hp_main').value == 0 ){
		if ( document.getElementById('zadani_polohy_souradnici').checked ){
			var longi_s = document.getElementById('long_deg').value;
			var lat_s = document.getElementById('lat_deg').value;
	
			if ( longi_s.length == 0 || lat_s == 0 ) {
				alert( 'Vyplňte prosím zeměpisnou ířku a délku.' );
				return false;
			}
			var longi = parseInt( longi_s );
			var lat = parseInt( lat_s );
			if ( longi < 0 || longi > 180 ) {
				alert('Opravte prosím zeměpisnou délku.');
				return false;
			}
			if ( lat < 0 || lat > 90 ) {
				alert('Opravte prosím zeměpisnou ířku.');
				return false;
			}
		}
	}
	if ( document.getElementById("datum_den").value == -1 ) {
		alert('Vyplňte prosím den, kdy jste se narodili.');
		return false;
	}

	if ( document.getElementById("datum_mesic").selectedIndex == 0 ) {
		alert('Vyplňte prosím měsíc, kdy jste se narodili.');
		return false;

	}
	if ( !document.getElementById("neznam").checked &&  document.getElementById("datum_hodina").selectedIndex == 0 ) {
		alert('Vyplňte prosím hodinu, kdy jste se narodili.');
		return false;
	}

	if (  !document.getElementById("neznam").checked && document.getElementById("datum_minuta").selectedIndex == 0 ) {
		alert('Vyplňte prosím minutu, kdy jste se narodili.');
		return false;
	}
	return true;
}

function zadani_zmena(){
	
	var text = document.getElementById('zadani_polohy_input').value;
	text = bezdiak( text );
	//var stat = document.getElementById('zadani_polohy_stat').selectedIndex;
	if ( text.length < 2 ) return;
	;
	document.getElementById('ajax_loading').style.display='inline';
	//	alert ('document.getElementById(\'ajax_loading\').style.display=\'inline\';');
	stat = document.getElementById("zadani_polohy_stat").options[  document.getElementById("zadani_polohy_stat").selectedIndex].value ;
	
	var url = 'http://www.horoskopyprozeny.cz/on-line-vyklad-osobniho-horoskopu/astro_ajax.php?mesto=' + text + '&stat=' + stat;
	if (window.ActiveXObject)
	{
		
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		
		httpRequest = new XMLHttpRequest();
	}
	
	httpRequest.open("GET", url, true);
	httpRequest.setRequestHeader( "Content-type", "text/html" );
	httpRequest.onreadystatechange= function () {processRequest(); } ;
	httpRequest.send(null);
}

	function processRequest(){
		
		if (httpRequest.readyState == 4)
		{
			if(httpRequest.status == 200)
			{
				var mistoZobrazeni = document.getElementById("zadani_polohy_ajax");
				mistoZobrazeni.innerHTML = httpRequest.responseText; 
				document.getElementById('ajax_loading').style.display='none';
			}
			else
			{
				alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
			}

		}	

	}


function ukaz( druh ){

	document.getElementById('zadani_souradnice').style.display = 'none';
	document.getElementById('zadani_vyber').style.display = 'none';
	document.getElementById('zadani_vyber_ajax').style.display = 'none';
	document.getElementById('zadani_souradnice_2').style.display = 'none';
	document.getElementById( druh ).style.display = 'table-row';


	if ( druh == 'zadani_vyber' ) document.getElementById( 'zadani_vyber_ajax' ).style.display = 'table-row';
	if ( druh == 'zadani_souradnice' ) document.getElementById('zadani_souradnice_2').style.display = 'table-row';
}
 
var show = 0;
function detailToggleShow(){
	if ( show == 0 ){
		show = 1;
		document.getElementById('obsah_detail').style.display='block';
		document.getElementById('zobrazit_obsah').innerHTML='Skrýt detaily výpočtu &gt;&gt;';
		
	} else {
		show = 0;
		document.getElementById('zobrazit_obsah').innerHTML='Zobrazit detaily výpočtu &gt;&gt;';
		document.getElementById('obsah_detail').style.display='none';
	}
}

function setMap(lat, lon, city){
try{		
				document.getElementById('nahled').style.display='block';
				document.getElementById('nahled').innerHTML = '';
				mapa = new SZN.MapEngine(document.getElementById('nahled'));
				mapa.init()
				var pp = mapa.wgsToPP(lat,lon);
				mapa.setCenter(pp.x,pp.y);    
			//	alert(pp.x); 
				mapa.zoomSet(8);
				//mapa.zoomSet(10);
				mapa.mouseSet(7);
			mapa.enableSelection(1);
			
			// box pro pridani ovladacich prvku
			var layoutBox = mapa.getDefaultLayoutBox()
			
			// vytvoreni a pridani ovladaciho prvku pro pohyb s mapou
			var moveControl = new SZN.Visual.MoveControl();
			var move = mapa.addControls(moveControl,layoutBox,10,12);
			
			// vytvoreni a pridani ovladaciho prvku pro nastaveni priblizeni
			var zoomControl = new SZN.Visual.ZoomControl('full');
			// vypocteme si vertikalni polohu pro umisteni 
			var pos = mapa.getControlById(move).getSize().height + 17;
			mapa.addControls(zoomControl,layoutBox,25,pos);
			
			// zapnuti ukazatele severu
			mapa.setNorthRuler(1);
			
			// zapnuti ukazatele meritka
			mapa.setScaleRuler(1);
		      // vytvorime znacku
			    var mark = mapa.makeMark('center',city);
			    
				  // umistime znacku do mapy na drive vypoctene souradnice 
					mapa.addMark(pp.x,pp.y,mark);	
					
		} catch(err){
				document.getElementById('nahled').style.display='none';
			//alert('Nelze zobrazit mapu.');
			document.getElementById('error_space').innerHTML = '<h3 style="margin-top:5px;">Mapa se nezobrazuje. Opakujte dotaz pozd&#283;ji.</h3>';
		}
		
}

