// ************************
// layer utility routines *
// ************************

function inspect(elm) {
  var str = "Inspect Attributes\n";
  for (var i in elm) {
    str += i + ": " + elm.getAttribute(i) + "\n";
  }
  alert(str);
}

function inspectStyle(elm){
  if (elm.style){
    var str = "Inspect Style\n";
    for (var i in elm.style){
	  str += i + ": " + elm.style[i] + "\n";
	}
	alert(str);
  }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function changeObjectDisplay(objectId, newDisplay) {
	// get a reference to the cross-browser style object and make sure the object exists
	var styleObject = getStyleObject(objectId);

	if(styleObject) {
		styleObject.display = newDisplay;
		return true;
	} else {
	     // we couldn't find the object, so we can't change its visibility
	     return false;
	}
} // changeObjectDisplay

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject

function popUpPlain(where) {

	newWin = window.open(where, "popupWindow", "width=650, height=500,resizable=yes,scrollbars=yes");
	if (newWin.opener == null) newWin.opener = self;
}

function popUpPlus(param, w, h, m) {

	where = "page.php?id=" + param;

	newWin = window.open(where, "popupWindow", "width=" + w + ", height=" + h + ",menubar=" + m + ",resizable=yes,scrollbars=yes");
	if (newWin.opener == null) newWin.opener = self;
}

function popVideo(arg) {

	where = "video.php?vid=" + arg;

	winVideo = window.open(where, "videoWindow", "width=500, height=450,resizable=yes,scrollbars=yes");
}

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) {
		requestsvc_over = newImage("../images/requestsvc-over.gif");
		applyjob_over = newImage("../images/applyjob-over.gif");
		preloadFlag = true;
	}
}

function popLoc(loc_id, x) {

	if ( x == null || x == 1 )
		where = "/home/loc_id/" + loc_id + "/a/home/-/getlocation.php";
	if ( x == 2 )
		where = "/service/loc_id/" + loc_id + "/a/svc/-/getlocation.php";
	if ( x == 3 )
		where = "/job/loc_id/" + loc_id + "/a/job/-/getlocation.php";

	newLocation = window.open(where, "locWindow", "width=820, height=610,resizable=yes,scrollbars=yes");
}

function popSLoc(arg) {

	where = arg + "?zip_code=" + document.zip_search.zip_code.value;

	newLocD = window.open(where, "locDirWindow", "width=820, height=610,resizable=yes,scrollbars=yes");

}

function changeOrder(newObjectId, oldObjectId, oldIndex, newIndex) {

	var oldStyleObject = getStyleObject(oldObjectId);
	var newStyleObject = getStyleObject(newObjectId);

	if(styleObject) {
		styleObject.left = newXCoordinate;

		return true;
	} else {
	     // we couldn't find the object, so we can't very well move it
	     return false;
	}
}

// this function makes sure the main window has a name
function nameWin() {
	name = "fetchMain";
} // end nameWin function

function validateTotal(totalID, submitID) {

	totalObj = document.getElementById(totalID);
	submitObj = document.getElementById(submitID);

	if ( totalObj.value == 1 ) {
		//alert("The total must equal 1.00 exactly. Please check your entry and try again.");
		//totalObj.value = 'xxx';
		submitObj.disabled = false;
	} else {
		submitObj.disabled = true;
     }
}

function showNewsInput(obj) {

	var val = obj.options[obj.selectedIndex].value;

	//alert("type = " + val);

     // hide all current divs

	if ( val == 0 )
		showDiv('hotlink');
	if ( val == 1 )
		showDiv('article');
	if ( val == -1 )
		hideCurrentDiv();

} // end function showNewsInput

function addBookmark(title,url) {
	if (window.sidebar) 
	{
		window.sidebar.addPanel(title, url,"");
	} 
	else if( document.all ) 
	{
		window.external.AddFavorite( url, title);
	} 
	else if( window.opera && window.print ) 
	{
	return true;
	}
}

function changeTymImages() {

	if (document.images) {
		for (var i=0; i<changeTymImages.arguments.length; i+=2) {
			document[changeTymImages.arguments[i]].src = changeTymImages.arguments[i+1];
		}
	}
}

function showAAAInputArea() {
	
	var selectID = document.getElementById('how_heard');
	var divID = document.getElementById('AAA_div');

	if(selectID.value == 'AAA')
	{
		divID.style.display = 'block';
	}
	else
	{
		divID.style.display = 'none';
	}
}

function chkConfirm(msg)
{
	var bln = window.confirm(msg);
	
	if (bln)
	{
		return true;
	}
	else
	{
		return false;	
	}
	
	return false;
}
