var IFrameObj; // our IFrame object
var targetWidth = 480;
var targetHeight = 200;

function getIFrameDocument(aID){ 
	if (IFrameObj.contentDocument) {
		// For NS6
		return IFrameObj.contentDocument; 
	} else if (IFrameObj.contentWindow) {
		// For IE5.5 and IE6
		return IFrameObj.contentWindow.document;
	} else if (IFrameObj.document) {
		// For IE5
		return IFrameObj.document;
	} else {
		return false;
	}
}

function createIframe(url, nr) {
	oContainer = document.getElementById("HOLDER"+(nr+1));
	if(!oContainer){
		tmp_start = url.indexOf("?camping_id=");
		tmp_end = url.indexOf("&object_id=");
		var camping_id = url.substr(tmp_start+12,tmp_end-tmp_start-12);
		oContainer = document.getElementById("HOLDER_"+camping_id+"_"+(nr+1));
	}
	if (!oContainer) { alert("Error:Geen holder gevonden!"); return false};
	if (!document.createElement) {return true};
	var IFrameDoc;

	if (document.createElement) {
		// create the IFrame and assign a reference to the
		// object to our global variable IFrameObj.
		try {
			var tempIFrame=document.createElement('iframe');
			tempIFrame.setAttribute('id','CO__IFRAME'+nr);
			tempIFrame.style.border='none';
			tempIFrame.style.width=targetWidth+"px";
			tempIFrame.style.height=targetHeight+"px";
			tempIFrame.frameBorder="0";
//			tempIFrame.scrolling="no";
			IFrameObj = oContainer.appendChild(tempIFrame);
			if (document.frames) {
				// this is for IE5 Mac, because it will only
				// allow access to the document object
				// of the IFrame if we access it through
				// the document.frames array
				IFrameObj = document.frames['CO__IFRAME'+nr];
			}
		} catch(exception) {
			// This is for IE5 PC, which does not allow dynamic creation
			// and manipulation of an iframe object. Instead, we'll fake
			// it up by creating our own objects.
			iframeHTML='<iframe id="CO__IFRAME'+nr+'" frameBorder="0" style="'; // scrolling="no"
			iframeHTML+='border:none;';
			iframeHTML+='width:'+targetWidth+'px;';
			iframeHTML+='height:'+targetHeight+'px;';
			iframeHTML+='"><\/iframe>';
			oContainer.innerHTML+=iframeHTML;
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById('CO__IFRAME'+nr);
			IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location;
			}
		}
	}

	IFrameDoc = getIFrameDocument('CO__IFRAME'+nr);
	IFrameDoc.location.replace(url); //+"?firstLoaded=1"
}

function showCalendars(){
	for(var i=0;i<objs;i++){
		createIframe(urls[i],i);
	}
}

if(window.addEventListener){ // Mozilla
	showCalendars()
} else if (window.attachEvent){ // IE
	showCalendars()
}
