//var lastNodeClicked="";
 
function OwnersUtilities(){
    //Global Variables
	this.isLeased = 0;
    this.lastNodeClicked = "";
    this.itemLastNodeClicked = "";
    //Directs a user to a defined URL location. Mimics the native href return behaviour.
    // @param hrefStr   URL to be directed too.
	this.gotoURL = function(hrefStr){
		window.location = hrefStr;
	}

    // Handles the toggle display of a contentTree node.
    // @param obj   Object calling the method (this).
    // @param loc   Set to 1 if sub subitem - used only to stop sub questions from closing parents.
	this.contentTree = function(obj){
        var nextDiv = getNextDiv(obj.parentNode.nextSibling);
        
        if (this.lastNodeClicked!="" && this.lastNodeClicked!=obj) {
            if (getNextDiv(this.lastNodeClicked.parentNode.nextSibling).style.display =='block') {            
                this.contentTree(this.lastNodeClicked);
            }
        }
        
		nextDiv.style.display = (nextDiv.style.display=='block')?'none':'block';
        obj.style.fontWeight = (obj.style.fontWeight=='')?'bold':'';
        
        this.lastNodeClicked=obj;
	}
    
  	this.questionSelect = function(obj, loc){
        var nextDiv = getNextDiv(obj.parentNode.nextSibling);
        
        if (this.lastNodeClicked!="" && this.lastNodeClicked!=obj && loc) {
            if (getNextDiv(this.lastNodeClicked.parentNode.nextSibling).style.display =='block') {            
                if (this.itemLastNodeClicked != "") this.questionSelect(this.itemLastNodeClicked);
            }
        }
        
		nextDiv.style.display = (nextDiv.style.display=='block')?'none':'block';
        obj.style.fontWeight = (obj.style.fontWeight=='')?'bold':'';
        
        this.itemLastNodeClicked=obj;
	}

    // Navigates through text nodes in a document. 
    // @param sibling  Current node.
	var getNextDiv = function(sibling){
		if(sibling.nodeName=="#text"){
			return getNextDiv(sibling.nextSibling);
		}else{
			return sibling;
		}	
	}
}
var ownersUtils = new OwnersUtilities();