// JavaScript Document


// for Google search button
function change_filterOut(obj) { 
	obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)" ; 
}
function change_filterOver(obj) { 
	obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=70)" ; 
}
		
function toggleDropDownDiv(displayText, toggleText) {

	var text = document.getElementById(displayText);
	var ele = document.getElementById(toggleText);

	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = " more >> ";
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "hide";
	}
} 

function resizeText_BODY(multiplier) {
  if (document.body.style.fontSize == "") {
	document.body.style.fontSize = "1.0em";
  }
  document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";
}

var m1 = "";
function resizeText(multiplier) {
    m1 = document.getElementById("main1").style;
    if (m1.fontSize == "") {
        m1.fontSize = "1.0em";
    }
    m1.fontSize = parseFloat(m1.fontSize) + (multiplier * 0.2) + "em";
}

var DocTitle = "empty";
var DocURL = "empty";
var myValue = "";
function GetDocTitle()
{
	DocTitle = document.title;
	DocURL = document.URL;
	myValue = "mailto:?Subject=An%20Excellent%20Arizona%20Department%20of%20Water%20Resources%20page.%20Take%20a%20look!&Body=The page title is '" + DocTitle + "'. The URL is " + DocURL
	document.location.href=myValue;
}
function GetDeptSectionDocTitle(pToWhom)
{
	DocTitle = document.title;
	DocURL = document.URL;
	myValue = "mailto:" + pToWhom + "?Subject=I%20would%20like%20to%20discuss%20this%20page&Body=The page title is '" + DocTitle + "'. The URL is " + DocURL
	document.location.href=myValue;
}


var urlAddress = document.URL; 
var pageName =  document.title; 
function addToFavorites() { 
	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName) 
	} else {
		alert("Sorry! Your browser doesn't support this function."); 
	} 
} 


<!-- ImageReady Preload Script (defineButton.psd) -->
<!-- alan start of add -->
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		defineButton_Layer_1_over = newImage("images/defineButton_Layer-1-over.jpg");
		preloadFlag = true;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
<!-- alan end of add -->




/* PopUp window - use this for PopUps */
/* use: 
	<a class="l2" href="/Ledger/" onclick="Javascript:PopDef('/Ledger/');return false;">Bank Deliveries (pop up)</a>
*/
function PopDef() { 
	cat=window.open(PopDef.arguments[0] ,"cat",	"location=0,status=1,scrollbars=1,resizable=1,width=775,height=500;top=25,left=25" )
	if (typeof(cat) != "undefined") {
		if (!cat.closed) {			
			window['cat'].focus();
			/* cat.moveTo(50,50); */	
		}
	}
	return false;
}


var posx;var posy;
function getMouse(e, elemId){

	/* http://www.w3schools.com/HTMLDOM/event_screenx.asp */

	var objDiv = document.getElementById( elemId ); 
	
	posx=0; posy=0;

	//alert("objDiv.style.display = "+objDiv.style.display + ",    elemId = " +elemId )

	if (objDiv.style.display == "none" )
	{
		
		var ev = (!e)?window.event:e; //IE:Moz

		if (ev.pageX){//Moz
		
			posx=ev.pageX;
			posy=ev.pageY;

			//alert("Moz, posx = " + posx + ", posy = "+ posy)	
			
		}
		else if(ev.clientX){//IE
		
			posx=mouseX(e); 
			posy=mouseY(e); 

			//posx=ev.clientX; //doesn't work correctly
			//posy=ev.clientY; //doesn't work correctly

			//posx=ev.clientX+document.body.scrollLeft; // doesn't allow for half open browser
			//posy=ev.clientY+document.body.scrollTop; // doesn't allow for half open browser

			//posx=ev.screenX; //doesn't work period
			//posy=ev.screenY; //doesn't work period
			//posx=e.screenX; //doesn't work period
			//posy=e.screenY; //doesn't work period

			//posx=ev.x; doesn't work correctly
			//posy=ev.y; doesn't work correctly
			//posx=e.x; //doesn't work correctly
			//posy=e.y; //doesn't work correctly

			//posx=event.x; doesn't work correctly
			//posy=event.y; doesn't work correctly
			//posx=e.x; //doesn't work correctly
			//posy=e.y; //doesn't work correctly
			//posx=ev.x; //doesn't work correctly
			//posy=ev.y; //doesn't work correctly

			//alert("IE, posx = " + posx + ", posy = "+ posy)			
			
		}
		else{
			alert('We\'re sorry! Your browser doesn\'t support the Level 1 DOM');
			return false}//old browsers

		var posxPx = posx + "px"
		var posyPx = posy + "px"

		document.getElementById( elemId ).style.left = posxPx; //posx; 
		document.getElementById( elemId ).style.top = posyPx //posy;
		document.getElementById( elemId ).style.display = 'block';

	}
	else
	{
		document.getElementById( elemId ).style.display = 'none';
	}
}



/* needed on every page for the "ADWR Information" mouse over */
function Toggle()
{


	if (!(document.getElementById && document.createElement))
	{
		alert('We\'re sorry! Your browser doesn\'t support the Level 1 DOM');
	}
	
	var elemId = Toggle.arguments[0];
	var	NoHide = Toggle.arguments[1];

	if(NoHide == null)
		NoHide = "HideMenu";

	/* "MilonicMenuDiv" is the div that houses the menu. The menu must be hidden cause it shouws over What Kind of User are you */
	var MilonicMenuDivID = document.getElementById( "MilonicMenuDiv" );
	var objDivWhatKindOfUserAreYou = document.getElementById( elemId ); 


	if (objDivWhatKindOfUserAreYou.style.display == "none")
	{

		document.getElementById( elemId ).style.left = mouseX(event); 
		document.getElementById( elemId ).style.top = mouseY(event);

		document.getElementById(elemId).style.display = 'block';
		/*
		if(NoHide != "NoHide")
			eval("MilonicMenuDivID.style.display = 'none';")
			*/
			
	}
	else
	{

		eval("objDivWhatKindOfUserAreYou.style.display = 'none';");
		
		/*
		if(NoHide != "NoHide")				
			eval("MilonicMenuDivID.style.display = 'block';")
			*/
						
	}
}



function mouseX(evt) {
	
	//alert("mouseX: " + evt)

	if (evt.pageX) return evt.pageX;
	else if (evt.clientX)
	   return evt.clientX + (document.documentElement.scrollLeft ?
	   document.documentElement.scrollLeft :
	   document.body.scrollLeft);
	else return null;
}

function mouseY(evt) {
	
	//alert("mouseY: " + evt)

	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)
	   return evt.clientY + (document.documentElement.scrollTop ?
	   document.documentElement.scrollTop :
	   document.body.scrollTop);
	else return null;
}

function ToggleHoldDisplay( elemId )	{
	var id = document.getElementById( elemId );
	if (id.style.display == "none")	
	{
		eval("id.style.display = 'block';");
	}
	else
	{
		eval("id.style.display = 'none';");
	}
}



var idsMenuDivs=new Array('divADWRVisitor','divAttorneys','divDamOwners','divDrillers', 'divEducators', 'divGovernment','divLandOwners','divRealtors','divResearch','divWaterCompany', 'divWells');
function ToggleMenuDiv( elemId )
{




// BECAUSE of the idsMenuDivs array you can only use this function on Menu calls

//alert("ToggleMenuDiv: " + elemId)

// elemId is one of the What Kind of user are you divs as divDrillers 

var menuDivID = document.getElementById( elemId );

// save for debug: alert ("menuDivID = " + menuDivID)
// save for debug: alert ("menuDivID.style.display = " + menuDivID.style.display)

if (menuDivID.style.display == 'none')
{
	
	// save for debug: alert("#20")
	
	//was 8/28/2008 aml - hideallids(); 
	for (var i=0;i<idsMenuDivs.length;i++){			
		hidediv(idsMenuDivs[i]);
	}		  
	eval("menuDivID.style.display = 'block';");
}
else
{
	// save for debug: alert("#30")
	eval("menuDivID.style.display = 'none';");
}
}	

function hideallids(){

//alert("hideallids()")

//loop through the array and hide each element by id
for (var i=0;i<idsMenuDivs.length;i++){

	hidediv(idsMenuDivs[i]);
}		  
}

function hidediv(id) {

//alert("hidediv: " + id)		

//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
	document.getElementById(id).style.display = 'none';
}
else {
	if (document.layers) { // Netscape 4
		document.id.display = 'none';
	}
	else { // IE 4
		document.all.id.style.display = 'none';
	}
}
}


