 //*******Calculate and set the min-height attribute so that we can fill the screen.*******
 function findheight() {
 
 	var wheight = screen.availHeight;
 	
 	if (document.all){
 	
 		var nheight = wheight-385;
 	}
 	else {
 		var nheight = wheight-377;
 	}
 	
 	document.getElementById('maincontent').style.minHeight=nheight+"px";
 	
}
 
 
 /* ====================================================
 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";

/************

**array commented out as it features on individual pages for this site**

var opimages = new Array();
opimages[0]='/uploads/soft_landscaping/img001.jpg';
opimages[1]='/uploads/soft_landscaping/img002.jpg';
opimages[2]='/uploads/soft_landscaping/img003.jpg';
***************/

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;
	}
	
	slideImg = new Image();
	slideImg.onload = function(){
		checkHeight = slideImg.height;
		//alert(checkHeight);
		nMarginTop = '';
		smlimgheight = checkHeight-189;
		
		slidecontstyle='';
		if(bName == "Explorer" && bVer == "7"){slidecontstyle = 'margin-left:1px;';}
		
		if(checkHeight >= 200 && checkHeight < 250){nMarginTop = "margin-top:-"+(smlimgheight/2)+"px;";}
		if(checkHeight >= 250){nMarginTop = "margin-top:-"+(checkHeight/4)+"px;";}
		document.getElementById("recentprojecth").innerHTML = '<div id="slidecontainer" class="imagefade" style="'+slidecontstyle+'"><img src="'+opimages[nimg]+'" border="0"  id="imgslide" class="'+imgclass+'" style="'+nMarginTop+'" alt="landscaping projects" /><span class="recentPtlay"></span></div>';
		opacityin('recentprojecth', 0, 100, 500);
		setTimeout("opacityin('recentprojecth', 100, 0, 500)",4400);  
		return true;
	}
	slideImg.src = opimages[nimg];
}

//****** Image Gallery - image change *******

function image_swap()
{
	slidecontstyle='';
	if(bName == "Explorer" && bVer == "7"){slidecontstyle = 'margin-left:1px;';}
	//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("recentprojecth").innerHTML = '<div id="slidecontainer" class="imagefade" style="'+slidecontstyle+'"><img src="'+opimages[nimgl]+'" border="0"  id="imageslide" alt="landscaping projects" /><span class="recentPtlay"></span></div>';
			
	slideImg = new Image();
	slideImg.onload = function(){
		checkHeight = slideImg.height;
		if(checkHeight >= 250){nMarginTop = "margin-top:-"+(checkHeight/4)+"px;";}
		opacityin('recentprojecth', 0, 100, 500);
		setTimeout("opacityin('recentprojecth', 100, 0, 500)",4400);
		var Tout = setTimeout("imagehide()", 4800);
	}
	slideImg.src = opimages[nimgl];

	//this part activates and loops the fade in/out and image change script	
	var Tinterval = setInterval("imagegallery()", 5000);
}
 


//*****This function is used to swap the contact details on servies pages, i.e. Soft Landscaping******

function swapcontact(timg,imgcat) {

	var contacta = document.getElementById("servcontacta");
	var contactb = document.getElementById("servcontactb");
	var contactimga = document.getElementById("servcontactimga");
	var contactimgb = document.getElementById("servcontactimgb");
	
	if (document.all)
	{
		if (timg == "contactabutton")
		{
		contactimga.setAttribute("src","/gfx/contacts/contactabutton"+imgcat+".gif");
		contactimgb.setAttribute("src","/gfx/contacts/contactbbutton"+imgcat+".gif");
		contactimga.setAttribute("className","contactabutton");
		contactimgb.setAttribute("className","contactbbutton");
		contacta.style.display = "block";
		contactb.style.display = "none";
		}
		else
		{
		contactimga.setAttribute("src","/gfx/contacts/contactabutton2"+imgcat+".gif");
		contactimgb.setAttribute("src","/gfx/contacts/contactbbutton2"+imgcat+".gif");
		contactimga.setAttribute("className","contactbbuttonb");
		contactimgb.setAttribute("className","contactabuttonb");
		contacta.style.display = "none";
		contactb.style.display = "block";
		}
	}
	else
	{
		if (timg == "contactabutton")
		{
		contactimga.setAttribute("src","/gfx/contacts/contactabutton"+imgcat+".gif");
		contactimgb.setAttribute("src","/gfx/contacts/contactbbutton"+imgcat+".gif");
		contactimga.setAttribute("class","contactabutton");
		contactimgb.setAttribute("class","contactbbutton");
		contacta.style.display = "block";
		contactb.style.display = "none";
		}
		else
		{
		contactimga.setAttribute("src","/gfx/contacts/contactabutton2"+imgcat+".gif");
		contactimgb.setAttribute("src","/gfx/contacts/contactbbutton2"+imgcat+".gif");
		contactimga.setAttribute("class","contactbbuttonb");
		contactimgb.setAttribute("class","contactabuttonb");
		contacta.style.display = "none";
		contactb.style.display = "block";
		}	
	}
}



/******* Admin - show/hide image upload depending on template selected *******/


function adjselect() {

	var sbutton = document.getElementById("thesubmit");

	if (document.getElementById("tempselect").value == "One Large and Three Small")
	{
		document.getElementById("imagefieldaa").disabled = "";
		//document.getElementById("imagefieldab").disabled = "";
		document.getElementById("imagefieldba").disabled = "";
		//document.getElementById("imagefieldbb").disabled = "";
		document.getElementById("imagefieldca").disabled = "";
		//document.getElementById("imagefieldcb").disabled = "";
		document.getElementById("imagefieldda").disabled = "";
		//document.getElementById("imagefielddb").disabled = "";
		document.getElementById("imagefieldea").disabled = "disabled";
		//document.getElementById("imagefieldeb").disabled = "disabled";
		document.getElementById("desctwo").disabled = "disabled";
		document.getElementById("clientquote").disabled = "disabled";
		document.getElementById("desctwo").value = "";
		document.getElementById("clientquote").value = "";
		document.getElementById("disbtexta").style.color = "#BB913C";
		document.getElementById("disbtextb").style.color = "#BB913C";
		
		sbutton.setAttribute("onsubmit","return verifya()");
		
	}
	else if (document.getElementById("tempselect").value == "One Large and Two Small")
	{
		document.getElementById("imagefieldaa").disabled = "";
		//document.getElementById("imagefieldab").disabled = "";
		document.getElementById("imagefieldba").disabled = "";
		//document.getElementById("imagefieldbb").disabled = "";
		document.getElementById("imagefieldca").disabled = "";
		//document.getElementById("imagefieldcb").disabled = "";
		document.getElementById("imagefieldda").disabled = "disabled";
		//document.getElementById("imagefielddb").disabled = "disabled";
		document.getElementById("imagefieldea").disabled = "disabled";
		//document.getElementById("imagefieldeb").disabled = "disabled";
		document.getElementById("desctwo").disabled = "disabled";
		document.getElementById("clientquote").disabled = "disabled";
		document.getElementById("desctwo").value = "";
		document.getElementById("clientquote").value = "";
		document.getElementById("disbtexta").style.color = "#BB913C";
		document.getElementById("disbtextb").style.color = "#BB913C";
		
		sbutton.setAttribute("onsubmit","return verifyb()");
	}
	else if (document.getElementById("tempselect").value == "One Large")
	{
		document.getElementById("imagefieldaa").disabled = "";
		//document.getElementById("imagefieldab").disabled = "";
		document.getElementById("imagefieldba").disabled = "disabled";
		//document.getElementById("imagefieldbb").disabled = "disabled";
		document.getElementById("imagefieldca").disabled = "disabled";
		//document.getElementById("imagefieldcb").disabled = "disabled";
		document.getElementById("imagefieldda").disabled = "disabled";
		//document.getElementById("imagefielddb").disabled = "disabled";
		document.getElementById("imagefieldea").disabled = "disabled";
		//document.getElementById("imagefieldeb").disabled = "disabled";
		document.getElementById("desctwo").disabled = "disabled";
		document.getElementById("clientquote").disabled = "disabled";
		document.getElementById("desctwo").value = "";
		document.getElementById("clientquote").value = "";
		document.getElementById("disbtexta").style.color = "#BB913C";
		document.getElementById("disbtextb").style.color = "#BB913C";
		
		sbutton.setAttribute("onsubmit","return verifyc()");
	}
	else if (document.getElementById("tempselect").value == "Two Medium and Three Small")
	{
		document.getElementById("imagefieldaa").disabled = "";
		//document.getElementById("imagefieldab").disabled = "";
		document.getElementById("imagefieldba").disabled = "";
		//document.getElementById("imagefieldbb").disabled = "";
		document.getElementById("imagefieldca").disabled = "";
		//document.getElementById("imagefieldcb").disabled = "";
		document.getElementById("imagefieldda").disabled = "";
		//document.getElementById("imagefielddb").disabled = "";
		document.getElementById("imagefieldea").disabled = "";
		//document.getElementById("imagefieldeb").disabled = "";
		document.getElementById("desctwo").disabled = "disabled";
		document.getElementById("clientquote").disabled = "disabled";
		document.getElementById("desctwo").value = "";
		document.getElementById("clientquote").value = "";
		document.getElementById("disbtexta").style.color = "#BB913C";
		document.getElementById("disbtextb").style.color = "#BB913C";
		
		sbutton.setAttribute("onsubmit","return verifyd()");
	}
	else if (document.getElementById("tempselect").value == "Two Medium and Two Small Long Desc")
	{
		document.getElementById("imagefieldaa").disabled = "";
		//document.getElementById("imagefieldab").disabled = "";
		document.getElementById("imagefieldba").disabled = "";
		//document.getElementById("imagefieldbb").disabled = "";
		document.getElementById("imagefieldca").disabled = "";
		//document.getElementById("imagefieldcb").disabled = "";
		document.getElementById("imagefieldda").disabled = "";
		//document.getElementById("imagefielddb").disabled = "";
		document.getElementById("imagefieldea").disabled = "disabled";
		//document.getElementById("imagefieldeb").disabled = "disabled";
		document.getElementById("desctwo").disabled = "";
		document.getElementById("clientquote").disabled = "disabled";
		document.getElementById("clientquote").value = "";
		document.getElementById("disbtexta").style.color = "#000000";
		document.getElementById("disbtextb").style.color = "#BB913C";
		
		sbutton.setAttribute("onsubmit","return verifye()");
	}
	else if (document.getElementById("tempselect").value == "Three Images And Quote")
	{
		document.getElementById("imagefieldaa").disabled = "";
		//document.getElementById("imagefieldab").disabled = "";
		document.getElementById("imagefieldba").disabled = "";
		//document.getElementById("imagefieldbb").disabled = "";
		document.getElementById("imagefieldca").disabled = "";
		//document.getElementById("imagefieldcb").disabled = "";
		document.getElementById("imagefieldda").disabled = "disabled";
		//document.getElementById("imagefielddb").disabled = "disabled";
		document.getElementById("imagefieldea").disabled = "disabled";
		//document.getElementById("imagefieldeb").disabled = "disabled";
		document.getElementById("clientquote").disabled = "";
		document.getElementById("desctwo").disabled = "disabled";
		document.getElementById("desctwo").value = "";
		document.getElementById("disbtexta").style.color = "#BB913C";
		document.getElementById("disbtextb").style.color = "#000000";
		
		sbutton.setAttribute("onsubmit","return verifyf()");
	}

}


function verifya()
{
	var themessage = "You must complete the following fields:\n";
	var origmessage = themessage;
	if (document.inputForm.title.value=="")
	{
		themessage += "\n - Project title";
	}
	if (document.inputForm.text1.value=="")
	{
		themessage += "\n - Text Box 1";
	}
	if (document.inputForm.image_file1.value=="")
	{
		themessage += "\n - Image 1";
	}
	if (document.inputForm.image_file2.value=="")
	{
		themessage += "\n - Image 2";
	}
	if (document.inputForm.image_file3.value=="")
	{
		themessage += "\n - Image 3";
	}
	if (document.inputForm.image_file4.value=="")
	{
		themessage += "\n - Image 4";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == origmessage)
	{
		document.myForm.submit();
		return true;
 	}
 	else
 	{
 		alert(themessage);
 		return false;
 	}
}


function verifyb()
{
	var themessage = "You must complete the following fields:\n";
	var origmessage = themessage;
	if (document.inputForm.title.value=="")
	{
		themessage += "\n - Project title";
	}
	if (document.inputForm.text1.value=="")
	{
		themessage += "\n - Text Box 1";
	}
	if (document.inputForm.image_file1.value=="")
	{
		themessage += "\n - Image 1";
	}
	if (document.inputForm.image_file2.value=="")
	{
		themessage += "\n - Image 2";
	}
	if (document.inputForm.image_file3.value=="")
	{
		themessage += "\n - Image 3";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == origmessage)
	{
		document.myForm.submit();
		return true;
 	}
 	else
 	{
 		alert(themessage);
 		return false;
 	}
}

function verifyc()
{
	var themessage = "You must complete the following fields:\n";
	var origmessage = themessage;
	if (document.inputForm.title.value=="")
	{
		themessage += "\n - Project title";
	}
	if (document.inputForm.text1.value=="")
	{
		themessage += "\n - Text Box 1";
	}
	if (document.inputForm.image_file1.value=="")
	{
		themessage += "\n - Image 1";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == origmessage)
	{
		document.myForm.submit();
		return true;
 	}
 	else
 	{
 		alert(themessage);
 		return false;
 	}
}

function verifyd()
{
	var themessage = "You must complete the following fields:\n";
	var origmessage = themessage;
	if (document.inputForm.title.value=="")
	{
		themessage += "\n - Project title";
	}
	if (document.inputForm.text1.value=="")
	{
		themessage += "\n - Text Box 1";
	}
	if (document.inputForm.image_file1.value=="")
	{
		themessage += "\n - Image 1";
	}
	if (document.inputForm.image_file2.value=="")
	{
		themessage += "\n - Image 2";
	}
	if (document.inputForm.image_file3.value=="")
	{
		themessage += "\n - Image 3";
	}
	if (document.inputForm.image_file4.value=="")
	{
		themessage += "\n - Image 4";
	}
	if (document.inputForm.image_file5.value=="")
	{
		themessage += "\n - Image 5";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == origmessage)
	{
		document.myForm.submit();
		return true;
 	}
 	else
 	{
 		alert(themessage);
 		return false;
 	}
}

function verifye()
{
	var themessage = "You must complete the following fields:\n";
	var origmessage = themessage;
	if (document.inputForm.title.value=="")
	{
		themessage += "\n - Project title";
	}
	if (document.inputForm.text1.value=="")
	{
		themessage += "\n - Text Box 1";
	}
	if (document.inputForm.image_file1.value=="")
	{
		themessage += "\n - Image 1";
	}
	if (document.inputForm.image_file2.value=="")
	{
		themessage += "\n - Image 2";
	}
	if (document.inputForm.image_file3.value=="")
	{
		themessage += "\n - Image 3";
	}
	if (document.inputForm.image_file4.value=="")
	{
		themessage += "\n - Image 4";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == origmessage)
	{
		document.myForm.submit();
		return true;
 	}
 	else
 	{
 		alert(themessage);
 		return false;
 	}
}

function verifyf()
{
	var themessage = "You must complete the following fields:\n";
	var origmessage = themessage;
	if (document.inputForm.title.value=="")
	{
		themessage += "\n - Project title";
	}
	if (document.inputForm.text1.value=="")
	{
		themessage += "\n - Text Box 1";
	}
	if (document.inputForm.image_file1.value=="")
	{
		themessage += "\n - Image 1";
	}
	if (document.inputForm.image_file2.value=="")
	{
		themessage += "\n - Image 2";
	}
	if (document.inputForm.image_file3.value=="")
	{
		themessage += "\n - Image 3";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == origmessage)
	{
		document.myForm.submit();
		return true;
 	}
 	else
 	{
 		alert(themessage);
 		return false;
 	}
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}

/** http://www.quirksmode.org/js/detect.html           **/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

var bName = BrowserDetect.browser;
var bVer = BrowserDetect.version;