function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
	
function setLocation(number,lay,layText) { locations=grpName
locations[0] = 'District 20'
lats[0] = 34.7;
longi[0] = -86.865;
//var locations = new Array ('District 20','Fellowship','Central Office','Downtown Group','Madison Hopeful','Trinity',
	//* 6 */ 'Decatur Serenity Group','Stairway','Despertar 2000','Unity Through Recovery','Faith and Hope',
	//*11*/ 'Fresh Air','Huntsville Group','Joy of Living','Redstone Arsenal','Solutions',
	//*16*/ 'Southside','Southside','Unity','New Hope','New Market',
	//*21*/ 'Harvest','3 Legacies','Primary Purose Meeting','Wits End Group','Athens Serenity',
	//*26*/	'Cove Group','Maple Leaf Group','AA Meeting','Live and Let Live')
	//var Streets = new Array (' ','2611 Leeman Ferry Rd SW','3322 Memorial Parkway SW','801 Governors Dr SW','181 Hughes Rd','702 N Seneca Dr',
	//* 6 */ '4110 Old US Hwy 31','6th Ave SE & Magnolia St SE','6th Ave SE & Magnolia St SE','801 Jackson St SE','3104 Ivy Ave SW',
	//*11*/  '3104 Ivy Ave SW','2207 Memorial Pkwy NW','4315 Holmes Ave NW','376 Goss Rd SW','205 Max Luther Dr',
	//*16*/  '301 Drake Ave SE','607 Airport Rd SW','3209 Whitesburg Dr S','5529 Main Dr','171 County Lake Rd',
	//*21*/  '5503B Hwy 53','12220 Bailey Cove SE','3321 Memorial Pkwy SW','400 W Market St','518 S Clinton',
	//*26*/	'283 Sutton Rd SE','145 Camp Ground Rd','1055 Hughes Rd.','4040 Memorial Pkwy SW')
	//var Cities = new Array (' ','Huntsville Al 35801','Huntsville Al 35801','Huntsville Al 38001','Madison AL 35758','Trinity AL 35673',
	//* 6 */ 'Decatur, AL 35603','Decatur, AL 35601','Decatur, AL 35601','Decatur, AL 35601','Huntsville AL 35811',
	//*11*/  'Huntsville AL 35805','Huntsville AL 35810','Huntsville AL 35815','Huntsville AL 35816','Huntsville AL 35898',
	//*16*/  'Huntsville AL 35802','Huntsville AL 35802','Huntsville AL 35802','New Hope AL 35760','New Market AL 35761',
	//*21*/  'Harvest AL 35749','Huntsville AL 35803','Huntsville AL 35801','Athens, AL 35611','Athens AL 35611',
	//*26*/	'Hampton Cove Al 35763','Brownsboro Al 35741','Madison AL 35758','Huntsville Al 35803')
	//var Photos = new Array (0,1,1,1,1,0,
	//* 6*/   0,0,0,0,1,
	//*11*/   1,1,0,0,1,
	//*16*/   0,0,1,1,0,
	//*21*/   0,1,1,1,0,
	//*26*/	 1,1,1,0) 
	var addrs = new Array;
	address  = Streets[number]+', '+Cities[number]; //new Array('12220 Bailey Cove&nbsp;SE , Huntsville,AL','2611 Leeman Ferry Rd SW,Huntsville,Al','3322 Memorial Parkway SW,Huntsville,AL',
	//* 3*/ '801 Governors Dr SW Huntsville, AL 38005','181 Hughes Rd, Madison AL 35758','702 N Seneca Dr,Trinity AL 35673','4110 Old US Hwy 31, Decatur, AL 35603',
	//* 7*/ '6th Ave SE %26 Magnolia St SE, Decatur, AL 35601','6th Ave SE %26 Magnolia St SE, Decatur, AL 35601','801 Jackson St SE,Decatur AL 35601',
	//*10*/ '3104 Ivy Ave SW, Huntsville AL 35805','3104 Ivy Ave SW, Huntsville AL 35805','2207 Memorial Pkwy NW, Huntsville, AL 35801',
	//*13*/ '4315 Holmes Ave NW, Huntsville AL 35816','376 Goss Rd SW, Huntsville, AL 35898','205 Max Luther Dr, Huntsville AL 35811',
	//*16*/ '301 Drake Ave SE, Huntsville AL 35802','700 Airport Rd, Huntsville,AL','3209 Whitesburg Dr S,Huntsville AL 35802','5526 Main Dr, New Hope AL 35760',
	//*20*/ '171 County Lake Rd, New Market,AL 35761','34.83571,-86.704402','12220 Bailey Cove SE, Huntsville,AL','3321 Memorial Pkwy SW, Huntsville, AL 35801',
	//*24*/ '400 W Market St, Athens, AL 35611','518 S Clinton, Athens, AL 35611','283 Sutton Rd SE, Hampton Cove, Al 35763',
	//*27*/ '145 Camp Ground Rd, Brownsboro, Al 35741','1055 Hughes Rd, Madison, AL 35758','4040 Memorial Pkwy SW, Huntsville, AL 35803')
	//var lats = new Array (34.7,34.709015,34.700993,34.719901,34.702339,34.606945,34.530246,34.577936,34.577936,34.600492,34.705295,34.705295,34.7499556,34.727490,34.698378,34.757990, 	34.705091,34.690953,34.702745,34.534853,34.843408,34.83571,34.630960,34.700704,34.803483,34.798624, 	34.660141,34.682364,34.733025,34.683691);
	//var longi = new Array (-86.685,-86.591582,-86.586179,-86.591892,-86.742027,-87.088135,-86.975864,-86.976718,-86.976718,-86.977608,-86.607279,-86.607279,-86.5987613,-86.633794,-86.634701,-86.580123,-86.568263, -86.573575, -86.569178,-86.394588,-86.458015,-86.704402,-86.539240,-86.585559,-86.973356,-86.969176,-86.488980,-86.500056,-86.741101,-86.578192)
	//whois = "<?php echo urlencode($locate); ?>"
	//MMShowLayer(0)
	var WINDOW_HTML = '<div style="width: 550px; font-size: 20; color: black">'+locations[number]+'<span style="width: 16em; font-size: )12; color: black"><BR> To get directions to '+locations[number]+' key in your starting location<br>( Street Address, City, State) and press the submit buttton</span><form name="frmLoc" method="post" action="javascript:;" onSubmit="getDirection('+number+',\''+address+'\')"><input type="text" name="txtLoc"><input type="submit" name="btnSubmit" value="Submit"></form><a href=javascript:; Onclick="getDirection('+number+',\''+address+'\')"></div>';
	var icon = new GIcon();
	icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
	icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	icon.iconSize = new GSize(12, 20);
	icon.shadowSize = new GSize(22, 20);
	icon.iconAnchor = new GPoint(6, 20);	
	icon.infoWindowAnchor = new GPoint(5, 1);
    var map = new GMap(lay);
    map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
    map.centerAndZoom(new GPoint(longi[number],lats[number]),3+4*(number==0))
	if (number==0) {var market = new Array;
		layText.innerHTML ='Click on Marker to show Group Name and Location';
		for (i=1;i<lats.length;i++) {if (lats[i]==null) {continue};
			var points = new Array 
			var infoBall = '<div style="width: 550px; style: font-size: small; color: black">Click on any marker to find Group Name and Address</div>'
			var balloon = new Array
			balloon[i] ='<div style="width: 300px; style: font-size: small; color: black">'+locations[i]+'<BR>'+Streets[i]+'<BR>'+Cities[i]+'</div>';
		points[i] =    createMarker(new GPoint(longi[i],lats[i]), balloon[i],'mouseover')           //////new GMarker(new GPoint(longi[i],lats[i]), 4)
		map.addOverlay(points[i])
		marker= points[i]
			 
		// GEvent.addListener(points[i], 'click', function() {points[i].openInfoWindowHtml(WINDOW_HTML);})
		}}
	else {
		if (Photos[number]=='1') {
			if (number==2) {layText.innerHTML='Click on Marker to show photo of Central Office'}
			else {layText.innerHTML='Click on Marker to show photo of meeting location'}}
		else {layText.innerHTML='Coming soon.  Photo of Meeting location'}
		var lyrPhoto = '<div style="width: 490px; height:370px; font-size: 20; color: black"><img name="imgFellow" border="0" src="images/grpPhoto'+number+'.jpg" ></div>';
        var marker=createMarker(new GPoint(longi[number],lats[number]), lyrPhoto,'mousedown')
		map.addOverlay(marker)
		marker.openInfoWindowHtml(WINDOW_HTML);
		}
	//map.setMapType(G_HYBRID_TYPE)
    //]]>
	function createMarker(point,HtMl,action) {
  var marker = new GMarker(point, icon);
  GEvent.addListener(marker, action, function() {
	marker.openInfoWindowHtml(HtMl);

  });
  
	  
  return marker;}
 // alert('mark '+WINDOW_HTML)
}
     
 function getDirection(number,addrs){
  	//window.alert(document.form11.txtLoc.value)
		if (number ==21) {
			location.href='http://maps.google.com/maps?saddr={'+document.frmLoc.txtLoc.value+'}&daddr=34.83571,-86.704402'
		}
		else {
		location.href='http://maps.google.com/maps?saddr={'+document.frmLoc.txtLoc.value+'}&daddr={'+addrs+'}'
		}}


