function _REQUEST()
{
	this.getHash = function() {
       // It would be nice if we could use document.location.hash here,
       // but it's faulty sometimes.
       var idx = document.location.href.indexOf('#');
       return (idx >= 0) ? document.location.href.substr(idx+1) : '';
    }
	var _G = {};
	var hash = this.getHash(); //window.location.hash.substring(1);
	var param = hash.split('-');
	var pL = param.length;
	var pE;
	for(var i=0;i<pL;i++)
	{
		pE = param[i].split('=');
		_G[pE[0]] = pE[1];
	}
	this.get = function(key)
	{
		return _G[key];
	}
}
var _request = new _REQUEST();
var dt = document.title;
function setTitle(title)
{
	dt = title;
    document.title = title;
	return true;
}
var lastPIset = Math.round(new Date().getTime() / 1000);
function setFlashPI(t)
{
	if(typeof t == 'undefined')
		t = '';
	// console.log("would: ", t);
	var now = Math.round(new Date().getTime() / 1000);
	if(lastPIset+2 >= now) return false;
	//console.log("do: ", t);
    // 
	// pageFlashTracker._trackPageview(t);	// google Analytics
    var dl = document.location;
    var url = "/";
    if(t != '' && t.indexOf('-') > 0)
    {
        t = t.split('-');
        url = url + t[1];
    }
    if(dt != '' && dt.indexOf('#app=') == -1)
    {
        var dt_ = dt.split('>');
        for(var E in dt_)
        {
            dt_[E] = dt_[E].replace (/^\s+/, '').replace (/\s+$/, '');
        }
        if(dt_[0] == 'VELTINS.de' && dt_.length > 1){ dt_ = dt_.slice(1); }
        dt = dt_.join('/');
    }
    else
    {
        dt = 'VELTINS.de/' + t[1];
    }
    try{
        switch(t[0])
        {
            case 'showSite':
                // piwikTracker.setDocumentTitle(dt);
                // piwikTracker.setCustomUrl(dl.protocol + "//" + dl.host + "/showSite" + url);
                // piwikTracker.trackPageView();
                if(_gaq)
                {
                	_gaq.push(['_trackPageview', url]);
                }
            break;
            case 'download':
                // piwikTracker.trackLink(t[1], 'download');
                _gaq.push(['_trackEvent', 'download', 'download', t[1]]);
            break;
            case 'external':
            default:
                // piwikTracker.trackLink(t[1], 'link');
                _gaq.push(['_trackEvent', 'link', 'link', t[1]]);
            break;
        }
    }catch( err ) {}
	lastPIset = now;	
	setInternalPI();
}
function setInternalPI()
{
	if(document.getElementById('internalPI'))
	{
		var imgPi = document.getElementById('internalPI');
		if(imgPi)
		{
			(/^(.*\.)v[0-9.]+\.(css|js|gif|png|jpg|swf|xml|flv)$/).exec(imgPi.src);
			var n = new Date();
			imgPi.src = RegExp.$1+'v'+n.getTime()+'.'+RegExp.$2;
		}
	}
}
