﻿// JavaScript Document<script type="text/javascript">

var map;
var	geocoder ;
var allMarkers  = [];
var map;
 
	function init(){
	  if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById("map-index"));
	    map.setCenter(new GLatLng(18.789155035974076,98.98492813110352), 12);
		//map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
		map.enableScrollWheelZoom();
	  }
	}
	

	/**
	 * Place Marker
	 * @param {Latlngt} latlng
	 * @param {HTML} html
	 */
	function  placeMarker(latlng,html) {

		  var marker = new GMarker(latlng);
		  allMarkers.push(marker);
		  map.addOverlay(marker);
		  
		  GEvent.addListener(marker, "click", function() {
		  	marker.openInfoWindowHtml(html);
		  });
 		return marker;
	}
	/**
	 * Romove All Marker
	 */
	function removeAllMarker(){
		
		if (allMarkers.length > 0) {
			map.removeOverlay(allMarkers.pop());
			removeAllMarker();
		}
	}
	
	function ShowMarkers() {
		removeAllMarker();
		
		var url = site_url+'xml/xmlProviderMarker.php'+param;
		GDownloadUrl(url, function(data) {
       		var xml = GXml.parse(data);
			var rows = xml.documentElement.getElementsByTagName('providers');
			  for (var i = 0; i < rows.length; i++) 
			  {
				 var id = rows[i].getAttribute('provider_id');
				 var business = rows[i].getAttribute('business');
				 var alias = rows[i].getAttribute('alias');
				 var logo = rows[i].getAttribute('logo');
				 var html=  ' <div class="marker_info">'+
				 			'<div class="map_logo"><img src="'+logo+'" alt="'+business+' logo" /></div>'+
							'<div class="map_name">'+
				 			' <h3>'+business+'</h3>'+
							' <span>'+alias+'<span></div></div>';
				 var lat = rows[i].getAttribute('lat');
				 var lng = rows[i].getAttribute('lng');
				 var zoom = rows[i].getAttribute('zoom');
				 placeMarker(new GLatLng(lat,lng),html);  
			   }
			});
	}
	
	
$(function(){
   
   	
 $('.anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        	// 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: 3500,                    	// How long between slide transitions in AutoPlay mode
                startStopped: false,            	// If autoPlay is on, this can force it to start stopped
                animationTime:800,             	// 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: "Go",             		// Start text
		        stopText: "Stop",               	// Stop text
		        navigationFormatter: null      // Details at the top of the file on this use (advanced use)
            });
   
  /* $("#provider-sortable").sortable();
	$("#provider-sortable").disableSelection();
    

	 $('.mdetail').click(function(){
								  $(".more-detail").slideToggle('show');
								  });
	*/
	$('#changetag').click(function(){
		$(".tagecloud").slideToggle('show');
	});
	
	$("a.video").fancybox({
		'frameWidth':  660, 
		'frameHeight':	505, 
		'hideOnContentClick':false, 
		'overlayShow':		true
	});

	$("a.mobile").fancybox({
		'frameWidth':	500, 
		'frameHeight':	400, 
		'hideOnContentClick':false,
		'overlayShow':		false
	});
	
		$("a.advertise-here").fancybox({
		'frameWidth':	250, 
		'frameHeight':	100, 
		'hideOnContentClick':false,
		'overlayShow':		false
	});

	
});

