function ShopPlan(PlanElement, nWidth, nHeight, sUrl, sClassName)
{
	this.PlanElement = PlanElement;
	this.nWidth = nWidth;
	this.nHeight = nHeight;
	this.sClassName = sClassName;
	
	this.render = function(nX, nY, sUrl)
	{
		// create new stuff
		var Link = document.createElement("a");
		Link.innerHTML = "&nbsp;";
		Link.className = this.sClassName;
		Link.style.top = nY+"px";
		Link.style.left = nX+"px";
		Link.href = "pics/map/"+sUrl;
		Link.title = "Bild";
		Link.rel = "lightbox";
		
		this.PlanElement.appendChild(Link);
	}
}

function initPlan()
{
	if(document.getElementById("shopplan")==null)
		return;
		
	var aPics = Array(21, 30, "zum_og.jpg",
							21,215, "kasse1.jpg",
							21,121, "mtb1.jpg",
							64,280, "mtb2.jpg",
							64,315, "mtb4.jpg",
							91,148,"mtb3.jpg",
							182,340,"front.jpg",
							399,295,"kasse2.jpg",
							137,85, "cross1.jpg",
							269,10, "cross2.jpg",
							350,10, "buero.jpg",
							355,135,"kinder.jpg",
							332,228,"bmx1.jpg",
							355,173,"bmx2.jpg",
							320,280,"cruiser1.jpg",
							267,280,"cruiser2.jpg",
							358,280,"cruiser3.jpg",
							320,135,"kinder2.jpg",
							415,327,"cruiser4.jpg");
	var PlanElement = document.getElementById("shopplan");
	var MyShopPlan = new ShopPlan(PlanElement, 40, 40, "images/bg_shopplanpreview.jpg", "shopplanpreview");

	for(var nI = 0; nI < aPics.length; nI+=3)
		MyShopPlan.render(aPics[nI], aPics[nI+1], aPics[nI+2]);
}

function initGMap() 
{
		if( document.getElementById("gmap") == null )
			return;
      if (GBrowserIsCompatible()) 
      {
       // create a simple map and center it on atb location
        var map = new GMap2(document.getElementById("gmap"));
        map.setCenter(new GLatLng(52.3690327, 9.7438606), 14);
        
        // add controls for moving and zooming
        map.addControl(new GSmallMapControl());
        
        // add the atb marker
        var atbmarker = new GMarker(new GLatLng(52.3690327, 9.7438606));
        map.addOverlay(atbmarker);
       
       // and show the info window when clicked
       atbmarker.bindInfoWindowHtml("<p style=\"color:#000\"><strong>ATB Sport GmbH<\/strong><br>Marienstr. 3<br>30171 Hannover<\/p>");
	}
}

function initFormular()
{
	if(document.getElementById("Formular") == null)
		return false;
		
	// set handler
	document.getElementById("Formular").onsubmit = function() 
			{ 
				if( document.getElementById("name").value == "" )		
				{
					document.getElementById("name").focus();
					alert("Bitte geben Sie Ihren Namen ein.");
					return false;
				}
				if( document.getElementById("telephone").value == "" )
				{
					document.getElementById("telephone").focus();
					alert("Bitte geben Sie Ihre Telefonnummer ein.");
					return false;
				}
				if( document.getElementById("email").value == "" )
				{
					document.getElementById("email").focus();
					alert("Bitte geben Sie Ihre E-Mail ein.");
					return false;					
				}
				if( document.getElementById("contentf").value == "" )
				{
					document.getElementById("contentf").focus();
					alert("Bitte geben Sie einen Inhalt ein.");
					return false;					
				} 

				var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
				if ( !filter.test(document.getElementById("email").value) )
				{
					document.getElementById("email").focus();
					alert("Bitte geben Sie eine korrekte E-Mail ein.");
					return false;			
				}
					
				return true;
			};
}

// START UP EVERYTHING
initPlan();
initGMap();
initFormular();