/*cMap vars*/

var cMapNumMaps = 3;//total number of maps
var cMapImgPath = "/webdata/graphics/";
var cMapSel = 0;//current map selected
cMapLetterRef = new Array('r','m','o');//img naming convention uses letters
var cMapReady = false; //once images preloaded this is set to true and MO's run permitted etc.

/*--------------------------------------------------------*/
/*cMap text title strings data*/

cMapStrs = new Array();
cMapStrs[0] = new Array();
cMapStrs[1] = new Array();
cMapStrs[2] = new Array();

cMapStrs[0][222] = "District Council of Cleve";
cMapStrs[0][227] = "The Flinders Ranges Council";
cMapStrs[0][253] = "District Council of Orroroo Carrieton";
cMapStrs[0][255] = "District Council of Peterborough";
cMapStrs[0][262] = "District Council of Renmark Paringa";
cMapStrs[0][285] = "Gerard";
cMapStrs[0][216] = "Berri Barmera Council";
cMapStrs[0][233] = "Kangaroo Island Council";
cMapStrs[0][233] = "District Council of Kangaroo Island";
cMapStrs[0][272] = "City of Victor Harbor";
cMapStrs[0][278] = "District Council of Yankalilla";
cMapStrs[0][213] = "Alexandrina Council";
cMapStrs[0][245] = "District Council of Mt Barker";
cMapStrs[0][246] = "City of Mt Gambier";
cMapStrs[0][231] = "District Council of Grant";
cMapStrs[0][231] = "District Council of Grant";
cMapStrs[0][275] = "Wattle Range Council";
cMapStrs[0][263] = "District Council of Robe";
cMapStrs[0][249] = "Naracoorte Lucindale Council";
cMapStrs[0][236] = "Kingston Regional Council";
cMapStrs[0][268] = "Tatiara District Council";
cMapStrs[0][224] = "The Coorong District Council";
cMapStrs[0][248] = "The Rural City of Murray Bridge";
cMapStrs[0][234] = "District Council of Karoonda East Murray";
cMapStrs[0][266] = "Southern Mallee District Council";
cMapStrs[0][240] = "District Council of Loxton Waikerie";
cMapStrs[0][214] = "Barossa Council";
cMapStrs[0][238] = "Light Regional Council";
cMapStrs[0][243] = "Mid Murray Council";
cMapStrs[0][230] = "Regional Council of Goyder";
cMapStrs[0][250] = "Northern Areas Council";
cMapStrs[0][221] = "Clare & Gilbert Valleys Council";
cMapStrs[0][241] = "District Council of Mallala";
cMapStrs[0][273] = "Wakefield Regional Council";
cMapStrs[0][279] = "District Council of Yorke Peninsula";
cMapStrs[0][225] = "District Council of the Copper Coast";
cMapStrs[0][215] = "District Council of Barunga West";
cMapStrs[0][260] = "Port Pirie Regional Council";
cMapStrs[0][247] = "District Council of Mt Remarkable";
cMapStrs[0][258] = "Pt Augusta City Council";
cMapStrs[0][277] = "The Corporation of the City of Whyalla";
cMapStrs[0][228] = "District Council of Franklin Harbour";
cMapStrs[0][246] = "City of Mt Gambier";
cMapStrs[0][285] = "Gerard";
cMapStrs[0][259] = "City of Pt Lincoln";
cMapStrs[0][259] = "City of Pt Lincoln";
cMapStrs[0][270] = "District Council of Tumby Bay";
cMapStrs[0][239] = "District Council of Lower Eyre Peninsula";
cMapStrs[0][226] = "District Council of Elliston";
cMapStrs[0][235] = "District Council of Kimba";
cMapStrs[0][237] = "District Council of Le Hunte";
cMapStrs[0][267] = "District Council of Streaky Bay";
cMapStrs[0][219] = "District Council Ceduna";

cMapStrs[1][229] = "Town of Gawler";
cMapStrs[1][212] = "Adelaide Hills Council";
cMapStrs[1][251] = "The City of Norwood, Payneham &amp; St Peters";
cMapStrs[1][274] = "Corporation of the Town of Walkerville";
cMapStrs[1][217] = "The City of Burnside";
cMapStrs[1][271] = "City of Unley";
cMapStrs[1][244] = "City of Mitcham";
cMapStrs[1][252] = "City of Onkaparinga";
cMapStrs[1][242] = "City of Marion";
cMapStrs[1][232] = "City of Holdfast Bay";
cMapStrs[1][220] = "City of Charles Sturt";
cMapStrs[1][276] = "City of West Torrens";
cMapStrs[1][211] = "Adelaide City Council";
cMapStrs[1][261] = "City of Prospect";
cMapStrs[1][257] = "Port Adelaide Enfield";
cMapStrs[1][218] = "Campbelltown City Council";
cMapStrs[1][269] = "City of Tea Tree Gully";
cMapStrs[1][265] = "City of Salisbury";
cMapStrs[1][256] = "City of Playford";

cMapStrs[2][284] = "Nepabunna";
cMapStrs[2][264] = "Municipal Council of Roxby Downs";
cMapStrs[2][264] = "Municipal Council of Roxby Downs";
cMapStrs[2][223] = "District Council of Coober Pedy";
cMapStrs[2][223] = "District Council of Coober Pedy";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][283] = "Yalata";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][254] = "Outback Areas Community Development Trust";
cMapStrs[2][282] = "Maralinga Tjarutja";
cMapStrs[2][281] = "Anangu Pitjantjatjara";


/*--------------------------------------------------------*/
/*cMap img preloader*/

//note list assumes all are gifs, each map (0,1,2) is delimited by '_legend' img str
cMapImgs = new Array("cMap_0_222","cMap_0_227","cMap_0_253","cMap_0_255","cMap_0_262","cMap_0_285","cMap_0_216","cMap_0_233","cMap_0_233","cMap_0_272","cMap_0_278","cMap_0_213","cMap_0_245","cMap_0_246","cMap_0_231","cMap_0_231","cMap_0_275","cMap_0_263","cMap_0_249","cMap_0_236","cMap_0_268","cMap_0_224","cMap_0_248","cMap_0_234","cMap_0_266","cMap_0_240","cMap_0_214","cMap_0_238","cMap_0_243","cMap_0_230","cMap_0_250","cMap_0_221","cMap_0_241","cMap_0_273","cMap_0_279","cMap_0_225","cMap_0_215","cMap_0_260","cMap_0_247","cMap_0_258","cMap_0_277","cMap_0_228","cMap_0_246","cMap_0_285","cMap_0_259","cMap_0_259","cMap_0_270","cMap_0_239","cMap_0_226","cMap_0_235","cMap_0_237","cMap_0_267","cMap_0_219","cMap_0_legend","cMap_1_229","cMap_1_212","cMap_1_251","cMap_1_274","cMap_1_217","cMap_1_271","cMap_1_244","cMap_1_252","cMap_1_242","cMap_1_232","cMap_1_220","cMap_1_276","cMap_1_211","cMap_1_261","cMap_1_257","cMap_1_218","cMap_1_269","cMap_1_265","cMap_1_256","cMap_1_legend","cMap_2_284","cMap_2_264","cMap_2_264","cMap_2_223","cMap_2_223","cMap_2_254","cMap_2_254","cMap_2_254","cMap_2_254","cMap_2_254","cMap_2_283","cMap_2_254","cMap_2_254","cMap_2_282","cMap_2_281","cMap_2_legend");


function cMapPreLoadImgs()
{
	/*loops through the images array (above) and loads each as a new
	/Image(). Once complete, hides loading animation GIF and shows
	/first map*/
	
	for (i in cMapImgs)
	{
		var newImg = new Image();
		newImg.src = cMapImgPath + cMapImgs[i] + ".gif";
	}
	
	setTimeout('cMapMakeReady()',3500);
}

function cMapMakeReady()
{
	/*If the preloader fn completes while imgs still loading, this
	/timed fn call holds the loading mode for a moment*/
	document.getElementById("cMap0HiLite").src = cMapImgPath + "cMap_clear.gif";
	cMapReady = true;
}

	

/*--------------------------------------------------------*/
/*cMap fns*/

function cMapView(viewingMap)
{
	if(!cMapReady) return;
	
	/*hides all other maps then shows requested map all via
	/style.display toggle*/
	
	//hide other maps
	for(i=0;i<cMapNumMaps;i++)
	{
		if(i!=viewingMap)
		{
			var mapIdRef = "cMap" + i;
			
			document.getElementById(mapIdRef).style.display = "none";
		}
	}
	//show requested map
	var mapIdRef = "cMap" + viewingMap;
	document.getElementById(mapIdRef).style.display = "block";
	
	//set roll states now new circumstance is set
	var prevSel = cMapSel;
	cMapSel = viewingMap;
	cMapRoll(prevSel,0);
	cMapRoll(cMapSel,1);
	
	//set map title
	document.getElementById("cMapTitle").src = cMapImgPath + "cMap_title_" + cMapLetterRef[cMapSel] + ".gif";
	
	//set relevant legend
	document.getElementById("cMapLegend").src = cMapImgPath + "cMap_" + viewingMap + "_legend.gif";
}

function cMapHilite(mapRef,hiLiteRef)
{
	if(!cMapReady) return;

	/*map region is illustrated as a bg img. On rollover of map
	/region 'hilites' by changing img src of foreground clear gif.*/
	
	//show hilite
	var hiLiteIdRef = "cMap" + mapRef + "HiLite";
	document.getElementById(hiLiteIdRef).src = cMapImgPath + "cMap_" + mapRef + "_" + hiLiteRef + ".gif";
	
	//render text
	var textDataRef = document.getElementById("cMapData");
	textDataRef.innerHTML = cMapStrs[mapRef][hiLiteRef];
}

function cMapLink(idRef)
{
	if(cMapReady){	
		content_id = eval("council_"+idRef);
		if(content_id!=0){
			location.href="page.cfm?c="+content_id;
		} else{
			alert('No information has been uploaded for this council yet');
		}
	}
}

function cMapReset(mapRef)
{
	if(!cMapReady) return;

	/*on rolloff after hilite, this resets img to 'cMap_clear.gif'
	/and text data to default*/

	//reset img
	var hiLiteIdRef = "cMap" + mapRef + "HiLite";
	document.getElementById(hiLiteIdRef).src = cMapImgPath + "cMap_clear.gif";
	
	//reset text
	var textDataRef = document.getElementById("cMapData");
	textDataRef.innerHTML = "&nbsp;";
}

function cMapRoll(imgRef,rollingOver)
{
	//if(!cMapReady) return;

	/*controls img rollover fn for map btn imgs and rollover hilites
	/are in context of which map is currently selected*/
	
	//get img src ref
	var srcRef = "cMap_btn_" + cMapLetterRef[imgRef];
	if(imgRef == cMapSel)//different img src if already displaying selected img
		srcRef = srcRef + "_sel";
	if(rollingOver)//diff img src if rolling off a roll img
		srcRef = srcRef + "_roll";

	//get img id ref
	var idRef = "cMapBtn" + cMapLetterRef[imgRef].toUpperCase();

	//set img src
	document.getElementById(idRef).src = cMapImgPath + srcRef + ".gif";
}

