<!--
var myWin = null;
var openConcernDivID = 0;

//Global variables for photo picker
var selectedPhotoIDsFieldID;
var photoSelectResultsDivID;
var photoIDs;
var photoIdArray;
var totPhotos;

var totSectionItems = 0;
var hideAssigned = 0;

function DoPopup(pURL)  {
	var sTmp = null;


	if (pURL.indexOf('http://') != -1) {

		// Opening window outside of the ReportHost domain, must refresh contents
		myWin = window.open(pURL, 'other','width=600,height=400,top=<%=20+DatePart("s", Now())%>,left=<%=20+DatePart("s", Now())%>,scrollbars=1,resizable=1,menubar=1,toolbar=1,location=1');

	} else {
		if (!myWin || myWin.closed ) {

			// Window doesn't exist, or reference is lost from main page navigation
			myWin = window.open(pURL, 'rhPopup','width=600,height=400,top=<%=20+DatePart("s", Now())%>,left=<%=20+DatePart("s", Now())%>,scrollbars=1,resizable=1,menubar=0,toolbar=1,location=0');

		} else {

			// Window exists, only change contents if not the requested URL
			sTmp = myWin.location.toString();
			if (sTmp.indexOf(pURL) == -1) {
				myWin.location = pURL;
			}
		}
	}
	myWin.focus();
	return(false);
}

function GoRHPage(pPage)  {
	window.location = pPage;
	return(false);
}

// Selects a checkbox for an item
function cs(nID) {
	if (document.myForm["do" + nID].checked == false) {
		document.myForm["do" + nID].checked = true;
	}
}

function blk() { alert('All images copyright ReportHost, LLC 2002-2009'); return false; }


// Clicked a concern's checklist prompt text in "compact" mode on doBldgCat.asp
// Close any other open concern divs, open this one, remember its ID
// oc = "open concern"
function oc(nID)
{
	// Check the select checkbox for the concern
	document.myForm["do" + nID].checked = true;

	// Close any previously opened concern
	if (openConcernDivID != 0) {
	    hideDiv(openConcernDivID)
	    openConcernDivID = 0;
	}

	// Get an object reference to the concern div
	objConcernDiv = document.getElementById(nID);

	// Figure div height based on window size and number of photos
	var bodyHeight = f_clientHeight();
	var divHeight = 500; //hardcoded for now since height property is ungettable for some reason

	// Figure div vertical position based on page scrol, window height and div height
	var vPos = f_scrollTop() + ((bodyHeight - divHeight)/2);
	objConcernDiv.style.top = vPos

	showDiv(nID);

	//Remember the div ID
	openConcernDivID = nID;
}


// Close the open concern div, select or unselect its selection checkbox
// sc = "select concern"
function cc(sel) {
	if (openConcernDivID != 0) {
		// Check or uncheck the select checkbox for the concern
		document.myForm["do" + openConcernDivID].checked = (sel == true) ? true : false;
		
		hideDiv(openConcernDivID)
		openConcernDivID = 0;
	}
}


// Make a div visible, reliably in any browser
function showDiv(nID) {

    document.getElementById(nID).style.display = "block";
}


// Hide a div, reliably in any browser
function hideDiv(nID) {

    document.getElementById(nID).style.display = "none";
}


var clickCounter = 0;
function clickOnce(){
	clickCounter++;
	if (clickCounter>1) {
		alert('Please only click this button one time.');
		return false;
	}
	else { return true; }
}

// Unselects all items on the doBldgCat.asp page
function unselectAll() {
	var ctr;
	var maxIX = parseInt(document.myForm["maxRows"].value);

	for (ctr = 1; ctr <= maxIX; ctr++) {
		document.myForm["do" + ctr].checked = false;
	}
}


// Handy function for getting the current page scroll, used to position divs
function getYPageScroll()
{
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	return yScroll;
}



function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


// Initializes and shows the photopicker div
function sp(hfIDs, psrdID)
{
	var divTopHeight = 47;
	var bodyPadding = 10;
	var objPhoto;
	var i;

	// Assign to global variables for processing when OK button clicked
	selectedPhotoIDsFieldID = hfIDs;
	photoSelectResultsDivID = psrdID;
	
	// Get an object references to the photopicker divs
	objPhotopicker = document.getElementById('photopicker');
	objPhotopickerTop = document.getElementById('photopickertop');

	// Figure div widths and height based on window page width/height
	// The -16 is a safety allowance for scrollbars in some browsers
	var divWidth = parseInt(f_clientWidth() - (2 * bodyPadding) - 16);
	objPhotopickerTop.style.width = divWidth;
	objPhotopicker.style.width = divWidth;
	objPhotopicker.style.height = parseInt(f_clientHeight() - (2 * bodyPadding) - divTopHeight - 20);

	// Figure div vertical position based on page scrol, window height and div height
	var vPos = f_scrollTop() + bodyPadding;
	objPhotopickerTop.style.top = vPos;
	objPhotopicker.style.top = vPos + divTopHeight;

	// Set these values from the photoIDs variable, which the .asp page code initialized
	photoIdArray = photoIDs.split(",");
	totPhotos = photoIdArray.length;
	
	// Unselect all the images by changing their CSS class
	for (var i = 0; i < photoIdArray.length; i++)
	{
		objPhoto = document.getElementById('ph' + photoIdArray[i]);
		if(objPhoto) { objPhoto.className = "up"; }
	}

	// For all selected images, show the image, and show it in a selected state
	var selectedPhotoIDs = document.getElementById(selectedPhotoIDsFieldID).value;
	if (selectedPhotoIDs != null && selectedPhotoIDs.length > 0)
	{
		var selectedPhotoIDArray = selectedPhotoIDs.split(",");

		for (var i = 0; i < selectedPhotoIDArray.length; i++)
		{
			objPhoto = document.getElementById('ph' + selectedPhotoIDArray[i]);
			if(objPhoto) {
				objPhoto.className = "sp";
				objPhoto.style.display="inline";
				}
		}
	}

	// Make it visible
	showDiv('photopickertop');
	showDiv('photopicker');
	
	return false;
}


// Sets results from photo picking in the corresponding hidden field, then hides the picker
function okPhotopicker()
{
	var selectedPhotoIdArray = new Array(0);

	// Build array of selected photo IDs based on what CSS class the corresponding image tag has
	for (var i = 0; i < photoIdArray.length; i++)
	{
		if (document.getElementById('ph' + photoIdArray[i]).className == "sp") {
			selectedPhotoIdArray.push(photoIdArray[i]);
		}
   	}

   	// Set the text of the hidden field that holds the selected IDs to those IDs as a comma separated string
   	document.getElementById(selectedPhotoIDsFieldID).value = selectedPhotoIdArray.toString();

	// Indicated photos are selected with checkmark graphic and text
   	if (selectedPhotoIdArray.length > 0)
   	{
   		document.getElementById(photoSelectResultsDivID).innerHTML = '<img src=\"_image/checkmark.gif\"> ' + selectedPhotoIdArray.length + ' photo(s) selected';
   	}
   	else
   	{
   		document.getElementById(photoSelectResultsDivID).innerHTML = "";
   	}
   	
	//Hide newly selected photos when closing picture picker if assigned photos are to be hidden
	if (hideAssigned == 1)
	{
		hidePhotosInInputList(selectedPhotoIDsFieldID)
	}

   	hideDiv('photopickertop');
   	hideDiv('photopicker');
	
	return false;
}


// Selects or unselects a photo 
function doPhotoSelect( photoID )
{
	//Toggle selected/unselected image style
	var objPhoto = document.getElementById('ph' + photoID);
	objPhoto.className = (objPhoto.className == "sp") ? "up" : "sp"
	
	return false;
}


// Selects or unselects a photo for deletion
function doPhotoSelectDelete( photoID )
{
	//Toggle selected/unselected delete image style
	var objPhoto = document.getElementById('ph' + photoID);
	if (objPhoto.className == "sd")
	{
		objPhoto.className = "ud"
		document.getElementById("hf" + photoID).value = "";
	}
	else
	{
		objPhoto.className = "sd"
		document.getElementById("hf" + photoID).value = "1";
	}
	
	return false;
}


// Called when the form to delete photos is submitted. Sets results from photo picking in the corresponding hidden field.
function submitDeletePhotos(hfID)
{
	var selectedPhotoIdArray = new Array(0);

	photoIdArray = photoIDs.split(",");

	// Build array of selected photo IDs based on what CSS class the corresponding image tag has
	for (var i = 0; i < photoIdArray.length; i++)
	{
		if (document.getElementById('ph' + photoIdArray[i]).className == "sd") {
			selectedPhotoIdArray.push(photoIdArray[i]);
		}
   	}

   	// Set the text of the hidden field that holds the selected IDs to those IDs as a comma separated string
   	document.getElementById(hfID).value = selectedPhotoIdArray.toString();

	return true;
}

function hideAllAssignedPhotos()
{
	hidePhotosInInputList("selPics");
	
	//If on doBldgCat.asp, loop through hidden photo divs to hide selections made after page rendered
	if (totSectionItems > 0)
	{
		for (var x = 1; x <= totSectionItems; x++)
		{
			hidePhotosInInputList("pn" + x);
		}
	}		
	
	document.getElementById("sa").style.display="inline";
	document.getElementById("ha").style.display="none";	
}

function hidePhotosInInputList(inputId)
{
	if (document.getElementById(inputId))
	{
		if (document.getElementById(inputId).value != "")
		{
			var a = document.getElementById(inputId).value.split(",");
			for (var x = 0; x < a.length; x++)
			{
				document.getElementById("ph" + a[x]).style.display="none";
			}
		}
	}
}


function showAllPhotos()
{
	for (var x = 1; x <= totPhotos; x++)
	{
		document.getElementById("ph" + x).style.display="inline";
   	}
	document.getElementById("ha").style.display="inline";
	document.getElementById("sa").style.display="none";	
}


function SetFocus(id)
{
	var thisId = 'first';
	if(id != '') { thisId = id; }
	var e = document.getElementById(thisId);
	if(e==null) { 
		e = document.getElementsByName(thisId); 
		if(e.length>0) { e = e.item(0); }
	}
	if(e) e.focus();
}


Array.prototype.inArray = function (value)
{
	// Returns true if the passed value is found in the
	// array. Returns false if it is not.
	var i;
	for (i=0; i < this.length; i++)
	{
	    if (this[i] == value)
	    {
	    return true;
	    }
	}
	return false;
};

//-->
