//This makes a bookmark link for ie4+ pc
var RunningIE4 = (msieversion() >=4.0); //IE 4+ ??
var oururl = "http://www.iccast.co.uk/";
var ourtitle = "Inter-City Casting";
var favtext = "Add Inter-City Casting to your Favourites";
var ie4fav = '';
var ie4favpc = '';
var ie4favpclink = '<a href="javascript:window.external.AddFavorite(oururl, ourtitle)" onMouseOver="window.status=\'       ' + favtext + '\'; return true" onMouseOut="window.status=\'\'; return true" title="' + favtext + '">Add to Favourites</a>'; 
var ie4favmac = '';
var da_site = oururl; 
var da_switch = "/";
var xmlhttp,alerted
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) { }
 }
@else
 xmlhttp=false
 alerted=true
@end @*/
if (!xmlhttp && !alerted) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { } }

/*function t() { document.getElementById('bot').innerHTML = "This is a test";
document.getElementById('src').innerHTML = "<iframe width=950 height=500 frameborder=0 border=0 scrolling=" + scrolling + " unselectable=on src='http://www.google.co.uk'></iframe>"; }*/

xmlreturn = "";
tab = "";
load = "";
tabs = "";
names = "";
urls = "";
mode = "";
tabsm = "home,radio,google,salford,timetable,transport,ldb,extra";//
namem = "Home,Entertainment,Google,Salford,Timetables,Transport,Live Departures,Others";//Entertainment Selector,
starttab = "<table width=100%><tr><td width=2>&nbsp;</td><td><UL id=portal-globalnav>";
limenu = "<LI class=plain><a href='javascript:void(0)'><span onclick=javascript:menu('";
linormal = "<LI class=plain><a href='javascript:void(0)'><span onclick=javascript:show('";
linormal2 = "')>";
linormal3 = "</span>";
limenu3 = "</span></a>";
liX = " <span title='Refresh Tab' style='cursor:hand' onclick=javascript:add('";
liX2 = "','ref')><img src='../include/r.png'></span> <span title='Delete Tab' style='cursor:hand' onclick=javascript:add('";
liX3 = "','del')><img src='../include/x.png'></span></a>";

linormalS = "<LI class=plain><a></a>";
lithisone = "<LI class=selected><a href='javascript:void(0)'><span onclick='javascript:void(0)'>";
lithisone2 = "</span>";
limenu2 = "</span></a>";
middletab = "</LI></UL><UL id=portal-personaltools>";
finishtab = "</UL></td><td width=2>&nbsp;</td></tr></table>";


function doFavLink() { 
   ie4favpc = '' + ie4favpclink; 

   // if mac no Fav Link, else if IE4 PC do link
   if ((navigator.userAgent.indexOf("Mac")!=-1 && RunningIE4 == true)) { ie4fav = ie4favmac; document.write(ie4fav);} 
   else if (RunningIE4 == true) { ie4fav = ie4favpc; document.write(ie4fav); } 
}

function msieversion() { var ua = window.navigator.userAgent; var msie = ua.indexOf ("MSIE"); // Check IE version.
if ( msie > 0 ) { return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) } else { return 0 } }


function closeme() {
   window.close();
}

var tmpx = "";

function returnxml() {
   if (xmlreturn == "ok") {
   document.getElementById('sync').innerHTML = tmpx + "[ " + xmlreturn + " ]<br /><br />";
      document.getElementById('sync').innerHTML = '';
      document.getElementById('items').innerHTML = '<img src="include/load.gif" width=16 height=16 align="absmiddle" alt="Loading..." onmouseover="window.status=\'       Loading...\'; return true" onmouseout="window.status=\'\';  return true"> Loading...<br /><br />';
      Retrieve("dynitem.aspx?type=" + section + "&id=" + tmpx); 
      //window.open("dynitem.aspx?type=" + section + "&id=" + tmpx); 
      window.setTimeout("returnitems()", 5000);
   }
   else {
      document.getElementById('sync').innerHTML = '<img src="include/fail.gif" width=16 height=16 align="absmiddle" alt="Update failed" onmouseover="window.status=\'       Update failed\'; return true" onmouseout="window.status=\'\';  return true"> Update failed.  ' + xmlreturn + '<br /><br />';
   }
}

function returnitems() {
   document.getElementById('sync').innerHTML = '<img src="include/done.gif" width=17 height=17 align="absmiddle" alt="Update Complete" onmouseover="window.status=\'       Update Complete\'; return true" onmouseout="window.status=\'\';  return true"> Update Complete.<br /><br />';
   document.getElementById('items').innerHTML = xmlreturn;
}

function updateitem(type ,actor , person) {
   tmpx = person; //(' + type + ' ' + actor + ' with id ' + person + ')
   document.getElementById('sync').innerHTML = '<img src="include/load.gif" width=16 height=16 align="absmiddle" alt="Updating..." onmouseover="window.status=\'       Updating...\'; return true" onmouseout="window.status=\'\';  return true"> Updating... <br /><br />';
   Retrieve("dynsync.aspx?type=" + type + "&actor=" + actor + "&person=" + person + "&id=" + person); 
   //window.open("dynsync.aspx?type=" + type + "&actor=" + actor + "&person=" + person + "&id=" + person);
   window.setTimeout("returnxml()", 5000);
}


function RSchange() { if (xmlhttp.readyState==4) { xmlreturn = xmlhttp.responseText; } }

function Retrieve(myurl) {
   xmlreturn = "";
   if (xmlhttp) { d=document; xmlhttp.open("GET", myurl ,true); xmlhttp.onreadystatechange=RSchange; xmlhttp.send(null); }
}