function initPage()
{
	clearFormFields({
		clearInputs: true,
		clearTextareas: true,
		passwordFieldText: true,
		filterClass: "default"
	});
}
function clearFormFields(o)
{
	if (o.clearInputs == null) o.clearInputs = true;
	if (o.clearTextareas == null) o.clearTextareas = true;
	if (o.passwordFieldText == null) o.passwordFieldText = false;
	if (o.addClassFocus == null) o.addClassFocus = false;
	if (!o.filter) o.filter = "default";
	if(o.clearInputs) {
		var inputs = document.getElementsByTagName("input");
		for (var i = 0; i < inputs.length; i++ ) {
			if((inputs[i].type == "text" || inputs[i].type == "password") && inputs[i].className.indexOf(o.filterClass)) {
				inputs[i].valueHtml = inputs[i].value;
				inputs[i].onfocus = function ()	{
					if(this.valueHtml == this.value) this.value = "";
					if(this.fake) {
						inputsSwap(this, this.previousSibling);
						this.previousSibling.focus();
					}
					if(o.addClassFocus && !this.fake) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				inputs[i].onblur = function () {
					if(this.value == "") {
						this.value = this.valueHtml;
						if(o.passwordFieldText && this.type == "password") inputsSwap(this, this.nextSibling);
					}
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
				if(o.passwordFieldText && inputs[i].type == "password") {
					var fakeInput = document.createElement("input");
					fakeInput.type = "text";
					fakeInput.value = inputs[i].value;
					fakeInput.className = inputs[i].className;
					fakeInput.fake = true;
					inputs[i].parentNode.insertBefore(fakeInput, inputs[i].nextSibling);
					inputsSwap(inputs[i], null);
				}
			}
		}
	}
	if(o.clearTextareas) {
		var textareas = document.getElementsByTagName("textarea");
		for(var i=0; i<textareas.length; i++) {
			if(textareas[i].className.indexOf(o.filterClass)) {
				textareas[i].valueHtml = textareas[i].value;
				textareas[i].onfocus = function() {
					if(this.value == this.valueHtml) this.value = "";
					if(o.addClassFocus) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				textareas[i].onblur = function() {
					if(this.value == "") this.value = this.valueHtml;
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
			}
		}
	}
	function inputsSwap(el, el2) {
		if(el) el.style.display = "none";
		if(el2) el2.style.display = "inline";
	}
}
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);
	
/* Google Maps */

function drawmap() {
 var data = [
   { name: "Club Eslek", address: "R&eacute;unions &agrave; l'h&ocirc;tel Leweck", address2: "Route de Clervaux", town: "L-9378 Lipperscheid", phone: "Tel : 99 00 22", fax: "",  email: "", lat:"49.923211750149164", lng:"6.092777252197266" },
   { name: "Club Guttland", address: "R&eacute;unions au Cercle Munster", address2: "3-7 rue M&uuml;nster", town: "L-2160 Luxembourg", phone: "Tel : 47 06 43", fax: "",  email: "", lat:"49.6085009", lng:"6.1362396" },
   { name: "Club Bassin Minier", address: "R&eacute;unions au restaurant Favaro", address2: "19, rue des Remparts", town: "L-4303 Esch-sur-Alzette", phone: "Tel : 54 27 23", fax: "",  email: "", lat:"49.49727858782729", lng:"5.980353131890297" },
   { name: "Club Esch-sur-Alzette", address: "R&eacute;unions au restaurant Acacia", address2: "10, rue de la Libération", town: "L-4210 Esch-sur-Alzette", phone: "Tel : 54 10 61", fax: "",  email: "", lat:"49.493202", lng:"5.9818892" },
   { name: "Club Echternach", address: "R&eacute;unions à l'h&ocirc;tel Bel-Air", address2: "Rue de Berdorf", town: "Echternach", phone: "Tel : 72 93 83", fax: "Fax : 72 86 94",  email: "", lat:"49.81896371980571", lng:"6.4018964767456055" },
   { name: "Club Letzebuerg", address: "R&eacute;unions à la Brasserie Fin Gourmand", address2: "2, route d'Esch", town: "L-1470 Luxembourg", phone: "Tel : 44 23 92", fax: "",  email: "", lat:"49.6055797", lng:"6.1196304" },
   { name: "Club Luxembourg", address: "R&eacute;unions à l'h&ocirc;tel Cravat", address2: "29, bvd Roosevelt", town: "L-2450 Luxembourg", phone: "Tel : 22 19 75", fax: "",  email: "", lat:"49.6097251", lng:"6.1296499" },
   { name: "Club Moselle", address: "R&eacute;unions au restaurant G&eacute;rard Mathes", address2: "37, route du Vin", town: "L-5401 Ahn", phone: "Tel : 76 01 06", fax: "",  email: "", lat:"49.6283592", lng:"6.4240672" },
   { name: "Club Ladies Luxembourg", address: "R&eacute;unions à l'h&ocirc;tel Royal", address2: "12, bvd Royal", town: "L-2449 Luxembourg", phone: "Tel : 24 16 16 1", fax: "Fax : 22 59 48",  email: "", lat:"49.6137028", lng:"6.1269525" },
   { name: "Club Ladies Luxembourg Europe", address: "R&eacute;unions au Cercle Munster", address2: "3-7 rue M&uuml;nster", town: "L-2160 Luxembourg", phone: "Tel : 47 06 43", fax: "",  email: "", lat:"49.6085009", lng:"6.1352396" },
 ];
 
 var map;
 var amyma = new google.maps.LatLng(49.75199266246325, 6.098785400390625);

 var myOptions = {
 zoom : 10,
        center : amyma,
        mapTypeId : google.maps.MapTypeId.TERRAIN,
        disableDefaultUI : true,
        navigationControl : true,
        navigationControlOptions : {
        style : google.maps.NavigationControlStyle.SMALL
		}
 };

 var map = new google.maps.Map(document.getElementById("map"), myOptions);
 
 var i = 0;
 
 var image = 'media/layout/marker51.png';
 var browserver = 0;

 if (jQuery.browser.msie) {
  			browserver= (parseInt(jQuery.browser.version));
		}
 if ( browserver == 6 ) {
		var image = '/media/layout/marker51.gif';
		}
 var infowindow = null;
 var markerarray = new Array();
 while ( i < 10 )
   {
   var contentString = "<div class='infowindow'>" +
   "<h3>"+ data[i].name + "<\/h3><p>" +
   data[i].address + "<br \/>" + data[i].address2 + "<br \/>" + data[i].town + "<br \/>" + "<span class=\"small\">" + data[i].phone + "<br \/>"  + "E-mail: <a href=\"mailto:" + data[i].email + "\">" + data[i].email + "<\/a>" + "<\/span><\/p><\/div>";
   var LatlngClub = new google.maps.LatLng(data[i].lat, data[i].lng);
   infowindow = new google.maps.InfoWindow
       ({
       content: contentString
       });
   markerarray[i] = new google.maps.Marker
       ({
       position: LatlngClub,
       map: map,
	   icon: image,
       title:data[i].name,
	   zIndex: i,
	   html: contentString
       }); 
   var marker = markerarray[i];
   google.maps.event.addListener(marker, 'click', function() 
	   {
       infowindow.setContent(this.html);
	   infowindow.open(map,this);
       });
   i++;
   };

}
/* Login Form */
$(document).ready(function() {
	$("#popup").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'fade',
		'transitionOut'	: 'fade',
		'type'			: 'iframe',
		'opacity'		: false,
		'overlayShow'   : false,
		'autoDimensions' : false,
		'autoScale' : true,
		'scrolling' : 'no',
		'width' : 600,
		'height' : 308
	});
});
