/* param */
var url_root = 'http://www.portail-du-demenageur.com/';

if (typeof Poly9 == 'undefined')
 var Poly9 = {};
 
Poly9.URLParser = function(url) {
 this._fields = {'Username' : 4, 'Password' : 5, 'Port' : 7, 'Protocol' : 2, 'Host' : 6, 'Pathname' : 8, 'URL' : 0, 'Querystring' : 9, 'Fragment' : 10};
 this._values = {};
 this._regex = null;
 this.version = 0.1;
 this._regex = /^((\w+):\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/;
 for(var f in this._fields)
  this['get' + f] = this._makeGetter(f);
 if (typeof url != 'undefined')
  this._parse(url);
}

Poly9.URLParser.prototype.setURL = function(url) {
  this._parse(url);
}

Poly9.URLParser.prototype._initValues = function() {
   for(var f in this._fields)
   this._values[f] = '';
}

Poly9.URLParser.prototype._parse = function(url) {
  this._initValues();
  var r = this._regex.exec(url);
  if (!r) throw "DPURLParser::_parse -> Invalid URL"
  for(var f in this._fields) if (typeof r[this._fields[f]] != 'undefined')
   this._values[f] = r[this._fields[f]];
}

Poly9.URLParser.prototype._makeGetter = function(field) {
 return function() {
  return this._values[field];
 }
}
function el(id){
	return document.getElementById(id);
	}

function init() {
  
  var url = window.location;

	var p = new Poly9.URLParser(url);

	var urlLoad = p.getProtocol() + '://' + p.getHost();

	var mdwidth = el('md-section').style.width;
	var mdheight = el('md-section').style.height;

	el('md-section').innerHTML='<iframe marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0"  scrolling="no"  id="md-iframe" style="width:'+mdwidth+';height:'+mdheight+';border:none;overflow:hidden;background-color:#E2E7F3" src="'+url_root+'volume/kit?method=iframe&url='+urlLoad+'&width='+mdwidth+'&height='+mdheight+'"></iframe>';

	el('md-texte').innerHTML='<iframe marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0"  scrolling="no" id="md-iframe-texte" style="width:'+mdwidth+';height:41px;border:none;overflow:hidden;background-color:#E2E7F3;" src="'+url_root+'volume/kit?method=texte&url='+urlLoad+'" ></iframe>';	
	el('md-texte').style.width=mdwidth;
	el('md-texte').style.margin='auto';
};