// Three functions retating to getting Window size and swapping CSS files

function alertSize() {
	// Gets usable window height and width
	
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Total Screen Height, Available Screen Height and Width = ' + screen.height + '; ' + myHeight + '; ' + myWidth + 'px.');
}

function getcss(cssfile){
loadcss = document.createElement('link')
loadcss.setAttribute("rel", "stylesheet")
loadcss.setAttribute("type", "text/css")
loadcss.setAttribute("href", cssfile)
document.getElementsByTagName("head")[0].appendChild(loadcss)
}
function GetWindowSize() {
	// Gets usable window height and width
	var myWidth = 0, myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
//    ret = myHeight;
    return [myHeight,myWidth];
}

function showEmail (add,dom,ext,cty,displaytxt) {
if(ext=="c")
	ext = "com";
if(ext=="n")
	ext = "net";
if(ext=="o")
	ext = "org";
if(cty=="oz")
	cty = "au";
if(cty=="u")
	cty = "uk";
if(cty=="z")
	cty = "nz";
var emailAddress = add + '@' + dom + "." + ext
if(cty!="")
emailAddress = emailAddress +'.' + cty;
if(displaytxt=="")
displaytxt = emailAddress;
document.write('<A href="mailto:' + emailAddress + '">' + displaytxt +'</A>');
}

function showEmailShort (add,dom,displaytxt) {
var emailAddress = add + '@' + dom
if(displaytxt=="")
displaytxt = emailAddress
document.write('<A href="mailto:' + emailAddress + '">' + "  " + displaytxt +'</A>');
}


function nbcEmail (add,displaytxt) {
	showEmail (add,'newcastlebridge','o','',displaytxt);
}

function uncloakEmail (xmail,displaytxt) {
	var emailAddress = "dummyemail"
var hideat = "hideat#"
var dot = "#dot#"
if (xmail.indexOf(hideat)<=1)
	hideat = ".atalt#";
var splbyat = xmail.split(hideat,3)
var splbydot = splbyat[1].split(dot,3)
if(splbydot[1]=="c")
	splbydot[1] = "com";
if(splbydot[1]=="n")
	splbydot[1] = "net";
if(splbydot[1] =="o")
	splbydot[1]  = "org";
if(splbydot[2]=="oz")
	splbydot[2]= "au";
if(splbydot[2]=="u")
	splbydot[2] = "uk";
if(splbydot[2]=="z")
	splbydot[2] = "nz";
emailAddress = splbyat[0] + '@' + splbydot[0] + "." + splbydot[1]; 
if(splbydot.length >= 2)
	emailAddress = emailAddress + '.' + splbydot[2];
if(displaytxt=="")
	displaytxt = emailAddress;
document.write('<A href="mailto:' + emailAddress + '">' + displaytxt +'</A>');
}

function uncloakEmailImage (xmail,esubject,ebody) {
if (typeof esubject == 'undefined' ) esubject = '';
if (typeof ebody == 'undefined' ) ebody = '';
	var mailtoextras = "";
	var emailAddress = "dummyemail";
var hideat = "hideat#";
var dot = "#dot#";
if (xmail.indexOf(hideat)<=1)	hideat = ".atalt#";
var splbyat = xmail.split(hideat,3)
var splbydot = splbyat[1].split(dot,3)
//	replace dots with . pre @
splbyat[0] = splbyat[0].replace("#dot#",".");
if(splbydot[1]=="c")
	splbydot[1] = "com";
if(splbydot[1]=="n")
	splbydot[1] = "net";
if(splbydot[1] =="o")
	splbydot[1]  = "org";
	emailAddress = splbyat[0] + '@' + splbydot[0] + "." + splbydot[1];
if(splbydot[2] != undefined) {
	if(splbydot[2]=="oz")
		splbydot[2]= "au";
	if(splbydot[2]=="u")
		splbydot[2] = "uk";
	if(splbydot[2]=="z")
		splbydot[2] = "nz";
	emailAddress = emailAddress + "." + splbydot[2];
}
	mailtoextras = "";
if (esubject.length>0) mailtoextras = "?subject="+esubject;
	if (ebody.length>0) mailtoextras = mailtoextras + "&body=" + ebody;
 document.write('<A href="mailto:' + emailAddress + mailtoextras + '">');
}

function printdate () {
    weekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    dateUpdated = new Date(document.lastModified) ;
    dateTime = dateUpdated.getHours() + ":" + dateUpdated.getMinutes();
    dateDay = dateUpdated.getDay();
    dateMonth = dateUpdated.getMonth() + 1 ;
    dateDate = dateUpdated.getDate() ;
    if(dateDate < 10) dateDate = "0" + dateDate;
    if(dateMonth < 10) dateMonth = "0" + dateMonth;
    dateYear = dateUpdated.getFullYear() ;
    document.write("<i>Last updated  " + weekDayName[dateDay] + ", " + dateDate + "/" + dateMonth + "/" + dateYear + "</i>") ;
}
function getlastmod(what)
{
  var http=new XMLHttpRequest()
  http.open('HEAD',what,false)
  http.send(null)
  if (http.status!=200) return undefined
  return http.getResponseHeader('Last-modified')
}
function printdate2 (fileName) {
    weekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    dateUpdated = new Date(getlastmod(fileName));
    dateTime = dateUpdated.getHours() + ":" + dateUpdated.getMinutes();
    dateDay = dateUpdated.getDay();
    dateMonth = dateUpdated.getMonth() + 1 ;
    dateDate = dateUpdated.getDate() ;
    if(dateDate < 10) dateDate = "0" + dateDate;
    if(dateMonth < 10) dateMonth = "0" + dateMonth;
    dateYear = dateUpdated.getFullYear() ;
    document.write("<i>Last updated  " + weekDayName[dateDay] + ", " + dateDate + "/" + dateMonth + "/" + dateYear + "</i>") ;
}
function printdatetest () {
    weekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    dateUpdated = new Date(document.lastModified) ;
    alert("dateUpdated = " + dateUpdated + ");//  fileName  =  " + fileName);
    dateTime = dateUpdated.getHours() + ":" + dateUpdated.getMinutes();
    dateDay = dateUpdated.getDay();
    dateMonth = dateUpdated.getMonth() + 1 ;
    dateDate = dateUpdated.getDate() ;
    if(dateDate < 10) dateDate = "0" + dateDate;
    if(dateMonth < 10) dateMonth = "0" + dateMonth;
    dateYear = dateUpdated.getFullYear() ;
    document.write("<i>Last updated  " + weekDayName[dateDay] + ", " + dateDate + "/" + dateMonth + "/" + dateYear + "</i>") ;
}

function MyReload()
{
window.location.reload();
}



