jQuery.noConflict();

jQuery(document).ready(function(){
	jQuery('ul#productos_listado li a.modulo, ul#productos_listado li a.servicio').click(function(){
		var element = this;
		if(!jQuery(element).parent('li').hasClass('seleccionado')){ //Si no tiene la clase lo desplegamos
				jQuery(element).parent('li').parent("ul").children("li.seleccionado").toggleClass("seleccionado",600);
				jQuery(element).parent('li').toggleClass("seleccionado",600);
		}
		return false;
	});
});
var map;
var arrMarkers = [];
var arrInfoWindows = [];

function mapInit(){
	var centerCoord = new google.maps.LatLng(41.538623, 2.109350); // Sabadell
	var mapOptions = {
		scrollwheel: false,
		zoom: 15,
		center: centerCoord,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map"), mapOptions);
	
	jQuery.getJSON("../map.json", {}, function(data){
		jQuery.each(data.places, function(i, item){
			//jQuery("#markers").append('<li><a href="#" rel="' + i + '">' + item.title + '</a></li>');
			var marker = new google.maps.Marker({
				position: new google.maps.LatLng(item.lat, item.lng),
				map: map,
				title: item.title
			});
			arrMarkers[i] = marker;
			var infowindow = new google.maps.InfoWindow({
				content: "<h3>"+ item.title +"</h3><p style=\"font-size:10px\">"+ item.description +"</p>"
			});
			arrInfoWindows[i] = infowindow;
			google.maps.event.addListener(marker, 'click', function() {
				infowindow.open(map, marker);
			});
		});
	});
}
jQuery(document).ready(function(){
	// initialize map (create markers, infowindows and list)
	if(jQuery('#map').length){
		mapInit();
		
		// "live" bind click event
		jQuery("#markers a").live("click", function(){
			var i = jQuery(this).attr("rel");
			// this next line closes all open infowindows before opening the selected one
			//for(x=0; x < arrInfoWindows.length; x++){ arrInfoWindows[x].close(); }
			arrInfoWindows[i].open(map, arrMarkers[i]);
		});
	}
});
jQuery(document).ready(function(){
	flowplayer("a.myPlayer", "../scripts/flowplayer-3.1.5.swf",{
		 clip: {  
                scaling: "fit" 
         }, 
		 plugins: { 
		 	controls: { 
				backgroundColor: '#CCCCCC',
				url: 'flowplayer.controls-3.1.5.swf', 
				// which buttons are visible and which are not? 
				play:true, 
				volume:false, 
				mute:false, 
				time:true, 
				stop:false, 
				playlist:false, 
				fullscreen:true, 
				// scrubber is a well-known nickname for the timeline/playhead combination 
        		scrubber: true,
				// tooltips (since 3.1)  
				tooltips: {  
					buttons: true,  
					fullscreen: "Fullscreen"  
				} 
			}
		 }
	});
});
