
var xmlhttp, alerted
//xmlhttp = "false";
//alerted = "true";
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
  try {
     xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
     alerted = "false";
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    alerted = "false";
  } catch (E) { }
 }
@else
 xmlhttp = "false";
 alerted = "true";
@end @*/
if (!xmlhttp && !alerted) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { } }

//alerted = "true";
//xmlhttp = "false";
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 } }
var RunningIE4 = (msieversion() >= 4.0); //IE 4+ ??
var csglink = "/Expertise/Network/Default.aspx";
var csglogin = "/Expertise/Network/Members/Default.aspx";

function load_em() {
    if (RunningIE4 == true) {
        window.showModalDialog("/em.aspx", "", "dialogHeight: 500px; dialogWidth: 750px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");
    } else {
        window.open("/em.aspx", null, "height=500,width=750,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
    }
}

function load_ccu() {
//    if (RunningIE4 == true) {
//        window.showModalDialog("http://dev.keepbritaintidy.org/ccu.aspx", "", "dialogHeight: 552px; dialogWidth: 772px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");
//    } else {
        window.open("http://www.keepbritaintidy.org/ccu.aspx", null, "height=550,width=770,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
  //  }
}

function vid(section, vid) {
    url = "http://archive.keepbritaintidy.org/play.aspx?s=" + section + "&v=" + vid;
    if (RunningIE4 == true) {
        window.showModalDialog(url, "", "dialogHeight: 244px; dialogWidth: 430px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");
    } else {
        window.open(url, null, "height=240,width=430,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
    }
}

function vid2(section, vid) {
    url = "http://archive.keepbritaintidy.org/play.aspx?s=" + section + "&v=" + vid;
    if (RunningIE4 == true) {
        window.showModalDialog(url, "", "dialogHeight: 276px; dialogWidth: 480px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");
    } else {
        window.open(url, null, "height=272,width=480,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
    }
}

function vid3(section, vid) {
    url = "http://archive.keepbritaintidy.org/play.aspx?s=" + section + "&v=" + vid;
    if (RunningIE4 == true) {
        window.showModalDialog(url, "", "dialogHeight: 244px; dialogWidth: 320px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: No;");
    } else {
        window.open(url, null, "height=244,width=320,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
    }
}

function nocsg() { window.parent.location = csglink; window.opener.location = csglink; window.close(); }
function logincsg() { window.parent.location = csglogin; window.opener.location = csglogin; window.close(); }

var xmlreturn = "";
var xmlfault = 0;
var returntime = 150;
var reloadtime = 30000;
var tmpx = "";
var curr_hour = 0;
var curr_min = 0;
var curr_sec = 0;
var weekday = new Array("Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday");
var monthname = new Array("Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec");
var a_p = "";
var timeqs = "";
var randomnumber = randomnumber = Math.floor(Math.random()*1001); //http://www.javascriptkit.com/javatutors/randomnum.shtml

function getthetime() {
   //http://www.webdevelopersnotes.com/tips/html/formatting_time_using_javascript.php3
   //http://www.aspnetcenter.com/cliktoprogram/javascript/date.asp
   var d = new Date();
   curr_hour = d.getHours();
   if (curr_hour < 12) { a_p = "AM"; } else { a_p = "PM"; }
   if (curr_hour == 0) { curr_hour = 12; }
   if (curr_hour > 12) { curr_hour = curr_hour - 12; }
   curr_min = d.getMinutes();
   curr_sec = d.getSeconds();
   timeqs = weekday[d.getDay()] + "-" + monthname[d.getMonth()] + "-" + d.getDate() + "-" + d.getFullYear() + "-" + curr_hour + "-" + curr_min + "-" + curr_sec + "-" + a_p;
}

function csg(wait, x) {
   if (alerted == "true") {
      document.getElementById('CSGmatrix').innerHTML = "<br /><br />The required XML technology appears to be disabled, please consult your IT department for a solution to this. <br /><br />For further information, please contact the <a href='/contactus/contactus.asp?id=8'>webmaster</a>.";
   }
   else {
	  getthetime();
      Retrieve("/includes/em?x=" + x + "&thetime=" + timeqs); 
      window.setTimeout("returncsg('" + x + "')", returntime);
   }
}

function btufeed(wait) {
   getthetime();
   Retrieve("../includes/btufeed.asp?thetime=" + timeqs); 
   window.setTimeout("returnrequested()", returntime);
}

function btufeed2(wait) {
   getthetime();
   Retrieve("includes/btufeed2.asp?thetime=" + timeqs); 
   window.setTimeout("returnrequested2()", returntime);
}

function waitbtu() { window.setTimeout("btufeed('0');", reloadtime); }
function waitbtu2() { window.setTimeout("btufeed2('0');", reloadtime); }

function returncsg(x) { 
	if (xmlreturn == "") { csg('1', x); } 
   else { document.getElementById('CSGmatrix').innerHTML = xmlreturn; } 
}

function returnrequested() { 
	if (xmlreturn == "") { btufeed('1'); } 
   else { document.getElementById('MainArea').innerHTML = xmlreturn; window.setTimeout("btufeed('0');", reloadtime); } 
}
function returnrequested2() { 
	if (xmlreturn == "") { btufeed2('1'); } 
   else { document.getElementById('MainArea').innerHTML = xmlreturn; window.setTimeout("btufeed2('0');", reloadtime); } 
}

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); } }

