
var tickspeed=5000 //ticker speed in miliseconds (2000=2 seconds)
var enablesubject=0 //enable scroller subject? Set to 0 to hide

if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}

var selectedDiv=0
var totalDivs=0

function contractall(){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}


function expandone(){
var selectedDivObj=document.getElementById("dropmsg"+selectedDiv)
contractall()
document.getElementById("dropcontentsubject").innerHTML=selectedDivObj.getAttribute("subject")
selectedDivObj.style.display="block"
selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
setTimeout("expandone()",tickspeed)
}

function startscroller(){
while (document.getElementById("dropmsg"+totalDivs)!=null)
totalDivs++
expandone()
if (!enablesubject)
document.getElementById("dropcontentsubject").style.display="none"
}

if (window.addEventListener)
window.addEventListener("load", startscroller, false)
else if (window.attachEvent)
window.attachEvent("onload", startscroller)

if (document.images) {

	contactOn = new Image();
	contactOff = new Image();
	contactOn.src = "images/contact1.jpg";
	contactOff.src = "images/contact.jpg";

	remodelsOn = new Image();
	remodelsOff = new Image();
	remodelsOn.src = "images/remodels1.jpg";
	remodelsOff.src = "images/remodels.jpg";

	productsOn = new Image();
	productsOff = new Image();
	productsOn.src = "images/products1.jpg";
	productsOff.src = "images/products.jpg";

	customOn = new Image();
	customOff = new Image();
	customOn.src = "images/customorders1.jpg";
	customOff.src = "images/customorders.jpg";

	servicesOn = new Image();
	servicesOff = new Image();
	servicesOn.src = "images/designservices1.jpg";
	servicesOff.src = "images/designservices.jpg";

}

function activate(image_name) {
	if (document.images) {
		document[image_name].src = eval(image_name + "On.src");
	}
}

function deactivate(image_name) {
	if (document.images) {
		document[image_name].src = eval(image_name + "Off.src");
	}
}

function doClock() {
	var y=new Date();
	var gy=y.getYear();
	var Hours;
	var Mins;
	var Time;
	Hours = y.getHours();
	if (Hours >= 12) {
		Time = " p.m.";
	}
	else {
		Time = " a.m.";
	}
	if (Hours > 12) {
		Hours -= 12;
	}
	if (Hours == 0) {
		Hours = 12;
	}
	Mins = y.getMinutes();
	if (Mins < 10) {
		Mins = "0" + Mins;
	}
	var dName=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var mName=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	//var currentDate = dName[y.getDay()] + ", " + mName[y.getMonth()] + " "  + y.getDate() + ", "  + y.getFullYear() + " " + Hours + ":" + Mins + Time ;
	var currentDate =  y.getFullYear();
	return (currentDate);
 }

sfHover = function() {
   var sfEls = document.getElementById("nav").getElementsByTagName("LI");
   for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
         this.className+=" sfhover";
      }
      sfEls[i].onmouseout=function() {
         this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
   }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHover = function() {
   var sfEls = document.getElementById("nav").getElementsByTagName("SPAN");
   for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
         this.className+=" sfhover";
      }
      sfEls[i].onmouseout=function() {
         this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
   }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function isblank(s) {
                for(var i=0; i<s.length; i++) {
                        var c = s.charAt(i);
                        if((c != ' ') && (c != '\n') && (c != '\t')) 
                        {
                                return false;
                        }
                }
                return true;
}

function verify(f) {
                var msg = "";
                var empty_fields = "";
                var errors = "";
                
                for (var i=0; i<f.length; i++) 
                {
                        var e = f.elements[i];
                        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                        {
                                if ((e.value == null) || (e.value == "") || isblank(e.value)) 
                                {
                                        empty_fields += "\n" + e.name;
                                        continue;
                                }
                                if (e.numeric || (e.min != null) || (e.max != null)) 
                                {
                                        var v = parseFloat(e.value);
                                        if (isNan(v) || ((e.min != null) && (v < e.min)) ||  ((e.max != null) && (v > e.max))) 
                                        {
                                                errors += "- The field " + e.name + " must be a number";
                                                if (e.min != null)
                                                {
                                                        errors += " that is greater than " + e.min;
                                                }
                                                if (e.max != null && e.min != null)
                                                {
                                                        errors += " and less than " + e.max;
                                                }
                                                else if (e.max != null)
                                                {
                                                        errors += " that is less than " + e.max;
                                                }
                                                errors += ".\n";
                                        }
                                }
                        }
                }
				               
               if (!empty_fields && !errors) 
                {
					return true;
                }
                
                 msg += "Your email can not be sent without all required information. Please review your form and fill in the needed information before submitting.\n\n";
                
                if (empty_fields) 
                {                        
                        msg += "- The following required field(s) are empty:" + empty_fields + "\n";
                        if (errors) msg += "\n";
                }

               msg += errors;
                                
               alert(msg);
                return false;
}


function toggleVisibility(id, NNtype, IEtype, WC3type) {
    if (document.getElementById) {
        eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
            }
        }
    }
}
function toggleDisplay(id, NNtype, IEtype, WC3type) {
    if (document.getElementById) {
        eval("document.getElementById(id).style.display = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].display = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.display = \"" + IEtype + "\"");
            }
        }
    }
}


function toggleDiv(showdiv,num) {
	var currentdiv = "div";
	var i = 1;
	for (i=1;i<=num;i++) {
		currentdiv = "div" + i;
		if (currentdiv == showdiv) {
			toggleVisibility(showdiv,'show','visible','visible');
			toggleDisplay(showdiv,'block','block','block');
		}
		else {
			toggleVisibility(currentdiv,'hidden','hidden','hidden');
			toggleDisplay(currentdiv,'none','none','none');			
		}
	}
}
