//Get current URL
var urlCurrent = window.location.href;


// Determin if the domain is short version "rct-cbc.gov.uk of full version.
// This will only effect "Council" and "Events" links
if (urlCurrent.match('rctcbc.gov.uk'))
{
    var urlRctDomain = "http://www.rctcbc.gov.uk";
}
else
{
    if (urlCurrent.match('rct-cbc.gov.uk')) 
    {
        var urlRctDomain = "http://www.rct-cbc.gov.uk";
    }
    else 
    {
        if (urlCurrent.match('http://www.rhondda-cynon-taff.gov.uk')) 
        {
            var urlRctDomain = "http://www.rhondda-cynon-taff.gov.uk";
        }
        else 
        {
            var urlRctDomain = "http://www.rhondda-cynon-taf.gov.uk";
        }
    }
}

//Variables containing the URL's for each link
if (urlCurrent.match('lang=cy'))
{
    //Welsh versions
    var urlCouncil = urlRctDomain + '/stellent/groups/public/documents/hcst/home_page.hcst?lang=cy&textonly=false';
    var urlCommunity = 'http://www.shape-it.org/';
    var urlBusiness = 'http://www.rctbusinessclub.co.uk/?diablo.lang=cym';
    var urlTourism = 'http://www.destinationrct.co.uk/?diablo.lang=cym';
    var urlEvents = urlRctDomain + '/stellent/groups/public/documents/hcst/content.hcst?lang=cy&textonly=false&xNodeID=2062';

    // Handle taff with two f's as Events is the only option this affects
    //var urlEventsTaff  = 'http://www.rhondda-cynon-taff.gov.uk/stellent/groups/public/documents/hcst/home_page.hcst?lang=cy&textonly=false';
    
    var strCouncil = "Cyngor";
    var strCommunity = "Cymunedau";
    var strBusiness = "Byd Busnes";
    var strTourism = "Twristiaeth";
    var strEvents = "Achlysuron";
    
        
    var strTitle = "Sianeli RhCT: ";
}
else
{
    //English versions
    var urlCouncil = urlRctDomain;
    var urlCommunity = 'http://www.shape-it.org/';
    var urlBusiness = 'http://www.rctbusinessclub.co.uk/?diablo.lang=eng';
    var urlTourism = 'http://www.destinationrct.co.uk/?diablo.lang=eng';
    var urlEvents = urlRctDomain + '/stellent/groups/public/documents/hcst/content.hcst?lang=en&textonly=false&xNodeID=2062';
    
    // Handle taff with two f's as Events is the only option this affects
    //var urlEventsTaff  = 'http://www.rhondda-cynon-taff.gov.uk/stellent/groups/public/documents/hcst/home_page.hcst?lang=en&textonly=false';
    
    var strCouncil = "Council";
    var strCommunity = "Community";
    var strBusiness = "Business";
    var strTourism = "Tourism";
    var strEvents = "Events";
    
        
    var strTitle = "RCT Channels: ";
}


var urlActive;
var urlImage = "";



//Set active URL so we can set a different style for that link
switch (urlCurrent)
{
case urlCouncil:
  urlActive = urlCouncil;
  DisplayChannels(urlActive);
  break;
case urlCommunity:
  urlActive = urlCommunity;
  DisplayChannels(urlActive);
  break;
case urlBusiness:
  urlActive = urlBusiness;
  DisplayChannels(urlActive);
  break;
case urlTourism:
  urlActive = urlTourism;
  DisplayChannels(urlActive);
  break;
case urlEvents:
  urlActive = urlEvents;
  DisplayChannels(urlActive);
  break;
default:
    if (urlCurrent.match('http://www.whatsonrct.co.uk/'))
    {
        urlActive = urlEvents;
    }
    else
    {
        urlActive = urlCouncil;
    }
    DisplayChannels(urlActive);
}


function DisplayChannels(urlActive)
{
	document.write("<div id='rct_channels_header' style='display: block; color: #84AA33; background-color: #cccccc; font-family: Verdana; font-size: 12px; text-transform: uppercase; list-style-image: none; letter-spacing: 1px; padding: 2px; margin: 0px; background-image: url(" + urlImage + "); height: 12px;'>");
	document.write("<ul style='display: inline; margin: 0;'>");
	document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; text-transform: uppercase; '><a href='" + urlCouncil + "' style='color: #343434; text-decoration: none; font-weight: bold;'>" + strTitle + "</a></li>");
		
	if (urlActive == urlCouncil) 
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; font-weight: bold; text-transform: uppercase; '><a href='" + urlCouncil + "' style='color: #343434; text-decoration: none;'>" + strCouncil + "</a></li>");
	} 
	else
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; text-transform: uppercase; '><a href='" + urlCouncil + "' style='color: #343434; text-decoration: none;'>" + strCouncil + "</a></li>");
	};
	
	if (urlActive == urlCommunity) 
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; font-weight: bold; text-transform: uppercase; '><a href='" + urlCommunity + "' style='color: #343434; text-decoration: none;'>" + strCommunity + "</a></li>");
	} 
	else
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; text-transform: uppercase; '><a href='" + urlCommunity + "' style='color: #343434; text-decoration: none;'>" + strCommunity + "</a></li>");
	};
	
	if (urlActive == urlBusiness) 
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; font-weight: bold; text-transform: uppercase; '><a href='" + urlBusiness + "' style='color: #343434; text-decoration: none;'>" + strBusiness + "</a></li>");
	} 
	else
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; text-transform: uppercase; '><a href='" + urlBusiness + "' style='color: #343434; text-decoration: none;'>" + strBusiness + "</a></li>");
	};

	if (urlActive == urlTourism) 
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; font-weight: bold; text-transform: uppercase; '><a href='" + urlTourism + "' style='color: #343434; text-decoration: none;'>" + strTourism + "</a></li>");
	} 
	else
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; text-transform: uppercase; '><a href='" + urlTourism + "' style='color: #343434; text-decoration: none;'>" + strTourism + "</a></li>");
	};

	if (urlActive == urlEvents) 
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; font-weight: bold; text-transform: uppercase; '><a href='" + urlEvents + "' style='color: #343434; text-decoration: none;'>" + strEvents + "</a></li>");
	} 
	else
	{
		document.write("<li style='width: 16%; display: block; margin: 0; padding: 0; list-style-type: none; float: left; font-family: Verdana; font-size: 9px; text-transform: uppercase; '><a href='" + urlEvents + "' style='color: #343434; text-decoration: none;'>" + strEvents + "</a></li>");
	};
		
	document.write("</ul>");
	document.write("</div>");
}