// JavaScript Document

var infoboxes = ["info_blank","info_delkote","info_bes","info_deltec","info_wnc","info_sundance","info_a2z"];
//var infoboxes = ["info_blank","info_delkote","info_bes","info_deltec","info_r","info_sundance","bullman"];

function showinfo(infobox) {
	

        // first make sure all the forms are hidden
        for(i=0; i < infoboxes.length; i++){
          var obj = document.getElementById(infoboxes[i]);
          obj.style.display = "none";
        }
          
        // show the form we're interested in
        var obj = document.getElementById(infobox);
        obj.style.display = "block";

      
    
}

var serviceboxes = ["hometext","insulation","woodprotection","renewableenergy","siding","ventilation","panelization","crawlspace","rainwater","greywater","wateraudit","radiantflooring","cavityfill","weatherization","hvac","geothermal"];

function showservices(service) {
	
		clearTimeout(t);
        // first make sure all the forms are hidden
        for(i=0; i < serviceboxes.length; i++){
          var obj = document.getElementById(serviceboxes[i]);
          obj.style.display = "none";
        }
          
        // show the form we're interested in
        var objimg = document.getElementById('mainphoto');
		objimg.style.background = "url(images/home/" + service + ".jpg)";
        var obj = document.getElementById(service);
        obj.style.display = "block";

      
    
}





var interval = 4; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;
var t = null;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("http://www.buildsmartnc.com/images/home/greenhousewithred.jpg");
image_list[image_index++] = new imageItem("http://www.buildsmartnc.com/images/home/flowchart.jpg");
image_list[image_index++] = new imageItem("http://www.buildsmartnc.com/images/home/grasshouse.jpg");
image_list[image_index++] = new imageItem("http://www.buildsmartnc.com/images/home/greenorangehouse.jpg");
image_list[image_index++] = new imageItem("http://www.buildsmartnc.com/images/home/greenphone.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
var objimg = document.getElementById('mainphoto');
objimg.style.background = "url(" + new_image + ")";
var recur_call = "rotateImage('"+place+"')";
t = setTimeout(recur_call, interval);
}