<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="test.css"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2" xml:lang="en">
	<head xmlns="http://www.w3.org/1999/xhtml"
	      xmlns:dc="http://dublincore.org/documents/dcmi-namespace/">
		<title>XHTML2 frames test page - 1</title>
		<meta property="dc:creator">Alessio Cartocci</meta>
		<script type="text/javascript">
		//<![CDATA[
			var frameObject = {
				init : function() {
					this.idColl = new Array();
					try {
						uri = location.href.split('src')[1].replace(/\(/g,'').replace(/\)/g,'').split(',');
						for (this.i=0; this.i<uri.length; this.i++) {
							try {
								this.uriVal = uri[this.i].split('=');
								// querystrings: todo
								uriVal2 = this.uriVal[2] ? '=' + this.uriVal[2] : '';
								this.uriVals = this.uriVal[1] + uriVal2;
								this.load();
							}
							catch (e) {}
						}
					}
					catch (e) {}
				},

				load : function() {
					try {
						body = document.getElementsByTagName('body')[0]
						this.el = document.getElementById(this.uriVal[0]);
						attr = this.el.getAttribute('src') ? 'src' : 'data';
						if (attr=='data') { // object
							this.idColl.push(this.el.id);
							uA = navigator.userAgent;
							uN = navigator.vendor;
							if (!window.opera && uN.indexOf('Apple')!=-1)  this.el.setAttribute('name',this.el.id);
							if (uA.indexOf("Firefox/3")!=-1)  this.el.setAttribute('data',this.uriVals);
							else  this.el.parentNode.innerHTML = this.el.parentNode.innerHTML.replace(/data="(.|\n)*?"/gi,'data="' + this.uriVals +	'"');
							// focus/blur: todo
							body.onmouseover = function() {
								t = setInterval('frameObject.objLocation()',1000);
							};
							body.onmouseout = function() {
								clearInterval(t);
							};
						}
						else { // iframe
							this.el.setAttribute(attr,this.uriVals);
							this.el.onload = function() {
								url = location.hash.replace(')',',)');
								reg = new RegExp(this.id + '=(.|\n)*?,');
								url = url.replace(reg,this.id + '=' + this.contentWindow.location + ',');
								location.replace(url.replace(',)',')'));
							};
						}
					}
					catch (e) {}
				},

				objLocation : function() {
					url = location.hash.replace(')',',)');
					for (i=0; i<this.idColl.length; i++) {
						a = document.getElementById(this.idColl[i]).getElementsByTagName('a')[0];
						reg = new RegExp(this.idColl[i] + '=(.|\n)*?,');
						idUrl = reg.exec(url);
						frameUrl = window.frames[this.idColl[i]].location;
						frameLoc = this.idColl[i] + '=' + frameUrl;
						a.setAttribute('href',frameUrl);
						a.firstChild.nodeValue = "Alternate content: " + frameUrl;
						if (idUrl!=frameLoc+',,/') {
							url = url.replace(reg,frameLoc + ',');
							location.replace(url.replace(',)',')'));
						}
					}
				}
			};

			window.onload = function() {
				frameObject.init();
			}
		//]]>
		</script>
	</head>
	<body xmlns="http://www.w3.org/1999/xhtml">
		<h>XHTML2 frames test page</h>
		<section>
			<h>1 - iframe + object</h>
			<section>
				<h>f1 (iframe)</h>
				<iframe id="f1" role="frame" src="about:blank" />
			</section>
			<section>
				<h>f2 (object)</h>
				<object id="f2" role="frame" type="text/html" data="#">
					<p><a href="#">Alternate content</a></p>
				</object>
			</section>
		</section>
	</body>
</html>