function MM_swapImgRestore()
{
    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()
{
    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)
{
    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); return x;
}

function MM_swapImage()
{
    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];}
}

function sendEmail()
{
    document.location="/article/mailtofriend/?url=" + document.URL;
}

function openArticle(articleId) {
    document.location="/link/gotoarticle/addhit/"+articleId;
    return false; // return false to indicate that this event has been handled
}

function gotoUrlClicked(targetSelectList) {
    var selectList;
    if (targetSelectList!=undefined) {
        selectList=targetSelectList;
    }
    else {
      selectList = document.site_switcher.gotourl;
    }

    var value = selectList[selectList.selectedIndex].value;

    if (value != '') {
      parent.location = value;
    }
    
    return false;
}


var all_visible = 'false';
var visibility = 'hidden';
function showhide(layer_ref, show_or_hide) {

    if (show_or_hide == 'show') {
        visibility = 'visible';
    }
    else {
        visibility = 'hidden';
    }
    if (all_visible == 'true' ) {
        visibility = 'visible';
    }

    if (document.all) { //IS IE 4 or 5 (or 6 beta)
        eval( "document.all." + layer_ref + ".style.visibility = visibility");
    }
    if (document.layers) { //IS NETSCAPE 4 or below
        document.layers[layer_ref].display = visibility;
    }
    if (document.getElementById &&!document.all) {
        hza = document.getElementById(layer_ref);
        hza.style.visibility = visibility;
    }
} 

var poptimer = null;

function showorhide(name) {
	thing = eval(name);
	thing.style.display = (thing.style.display == 'none') ? 'block' : 'none';
}

function ro(tag,suffix) {
//	alert("ro('" + tag + "','" + suffix + "')");
	document.images[tag].src = eval(tag + suffix + '.src');
}

function tabro(tag,suffix) {
//	alert("tabro('" + tag + "','" + suffix + "')");
	document.images[tag + '_tab'].src = eval(tag + suffix + '.src');
}

function playstream() {
	if (document.embeds[0].GetPlayState() != 3) {
		document.embeds[0].DoPlay();
	}
}

function stopstream() {
	if (document.embeds[0].GetPlayState() >= 3) {
		document.embeds[0].DoStop();
	}
}

function pausestream() {
	if (document.embeds[0].GetPlayState() == 3) {
		document.embeds[0].DoPause();
	} else if (document.embeds[0].GetPlayState() == 4) {
		document.embeds[0].DoPlay();
	}
}

function changestream(url) {
	document.embeds[0].DoStop();
	document.embeds[0].SetSource(url);
	document.embeds[0].DoPlay();
}

function playerpop(url) {

	viewerurl = url + "&window=viewer";
        windowstring = "width=494,height=540,status=no,resizable=no";
	player = window.open(viewerurl,'player', windowstring);
	player.opener.name = "boss";
	player.document.close();
	player.focus();
}	

function playerpopwithreload(url, docurl) {

        this.location = docurl;
        viewerurl = url + "&window=viewer";
        windowstring = "width=494,height=540,status=no,resizable=no";
        player = window.open(viewerurl,'player', windowstring);
        player.opener.name = "boss";
        player.document.close();
        player.focus();
}


function popbox(wurl, wwidth, wheight) {
	if (!wurl) { 
		return false;
	}
	if (!wwidth) {
		wwidth = 210;
	}
	if (!wheight) {
		wheight = 297;
	}
	windowstring = "width=" + wwidth + ",height=" + wheight + ",status=no,scrollbars=yes";
	popbox = window.open(url,"popbox", windowstring);
	popbox.opener.name = "boss";
	popbox.document.close();
	popbox.focus();
}

function bg(thing, colour) {
	thing.style.backgroundColor = (colour == 't') ? 'transparent' : colour;
}

function chooseBlock(choosethis,fromthese) {
	blocklist = eval(fromthese);
	for (i=0; i < blocklist.length; i++) {
		thisblock = eval(blocklist[i]);
		thisblock.style.display = (blocklist[i] == choosethis) ? 'block' : 'none';
	}
}

function showif(button, layername) {
	layerobj = eval(layername);
	if (button.checked) {
		layerobj.style.display='block';
	} else {
		layerobj.style.display='none';
	}
}

function hideif(button, layername) {
	layerobj = eval(layername);
	if (button.checked) {
		layerobj.style.display='none';
	} else {
		layerobj.style.display='block';
	}
}


function whenitsfinished(howmanyseconds) {
	poptimer = setTimeout("isitfinished()", howmanyseconds * 1000 );
}

function isitfinished() {
        if (document.embeds[0].GetPlayState() == 3) {
            hideClipLinks();
        } else {
            showClipLinks();
	}
}

function showClipLinks() {
     showhide( 'TopLeftClipSummary', 'show' );
     showhide( 'TopCenterClipSummary', 'show' );
     showhide( 'TopRightClipSummary', 'show' );
     showhide( 'MiddleLeftClipSummary', 'show' );
     showhide( 'MiddleRightClipSummary', 'show' );
     showhide( 'LowerLeftClipSummary', 'show' );
     showhide( 'LowerRightClipSummary', 'show' );
}

function hideClipLinks() {
     showhide( 'TopLeftClipSummary', 'hide' );
     showhide( 'TopCenterClipSummary', 'hide' );
     showhide( 'TopRightClipSummary', 'hide' );
     showhide( 'MiddleLeftClipSummary', 'hide' );
     showhide( 'MiddleRightClipSummary', 'hide' );
     showhide( 'LowerLeftClipSummary', 'hide' );
     showhide( 'LowerRightClipSummary', 'hide' );
}

function PlayIt(element, what ){
    document.getElementById(element).innerHTML='<img src="/sitedesign/tv/images/spacer.gif" height="29" border="0" /><br />'
      +'<embed '
      +'controller="false" showcontrols="false"  CONTROLS="ImageWindow"'
      +'width="160" height="120" enablejavascript="true"'
      +'src="'+what+'" autostart="true" type="video/3gp" name="mobvid">'
      +'</embed>';
}
function StopIt(element, what, src, caption, width, height ){
    document.getElementById(element).innerHTML=
     '<a href="'+what+'" onclick="javascript:PlayIt('+element+',this.href);return false;">'
     +'<IMG class="mobileimg"'
     +'src="'+src+'" alt="'+caption+'"'
     +'border="0"'
     +'width="'+width+'"'
     +'height="'+height+'"'
     +'></a>';

}

function gotoURL (which,win) {
  
  var url = 'http://uk.oneworld.net' + which.options[which.selectedIndex].value; 
  

  if ( win )
    {
      openWindow ( url );
    }
    else
    {
      location.href = url;
    }
  

	
	
}

