/* Estrae i parametri da una stringa, dalla query o dall'hash dell'url.
 * I parametri devono essere codificati come nella query delle url: nome1=valore1&nome2=valore2
 * Se un parametro non ha valore, nell'array viene impostato come valore true.
 */
function getParams(s) {
    if (s == null) {
        s = document.location.search;
        if (s == null || s == '') {
            s = document.location.hash;
        }
    }
    if (s.match(/^\?/) || s.match(/^#/)) {
        s = s.substring(1);
    }
    var strParams = s.split('&');
    var params = {};
    var i = 0;
    for (i in strParams) {
        var name = strParams[i];
        var value = true;
        var pos = name.indexOf('=');
        if (pos>0) {
            value = decodeURIComponent(name.substring(pos+1));
            name = name.substring(0, pos);
        }
        params[name] = value;
    }
    return params;
};
function getParam(name, string) {
    var params = getParams(string);
    return params[name] || false;
}
var cid = getParam('cid');
var channel = getParam('channel');
if (cid) {
	document.location.replace('http://www.rai.tv/dl/RaiTV/dirette/' + cid + '.html?channel=' + channel);
}
