var newOn = new Image();
var newOff = new Image();
var conversionsOn = new Image();
var conversionsOff = new Image();
var extensionsOn = new Image();
var extensionsOff = new Image();
var selfOn = new Image();
var selfOff = new Image();

var officeOn = new Image();
var officeOff = new Image();
var automotiveOn = new Image();
var automotiveOff = new Image();
var fitoutOn = new Image();
var fitoutOff = new Image();
var retailOn = new Image();
var retailOff = 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 NumberOfChar(str,char)
{
	var ii, charCount;
	charCount = 0;
	for (ii=0; ii < str.length;ii++)
	{
		var cc = str.charAt(ii);
		if (cc == char)
		{
			charCount = charCount + 1;
		}
	}
	return charCount;
}

function validEmail(str)
{
	var bool;
	bool = true;
	if (str.length < 6)
	{
		bool = false;
		alert("Email address has too few characters.");
	}
	if ((bool) && ((NumberOfChar(str,'@')==0)||(NumberOfChar(str,'@')>1)))
	{
		bool = false;
		alert("Email address contains the wrong number of @'s.");
	}
	if ((bool) && (NumberOfChar(str,'.')==0))
	{
		bool = false;
		alert("Email address must contain at least one '.'.");
	}
	if ((bool) && (NumberOfChar(str,' ')!=0))
	{
		bool = false;
		alert("Email address must not contain any spaces.");
	}
	return bool;
}

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);
    }
}

function changeText(pSection)
{
	oTextDiv = document.getElementById('projectoverview');
	var sHTML = '';

	switch (pSection)
	{
		case "Residential":
			sHTML += "<h1>residential</h1>" + "\r\n";
			sHTML += "<p>Please select one of the following links:</p>" + "\r\n";
			sHTML += "<ul class='contentnav'>" + "\r\n";
			sHTML += "	<li><a href='projects_new.aspx'>new build</a></li>" + "\r\n";
			sHTML += "	<li><a href='projects_conversions.aspx'>conversions &amp; listed buildings</a></li>" + "\r\n";
			sHTML += "	<li><a href='projects_extensions.aspx'>extensions &amp; refurbishments</a></li>" + "\r\n";
			sHTML += "	<li><a href='projects_self.aspx'>self build</a></li>" + "\r\n";
			sHTML += "</ul>" + "\r\n";
			sHTML += "<p>The major emphasis of <span class='bluetxt'>ehp</span>&acute;s portfolio from the outset has been the residential market, ranging from modest house extensions or small individual new build dwellings, to large urban regeneration projects for major housing developers. The practice has a wealth of experience having provided architectural services for all types of residential project which have been built in accordance with individual needs, budgets, land restrictions and Town Planning requirements.</p>" + "\r\n";
			sHTML += "<p>The practice has built up a reputation particularly in one-off housing having been commissioned as concept architects for a number of bespoke houses including two of the largest new build properties in England in recent years.</p>" + "\r\n";
			sHTML += "<p><a href='projects.aspx' title='projects overview'>back to project overview page</a></p>" + "\r\n";
			break;

		case "Commercial":
			sHTML += "<h1>commercial</h1>" + "\r\n";
			sHTML += "<p>Please select one of the following links:</p>" + "\r\n";
			sHTML += "<ul class='contentnav'>" + "\r\n";
			sHTML += "	<li><a href='projects_office.aspx'>office &amp; industrial</a></li>" + "\r\n";
			sHTML += "	<li><a href='projects_automotive.aspx'>automotive</a></li>" + "\r\n";
			sHTML += "	<li><a href='projects_fitout.aspx'>fit-out</a></li>" + "\r\n";
			sHTML += "	<li><a href='projects_retail.aspx'>retail</a></li>" + "\r\n";
			sHTML += "</ul>" + "\r\n";
			sHTML += "<p>Our expertise in new build, refurbishment and fit-out spans the whole commercial sector.</p>" + "\r\n";
			sHTML += "<p>At <span class='bluetxt'>ehp</span> we strive to deliver our clients with creative, cost-effective, low maintenance design solutions both on traditional and design &amp; build procurement routes.</p>" + "\r\n";
			sHTML += "<p><a href='projects.aspx' title='projects overview'>back to project overview page</a></p>" + "\r\n";
			break;

		case "Interiors":
			sHTML += "<h1>interiors</h1>" + "\r\n";
			sHTML += "<p>We believe that interior design is as much an art as it is a science, and the highly experienced design team applies these principles to every project, from concept to completion.</p>" + "\r\n";
			sHTML += "<p>The creation of inspirational interiors involves a complex process, including a detailed survey of the property, an assessment of the architectural implications, its limitations and potential, together with in-depth discussions to determine the requirements of the client and the end-users.  Interior design schemes are customised to the individual project, whilst reflecting ever changing trends.</p>" + "\r\n";
			setTimeout("document.location='projects_interiors.aspx';", 1000);
			break;

		case "Special":
			sHTML += "&nbsp;";
			setTimeout("document.location='projects_special.aspx';", 1000);
			break;
	}
	oTextDiv.innerHTML = sHTML;
	$('projectoverview').appear({ duration: 0 });
}

/*************************************************/
/****************** Image Fading *****************/
/*************************************************/

var iImageIndex = 1;
var iImageCount = 0;
var sImageHTML = '';
var sSection = '';
var sCategory = '';
var sType = '';
var sProject = '';
var oImageDiv = null;
var oTextDiv1 = null;
var oTextDiv2 = null;
var iTextDelay = 0;

function OutputImage(pCount,pSection)
{
	if (document.getElementById('mainimage') != null)
	{
		oImageDiv = document.getElementById('mainimage');

		iImageCount = pCount;
		sSection = pSection;

		if (iImageCount > 1)
			SetImageContent();
		else
			SetImage();

		iTextDelay = 500;
	}

	if (pSection == 'contact') { iTextDelay = 400 }
	if (document.getElementById('maincontent1') != null) setTimeout("SetText('1')", iTextDelay);

	if (pSection == 'contact') { iTextDelay = 1000 }
	if (document.getElementById('maincontent2') != null) setTimeout("SetText('2')", iTextDelay);
}

function DisplayImage()
{
	$('mainimage').fade({ duration: 0.5 });

	setTimeout("SetImageContent()", 1000);
}

function SetImage()
{
	var sFileExtension = '.jpg';
	if (sSection == 'december2010') sFileExtension = '.gif';
	if (sSection == 'january2011') sFileExtension = '.png';
	if (sSection == 'may2011') sFileExtension = '.png';
	if (sSection == 'august2011') sFileExtension = '.png';
	if (sSection == 'december2011') sFileExtension = '.png';
	sImageHTML = '<img src="images/main_' + sSection + sFileExtension + '" alt="ehp - Eades Hotwani Partnership - architects and designers"/>';
	oImageDiv.innerHTML = sImageHTML;
	$('mainimage').appear({ duration: 0.5 });
}

function SetText(pID)
{
	$('maincontent' + pID).appear({ duration: 0 });
}

function SetImageContent()
{
	sImageHTML = '<img src="images/main_' + sSection + '_' + iImageIndex + '.jpg" alt="ehp - Eades Hotwani Partnership - architects and designers"/>';
	oImageDiv.innerHTML = sImageHTML;
	$('mainimage').appear({ duration: 0.5 });

	iImageIndex++;
	if (iImageIndex > iImageCount) iImageIndex = 1;

	setTimeout("DisplayImage()", 4000);
}

function OutputProjectImage(pImageNo,pCategory,pType,pProject)
{
	sCategory = pCategory + '/';
	sType = (pType == '') ? '' : pType + '/';
	sProject = pProject;
	oImageDiv = document.getElementById('mainimagecontent');

	SetProjectImageContent(pImageNo);

	var sHTML = document.getElementById('imagelinks').innerHTML;
	sHTML = sHTML.replace('<span class="selected">','');
	sHTML = sHTML.replace('<SPAN class=selected>','');
	sHTML = sHTML.replace('</span>','');
	sHTML = sHTML.replace('</SPAN>','');
	sHTML = sHTML.replace('>1<','><span class="selected">1</span><');
	document.getElementById('imagelinks').innerHTML = sHTML;

}

function DisplayProjectImage(pImageNo)
{
	$('mainimagecontent').fade();
	setTimeout("SetProjectImageContent(" + pImageNo + ")", 1000);
	var sHTML = document.getElementById('imagelinks').innerHTML;
	sHTML = sHTML.replace('<span class="selected">','');
	sHTML = sHTML.replace('<SPAN class=selected>','');
	sHTML = sHTML.replace('</span>','');
	sHTML = sHTML.replace('</SPAN>','');
	sHTML = sHTML.replace('>' + pImageNo.toString() + '<','><span class="selected">' + pImageNo.toString() + '</span><');
	document.getElementById('imagelinks').innerHTML = sHTML;
}

function SetProjectImageContent(pImageNo)
{
	sImageHTML = '<img src="images/' + sCategory + sType + sProject + '_' + pImageNo + '.jpg" alt="' + sProject + '"/>';
	oImageDiv.innerHTML = sImageHTML;
	$('mainimagecontent').appear();
}

