//parseUri 1.2.2
//(c) Steven Levithan <stevenlevithan.com>
// http://blog.stevenlevithan.com/archives/parseuri
//MIT License

function parseUri (str) {
 var o   = parseUri.options,
     m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
     uri = {},
     i   = 14;

 while (i--) uri[o.key[i]] = m[i] || "";

 uri[o.q.name] = {};
 uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
     if ($1) uri[o.q.name][$1] = $2;
 });

 return uri;
};

function info(what) {
  if(what == 'bazaarvoice') {
    //final_url = 'http://mop.wiethe-preview.com/info/bazaarvoice/?content_only=true';
    final_url = 'http://www.marc-o-polo.de/info/bazaarvoice/?content_only=true';
  }
	else if (what.href.search(/\?/) != -1)
	{
		final_url = what.href + '&content_only=true';
	}
	else
	{
		final_url = what.href + '?content_only=true';
	}

  

	win = new Window( "info", {
		className:"mop",
		url:final_url,
		title:false,
		width:777,
		height:582,
		top:100,
		left:100,
		zIndex:1000,
		showEffect:Element.show, /* BUGFIX FÜR IE6 */
		hideEffect:Element.hide, /* BUGFIX FÜR IE6 */
		showEffectOptions:{duration: 0.3},
		hideEffectOptions:{duration: 0.4},
		maximizable:false,
		minimizable:false,
		draggable:false }
	);
	win.setDestroyOnClose();
	win.showCenter(true);

	win.refresh();

	return false;
}

function info_size(what,l_width, l_height) {

	if (what.href.search(/\?/) != -1)
	{
		final_url = what.href + '&content_only=true';
	}
	else
	{
		final_url = what.href + '?content_only=true';
	}

	win = new Window( "info", {
		className:"mop",
		url:final_url,
		title:false,
		width:l_width,
		height:l_height,
		top:100,
		left:100,
		zIndex:1000,
		showEffect:Element.show, /* BUGFIX FÜR IE6 */
		hideEffect:Element.hide, /* BUGFIX FÜR IE6 */
		showEffectOptions:{duration: 0.3},
		hideEffectOptions:{duration: 0.4},
		maximizable:false,
		minimizable:false,
		draggable:false }
	);
	win.setDestroyOnClose();
	win.showCenter(true);

	win.refresh();

	return false;
}

parseUri.options = {
 strictMode: false,
 key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
 q:   {
     name:   "queryKey",
     parser: /(?:^|&)([^&=]*)=?([^&]*)/g
 },
 parser: {
     strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
     loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
 }
};


document.observe("dom:loaded", function() {
	url = parseUri(document.URL);

	if( typeof(url.queryKey['info']) != 'undefined')
	{
		if( typeof(url.queryKey['scrollto']) != 'undefined'){
			var scrollTo = '?scrollToId=' + url.queryKey['scrollto'];
		}
		else
		{
			var scrollTo = '';
		}
		
		var a = document.createElement('a');
		a.setAttribute('href', '/info/' + url.queryKey['info'] + '/' + scrollTo);
		
		info(a);
	}
});
