/*********************************************
* Dynamic Charts Overrides *
**********************************************/
function parseDynCharts(){
var prefix = "if_nt_dynCharts_";
var charts = [
"albums",
"artistBrds",
"artists",
"news",
"photoArtists",
"photoShows",
"shows",
"showBrds",
"tours",
"videos"
];

var chartsCall = "";
for(i in charts){
if(com.mtvi.config.SectionSetup[(prefix + charts[i])]){
chartsCall += charts[i] + "_" + com.mtvi.config.SectionSetup[(prefix + charts[i])] + "|";
delete com.mtvi.config.SectionSetup[(prefix + charts[i])];
}
}
chartsCall = chartsCall.substring(0, chartsCall.length-1);
com.mtvi.config.SectionSetup.dynCharts=(chartsCall != "")?unescape(chartsCall):"";
}
parseDynCharts();

/*********************************************
* Yahoo Partner Overrides *
**********************************************/
if(document.referrer.indexOf("yahoo")>=0)
com.mtvi.config.SectionSetup.partner="yahoo";

/***
--->FIGURE OUT HOW TO HANDLE THIS
/global/droplets/reporting/searchstate.jhtml
*/

try{
var pageName = com.mtvi.config.SectionSetup["pageName"];
if(pageName.indexOf("loaded")!=-1){
com.mtvi.config.SectionSetup["pageName"]=pageName.replace(/loaded/,"CMTLoaded");
} 
}catch(e){}

function getChannel(){
var pageName = getPath();
if(typeof com.mtvi.config.SectionSetup["gateway"] != "undefined" && com.mtvi.config.SectionSetup["gateway"]!="") return com.mtvi.config.SectionSetup["gateway"];
else if(typeof com.mtvi.config.SectionSetup["portal"] != "undefined" && com.mtvi.config.SectionSetup["portal"]!="")	return com.mtvi.config.SectionSetup["portal"];
else if(pageName.split("/").length>1)return pageName.split("/")[0];
else return null;
}
function getPath(){
var path = "";
var defaultPageName = (location.pathname+location.search).substring(1);
var origPageName = typeof com.mtvi.config.SectionSetup["pageName"]!="undefined"?com.mtvi.config.SectionSetup["pageName"]:dispatcher.getAttribute("pageName");

for(s in com.mtvi.config.SectionSetup){
if(s.indexOf("section_")==0 && com.mtvi.config.SectionSetup[s]!=""){
path += com.mtvi.config.SectionSetup[s]+"/";
}
}

path += origPageName;
return path!=""?path:defaultPageName;
}

function getPagename(){
var pn;
var path = getPath();
try {

var channel = getChannel();
if(channel) path = channel + "/" + path ;
path = path.replace(new RegExp("/+","g"),"/");
path=path.replace(/loaded/,"CMTLoaded");
if(path.charAt(0)=="/")path=path.substring(1);
return path;
}catch(e){}
}
function getHierarchy() {
var h = getPagename();
try {
h = h.replace(new RegExp("#VID:","g"),"/VID/");
} catch(e){}

return h;
}
