/*  -------------------------------------------  //
//  Projekt:   GRAVIS.de                         //
//  Autor:     Clemens Daum                      //
//  Datum:     16.07.10                          //
//                                               //
//  Dateiname: js/storemap_simple_noflash.js    //
//  -------------------------------------------- */


/*
* 
*
* Liest fileadmin/xml/stores_map.xml aus und fügt die Marker der Store-Karte zu
* die jeweiligen Namen werden per Maus ein-/ausgeblendet
* 
*
* @package  
* @author   Clemens Daum
* @since    16.07.2010
* @change   25.07.2010
* @access   public
* @param    
*/


	$(document).ready(function(){
		// remove noscript fallbacks
		$('.noscript_fallback_hide').removeClass('noscript_fallback_hide');
		
		$.get("fileadmin/xml/stores_map.xml",{},function(xml){
			var scale_xycoordinates = 0.75;
			var x_offset = 27;
			var y_offset = -8;

			$('store',xml).each(function(i) {
				
				var par_id = $(this).attr('id')*1;
				var par_x = ($(this).attr('x')*1*scale_xycoordinates+x_offset);
				var par_y = ($(this).attr('y')*1*scale_xycoordinates+y_offset);
				var par_title = $(this).find('city').text();
				var par_url = $(this).find('page_url').text();

				output_markers = '<a id="store'+par_id+'" class="stores" href="'+par_url+'"><p id="store_name'+par_id+'" class="stores_names" ><span class="left_corner">&nbsp;'+par_title+'</span><span class="right_corner">&nbsp;</span></p></a>';

				$("#storemap_markers").append(output_markers);
				$('#store'+par_id).css({'left':par_x, 'top':par_y, 'display':'inline'});
			});

			// ask for opacity-support - if not take fallback-functions
			if (jQuery.support.opacity) {
				$("a.stores").hover(
						function () {
							var element = $(this).find(".stores_names");
							element.stop();
							element.show();
							element.animate({opacity: 1}, {duration: 500});
						},
						function () {
							var element = $(this).find(".stores_names");
							element.stop();
							element.animate({opacity: 0}, {duration: 500, complete: function() {element.hide();}});
						}
				);
			} else {
				$("a.stores").hover(
						function () {
							var element = $(this).find(".stores_names");
							element.show();
						},
						function () {
							var element = $(this).find(".stores_names");
							element.hide();
						}
				);
			}
		});
	});

