var folOn = new Image();
var folOff = new Image();
var reOn = new Image();
var reOff = new Image();

function SwapIMG(imageName, image, imagePath)
{
	if (image.src == '')
	{
		image.src = imagePath;
	}
	document.images[imageName].src = image.src;
}

function winPop(pageToLoad, winName, width, height, center, scroll, control)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=" + control + ","
    + "scrollbars="+scroll+", "
    + "status=1,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open(pageToLoad,winName,args );
}

function winPopFull(pageToLoad, winName, width, height, center, scroll, control)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=1,"
    + "menubar=1,"
    + "resizable=" + control + ","
    + "scrollbars="+scroll+", "
    + "status=1,"
    + "titlebar=1,"
    + "toolbar=1,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open(pageToLoad,winName,args );
}

function validateEnquiry(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Name.value == ''))
	{
		alert('You must enter your Full Name.');
		bValid = false;
	}

	if ((bValid) && (pForm.Street.value == ''))
	{
		alert('You must enter your Street.');
		bValid = false;
	}	
	
	if ((bValid) && (pForm.CityTown.value == ''))
	{
		alert('You must enter your City/Town.');
		bValid = false;
	}	
	
	if ((bValid) && (pForm.Postcode.value == ''))
	{
		alert('You must enter your Postcode.');
		bValid = false;
	}	
	
	if ((bValid) && (pForm.Telephone.value == ''))
	{
		alert('You must enter your Telephone Number.');
		bValid = false;
	}	
	
	if ((bValid) && (pForm.Email.value == ''))
	{
		alert('You must enter your Email Address.');
		bValid = false;
	}		
	
	if ((bValid) && (pForm.Comment.value == ''))
	{
		alert('You must enter a Comment.');
		bValid = false;
	}
	
	return bValid;	
}

function Left(pString, pLength)
{
	if (pLength <= 0)
	{
	    return "";
	}
	else if (pLength > String(pString).length)
	{
	    return pString;
	}
	else
	{
	    return String(pString).substring(0,pLength);
	}
}

function Right(pString, pLength)
{
    if (pLength <= 0)
    {
		return "";
	}
    else if (pLength > String(pString).length)
    {
    	return pString;
    }
    else 
    {
       var iStringLength = String(pString).length;
       return String(pString).substring(iStringLength, iStringLength - pLength);
    }
}

/*********************************************************/
/******************** TypeWriter Text ********************/
/*********************************************************/
var arrNews			= new Array();
var iDelay			= 60;
var iCurrentChar	= 1;
var iCurrentStory	= 1;
var bFlickOn		= true;
var iStoryCount		= 0;

arrNews[0] = ['Property consultant Ardent has been appointed by Centro, the West Midlands Integrated Transport Authority...'];
arrNews[1] = ['Ardent is to play a key role in the improvement of railway services...'];
arrNews[2] = ['We are pleased to announce the appointment of a new Associate Director to the Ardent team...'];

function TypeNews()
{
	if ((document.getElementById) && (arrNews.length > 0))
	{
		var sText		= arrNews[iCurrentStory - 1].toString();

		oDiv = document.getElementById('news');
		
		if (bFlickOn)
		{
			oDiv.innerHTML = '<a href="news.shtml">' + sText.substr(0, iCurrentChar) + '_</a>';
			
			bFlickOn 		= false;
			iCurrentChar++;
		}
		else
		{
			oDiv.innerHTML = '<a href="news.shtml">' + oDiv.innerHTML.substr(0, oDiv.innerHTML.length - 5) + '</a>';;
			bFlickOn 		= true;
		}

		// if we come to the end of the text
		if (iCurrentChar > sText.length)
		{
			oDiv.innerHTML = oDiv.innerHTML.substr(0, oDiv.innerHTML.length - 1);
			iCurrentChar 	= 1;			
			if (iCurrentStory == iStoryCount)
			{
				iCurrentStory = 1;	
			}
			else
			{
				iCurrentStory++;
			}
			setTimeout("TypeNews()", 3000);
		}
		else
		{
			setTimeout("TypeNews()", iDelay);
		}
	}
}

function OutputNews(pItemCount)
{
	if (pItemCount > arrNews.length)
		iStoryCount = arrNews.length;	
	else
		iStoryCount = pItemCount;
	TypeNews();
}

/*********************************************************/
/******************** Random Quotes ********************/
/*********************************************************/

var arrQuotes			= new Array();

arrQuotes[0] = ['The team at Ardent consistently meets our expectations and often exceeds them. They take the time to think beyond the brief to bring more value or find a solution that delivers time and cost benefits. They are committed to getting the job done.','Jonathan Fox, Director<br/>Docklands Light Railway'];
arrQuotes[1] = ['Ardent is great value for money. Experts in a broad range of services, they are responsive, excellent negotiators and they always exceed my expectations. With Ardent, I know my interests are protected.','Neil Scales<br/>OBE Mersey Tram'];
arrQuotes[2] = ['We started to use Ardent following a recommendation and the team has never let us down.  They have the knowledge and experience to provide an exceptional service and always give excellent advice, which often leads to elements of the strategy being improved as a result.','Andrew Sissons<br/>Hackney Homes'];
arrQuotes[3] = ['Ardent are very responsive not just to us and other team members but also with stakeholders with whom they communicate effectively and proactively.  They continue to exceed my expectations.','Andrew Sissons<br/>Hackney Homes'];
arrQuotes[4] = ['On appointment Ardent took the reins immediately, working within tight deadlines and carefully handling issues and objections.  I have every confidence in the team, which is professional and offers specialist advice based on excellent experience and a strong track record.','Chris Deas<br/>Nottingham City Council'];

function OutputQuote()
{
	var iRandom = Math.floor(Math.random() * arrQuotes.length);
	var shtml;
	
	shtml = '<div id="quote">';
	shtml += '    <div id="quote-content">';
	shtml += '        <p>' + arrQuotes[iRandom][0] + '</p>';
	shtml += '        <p class="quotee">' + arrQuotes[iRandom][1] + '</p>';
	shtml += '    </div>';
	shtml += '</div>';
	
	document.write(shtml);

}

