
// settings.js - added by John Mounsey 14.12.2006

// Some Global settings/variables

defaultStatus 			= 'ComptonBuildings.co.uk'
lastPage				= document.referrer
siteExtension			= '.chtml'

bolGoogleMap            = 0;


var PositionX = 100;
var PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

var defaultWidth  = 620;
var defaultHeight = 420;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = false;

if (parseInt(navigator.appVersion.charAt(0))>=4)
{
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName.indexOf("Opera")!=-1 || navigator.appName.indexOf("Firefox")!=-1)?1:0;
}
	
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;


// Print today's date

function theDayToday()
{
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)
year = year + 1900;
document.write(lmonth + " " + date + ", " + year);
}

function startRotateOffer(inum){

	cardID = "hoi"+inum;
	document.getElementById(cardID).style.zIndex = "1";
	totalCards = document.getElementById("homeoffercont").getElementsByTagName("img");
	
	if(totalCards.length>1)
	{
		nextCard = setTimeout("rotateOffer("+inum+")",4000);
	}
}


function rotateOffer(inum)
{		
	oldCard = "hoi"+inum;
	oldIndex = document.getElementById(oldCard).style.zIndex;

	totalCards = document.getElementById("homeoffercont").getElementsByTagName("img");
	mCard = parseInt(inum)+1;
	if(mCard>= totalCards.length){mCard=0;}
	cardID = "hoi"+mCard;
	
	document.getElementById(cardID).style.zIndex = parseInt(oldIndex)+1;
	
	$("#"+oldCard).animate({"top": "110px"}, "slow");
	$("#"+cardID).animate({"top": "0px"}, "slow");
	$("#"+oldCard).animate({"top": "-110px"}, 0);
	//document.getElementById(oldCard).style.top = "-110px";
	
	nextCard = setTimeout("rotateOffer("+mCard+")",4000);
}


// Stuff that occurs on all pages when they have finished downloading

function loaded(currentPage)
	{
		if(bolGoogleMap == 1)
		{
			GoogleMapInit();
		}

	}



// Return to the previous page

function goBack()
	{
	history.go(-1);
	}
	


// Ye Olde generic rollover

function rollTo(obj,toStyle)
	{
	obj.className = toStyle;
	}
	
// Ye Olde generic images rollover

function chgImg(obj,toSrc)
	{
	obj.src = toSrc;
	}
	


// The slideshow code bit

// configure seconds delay between changing (1000 = 1 second) //

var changeDelay = 3000

images=new Array();
images_pop=new Array();
index = 0;
currentindex = 0;

function changer()
{
	if(document.billboard)
	{
		currentindex = index;
		document.billboard.src = images[index].src;
		index++;
		if (index == images.length)
		{
			index = 0;
		}
		setTimeout("changer()",changeDelay);
		return;
	}
}



function popImage(imageURL,imageTitle)
{
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	
	with (imgWin.document)
	{
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');
		writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName.indexOf("Opera")!=-1 || navigator.appName.indexOf("Firefox")!=-1)?1:0;}');
		
		writeln('function reSizeToImage(){');
		writeln('docImg = new Image();');
		writeln('docImg.onload = function() {');
		writeln('if (isIE){');
		writeln('window.resizeTo(100,100);');
		//writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		//writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('width=docImg.width;');
		writeln('height=docImg.height+75;');
		writeln('window.resizeTo(width,height);}');
		writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["onlyone"].width;');
		writeln('window.innerHeight=document.images["onlyone"].height;}}');
		writeln('docImg.src = document.images[0].src;');
		writeln('}');
		
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
		writeln('</sc'+'ript>');
		
		writeln('</head><body bgcolor=000000 scroll="no">');
		
		writeln('<img name="onlyone" src='+imageURL+' style="display:block">');
		writeln('<sc'+'ript>reSizeToImage();doTitle();self.focus();</sc'+'ript>')
		writeln('</body></html>');
		close();
	}
}



function hideHotSpots(showThisOne)
{
document.getElementById('hotspot0').className='hidden';
document.getElementById('hotspot1').className='hidden';
document.getElementById('hotspot2').className='hidden';
document.getElementById('hotspot3').className='hidden';
document.getElementById('hotspot4').className='hidden';
document.getElementById('hotspot5').className='hidden';
document.getElementById('hotspot6').className='hidden';
document.getElementById('hotspot7').className='hidden';
document.getElementById('hotspot8').className='hidden';
document.getElementById('hotspot9').className='hidden';
document.getElementById('hotspot10').className='hidden';

document.getElementById(showThisOne).className='visible';

}


 /* ====================================================
 Image Slide Show
==================================================== */

//*** Fader script ***
// http://brainerror.net/scripts/javascript/blendtrans/ for the fade transition

function opacityin(id, opacStart, opacEnd, millisec) { 
//speed for each frame 
var speed = Math.round(millisec / 100); 
var timer = 10; 

//determine the direction for the blending, if start and end are the same nothing happens 
if(opacStart > opacEnd) { 
 for(i = opacStart; i >= opacEnd; i--) { 
     setTimeout("changeOpacin(" + i + ",'" + id + "')",(timer * speed)); 
     timer++; 
 } 
} else if(opacStart < opacEnd) { 
 for(i = opacStart; i <= opacEnd; i++) 
 { 
     setTimeout("changeOpacin(" + i + ",'" + id + "')",(timer * speed)); 
     timer++; 
 } 
} 
} 

//change the opacity for different browsers 
function changeOpacin(opacity, id) { 
var object = document.getElementById(id).style; 
	object.filter = "alpha(opacity=" + opacity + ")"; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
} 


//*** DECLARE VARIABLES *** these have been removed for this website to allow for a varied size in images via css

var imgwidth = "275";
var imgheight = "275";
var imgclass = "rsimg";


var nimg = -1;


//*** Image swaper ***
function imagehide() {

	//this hides the initial fade-in image to make way for the full slide-show 	
	document.getElementById("imageslide").style.display = "none";

}


function imagegallery() {

	//this part is what generates the image and calculates what image it is on and increment it by one on each loop of the image_swap() function
	if (nimg<opimages.length-1)
	{
	nimg++
	}
	else if (nimg>=opimages.length-1)
	{
	nimg = 0;
	}
	
	document.getElementById("homeimages").innerHTML = '<div id="slidecontainer" class="imagefade"><img src="'+opimages[nimg]+'" border="0"  class="'+imgclass+'" alt="Compton Commercial Buildings" /></div>';
	opacityin('slidecontainer', 0, 100, 500);
	setTimeout("opacityin('slidecontainer', 100, 0, 500)",4400);  
	return true;
}

//****** Image Gallery - image change *******

function changer2()
{
	//taken from changer() function for homepage
	if(document.billboard)
	{
		currentindex = index;
		document.billboard.src = images[index].src;
		index++;
		if (index == images.length)
		{
			index = 0;
		}
		setTimeout("changer()",changeDelay);
		return;
	}
	
	//this part has been added to show the last image in the array to start with for 5 seconds as the slideshow has a 5 second delay	
	document.getElementById("homeimages").innerHTML = '<div id="slidecontainer" class="imagefade"><img src="'+opimages[nimgl]+'" border="0"  id="imageslide" alt="Compton Commercial Buildings" /></div>';
	opacityin('slidecontainer', 0, 100, 500);
	setTimeout("opacityin('slidecontainer', 100, 0, 500)",4400);
	var Tout = setTimeout("imagehide()", 4800);

	//this part activates and loops the fade in/out and image change script	
	var Tinterval = setInterval("imagegallery()", 5000);
}

/* ******* gallery desc width ****** */

function findattribs(link,id) {

var imgid = "dimg"+id;

var newImg = new Image();
newImg.src = link;
newImgwidth = newImg.width;

	if(newImgwidth == "0")
	{
		return;
	}
	else
	{
		document.getElementById(imgid).style.width = newImgwidth+"px";
	}
}


/* *** New Gallery Pop-Up MW - Oct 2008*** */


function largephoto(tImg,tTitle){


	if(!document.getElementById("lgphoto"))
	{
		var body = document.getElementsByTagName("body")[0];
		var dv = document.createElement("div");
		body.appendChild(dv);
		dv.setAttribute("id", "lgphoto");
	}
	
	strInnerHTML  = '<div id="lgptitle">'+tTitle+'</div><div id="lgpclose"><a href="javascript:closelgphoto();"><img src="/gfx/galleryclose.gif" alt="Click to close Photo" /></a></div>';
	strInnerHTML += '<img src="'+tImg+'" alt="'+tTitle+'" id="lgphotoimg" />';

	var currScroll = document.documentElement.scrollTop+60;

	document.getElementById("lgphoto").style.display = "block";
	document.getElementById("lgphoto").style.top = currScroll+"px";
	document.getElementById("lgphoto").innerHTML = strInnerHTML;
	
}


function closelgphoto(){

var lgpimgwidth = "";
document.getElementById("lgphoto").style.display = "none";
document.getElementById("lgphoto").innerHTML = "";

}


function chkPost(chgStage){

	postVal = document.agentFinderForm.strPostcode.value;

	if(chgStage == 1)
	{
		if(postVal == "Your Post Code")
		{
			document.agentFinderForm.strPostcode.value = "";
		}
	
	}
	else if(chgStage == 0)
	{
		if(postVal == "")
		{
			document.agentFinderForm.strPostcode.value = "Your Post Code";
		}
		else
		{
			document.agentFinderForm.strPostcode.className = "agent-finder-input-boxHi";
		}
	}

}
