function hl(x){
	if(x.className=='active'){ x.className='active-over' }
	else{ x.className='over' }
}

function dhl(x){
	if(x.className=='active-over'){ x.className='active' }
	else{ x.className='' }
}

function checkpoll(vote) {
  bcheck="false";
  for (i=0;i<document.votingform.voted.length;i++) {
    if (document.votingform.voted[i].checked) {
      bcheck = "true";
    }
  }
  if (bcheck=="true") {
	  document.votingform.submit();
	  return true;
  } else {
    alert("Palun vali oma eelistus");
    return false;
  }
}

function checkAll(field) {
  if (document.svorm.all.checked==true) {
    document.svorm.sg1.checked=true;
    document.svorm.sg2.checked=true;
    document.svorm.sg3.checked=true;
    document.svorm.sg4.checked=true;
  } else {
    document.svorm.sg1.checked=false;
    document.svorm.sg2.checked=false;
    document.svorm.sg3.checked=false;
    document.svorm.sg4.checked=false;
  }
}

function ssyndmus(num) {
  document.svorm.salvesta.value='0';
  document.svorm.submit();
}

function verify(theform,eelvaade) {
  theform=document.svorm;
  var msg = '';

  if (theform.nimetus.value=='') {
    msg=msg+'Sündmuse nimi\n';
  }
  if ((theform.koht.selectedIndex==0) & (theform.muukoht.value=='')) {
    msg=msg + 'Sündmuse toimumiskoht\n';
  }

  if ((theform.esindaja.value=='') & (theform.korraldaja.value=='') & (theform.korraldaja_id.selectedIndex==0)) {
    msg=msg + 'Kontaktisik või korraldaja\n';
  }
  if (((theform.telefon.value=='') || (theform.telefon.value=='')) & (theform.web.value=='') & (theform.email.value=='')) {
    msg=msg + 'Telefon või WWW aadress või e-posti aadress\n';
  }
  if ((msg == '') || (msg == null) ) {
    if (eelvaade=='1') {
      document.svorm.eelvaade.value='1';
    }
    document.svorm.salvesta.value='1';
    document.svorm.submit();
  } else {
    var alertmsg;
    alertmsg = "Täitke palun tühjaks jäänud väljad ja proovige ärasaatmist uuesti:\n\n";
    alertmsg += msg + "\n";
    alert (alertmsg);
    return false;
  }
}

function save(num) {
  document.svorm.salvesta.value='1';
}

function noenter() {
	return !(window.event && window.event.keyCode == 13); 
}

function enter(nextfield) {
	if(window.event && window.event.keyCode == 13) {
	  nextfield.focus();
	  return false; 
	} else {
	  return true; 
	}
}

function kirje(url) {
	if (window.open(url,'kirje','width=screen.width,height=screen.height,toolbar=0,status=1,menubar=0,directories=0,location=1,scrollbars=yes,copyhistory=0,resizable=yes'));
	else
	window.open(url,'kirje','width=screen.width,height=screen.height,toolbar=0,status=1,menubar=0,directories=0,location=1,scrollbars=yes,copyhistory=0,resizable=yes');
}

function regverify(theform) {
	var msg = "";

	if (theform.rl.value=='') {
		msg='e-posti aadress';
	}
	if (theform.rp.value=='') {
		msg=msg+'\nSalasõna';
	}
	if ((msg == '') || (msg == null) ) {
		return true;
	} else {
		var alertmsg;
		alertmsg = "Ei saa registreeruda, kuna täidetud pole lahtrid:\n\n";
		alertmsg += msg + "\n";
		alertmsg += "\nTäitke kõik lahtrid ja proovige uuesti.";
		alert (alertmsg);
		return false;
	}
}

function cs() {
	var agree=confirm("Kas soovid kustutada?");
	if (agree)
			return true ;
	else
			return false ;
}

function notify(jsStr) { //v2.0
  document.nvorm.submit();
  return eval(jsStr)
}

function galwin(url) {
	listin = open(url, 'popup', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=100,height=100');
}


function loadGMap(lat, lng, html) {
  if (GBrowserIsCompatible() && lat && lng) {
    var map = new GMap2(document.getElementById("gmap"));
    var point = new GLatLng(lat, lng);
    map.setCenter(point, 15);
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.openInfoWindowHtml(map.getCenter(), html);
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
    map.addOverlay(marker);
  }
}
