//*********************
// JavaScript Document
//*********************

//-----------------------------------------------------
// Image Preloads - Note: Update path to your live root
//-----------------------------------------------------
img1=new Image()
img1.src="/media/images/nav-home-01.gif"
img2=new Image()
img2.src="/media/images/nav-home-02.gif"
img3=new Image()
img3.src="/media/images/nav-aboutus-01.gif"
img4=new Image()
img4.src="/media/images/nav-aboutus-02.gif"
img5=new Image()
img5.src="/media/images/nav-ourmusic-01.gif"
img6=new Image()
img6.src="/media/images/nav-ourmusic-02.gif"
img7=new Image()
img7.src="/media/images/nav-musicpublishing-01.gif"
img8=new Image()
img8.src="/media/images/nav-musicpublishing-02.gif"
img9=new Image()
img9.src="/media/images/nav-news-01.gif"
img10=new Image()
img10.src="/media/images/nav-news-02.gif"
img11=new Image()
img11.src="/media/images/nav-contactus-01.gif"
img12=new Image()
img12.src="/media/images/nav-contactus-02.gif"


//-----------------------------------------------------------------
// Image Swaps and Hide/Show content for Billboard and Main Content
//-----------------------------------------------------------------
function showPanelsOpen(panelid, imgid, droptype) {
	var p = document.getElementById(droptype+panelid);
	var img = document.getElementById(imgid);
		
	if (p.style.display == "block" || p.style.display == "") {
		p.style.display = "none";
		img.src = img.src.replace(/arrow-up/, "arrow-down");
		img.src = img.src.replace(/-on/, "-off");		
	} else {
		p.style.display = "block";	
		img.src = img.src.replace(/arrow-down/, "arrow-up");	
		img.src = img.src.replace(/-off/, "-on");
	};
}

function showPanelsClosed(chartid, imgid) {
	var p = document.getElementById("chart"+chartid);
	var img = document.getElementById(imgid);
	
	if (p.style.display == "" || p.style.display == "none") {
		p.style.display = "block";
		img.src = img.src.replace(/-off/, "-on");
	} else {
		p.style.display = "none";
		img.src = img.src.replace(/-on/, "-off");
	};
}

//--------------------
//LOSE IE6 FLICKER BUG
//--------------------
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}



//--------------------
// Various Functions
//--------------------
function PlayAdvert() {
    // Play advert playlist
	if (parent) parent.ChangeFlashPlayerPlaylist('advert.xml',0);
}

function GetPageNameFromURL(URL) {
    // Page start position(in brackets): http://testsite/(T)estPage.aspx
	var _pagestartpos = URL.lastIndexOf('/')+1;
	
	// Extension start position(in brackets): http://testsite/TestPage(.)aspx
	var _extstartpos = URL.lastIndexOf('.');
	
	// Exclude the langtype added e.g. EnGB
	var _langexclusion = 4;
	
	// Check if there is a prefix of EnGB : http://testsite/Test(Page).aspx
	if (URL.substring(_extstartpos - _langexclusion, _extstartpos).toLowerCase() != "engb")
	{
	    _langexclusion = 0;
	}
	
	// Page name(in brackets) : http://testsite/(TestPage).aspx
	var _pagename = URL.substring(_pagestartpos,(_extstartpos - _langexclusion)).toLowerCase();
	
	return _pagename;
}

function MenuHighlight() {
	// Highlight the relevant menu item for this content
	parent.ChangeFrameLink("",GetPageNameFromURL(String(location.href)),"");
}

function ChangeFrameLink(url,alink,anchor) {
    if (url != "")
    {
        if (document.getElementById("ifContent") != null)
        {
            // GUID
            if (url.lastIndexOf('?') == -1)
            {
                url = url + '?GUID=';
            }
            else
            {
                url = url + '&GUID=';
            }
            url = url + document.getElementById('ctl00_GUID').value;
            
            // Anchor?
            if (anchor != "")
            {
                url = url + "#" + anchor
            }
            //********************
            // Set iFrame Content
            //********************
            parent.ifContent.location.href=url;
            
            document.title = "S1 Songs";
        }
    }
    
    //******
    // HOME
    //******
    if (document.getElementById("home") != null)
    {
        if (alink == "home")
        {
            document.getElementById("home").className = "nav-home-active";
        }
        else
        {  
            document.getElementById("home").className = "nav-home";
        }
    }
    
    //**********
    // ABOUT US
    //**********
    if (document.getElementById("aboutus") != null)
    {
        if (alink == "aboutus" || alink == "corporatestructure" || alink == "management" || alink == "legalandcorporateinformation")
        {
            document.getElementById("aboutus").className = "nav-aboutus-active";
        }
        else
        {
            document.getElementById("aboutus").className = "nav-aboutus";
        }
    }
    
    //***********
    // OUR MUSIC
    //***********
    if (document.getElementById("ourmusic") != null)
    {
        if (alink == "ourmusic" || alink == "whatscurrent" || alink == "topperformingsongs" || alink == "songwriters" || alink == "musicsearch" || alink == "ourartists")
        {
            document.getElementById("ourmusic").className = "nav-ourmusic-active";
        }
        else
        {
            document.getElementById("ourmusic").className = "nav-ourmusic";
        }
    }
    
    //******************
    // MUSIC PUBLISHING
    //******************
    if (document.getElementById("musicpublishing") != null)
    {
        if (alink == "musicpublishing" || alink == "musicpublishingadministration" || alink == "creativeservices" || alink == "getaquote" || alink == "globalcoverage" || alink == "subpublishers")
        {
            document.getElementById("musicpublishing").className = "nav-musicpublishing-active";
        }
        else
        {
            document.getElementById("musicpublishing").className = "nav-musicpublishing";
        }
    }
    
    //****************
    // NEWS AND PRESS
    //****************
    if (document.getElementById("newsandpress") != null)
    {
        if (alink == "newsandpress" || alink == "latestnews" || alink == "pressreleases" || alink == "newsarchive" || alink == "gallery")
        {
            document.getElementById("newsandpress").className = "nav-newsandpress-active";
        }
        else
        {
            document.getElementById("newsandpress").className = "nav-newsandpress";
        }
    }
    
    //************
    // CONTACT US
    //************
    if (document.getElementById("contactus") != null)
    {
        if (alink == "contactus" || alink == "ouroffices")
        {
            document.getElementById("contactus").className = "nav-contactus-active";
        }
        else
        {
            document.getElementById("contactus").className = "nav-contactus";
        }
    }
}


//--------------------------------------------------
// Play Specific Music - Called Within CMS Content
//--------------------------------------------------
function PlaySong(songXML) {
    // Play specific song
	if (parent) parent.ChangeFlashPlayerPlaylist(songXML,1);
}
