function loadXMLDoc(file, div)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(div).innerHTML=xmlhttp.responseText;
	setTimeout("$('#d1').dialog('open')",150);
    }
  }
xmlhttp.open("GET",file,true);
xmlhttp.send();
}
////////////////////////////////////////////////
$(document).ready(function() {
    $("#tabs").tabs();
  });
////////////////////////////////////////////////
//<![CDATA[
function ShowHide(a){
$("#"+a).animate({"height": "toggle"}, { duration: 1000 });
}
//]]>
////////////////////////////////////////////////
	var geocoder;
	var map;
	
	// initializing the map
	function initialize()
	{
		// define map center
		var latlng = new google.maps.LatLng(43.27165951822584,26.92712570394906);
		// define map options
		var myOptions = 
		{
			zoom: 15,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.HYBRID,
			scrollwheel: false,
			scaleControl: true,
			navigationControl: true,
			navigationControlOptions: {
				style: google.maps.NavigationControlStyle.ZOOM_PAN
			},
			mapTypeControl: true,
			mapTypeControlOptions: {
				style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
			}
		};
		
		// initialize map
		map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		
		// add event listener for when a user clicks on the map
		/*google.maps.event.addListener(map, 'zoom_changed', function(event) {
			document.getElementById('user_location').value = map.getZoom();
		});	*/	
	}
	
	
	// initialize the array of markers
	var markers = new Array();
	
	// the function that adds the markers to the map
	function addMarkers()
	{
		// get the values for the markers from the hidden elements in the form
		var lats = document.getElementById('lats').value;
		var lngs = document.getElementById('lngs').value;
		var names = document.getElementById('names').value;
		var descrs = document.getElementById('descrs').value;
		var photos = document.getElementById('photos').value;
		var ids = document.getElementById('ids').value;
		
		var las = lats.split(";;")
		var lgs = lngs.split(";;")
		var id = ids.split(";;")
		var nms = names.split(";;")
		var dss = descrs.split(";;")
		var phs = photos.split(";;")
		
		// for every location, create a new marker and infowindow for it
		for (i=0; i<las.length; i++)
		{
			if (las[i] != "")
			{
				// add marker
				var loc = new google.maps.LatLng(las[i],lgs[i]);
				var marker = new google.maps.Marker({
					position: loc, 
					map: window.map,
					title: nms[i]
				});
				
				markers[i] = marker;
				markers[i].setIcon(phs[i]);
				markers[i].setVisible(false);
				if(phs[i].lastIndexOf("_1.")==-1)
					var contentString = ['<a style="font-size:16px; color:#000000;">',nms[i],'</a>'].join('');
				else 
					var contentString = [
				'<script type="text/javascript">',
       ' var GB_ROOT_DIR = "./greybox/";',
    '</script>',
    '<script type="text/javascript" src="greybox/AJS.js"></script>',
    '<script type="text/javascript" src="greybox/AJS_fx.js"></script>',
    '<script type="text/javascript" src="greybox/gb_scripts.js"></script>',
    '<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />',
				  '<div align="center" valign="middle">',
				  '<a style="cursor:pointer; font-size:16px; color:#000000;" onclick="return parent.GB_show(',
				  "'' , '",
				  '../place.php?id=',
				  id[i],
				  "'",
				  ',525, 780)">',
				  nms[i],
				  '</a>',
				  '</div>'
				].join('');
			
				var infowindow = new google.maps.InfoWindow;
				
				bindInfoWindow(marker, window.map, infowindow, contentString);
			}
		}
	}
	
	// make conection between infowindow and marker (the infowindw shows up when the user goes with the mouse over the marker)
	function bindInfoWindow(marker, map, infoWindow, contentString)
	{
		google.maps.event.addListener(marker, 'click', function() { // mouseover || click
			
			//map.setCenter(marker.getPosition());  // premestva kartata to4no v/u obekta
			if(map.getZoom() < 17) { map.setCenter(marker.getPosition()); map.setZoom(18); }
			infoWindow.setContent(contentString);
			infoWindow.open(map, marker);
			$("#tabs").tabs();
		 });
	}


function Markers(color){

// map.closeInfoWindow();
map.getInfoWindow().hide() 
   if (document.getElementById(color).checked==false) { // hide the marker
      for (var i=0;i<markers.length;i++) {
         if (gmarkers[i].type==color)  {
            map.removeOverlay(gmarkers[i]);
         }
      }
   } else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].type==color)  {
            map.addOverlay(gmarkers[i]);
         }
      }
   }
}

  
function sh(category,id) {
        for (var i=0; i<markers.length; i++) {
          if (markers[i].getIcon() == category || markers[i].getIcon().substring(0,(markers[i].getIcon().lastIndexOf('.')-2)) == category.substring(0,(markers[i].getIcon().lastIndexOf('.')-2))) {
			if(document.getElementById(id).checked==false)
				{
					markers[i].setVisible(false);
					//map.closeInfoWindow();
				}
				else
					markers[i].setVisible(true);
          //}
        } 
	   }	
}
/////////////////////////////////////////////////////////////////////
$(document).ready(function () {
    $('a.menu_head').click(function () {
	$('ul.menu_body').slideToggle('medium');
    });	
});
/////////////////////////////////////////////////////////////////////
    
        function formatText(index, panel) {
    		  return index + "";
    	  };
    
        $(function () {
        
            $('.anythingSlider').anythingSlider({
                easing: "swing",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 6,                    // How long between slide transitions in AutoPlay mode
                startStopped: true,            // If autoPlay is on, this can force it to start stopped
                animationTime: 6,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
            		pauseOnHover: false,             // If true, and autoPlay is enabled, the show will pause on hover
            		startText: "Пусни",                // Start text
    		        stopText: "Спри",               // Stop text
    		        navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
            });
            
            $("#slide-jump").click(function(){
                $('.anythingSlider').anythingSlider(6);
            });
            
        });
////////////////////////////////////////////////////////////////////////
			$.uicornerfix('5px');
////////////////////////////////////////////////////////////////////////

