var studioPageAdRotationTimer = null;

function initMasherICC() {
	SERVICE_WWW_ROOT = "/icc/";
	init();
}

function openSiteIndex() {
    window.location="http://www.catchthespirit.com/";
}
//
//
function openStudioPage(mashId){
    if(!rememberToSaveYourMash(openStudioPage,[mashId])){
        return;
    }
    selectNavItem("openStudioPage");
    if(mashId && mashId.length>1){
    	setRefreshCurrentContent(openStudioPage,[mashId]);
    }
    else{
        setRefreshCurrentContent(openStudioPage);
    }
    hideWidgets(openWidgetsMap.readFromKey("content"));
    var c=function(){
        if(!studioPage){
            studioPage = new StudioPageWidget("studioPage","content",null);
        }
        var obj= new Object();
        var requestParameters = "";
        if(mashId && mashId.length>1) {
            requestParameters = "?mashId=" + mashId;
        }
        obj.contentURL=SERVICE_WWW_ROOT+"jsp/studioPage.jsp" + requestParameters;
        obj.loadDomModel=true;
        studioPage.setQueryParams(obj);
        studioPage.reloadDomModel(true);
        studioPage.open();
        openWidgetsMap.replaceAllFromKey("content",new Array(studioPage));
        try {
            scroll(0,0);
        }
        catch (e) {}
        //
        //
        startStudioPageAdRotationUpdateTimer();
    }
    importJS("/jsp/guid.jsp",c);
    //
    // google analytics
    try {
        if(isLoggedIn())
        {
            pageTracker._trackPageview("/loggedIn/studioPage");
        }
        else
        {
            pageTracker._trackPageview("/studioPage");
        }
    }
    catch(gatException) {
    }

}
//
//
function startStudioPageAdRotationUpdateTimer() {
    studioPageRotateAdTimer(1);
}
function stopStudioPageAdRotationUpdateTimer() {
    if(studioPageAdRotationTimer) {
        clearTimeout(studioPageAdRotationTimer);
        studioPageAdRotationTimer = null;
    }
}
//
//
function studioPageRotateAdTimer(rotatePhaseIndex) {
    if(studioPageAdRotationTimer) {
        studioPageAdContentDiv = document.getElementById("studioPage_adbannersideDiv");
        if(studioPageAdContentDiv) {
            if(rotatePhaseIndex == 1) {
                studioPageAdContent =
                    '<a href="http://gettyimages.co.uk/sport">' +
                    '<img src="/icc/images/The-power-of-sport-skyscrapper-120x600px.png" alt="The power of sport / Getty" name="The power of sport / Getty" />' +
                    '</a>';
                studioPageAdContentDiv.innerHTML = studioPageAdContent;
                rotatePhaseIndex = 0;
            }
            else {
                studioPageAdContent =
                    '<a href="http://www.catchthespirit.com/multimedia/cts-competition.html">' +
                    '<img src="/icc/images/CatchTheSpiritCompetitionBanner.jpg" alt="Catch the spirit competition" name="Catch the spirit competition" />' +
                    '</a>';
                studioPageAdContentDiv.innerHTML = studioPageAdContent;
                rotatePhaseIndex = 1;
            }
        }
    }
    studioPageAdRotationTimer = setTimeout("studioPageRotateAdTimer(" + rotatePhaseIndex + ")", 15000);
}
