// Initilise
//window.onload = initStuff;
 
addDOMLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener("DOMContentLoaded",x,false);/*@cc_on@*//*@if(@_win32)d.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();
addDOMLoadEvent(initStuff);


function initStuff()
{
	initAbce();
	footMenu();
}


function initAbce()
{
	if (document.getElementById("abce"))
	{
		document.getElementById("abce").onclick = abce;
	}
}

function footMenu()
{
       if (document.getElementById("footMenu"))
       {
       document.getElementById("footMenu").innerHTML = '<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"953\" align=\"right\"><tr><td width=\"188\" align=\"left\"><a href=\"http://www.britishinformation.com/arts/\" class=\"footerNav\" target=\"_top\">Arts</a><a href=\"http://www.britishinformation.com/business/\" class=\"footerNav\" target=\"_top\">Business</a><a href=\"http://www.britishinformation.com/education/\" class=\"footerNav\" target=\"_top\">Education</a><a href=\"http://www.britishinformation.com/employment/\" class=\"footerNav\" target=\"_top\">Employment</a></td><td width=\"188\" align=\"left\"><a href=\"http://www.britishinformation.com/entertainment/\" class=\"footerNav\" target=\"_top\">Entertainment</a><a href=\"http://www.britishinformation.com/finance/\" class=\"footerNav\" target=\"_top\">Finance</a><a href=\"http://www.britishinformation.com/food/\" class=\"footerNav\" target=\"_top\">Food &amp; Drink</a><a href=\"http://www.britishinformation.com/betting/\" class=\"footerNav\" target=\"_top\">Gambling</a></td><td width=\"188\" align=\"left\"><a href=\"http://www.britishinformation.com/fun/\" class=\"footerNav\" target=\"_top\">Games</a><a href=\"http://www.britishinformation.com/health/\" class=\"footerNav\" target=\"_top\">Health &amp; Beauty</a><a href=\"http://www.britishinformation.com/horoscopes/\" class=\"footerNav\" target=\"_top\">Horoscopes</a><a href=\"http://www.britishinformation.com/insurance/\" class=\"footerNav\" target=\"_top\">Insurance</a></td><td width=\"168\" align=\"left\"><a href=\"http://www.britishinformation.com/it/\" class=\"footerNav\" target=\"_top\">IT</a><a href=\"http://www.britishinformation.com/legal/\" class=\"footerNav\" target=\"_top\">Legal</a><a href=\"http://www.britishinformation.com/lifestyle/\" class=\"footerNav\" target=\"_top\">Lifestyle</a><a href=\"http://www.britishinformation.com/lottery/\" class=\"footerNav\" target=\"_top\">Lottery</a></td><td width=\"188\" align=\"left\"><a href=\"http://www.britishinformation.com/motor/\" class=\"footerNav\" target=\"_top\">Motor</a><a href=\"http://www.britishinformation.com/music/\" class=\"footerNav\" target=\"_top\">Music</a><a href=\"http://www.britishinformation.com/property/\" class=\"footerNav\" target=\"_top\">Property</a><a href=\"http://www.britishinformation.com/relationships/\" class=\"footerNav\" target=\"_top\">Relationships</a></td><td width=\"108\" align=\"left\"><a href=\"http://www.britishinformation.com/sport/\" class=\"footerNav\" target=\"_top\">Sport</a><a href=\"http://www.britishinformation.com/travel/\" class=\"footerNav\" target=\"_top\">Travel</a><a href=\"http://www.britishinformation.com/tv/\" class=\"footerNav\" target=\"_top\">TV &amp; Radio</a><a href=\"http://www.britishinformation.com/weather/\" class=\"footerNav\" target=\"_top\">Weather</a></td></tr></table>';
   }
}


function abce()
{
	document.getElementById("abce").href='http://www.britishinformation.com/imgs/abceMarch09.pdf';
}

function clickTag(url)
{
       url.href = url.href + '&j=y';
}

// JavaScript Document
/* Custom News Widget */

function switchbutton(chosendiv)
{
        var i,divbuttons=['button1','button2','button3'],divtext=['newsdiv1','newsdiv2','newsdiv3'];
        for(i =0; i <'3' ;i++)
        {
                if (divbuttons[i] != chosendiv)
                {
                        document.getElementById(divbuttons[i]).className='notSelectLink'; 
                        document.getElementById(divtext[i]).style.display = 'none'; 
                }
                else {document.getElementById(divbuttons[i]).className = 'selectLink'; document.getElementById(divtext[i]).style.display = 'inline';}
        }
}

function switchbutton2(chosendiv)
{
        var i,divbuttons=['buttonb1','buttonb2','buttonb3'],divtext=['stuffdiv1','stuffdiv2','stuffdiv3'];
        for(i =0; i <'3' ;i++)
        {
                if (divbuttons[i] != chosendiv)
                {
                        document.getElementById(divbuttons[i]).className='notSelectLink'; 
                        document.getElementById(divtext[i]).style.display = 'none'; 
                }
                else {document.getElementById(divbuttons[i]).className = 'selectLink'; document.getElementById(divtext[i]).style.display = 'inline';}
        }
}

function NewsImage(imgdat)
{
        document.write('<img src="' + decode64(imgdat) + '" height="49" width="66">');
}

function decode64(input)
{
     var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
     var output = "";
     var chr1, chr2, chr3 = "";
     var enc1, enc2, enc3, enc4 = "";
     var i = 0;

     // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
     var base64test = /[^A-Za-z0-9\+\/\=]/g;

     input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

     do {
        enc1 = keyStr.indexOf(input.charAt(i++));
        enc2 = keyStr.indexOf(input.charAt(i++));
        enc3 = keyStr.indexOf(input.charAt(i++));
        enc4 = keyStr.indexOf(input.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        output = output + String.fromCharCode(chr1);

        if (enc3 != 64) {
           output = output + String.fromCharCode(chr2);
        }
        if (enc4 != 64) {
           output = output + String.fromCharCode(chr3);
        }

        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";

     } while (i < input.length);

     return unescape(output);
}



// POP UP WINDOWS
function openScript(url, width, height) {
        Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=0,menubar=0,status=0' );	
	
	// calculate the center of the page
	x = (screen.availWidth - width) / 2;
	y = (screen.avaiHeight - height) / 2;

	// move to the center of the page
	Win.moveTo(x, y);
}



// NEWS MAKER FORM JAVASCRIPT
function showBoxBackground(boxBackCol) {
	document.makeNewsForm.boxBackground.value = '#'+boxBackCol;
	document.getElementById('boxBackgroundSelection').style.backgroundColor='#'+ boxBackCol;
}
	
function showHeadlineBackgroundColor(headBackCol) {
	document.makeNewsForm.showHeadlineBg.value = '#'+ headBackCol;
        document.getElementById('showHeadlineBgSelection').style.backgroundColor='#'+ headBackCol;
}

function showHeadlineColor(headCol) {
	document.makeNewsForm.headlineColor.value = '#'+headCol;
        document.getElementById('headlineColorSelection').style.backgroundColor='#'+ headCol;
}

function showColorLink(linkCol) {
	document.makeNewsForm.colorLink.value = '#'+linkCol;
        document.getElementById('colorLinkSelection').style.backgroundColor='#'+ linkCol;
}

function showNewsText(textCol) {
	document.makeNewsForm.newsText.value = '#'+textCol;
        document.getElementById('newsTextSelection').style.backgroundColor='#'+ textCol;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// FOR FIREFOX BUG IN THE MAKE-NEWS-FORM
function moveLeft()
{
        var layerElement = document.getElementById("PcjsColorChooserPopup");

        x-=90;

        layerElement.style.left=x;
}






// For the advertising page image rollover

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



// FOR JUMP SELECT MENUS

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
