   function check_correct(){
      var err=0;
      
      if (document.getElementById("work_name").value==''){
         err=err+1;
         alert('Моля попълнете "Работно място" (Месторабота).')
      }
    
      if (document.getElementById("vid").value==0){
         if (document.getElementById("ch_1").checked){
            if (!(document.getElementById("1_bh").value>0)||!(document.getElementById("1_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Понеделник".')
               }
         }
         if (document.getElementById("ch_2").checked){
            if (!(document.getElementById("2_bh").value>0)||!(document.getElementById("2_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Вторник".')
               }
         }
         if (document.getElementById("ch_3").checked){
            if (!(document.getElementById("3_bh").value>0)||!(document.getElementById("3_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Сряда".')
               }
         }
         if (document.getElementById("ch_4").checked){
            if (!(document.getElementById("4_bh").value>0)||!(document.getElementById("4_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Четвъртък".')
               }
         }
         if (document.getElementById("ch_5").checked){
            if (!(document.getElementById("5_bh").value>0)||!(document.getElementById("5_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Петък".')
               }
         }
         if (document.getElementById("ch_6").checked){
            if (!(document.getElementById("6_bh").value>0)||!(document.getElementById("6_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Събота".')
               }
         }
         if (document.getElementById("ch_7").checked){
            if (!(document.getElementById("7_bh").value>0)||!(document.getElementById("7_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Неделя".')
               }
         }                                             
      } else {
         if (document.getElementById("ch_even").checked){
            if (!(document.getElementById("even_bh").value>0)||!(document.getElementById("even_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Четни дати".')
               }
         }
         if (document.getElementById("ch_odd").checked){
            if (!(document.getElementById("odd_bh").value>0)||!(document.getElementById("odd_eh").value>0)){
                 err=err+1;
                 alert('Моля попълнете часове за "Нечетни дати".')
               }
         }         
        
      }    
    
   
   if (err==0){
     return true;    
   }else{
     return false; 
   }
    
   }




    var map;
    var geocoder;
    var bounds;
    var myEventListener;
    var baseIcon;

    function initialize_vk(btn,l1,l2) {
     
     map = new GMap2(document.getElementById("mapdiv1"));
     
     bounds = new GLatLngBounds();
     map.addControl(new GLargeMapControl());
    // map.addControl(new GMapTypeControl());
     //map.addControl(new TextualZoomControl());
     map.setCenter(new GLatLng(34, 0), 1);
     geocoder = new GClientGeocoder();
     myEventListener = GEvent.bind(map, "click", this, getAddress);

      if (btn==1){geocoder.getLocations(document.getElementById("work_city").value+', '+document.getElementById("work_adress").value, addAddressToMap)};
      if (btn==2){geocoder.getLocations(document.getElementById("work_city").value, addAddressToMap)};
      if (l1>0){
       if (btn==0){
       baseIcon = new GIcon(G_DEFAULT_ICON);
       baseIcon.shadow = "#";
       baseIcon.iconSize = new GSize(20, 34);
       baseIcon.iconAnchor = new GPoint(9, 34);
       baseIcon.infoWindowAnchor = new GPoint(9, 2);
       point = new GLatLng(l1,l2);
       var letteredIcon = new GIcon(baseIcon);
       letteredIcon.image = "http://www.bgpacient.com/icons/medical.png";
       markerOptions = { icon:letteredIcon };
       var marker = new GMarker(point, markerOptions);
       bounds.extend(point);
       map.addOverlay(marker);
       //map.setZoom(map.getBoundsZoomLevel(bounds));
       map.setZoom(14);
       map.setCenter(bounds.getCenter());
        
}}
}  
/*
function TextualZoomControl() {}
TextualZoomControl.prototype = new GControl();

TextualZoomControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

/*  var zoomInDiv = document.createElement("div");
  this.setButtonStyle_(zoomInDiv);
  container.appendChild(zoomInDiv);
  zoomInDiv.appendChild(document.createTextNode("By mouse"));
  GEvent.addDomListener(zoomInDiv, "click", function() {
    
  });

  var adresDiv = document.createElement("div");
  this.setButtonStyle_(adresDiv);
  container.appendChild(adresDiv);
  adresDiv.appendChild(document.createTextNode("By Address"));
  GEvent.addDomListener(adresDiv, "click", function() {
    document.getElementById('work_adress').onblur= function() {GUnload();initialize();};
  });

  map.getContainer().appendChild(container);
  return container;
}*/

function getAddress(overlay, latlng) {

  document.getElementById('work_adress').onblur=function() {};

  if (latlng != null) {
    address = latlng;
    document.getElementById('work_l1').value=latlng.y;
    document.getElementById('work_l2').value=latlng.x;

    map.clearOverlays();
    marker = new GMarker(latlng);
    map.addOverlay(marker);

    //geocoder.getLocations(latlng, showAddress);
  }
  //GEvent.removeListener(myEventListener);
}

function showAddress(response) {
  map.clearOverlays();
  if (!response || response.Status.code != 200) {
    alert("Status Code:" + response.Status.code);
  } else {
    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],
                        place.Point.coordinates[0]);
    marker = new GMarker(point);
    map.addOverlay(marker);

    document.getElementById('work_adress').value=place.address;
    document.getElementById('work_l1').value=place.Point.coordinates[1];
    document.getElementById('work_l2').value=place.Point.coordinates[0];

}}


/*
TextualZoomControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}

TextualZoomControl.prototype.setButtonStyle_ = function(button) {
  button.style.textDecoration = "none";
  button.style.color = "#0000cc";
  button.style.backgroundColor = "white";
  button.style.font = "small Arial";
  button.style.border = "1px solid black";
  button.style.padding = "1px";
  button.style.marginBottom = "3px";
  button.style.textAlign = "center";
  button.style.width = "6em";
  button.style.cursor = "pointer";
}
*/

    function addAddressToMap(response) {
     if ((!response) || (response.Status.code != 200)) {
       //alert("Sorry, we were unable to geocode that address");
     } else {
       place = response.Placemark[0];
       point = new GLatLng(place.Point.coordinates[1],
                           place.Point.coordinates[0]);
       marker = new GMarker(point);

       document.getElementById("work_l1").value=place.Point.coordinates[1];
       document.getElementById("work_l2").value=place.Point.coordinates[0];

       bounds.extend(point);
       map.addOverlay(marker);
       map.setZoom(map.getBoundsZoomLevel(bounds));
       map.setCenter(bounds.getCenter());
     }

    }

    function fitMap() {
      map.setZoom(map.getBoundsZoomLevel(bounds));
      map.setCenter(bounds.getCenter());
    }

