function initialize() {

    var plPrimera = new google.maps.LatLng(31.85694693964464, -116.60934805870056);
    var plDecima = new google.maps.LatLng(31.872892847840703, -116.62326335906982);
    var plMacroplaza = new google.maps.LatLng(31.821240888157984, -116.60187005996704);
    var plRosarito = new google.maps.LatLng(32.37668144376364, -117.05990552902222);
    var center = new google.maps.LatLng(32.130, -116.84371948242188);
    var shape = [37,0,40,1,42,2,44,3,46,4,47,5,48,6,50,7,50,8,51,9,52,10,53,11,53,12,54,13,55,14,55,15,55,16,56,17,59,18,60,19,61,20,62,21,63,22,63,23,64,24,64,25,64,26,64,27,64,28,64,29,63,30,63,31,62,32,61,33,60,34,58,35,54,36,53,37,53,38,52,39,51,40,50,41,49,42,48,43,47,44,46,45,44,46,42,47,40,48,37,49,26,49,23,48,20,47,18,46,17,45,16,44,14,43,13,42,5,41,4,40,3,39,2,38,1,37,0,36,0,35,0,34,0,33,0,32,0,31,0,30,1,29,1,28,2,27,3,26,4,25,6,24,6,23,6,22,6,21,6,20,6,19,7,18,7,17,7,16,8,15,8,14,9,13,9,12,10,11,11,10,11,9,12,8,13,7,14,6,16,5,17,4,18,3,20,2,23,1,26,0];
    var icon = 'images/marker/image.png';
    var shadow = '/images/marker/shadow.png';
    
    var myOptions = {
      zoom: 10,
      center: center,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }     		
		
    var map = new google.maps.Map(document.getElementById("map"), myOptions);
		
		var markerPrimera = new google.maps.Marker({position: plPrimera, map: map, title:"Lourdes Pasteles y Ambigus - Calle Primera", zIndex: 1, icon:icon, shadow:shadow, shape: shape});
		var markerDecima = new google.maps.Marker({position: plDecima, map: map, title:"Lourdes Pasteles y Ambigus - Calle Decima", zIndex: 1, icon:icon, shadow:shadow, shape: shape});
		var markerMacroplaza = new google.maps.Marker({position: plMacroplaza, map: map, title:"Lourdes Pasteles y Ambigus - Macroplaza del Mar", zIndex: 1, icon:icon, shadow:shadow, shape: shape});
		var markerRosarito = new google.maps.Marker({position: plRosarito, map: map, title:"Lourdes Pasteles y Ambigus - Rosarito", zIndex: 1, icon:icon, shadow:shadow, shape: shape});

		
		var infowindowPrimera = new google.maps.InfoWindow({'content': '<div class="infoWindow">'+$("#sucursalPrimera").html()+"</div>"});
		google.maps.event.addListener(markerPrimera, 'click', function(){infowindowPrimera.open(map,markerPrimera);map.setZoom(13);});
		google.maps.event.addDomListener(document.getElementById("sucursalPrimera"), 'click', function() {google.maps.event.trigger(markerPrimera, 'click');});
		
		var infowindowDecima = new google.maps.InfoWindow({'content': '<div class="infoWindow">'+$("#sucursalDecima").html()+"</div>"});
		google.maps.event.addListener(markerDecima, 'click', function(){infowindowDecima.open(map,markerDecima);map.setZoom(13);});
		google.maps.event.addDomListener(document.getElementById("sucursalDecima"), 'click', function() {google.maps.event.trigger(markerDecima, 'click');});
		
		var infowindowMacroplaza = new google.maps.InfoWindow({'content': '<div class="infoWindow">'+$("#sucursalMacroplaza").html()+"</div>"});
		google.maps.event.addListener(markerMacroplaza, 'click', function(){infowindowMacroplaza.open(map,markerMacroplaza);map.setZoom(13);});
		google.maps.event.addDomListener(document.getElementById("sucursalMacroplaza"), 'click', function() {google.maps.event.trigger(markerMacroplaza, 'click');});
		
		var infowindowRosarito = new google.maps.InfoWindow({'content': '<div class="infoWindow">'+$("#sucursalRosarito").html()+"</div>"});
		google.maps.event.addListener(markerRosarito, 'click', function(){infowindowRosarito.open(map,markerRosarito);map.setZoom(13);});
		google.maps.event.addDomListener(document.getElementById("sucursalRosarito"), 'click', function() {google.maps.event.trigger(markerRosarito, 'click');});
}
  
  
$(document).ready(function(){	

	$('li[id|=tag]').click(function(){
		var tag = $(this).attr('id').substring(4,10);
		$('#productos_browser').load('tag/index.php',{'tag':tag});
		$('li[id|=tag]').removeClass('active');
		$(this).addClass('active');
	});	
	
	
	$('#navigation > li').click(function(event){
		$(this).children('a').trigger('click');
	});
	
	
	$('#navigation > li > a').smoothScroll();	
	$('#navigation > li > a').click(function(event){event.stopPropagation();})
	
	$('#bottomNavigation > li > a').smoothScroll();	
	$('#bottomNavigation > li > a').click(function(event){event.stopPropagation();})
	
	
	$("#gallery").jCarouselLite({
	    vertical: false,
	    mouseWheel: true,
	    auto:4000,
	    speed:1500,
	    visible:5,
	    easing: "elasout"
	    /*btnNext: ".next",
	    btnPrev: ".prev"*/
	});
	
	$("#frmContacto").submit(function(){
		$(this).addClass("hidden");
		$("#frmContactoAjax").removeClass("hidden");
		
		var dataString = $("#frmContacto").serialize();
		jQuery.ajax({
      type: "POST",
      url: "contacto.php",
      data: dataString,
      dataType: "html",      
      success: function(response) {
    		$("#frmContactoResponse").css('display','block');
      	$("#frmContactoResponse").html(response);
      	$("#frmContacto").removeClass("hidden");
      	document.forms['frmContacto'].reset()
      	$("#frmContactoAjax").addClass("hidden");
      	$("#frmContactoResponse").fadeOut(10000);
      }		       
    });
    return false;
	});
	
	$(".addButton").click(function(){
		var producto = $(this).attr('value');
		$("#cart").load("cart.php", {'producto':producto, /*'opcion':opcion, 'opciones':opciones*/}, function(){
			//$('.col3').fadeOut(250);
			//$('.col3').fadeIn(450);
	 	});
	});
	
	$("#productThumb").click(function(){
		$("#btPopup").trigger('click');
	});
			
	
});


		
$(window).load(function() {
	$('#slider').nivoSlider({pauseTime:8000});
	$('#sliderSucursales').nivoSlider({pauseTime:5000,controlNavThumbs:true});
	
	initialize();
});


function cancelItem(item){$("#cart").load("cart.php", {'item':item}, function(){});}
function editItem(item){Shadowbox.open({player:'iframe', content:'edit.php?id='+item, width:500, height:500});}
function refreshCart(){$("#cart").load("cart.php");}
