var flashvars = {};
var params = {};
var attributes = {};
params.wmode = 'transparent';
params.allowFullScreen = true;

var Pages = {}

Pages.materia_prima = {
	load: function () {
		swfobject.embedSWF('/files/swf/pages-materia-prima.swf', 'info', '1100', '472', '9.0.0', false, flashvars, params, attributes);
	}
}

Pages.home = function () {
	swfobject.embedSWF('/files/swf/varsovienne.swf', 'main', '1100', '650', '9.0.0', false, flashvars, params, attributes);
}

Pages.tiendas = {
	map: null,
	marker: null,
	load: function () {
	    var options = {
	      zoom: 16,
	      mapTypeId: google.maps.MapTypeId.ROADMAP
	    }

	    $('div.list ul a').click(function () {
	    	var t = $(this);

	    	$('div#content div.map').fadeIn();
	    	$('div#content div.wrap').css('background', 'none');
	    	
			if (Pages.tiendas.map == null) Pages.tiendas.map = new google.maps.Map(document.getElementById("map"), options);
		    if (Pages.tiendas.marker == null) Pages.tiendas.marker = new google.maps.Marker({ map: Pages.tiendas.map, icon: '/img/pages-tiendas-icon.png' });
	    	Pages.tiendas.changeAddres(t.attr('href').replace('#', ''));

		    return false;
	    });
	},
	changeAddres: function (address) {
	    var geocoder = new google.maps.Geocoder();
		geocoder.geocode({ 'address': address }, function (results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				Pages.tiendas.map.setCenter(results[0].geometry.location);
				Pages.tiendas.marker.setPosition(results[0].geometry.location);
			}
		});
	}
}

Pages.productos = {
	load: function () {
		swfobject.embedSWF('/files/swf/pages-productos.swf', 'info', '1100', '371', '9.0.0', false, flashvars, params, attributes);
	}
}

$(document).ready(function () {
	if ($('div.pages.home').length) Pages.home();
	if ($('div.pages.materia-prima').length) Pages.materia_prima.load();
	if ($('div.pages.tiendas').length) Pages.tiendas.load();
	if ($('div.pages.productos').length) Pages.productos.load();
})
