window.addEvent('domready', function() {
	var status = {
		'true': 'open',
		'false': 'close'
	};
	
	//--horizontal
	zchm = new Fx.Slide('zchmContent', {mode: 'horizontal'});
	zchm.hide();

	toolbox = new Fx.Slide('toolsArea');	
	
	$('showLocation').addEvent('click', function(e){
	//document.getElementById("showLocation").addEvent('click', function(e){
		//document.getElementById("toolsArea").style.height = "225px";
	
		if(status[toolbox.open]=="close"){
			e.stop();
			toolbox.slideIn();
		}
		showTools('Location')
		displayTools('Location')
	});
	
	$('showDefine').addEvent('click', function(e){
	
		//document.getElementById("toolsArea").style.height = "200px";
	
		if(status[toolbox.open]=="close"){
			e.stop();
			toolbox.slideIn();
		}
		showTools('Define')
		displayTools('Define')
	});
	
	$('showDrawing').addEvent('click', function(e){
		if(status[toolbox.open]=="close"){
			e.stop();
			toolbox.slideIn();
		}
		showTools('Drawing')
		displayTools('Drawing')	
	});
	
	$('hideAll').addEvent('click', function(e){
		e.stop();
		toolbox.slideOut();
	});
	
	$('closeBox1').addEvent('click', function(e){
		e.stop();
		toolbox.slideOut();
	});
	$('closeBox2').addEvent('click', function(e){
		e.stop();
		toolbox.slideOut();
	});
	$('closeBox3').addEvent('click', function(e){
		e.stop();
		toolbox.slideOut();
	});
	$('closeBox4').addEvent('click', function(e){
		e.stop();
		toolbox.slideOut();
	});
		
	/*Define layers that can moved by mouse
	new Drag.Move('annoProperties', {});
	new Drag.Move('gsInfoContent', {});
	new Drag.Move('gsInfoContent2', {});
	new Drag.Move('productInfoContent', {});
	new Drag.Move('previewsInfoContent', {});*/
	

});

function setDrag(theAction){
	/*if(theAction == "on"){
		myDrag = new Drag.Move('gsInfoContent', {});
		//alert("on")
	}else{
	//alert("off")
		if(myDrag != null){
		//alert("off")
			myDrag.stop();
		}
	}*/
}


//****************Hide the toolbox when user mouseovers the map
function hideOnMapOver(){
	if(canHideIt){
		toolbox.slideOut();
	}
}
//****************Show the dropdown tool areas at the top of the page
function showTools(theTool){
		document.getElementById("toolboxTitle").style.display = "block";
		var allTools = new Array("Location","Define","Drawing");   //"Define",
		for(i=0; i < allTools.length;i++){
			if (theTool == allTools[i]){
				
				var tool =  document.getElementById(allTools[i])
				tool.src = 'images/btn' + allTools[i] + 'ON.png';
				if(theTool == "Define"){
					document.getElementById("toolboxTitle").style.display = "none";
				}else{	
					var toolTitle = document.getElementById("toolboxTitle")
					toolTitle.src = "images/title"+theTool+".png"
			  	}
			}else{
			   var tool =  document.getElementById(allTools[i])
			   tool.src = 'images/btn' + allTools[i] + '.png';
			   
			   var toolTitle = document.getElementById("toolboxTitle")
			   toolTitle.src = "images/title"+theTool+".png"
			}
		}	
		
	hideMapLayers();  //Ensure road aerial tab closed	
}	
//****************Show relevant tool tab content
function displayTools(toolType){
	if(toolType=="Drawing"){
		document.getElementById("toolsDrawing").style.display = 'block';
		document.getElementById("toolsDefine").style.display = 'none';
		document.getElementById("toolsLocation").style.display = 'none';
		toogleSteps("Step4");	
	}else if(toolType=="Define"){
		document.getElementById("toolsDrawing").style.display = 'none';
		document.getElementById("toolsDefine").style.display = 'block';
		document.getElementById("toolsLocation").style.display = 'none';
		toogleSteps("Step3");	
		//Get extent drawing tools content
		var qstring = "data=" + document.varform.data.value.toLowerCase() + "&multi=" + document.varform.ismultiextent.value + "&nofextents=" + getNumExtents() + "&scale=" + document.varform.scale.value + "&scales=" + document.varform.thescales.value + "&prodtype=" + document.varform.productoption.value;
		var getToolsReq = new ajaxObject('drawExtentTools.php', getToolsResponse);
		getToolsReq.update(qstring,'POST');			
	}else if(toolType=="Location"){
		document.getElementById("toolsDrawing").style.display = 'none';
		document.getElementById("toolsDefine").style.display = 'none';
		document.getElementById("toolsLocation").style.display = 'block';
		toogleSteps("Step1");
	}
}
//****************Toggles the step indicator and prompt at the top of the page
function toogleSteps(turnOn){									
	var theOptions = new Array("Step1","Step2","Step3","Step4");
	var thePrompts = new Array("Search for your required location","Choose your data product from list.","Define area for your data.","Annotate your data.");
	for (var n=0;n<(theOptions.length);n++){
		var theObj = document.getElementById(theOptions[n]);	
		if(turnOn == theOptions[n]){						
			theObj.src = "images/ico" + theOptions[n] + "ON.jpg";
			document.getElementById("stepTip").innerHTML = thePrompts[n];
		}else{
			theObj.src = "images/ico" + theOptions[n] + ".jpg";										
		}
	}
}

//-------------------------------------------------End of file.
