/*****************************************************************
  Returns true if string only contains whitespace
                               21/04/2004 10:37
*****************************************************************/
function isBlank(string)
{
  for(var i=0; i<string.length; i++) {
    var c = string.charAt(i);
    if((c!=' ') && (c!='\n') && (c!='\t'))
      return false;
  }
  return true;
}  // isBlank

/*****************************************************************
  Returns true if form element is blank
                               21/04/2004 10:37
*****************************************************************/
function isFieldEmpty( field_name )
{
 if(field_name.value == null || field_name.value == "" || isBlank(field_name.value))
    return true;
 else
    return false;
}  // isFieldEmpty

/*****************************************************************
  Gets username and password from input fields and logs the
  user in.
                               21/04/2004 10:37
*****************************************************************/
function logMeIn()
{
	
	var fm = document.forms[0];
	var bFieldsValid = true;
	
	if ( isFieldEmpty ( fm.sUsername ) )
	{
		alert("You must enter a username");
		fm.sUsername.value = '';
		fm.sUsername.focus();
		bFieldsValid = false;
	}
	
	if ( isFieldEmpty ( fm.sPassword ) && bFieldsValid )
	{
		alert("You must enter a password");
		fm.sPassword.value = '';
		fm.sPassword.focus();
		bFieldsValid = false;
	}
	
	if ( bFieldsValid )
	{
		window.location.replace('/login_processor.aspx?username=' + fm.sUsername.value + '&password=' + fm.sPassword.value);
	}
	
	
	
}

/*****************************************************************
  Redirects the user to the logout_proccessor and removes any
  relevant cookies from the users system.
                               21/04/2004 10:37
*****************************************************************/
function logMeOut()
{
	
	window.open('/logout_processor.aspx', '_self');

}

/*****************************************************************
  
  Sets dynamic "Sponsor Logo" rotation.
                               21/05/2004 10:37
                               
	NOTE THAT THESE ARE ONLY FOR THE BANNERS ON THE RIGHT
	OF EVERY PAGE - LOOK FURTHER DOWN WITH REF TO THE BANNERS
	ON THE TOP OF EVERY PAGE.
	
*****************************************************************/
//Some global variables and a browser version check

	var numAds = 5;																					//We've split the banners into equal groups
	var isMSIE4plus = false;
	var isNav4plus = false;
	var interval = 2;
	var adNumber = 0;
	var allowRotation = true;															//There are problems when submitting a form in the middle of rotation
																												//so in the submission of a form we will set this variable to false
																												//using the "stopRotation()" function.
	

	if (navigator.userAgent.indexOf("MSIE") >= 1)							//Microsoft
	{
		var tmpFloat=parseFloat(navigator.appVersion);
		if (tmpFloat>=4.0) isMSIE4plus = true;										//v4 or better!
	}

	if (navigator.appName == "Netscape")											//Netscape
	{
		var tmpFloat=parseFloat(navigator.appVersion);
		if (tmpFloat >= 4.0) isNav4plus = true;									//v4 or better!
	}

//Create arrays to hold all the info for the banners

	var banIMG  = new Array(numAds);
	var banURL  = new Array(numAds);
	var banALT  = new Array(numAds);

//This is where we give the FILENAME of the image, a URL for the company and some Alt text
//We don't need to specify file extensions, because we later assume they're all gifs

	banIMG[0] = "colt";
	banURL[0] = "www.colt.net";
	banALT[0] = "COLT";
	
	banIMG[1] = "nsi";
	banURL[1] = "";
	banALT[1] = "N.S.I. Digital Rights Management";
	
	banIMG[2] = "oneworld";
	banURL[2] = "www.oneworldinteractive.com";
	banALT[2] = "One World Interactive";
	
	banIMG[3] = "operatelecom";
	banURL[3] = "www.operatelecom.com";
	banALT[3] = "Opera Telecom";
	
	banIMG[4] = "2ergo";
	banURL[4] = "www.2ergo.com";
	banALT[4] = "2ergo";
	
//And now some functions
function getRandNum(lower, upper)
{
	return (Math.floor(Math.random() * ((1+upper) - lower)) + lower);
}

function getAdvert()
{

	//Because we are generating a 'Random'
	//number we need to be sure that the
	//same number is not generated x2 in
	//a row - otherwise we could have the
	//same ad displaying for longer than
	//the interval specifies
	oldAdNumber = adNumber;
	
	while ( oldAdNumber == adNumber )
	{
		adNumber = getRandNum(0, numAds-1);
	}

	//now find the info from the arrays
	adName = banIMG[adNumber];
	adURL  = banURL[adNumber];
	adAlt	 = banALT[adNumber];

	adPath = "images/sponsors/" + adName + ".gif";

	document.advert.src = adPath;
	document.advert.alt = adAlt;
	document.advert.border = 0;

	if ( allowRotation == true )
	{
		setTimeout(getAdvert, interval * 1000);
	}
}

function getAdvertMembers()
{

	//Because we are generating a 'Random'
	//number we need to be sure that the
	//same number is not generated x2 in
	//a row - otherwise we could have the
	//same ad displaying for longer than
	//the interval specifies
	oldAdNumber = adNumber;
	
	while ( oldAdNumber == adNumber )
	{
		adNumber = getRandNum(0, numAds-1);
	}

	//now find the info from the arrays
	adName = banIMG[adNumber];
	adURL  = banURL[adNumber];
	adAlt	 = banALT[adNumber];

	adPath = "../images/sponsors/" + adName + ".gif";

	document.advert.src = adPath;
  document.advert.alt = adAlt;
  document.advert.border = 0;

	setTimeout(getAdvertMembers, interval * 1000);
}


function linkFromAd()
{
	if (isMSIE4plus || isNav4plus)
	{
			if(banURL[adNumber] != "")
			{
				//'window.location.href="http://" + banURL[adNumber];
				window.open('http://' + banURL[adNumber], '_blank');
			}
	}
}

function stopRotation()
{
	interval = 60;
}

/*****************************************************************
  
  Sets dynamic "Sponsor Logo" rotation.
                               21/05/2004 10:37
                               
	NOTE THAT THESE ARE ONLY FOR THE BANNERS ON THE TOP
	OF EVERY PAGE - LOOK FURTHER DOWN WITH REF TO THE BANNERS
	ON THE LEFT OF EVERY PAGE.
	
*****************************************************************/

//Global Vars

	var t_banCount = 2;			//This is the amount of banners available. Make sure this is up to date.



//Create arrays to hold all the info for the banners
//LEAVE THE FOLLOWING 3 LINES ALONE

	var t_banIMG  = new Array(numAds);
	var t_banURL  = new Array(numAds);
	var t_banALT  = new Array(numAds);
	var activeIMG = 0;

//This is where we give the FILENAME of the image, a URL for the company and some Alt text
//We don't need to specify file extensions, because we later assume they're all gifs

	t_banIMG[0] = "wt_exponconf2004";
	t_banURL[0] = "www.worldtelemedia.co.uk";
	t_banALT[0] = "WORLDTELEMEDIA CONFERENCE IN LISBON";
	
	t_banIMG[1] = "OneWorld";
	t_banURL[1] = "www.oneworldinteractive.com";
	t_banALT[1] = "One World Interactive";
	
//And now some functions
function gett_Advert()
{
	activeIMG =  getRandNum(0, t_banCount - 1);
	
	//now find the info from the arrays
	t_adName = t_banIMG[activeIMG];
	t_adURL  = t_banURL[activeIMG];
	t_adAlt	 = t_banALT[activeIMG];

	t_adPath = "images/banners/" + t_adName + ".gif";

	document.t_advert.src = t_adPath;
	document.t_advert.alt = t_adAlt;
	document.t_advert.border = 0;
}

function gett_AdvertMembers()
{
	activeIMG =  getRandNum(0, t_banCount - 1);
	
	//now find the info from the arrays
	t_adName = t_banIMG[activeIMG];
	t_adURL  = t_banURL[activeIMG];
	t_adAlt	 = t_banALT[activeIMG];

	t_adPath = "../images/banners/" + t_adName + ".gif";

	document.t_advert.src = t_adPath;
	document.t_advert.alt = t_adAlt;
	document.t_advert.border = 0;
}

function linkFromt_Ad()
{
	
	if (isMSIE4plus || isNav4plus)
	{
			if(t_banURL[activeIMG] != "")
			{
				//'window.location.href="http://" + banURL[adNumber];
				window.open('http://' + t_banURL[activeIMG], '_blank');
			}
	}
}