var undefined;	// 	required by IE 5.2 MAC
var ciStatus;	//	global variabe
// only create one new status object per page.
if(ciStatus==undefined){
 ciStatus = new ContentIncludeStatus();
}

function includeContent(sourceWindow, sourceElementId, targetDoc, targetElementId, includeStatus){
	var sourceName 	= sourceWindow.name; // ie the name of the iFrame - we us this as the key in the maps.
	var sourceDoc 	= sourceWindow.document;
if(!includeStatus){
includeStatus=ciStatus;
includeStatus.setTimeoutStatus(sourceName,false);
}
		if(includeStatus.getTimeoutStatus(sourceName)==false) {
			var x = sourceDoc.getElementById(sourceElementId).innerHTML;
			targetDoc.getElementById(targetElementId).innerHTML = x;
			includeStatus.setLoadStatus(sourceName,true);
		}
}
function ContentIncludeStatus(){
	
	this.timeoutStatusMap = new Array();
	this.loadStatusMap = new Array();
	
	ContentIncludeStatus.prototype.getTimeoutStatus = function(key) {
		return this.timeoutStatusMap[key];
	}
	
	ContentIncludeStatus.prototype.setTimeoutStatus = function(key,boolStatus) {
		this.timeoutStatusMap[key]=boolStatus;
	}
	
	ContentIncludeStatus.prototype.getLoadStatus = function(key) {
		return this.loadStatusMap[key];
	}
	
	ContentIncludeStatus.prototype.setLoadStatus = function(key,boolStatus) {
		this.loadStatusMap[key]=boolStatus;
	}
	
	ContentIncludeStatus.prototype.getTimeoutStatusToString = function() {
		for(var i in this.timeoutStatusMap) { 
		   alert(i+" : "+this.timeoutStatusMap[i]);
		}
	}
	
	ContentIncludeStatus.prototype.getLoadStatusToString = function() {
		for(var i in this.loadStatusMap) { 
		   alert(i+" : "+this.loadStatusMap[i]);
		}
	}
	
	// if load status is false -set timeout status to true;
	ContentIncludeStatus.prototype.checkContentLoadStatus = function(sourceElementId, targetElementId, defaultContent){
		var loadStatus = this.getLoadStatus(sourceElementId);
		if(loadStatus == true){}//do nothing
		else{
			this.setTimeoutStatus(sourceElementId,true);
			//	make call to set default content
			if(targetElementId!=null && defaultContent !=null){
				document.getElementById(targetElementId).innerHTML = defaultContent;
			}
		}
	}
}


