/**
 * auto triggered by jQuery when document is loaded.
 * attach all events.
 */
var gmaploaded=0;
var requestdata=1;
var bgmapicon;
var countrymarkers=[];
var localmarkers=[];
var countrycounticons=[];
var swfplayers=[];
var iconOptions;
var geocoder;
var viewlevel;
var mymapcontrol;
var europecenter ="Zurich";

$(document).ready( function() {
	
	setvars.init();
	tournaments.init();
	tournamentInfoLocation.init();
	tournamenttextsearch.init();
	tournamenttextsearchtop.init();
	
	galleryvideoitems.init()
	if ($('#firstfocus').length !=0){
		$('#firstfocus').focus();
	}

	$('a.galleryitemimageclickablebymouse').lightBox({
	imageLoading: '/fileadmin/newtemplates/img/lightbox-ico-loading.gif',
	imageBtnClose: '/fileadmin/newtemplates/img/lightbox-btn-close.gif',
	imageBtnPrev: '/fileadmin/newtemplates/img/lightbox-btn-prev.gif',
	imageBtnNext: '/fileadmin/newtemplates/img/lightbox-btn-next.gif'
   	}); 
});


var galleryvideoitems = {	
		init : function() {  
			if ($('#medianavwrap').length ==0) return;
		
			$('div.galleryvideoitem').each(function(){
				renderVideoPlayer($(this).children('input').val(),$(this).attr('id'));
			});
		}
	}

var tournamentInfoLocation = {	
		init : function() {  
			if ($('#tournament_info_map').length ==0) return;
		
			if (GBrowserIsCompatible()) { 		
				var el_tourInfoMap = $('#tournament_info_map');
				var str_tourInfoAddress =el_tourInfoMap.html();
					
				gmap = new GMap2(document.getElementById("tournament_info_map"));
				geocoder = new GClientGeocoder();
				geocoder.getLocations(str_tourInfoAddress, function(response){
					
					var icon = new GIcon();
					icon.image = "/fileadmin/newtemplates/img/icon_cup.png";
					icon.iconSize = new GSize(28, 35);
					icon.iconAnchor = new GPoint(14, 35);
					icon.infoWindowAnchor = new GPoint(5, 2);
					icon.infoShadowAnchor = new GPoint(14, 25);
					icon.transparent = "/fileadmin/newtemplates/img/icon_cup.png";

					
					var place = response.Placemark[0];
					var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
					var marker = new GMarker(point,icon);
					gmap.setCenter(point, 9, G_HYBRID_MAP);
					gmap.addControl(new GSmallMapControl());
					gmap.addOverlay(marker);						
				}						
				);
				
				 
			}
		}
	}


var tournamenttextsearch={
	init : function() {
	  if ($('#query').length !=0){		
			var options, a;
			jQuery(function(){
			  options = { serviceUrl:location.href,
					  	params: { ajax:'1' },
					  	onSelect: function(value, data){ 
					  		var domain=document.domain;
					  		var url="";
					  		if(domain){
					  			url="http://"+domain+"/"+data;
					  		}else{
					  			url=data;
					  		}
					  		document.location.href=url; 
					  	}		  	
			  };
			  a = $('#query').autocomplete(options);
			});
	  }
	}
}

var tournamenttextsearchtop={
	init : function() {
	  if ($('#querytop').length !=0){
			if($("#querytop").val().length==0)
				$("#querytop").DefaultValue($("#querytopbaseval").val());
	  
	  
			  $("#querytop").keypress(function(e)
				{
					code= (e.keyCode ? e.keyCode : e.which);
					if (code == 13 || code==10) {
						document.location.href=$('#hiddentournamentspagelink').val()+"?tournamentname="+encodeURIComponent($("#querytop").val()); 
						e.preventDefault();
					}
					
				});

				$('#submittopquerysearch').click(function() {
						document.location.href=$('#hiddentournamentspagelink').val()+"?tournamentname="+encodeURIComponent($("#querytop").val()); 
				});
								
	  
			var options, a;
			jQuery(function(){//service url hidden in footer plugin
			  options = { serviceUrl:$('#hiddentournamentspagelink').val(),
					  	params: { ajax:'1' },
					  	onSelect: function(value, data){ 
					  		var domain=document.domain;
					  		var url="";
					  		if(domain){
					  			url="http://"+domain+"/"+data;
					  		}else{
					  			url=data;
					  		}
					  		document.location.href=url; 
					  	}		  	
			  };
			  a = $('#querytop').autocomplete(options);
			});
	  }
	}
}

var setvars = {	
	init : function() {
	  $('#topfaqlink').html($('#footerfaqlink').text());
	  $("#topfaqlink").attr("href", $('#footerfaqlink').attr("href"));

		$('#lang_type').html($('#sportselector option:selected').text());
		//$('#lang_lang').html($('#languageselector option:selected').text()+' <img src="/fileadmin/newtemplates/img/lang.png" height="15px"/>');
	  

	}
}


function submitmailafriend(errormsg){
	var namesender;
	var emailsender;
	var namereceiver;
	var emailreceiver;
	var subject;
	var content;
	
	var errors=0;
	
	if($("#namesender").val()){
		namesender=$("#namesender").val();
	}else{
		errors=1;
	}

	if($("#emailsender").val()){
		emailsender=$("#emailsender").val();
	}else{
		errors=1;
	}

	if($("#namereceiver").val()){
		namereceiver=$("#namereceiver").val();
	}else{
		errors=1;
	}

	if($("#emailreceiver").val()){
		emailreceiver=$("#emailreceiver").val();
	}else{
		errors=1;
	}

	if($("#subject").val()){
		subject=$("#subject").val();
	}else{
		errors=1;
	}

	if($("#content").val()){
		content=$("#content").val();
	}else{
		errors=1;
	}

	if(errors>=1){
		alert(errormsg);
	}else{		
		$.getJSON(location.href, 
		 {"ajax":"1","namesender":namesender,"emailsender":emailsender,"namereceiver":namereceiver,"emailreceiver":emailreceiver,"subject":subject,"content":content} ,function(data){
	
				$.each(data.result, function (i, t) {	  
					
					if(t["errorsfound"]){
						alert(t["response"]);
					}else{					
						$('#mailteamdivbody').html(t["response"]);
					}
				});
	
		 });
	}
		
	return false;
}

function jqCheckAll( id, name,disable )//used on tournaments page
{
	
	if($("#" + id).is(':checked')){
		
			$("INPUT[name=" + name + "][type='checkbox']").attr('checked', false);
			if(disable)
			 $("#" + id).attr('disabled', true);
	}
	
	getNumberOfSearchResults();
   
}


function jqOnClickCkbx(id,name,disable){
	
	
	if($("INPUT[name=" + name + "][type='checkbox']").is(':checked')){
	   if(disable)
		   $("#" + id).attr('disabled', false);
	   
	   $("#" + id).attr('checked', false);
	}else{	   
	   $("#" + id).attr('checked', true);
	   
	   if(disable)
		   $("#" + id).attr('disabled', true);
	} 
	getNumberOfSearchResults();
}

function jqOnClickCkbxoffer(id,name){	
	
	if($("INPUT[name=" + name + "][type='checkbox']").is(':checked')){	   
	   $("#" + id).attr('checked', false);
	}
}




$.ajaxSetup ({   
    cache: false  
});   

function jqQuickSearchGetValues(){
	var selectedsport = $("#searchsport").val();
	//location.href
	$('#searchperiod option:not(:first)').remove();
	$('#searchgroups option:not(:first)').remove();
	$('#searchcountries option:not(:first)').remove();
	
    $.getJSON(location.href+'?ajax=1', {'selectedsport' : selectedsport}, function(data){
    	
    	$.each(data.periods, function (i, t) {	    		
    		$("#searchperiod").append("<option value='"+t['id']+"'>"+t['name']+"</option>");
    				        		
    	});
    	
    	$.each(data.groups, function (i, t) {	    		
    		$("#searchgroups").append("<option value='"+t['id']+"'>"+t['name']+"</option>");
    				        		
    	});
    	
    	$.each(data.countries, function (i, t) {	    		
    		$("#searchcountries").append("<option value='"+t['id']+"'>"+t['name']+"</option>");
    				        		
    	});

    	$.each(data.posturl, function (i, t) {	 
    		$("#quicksearchform").attr("action",t['value']);
    				        		
    	});

    	
    });
}

function jqTourneyInfoDivChange(clickid){
	
	//alles inactivaten
	 $("#" + "tournamentinfomain").attr('class', '');
	 $("#" + "tournamentinfoprogramme").attr('class', '');
	 $("#" + "tournamentinfostay").attr('class', '');
	 $("#" + "tournamentinfohistory").attr('class', '');
	 $("#" + "tournamentinfotouristinfo").attr('class', '');
	 $("#" + "tournamentinfosponsorpackage").attr('class', '');
	 
	 $("#" + "tournamentinfomain_div").css({display:"none"});
	 $("#" + "tournamentinfoprogramme_div").css({display:"none"});
	 $("#" + "tournamentinfostay_div").css({display:"none"});
	 $("#" + "tournamentinfohistory_div").css({display:"none"});
	 $("#" + "tournamentinfotouristinfo_div").css({display:"none"});
	 $("#" + "tournamentinfosponsorpackage_div").css({display:"none"});
	//activate div + link
	 $("#" + clickid).attr('class', 'active');
	 $("#" + clickid+"_div").css({display:"block"});
}


function renderVideoPlayer(defile,thevideodiv){
	
	var flashvars  = {};	
	var params     = {};
	var attributes = {};
	flashvars.file = defile;
	flashvars.bufferlength=10; 
	///params.base = "static/swf"; 
	params.allowFullScreen = "true";
	params.allowscriptaccess="always"; 
	params.wmode = "opaque";
	params.name=thevideodiv;
	swfobject.embedSWF("fileadmin/newtemplates/iframes/swf/player.swf", thevideodiv, "320", "210", "9.0.115.0", "swf/expressInstall.swf", flashvars, params, attributes);
	
	
	/*
	swfobject.embedSWF("fileadmin/newtemplates/iframes/swf/flowplayer-3.1.5.swf", thevideodiv, "320", "210", "9.0.0", null, {  
	    config: "{'clip': '"+defile+"' }}" 
	    } 
	);  
	*/
	return true;
}

/*
 * tournament googlemaps search
 */


var tournaments = {	
		init : function() {
		  
			$("#search_results").change(function () {
				$("#search_results_form").submit();
		      });
			
			$("#search_sort").change(function () {
				$("#search_sort_form").submit();
		      });
			
			if ($('#map').length ==0) return;
			
			if (GBrowserIsCompatible()) { 		
				
				
				bgmapicon = new GIcon();
				bgmapicon.image = "/fileadmin/newtemplates/img/bg_map_number.png";
				bgmapicon.iconSize = new GSize(25, 25);
				bgmapicon.iconAnchor = new GPoint(5, 34);
				bgmapicon.infoWindowAnchor = new GPoint(5, 2);
				bgmapicon.infoShadowAnchor = new GPoint(14, 25);
				bgmapicon.transparent = "/fileadmin/newtemplates/img/bg_map_number.png";

				
				gmap = new GMap2(document.getElementById("map"));
				geocoder = new GClientGeocoder();
				geocoder.getLocations(europecenter, function(response){
					var place = response.Placemark[0];
					var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
					gmap.setCenter(point, 4, G_HYBRID_MAP);
				});
				//gmap.addControl(new GSmallMapControl());
				//gmap.addControl(new GMapTypeControl());

				GDownloadUrl("/fileadmin/newtemplates/polylines/Netherlands", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Belgium", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/France", loadcountry);				
				GDownloadUrl("/fileadmin/newtemplates/polylines/United%20Kingdom", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Germany", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Spain", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Denmark", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Italy", loadcountry);

				GDownloadUrl("/fileadmin/newtemplates/polylines/Switzerland", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Austria", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Croatia", loadcountry);
				GDownloadUrl("/fileadmin/newtemplates/polylines/Czech%20Republic", loadcountry);

				
				iconOptions = {};
				iconOptions.width = 25;
				iconOptions.height = 25;
				iconOptions.primaryColor = "#85180f";
				iconOptions.label = "10";
				iconOptions.labelSize = 0;
				iconOptions.labelColor = "#FFFFFF";
				iconOptions.shape = "circle";
				
				gmaploaded=1;
				viewlevel="europe";
				getNumberOfSearchResults();

				/*
				countrymarkers[0] = new GMarker(new GLatLng(52.3, 5.2),icon);//netherlands
				gmap.addOverlay(countrymarkers[0]);
				countrymarkers[1] = new GMarker(new GLatLng(50.6, 4.9),icon);//belgium
				gmap.addOverlay(countrymarkers[1]);
				countrymarkers[2] = new GMarker(new GLatLng(47.0, 2.4),icon);//france
				gmap.addOverlay(countrymarkers[2]);
				countrymarkers[3] = new GMarker(new GLatLng(52.7, -1.4),icon);//uk
				gmap.addOverlay(countrymarkers[3]);
				countrymarkers[4] = new GMarker(new GLatLng(52, 10),icon);//germany
				gmap.addOverlay(countrymarkers[4]);
				countrymarkers[5] = new GMarker(new GLatLng(39.8, -4.2),icon);//spain
				gmap.addOverlay(countrymarkers[5]);				
				countrymarkers[6] = new GMarker(new GLatLng(55.2, 9.4),icon);//denmark
				gmap.addOverlay(countrymarkers[6]);				
				countrymarkers[7] = new GMarker(new GLatLng(41.7, 14.2),icon);//italy
				gmap.addOverlay(countrymarkers[7]);				
				countrymarkers[8] = new GMarker(new GLatLng(46.7, 8.1),icon);//switzerland
				gmap.addOverlay(countrymarkers[8]);				
				countrymarkers[9] = new GMarker(new GLatLng(47.4, 14.4),icon);//austria
				gmap.addOverlay(countrymarkers[9]);				
				countrymarkers[10] = new GMarker(new GLatLng(44.7, 15.1),icon);//Croatia
				gmap.addOverlay(countrymarkers[10]);				
				countrymarkers[11] = new GMarker(new GLatLng(49.7, 15.0),icon);//Czech republic
				gmap.addOverlay(countrymarkers[11]);				
					
				*/
			}			
		}
	}

function loadcountry(data, responseCode)
{
	if((200==responseCode)&&(0!=data.length))
	{
		try{
			var iStart = 0;
			var arePoints = false;
			var polylineLevels = "";
			//File structure is [encoded Levels<br>encoded Polylines<br>...]
			do
			{
				var iEnd = data.indexOf("<br>",iStart);
				if( false == arePoints)
				{//Levels
					polylineLevels = data.substring(iStart,iEnd);
					arePoints = true;
				}
				else
				{//Points
					var polygon = new  GPolygon.fromEncoded({
					 polylines: [{color: "#000000", weight: 1, opacity:1.0,
					 points: data.substring(iStart,iEnd),
					 levels: polylineLevels,
					 zoomFactor: 2, numLevels: 18}], 
					fill: true, color:"#85180f", opacity: 0.2, outline: true});
					gmap.addOverlay(polygon);
					arePoints = false;
				}
				iStart = iEnd + 4;//jump above '<br>' to the next polylines
			}while( data.length > iStart)
		}catch(e){
			//here code to deal with errors;
		}
	}
	else
	{
		//here code to deal with errors;
	}
}
 

function getNumberOfSearchResults(){
	
	var categories="";
	var periods="";
	var countries="";

	if(!$("#checkAllAge").is(':checked')){
		var selectedItems = new Array();
		$("input[name='checkAge[]']:checked").each(function() {selectedItems.push($(this).val());});
		categories=selectedItems.join(',');
	}

	if(!$("#checkAllPeriod").is(':checked')){
		var selectedItems = new Array();
		$("input[name='checkPeriod[]']:checked").each(function() {selectedItems.push($(this).val());});
		periods=selectedItems.join(',');
	}
	
	if(!$("#checkAllCountry").is(':checked')){
		var selectedItems = new Array();
		$("input[name='checkCountry[]']:checked").each(function() {selectedItems.push($(this).val());});
		countries=selectedItems.join(',');
	}
	
	
	if(viewlevel=="europe"){
	
		$.getJSON(location.href,  {"ajax":"1","categories":categories,"periods":periods,"countries":countries} ,function(data){
		//$("#preliminarysearchresults").html(data.data);
				
				if(gmaploaded){
					for(var i=0;i<countrymarkers.length;i++){
						if(countrymarkers[i])
							gmap.removeOverlay(countrymarkers[i]);
						countrymarkers[i]=false;
					}
					if(data.country){
		
						$.each(data.country, function (i, t) {	  
							//alert(t['id']+"|"+t['count']);
							
							iconOptions.label = t['count'];				
							var icon = MapIconMaker.createFlatIcon(iconOptions);
							
							if(t['id']==85){
								countrymarkers[9] = new GMarker(new GLatLng(47.4, 14.4),icon);//austria
								gmap.addOverlay(countrymarkers[9]);	
								GEvent.addListener(countrymarkers[9], "click", function() {  showCountryTournies(categories,periods,t['id'],"Austria",6);  });
							}else if(t['id']==134){
								countrymarkers[1] = new GMarker(new GLatLng(50.6, 4.9),icon);//belgium
								gmap.addOverlay(countrymarkers[1]);
								GEvent.addListener(countrymarkers[1], "click", function() {  showCountryTournies(categories,periods,t['id'],"Belgium",7);  });
							}else if(t['id']==281){
								countrymarkers[8] = new GMarker(new GLatLng(46.7, 8.1),icon);//switzerland
								gmap.addOverlay(countrymarkers[8]);	
								GEvent.addListener(countrymarkers[8], "click", function() {  showCountryTournies(categories,periods,t['id'],"Switzerland",6);  });
							}else if(t['id']==365){
								countrymarkers[11] = new GMarker(new GLatLng(49.7, 15.0),icon);//Czech republic
								gmap.addOverlay(countrymarkers[11]);
								GEvent.addListener(countrymarkers[11], "click", function() {  showCountryTournies(categories,periods,t['id'],"Czech republic",7);  });
							}else if(t['id']==372){
								countrymarkers[4] = new GMarker(new GLatLng(52, 10),icon);//germany
								gmap.addOverlay(countrymarkers[4]);
								GEvent.addListener(countrymarkers[4], "click", function() {  showCountryTournies(categories,periods,t['id'],"Germany",5);  });
							}else if(t['id']==386){
								countrymarkers[6] = new GMarker(new GLatLng(55.2, 9.4),icon);//denmark
								gmap.addOverlay(countrymarkers[6]);	
								GEvent.addListener(countrymarkers[6], "click", function() {  showCountryTournies(categories,periods,t['id'],"Denmark",6);  });
							}else if(t['id']==449){
								countrymarkers[5] = new GMarker(new GLatLng(39.8, -4.2),icon);//spain
								gmap.addOverlay(countrymarkers[5]);
								GEvent.addListener(countrymarkers[5], "click", function() {  showCountryTournies(categories,periods,t['id'],"Spain, Zaragosa",6);  });
							}else if(t['id']==498){
								countrymarkers[2] = new GMarker(new GLatLng(47.0, 2.4),icon);//france
								gmap.addOverlay(countrymarkers[2]);
								GEvent.addListener(countrymarkers[2], "click", function() {  showCountryTournies(categories,periods,t['id'],"France",5);  });
							}else if(t['id']==512){
								countrymarkers[3] = new GMarker(new GLatLng(52.7, -1.4),icon);//uk
								gmap.addOverlay(countrymarkers[3]);
								GEvent.addListener(countrymarkers[3], "click", function() {  showCountryTournies(categories,periods,t['id'],"United Kingdom",5);  });
							}else if(t['id']==645){
								countrymarkers[10] = new GMarker(new GLatLng(44.7, 15.1),icon);//Croatia
								gmap.addOverlay(countrymarkers[10]);
								GEvent.addListener(countrymarkers[10], "click", function() {  showCountryTournies(categories,periods,t['id'],"Croatia",7);  });
							}else if(t['id']==722){
								countrymarkers[7] = new GMarker(new GLatLng(41.7, 14.2),icon);//italy
								gmap.addOverlay(countrymarkers[7]);	
								GEvent.addListener(countrymarkers[7], "click", function() {  showCountryTournies(categories,periods,t['id'],"Italy, Bologna",6);  });
							}else if(t['id']==1093){
								countrymarkers[0] = new GMarker(new GLatLng(52.3, 5.2),icon);//netherlands
								gmap.addOverlay(countrymarkers[0]);							
								GEvent.addListener(countrymarkers[0], "click", function() {  showCountryTournies(categories,periods,t['id'],"Netherlands",7);  });							 
							}
							
				    		//$("#searchperiod").append("<option value='"+t['id']+"'>"+t['name']+"</option>");
				    				        		
				    	});
						
					}
					
				}
		});
	}
	
}

function showCountryTournies(categories,periods,countries,address,fov){
	viewlevel="country";
	
	for(var i=0;i<countrymarkers.length;i++){
		if(countrymarkers[i])
			gmap.removeOverlay(countrymarkers[i]);
		countrymarkers[i]=false;
	}
	for(var i=0;i<localmarkers.length;i++){
		if(localmarkers[i])
			gmap.removeOverlay(localmarkers[i]);
		localmarkers[i]=false;
	}	
	
	geocoder.getLocations(address, function(response){
		var place = response.Placemark[0];
		var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
		gmap.setCenter(point,fov);
	});
	
	var iterator=0;
	
	var icon = new GIcon();
	icon.image = "/fileadmin/newtemplates/img/icon_cup.png";
	icon.iconSize = new GSize(28, 35);
	icon.iconAnchor = new GPoint(14, 35);
	icon.infoWindowAnchor = new GPoint(5, 2);
	icon.infoShadowAnchor = new GPoint(14, 25);
	icon.transparent = "/fileadmin/newtemplates/img/icon_cup.png";

	mymapcontrol = new mapcontrolbutton();
	gmap.addControl(mymapcontrol);
	$.getJSON(location.href, 
			 {"ajax":"1","categories":categories,"periods":periods,"countries":countries,"viewlevel":viewlevel} ,function(data){
				
				$.each(data.tournament, function (i, t) {	  

					localmarkers[iterator] = new GMarker(new GLatLng(t['lat'], t['long']),icon);
					
					GEvent.addListener(localmarkers[iterator], "click", function() {
						gmap.openInfoWindowHtml(new GLatLng(parseFloat(t['lat']), parseFloat(t['long'])),t['infowindowhtml'],  {pixelOffset: new GSize(10,-15)});
					  });

					GEvent.addListener(localmarkers[iterator], "mouseover", function() {
						gmap.openInfoWindowHtml(new GLatLng(parseFloat(t['lat']), parseFloat(t['long'])),t['infowindowhtml'],  {pixelOffset: new GSize(10,-15)});
					  });
					
			        gmap.addOverlay(localmarkers[iterator]);
		    				        	
			        iterator++;
		    	});
		});
}

function mapcontrolbutton(){

}

mapcontrolbutton.prototype= new GControl();
mapcontrolbutton.prototype.initialize= function(map){
	var buttondiv = document.createElement("div");
	this.setButtonStyle_(buttondiv);
	buttondiv.appendChild(document.createTextNode($("#maptoeuropelabelname").val()));
	
	GEvent.addDomListener(buttondiv,"click",function(){
		gmap.removeControl(mymapcontrol);
		for(var i=0;i<localmarkers.length;i++){
			if(localmarkers[i])
				gmap.removeOverlay(localmarkers[i]);
			localmarkers[i]=false;
		}	
		geocoder.getLocations(europecenter, function(response){
			var place = response.Placemark[0];
			var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
			gmap.setCenter(point, 4, G_HYBRID_MAP);
		});
		viewlevel="europe";
		getNumberOfSearchResults();
		
	});
	
	gmap.getContainer().appendChild(buttondiv);
	return buttondiv;
}

mapcontrolbutton.prototype.getDefaultPosition = function (){
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7,7));
}

mapcontrolbutton.prototype.setButtonStyle_ = function(button){
	button.style.backgroundColor = "#85180f";
	button.style.border = "1px solid gray";
	button.style.color = "white";
	button.style.padding = "2px";
	button.style.marginBottom = "3px";
	button.style.textAlign = "center";
	button.style.width = "6em";
	button.style.cursor = "pointer";
}


jQuery.fn.DefaultValue = function() {

		// Scope
		var elements = this;
		var args = arguments;
		var c = 0;

		return(
			elements.each(function() {				

				// Default values within scope
				var el = $(this);
				var def = args[c++];

				el.val(def).focus(function() {
					if(el.val() == def) {
						el.val("");
					}
					el.blur(function() {
						if(el.val() == "") {
							el.val(def);
						}
					});
				});

			})
		);
	};

