// JavaScript Document
function Alert() {
	alert('hello');
}

function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }

function enableSelect(ID)  {
  document.getElementById("pocet_"+ID).disabled=false;
  }
  
function Redirect1(url) {
	window.location = "/"+url+"/";
}
  
function hidePolozka(i)  {
  document.getElementById("polozka_"+i).style.display="none";
  }

function confirmSubmit(ID) {
  var agree=confirm("Opravdu chcete odebrat z košíku vybrané zboží ?");
  if (agree) {
	  processDeleteKosik(ID);
	  return true ;
	  }
  else {
	  return false ;
	  }
}

function changeStyle1(i) {
	var zmenPodklad = document.getElementById("box-vyrobek-obrazek-"+i);
	zmenPodklad.style.border="#FFF 2px solid";
}

function formSubmitJazykoveMutace(id) {
  var myDiv = document.getElementById("hiddenField");
  var form = document.getElementById("formJazykoveMutace");
  var html = "<input name=\"lang_vyber\" type=\"hidden\" value=\"" + id + "\" />";
  
  //pridej obsah do elementu <div>
  myDiv.innerHTML = html;
  form.target="_self";
  form.submit();
}

function checkEmail() {
  var email = document.getElementById('inputRegisterEmail');
  var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
  if (!filter.test(email.value)) {
	alert('Please provide a valid email address');
	email.focus
	return false;
  }
}

function checkemail(email) {
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  if (filter.test(email)) {
	return true;
  }
  else {
	return false;
  }
}

function setOpacity( element, alpha ){
  var el = document.getElementById(element);

  if( el.style.opacity != undefined ){
	  el.style.opacity = alpha;
  }

  else if( el.style.MozOpacity != undefined ){ 
	  el.style.MozOpacity = alpha;
  }

  else if( el.style.filter != undefined ){
	  el.style.filter = "alpha(opacity=0)";
	  el.filters.alpha.opacity = ( alpha * 100 );
  }

  return true;
}

function PPOpen(foto, nazev, popis) {
	$.prettyPhoto.open(foto, nazev, popis);
}

function formSubmitStrankovani(strana) {
  var myDiv = document.getElementById("divInsertPage");
  var form = document.getElementById("formStrankovani");
  var html="<input name=\"strana\" type=\"hidden\" value=\""+strana+"\" />";
  
  //pridej obsah do elementu <div>
  myDiv.innerHTML = html;
  form.target="_self";
  form.submit();
}

/* google maps */
var map;
var infowindowLevel = 0;

var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://www.drakknet.cz/useruploads/files/souradnice.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.
  if (txtFile.status === 200) {  // Makes sure it's found the file.
	allText = txtFile.responseText; 
	lines = txtFile.responseText.split("\n"); // Will separate each line into an array
  }
}
}
txtFile.send(null);

function initialize() {
  var myLatlng = new google.maps.LatLng(49.894330, 18.45442);
  var myOptions = {
	zoom: 12,
	center: myLatlng,
	mapTypeId: google.maps.MapTypeId.ROADMAP
  }
 
  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 
  // Add 5 markers to the map at random locations
  for (var i = 0; i < lines.length; i++) {
	oneLine = lines[i].split(";");
	LatX = oneLine[0];
	LatY = oneLine[1];
	popis = jQuery.trim(oneLine[2]);
	nazev = jQuery.trim(oneLine[3]);
	
	var location = new google.maps.LatLng(LatX, LatY);
	var marker = new google.maps.Marker({
		position: location,
		map: map
	});
	marker.setTitle(nazev.toString());
	if(popis != '') {
		attachInfowindow(marker, popis);
	}
  }
}
 
function attachInfowindow(marker, obsah) {
  var infowindow = new google.maps.InfoWindow(
	  { content: '<div style="padding-left:5px; padding-right:20px;">' + obsah + '</div>'
	  });
  google.maps.event.addListener(marker, 'click', function() {
	infowindow.setZIndex(++infowindowLevel);
	infowindow.open(map,marker);
  });
}
