var nextpic = 1;
var lastpic = 8;
var slideruns = 0;
var opacity_runs = 100;

function runslideshow() {
	pic_el = document.getElementById("homeimg");
  pic_td = document.getElementById("homeimg_td");
    
  if (slideruns == 0) {
		timerID = self.setTimeout("runslideshow()", 2000);
	} else if (opacity_runs == 100) {
		nextpic=nextpic+1;
    if (nextpic > lastpic) {
			nextpic = 1;
		}	
    pic_td.style.backgroundImage = "url('http://www.rmbuilding.com/images/slideshow/"+nextpic+".jpg')";
    opacity_runs = opacity_runs - 3;
    pic_el.style.opacity = opacity_runs / 100;
    pic_el.style.filter = "alpha(opacity=" + opacity_runs + ")";
    timerID = self.setTimeout("runslideshow()", 5);
	} else if (opacity_runs < 1) {
    pic_el.src="http://www.rmbuilding.com/images/slideshow/"+nextpic+".jpg";
    timerID = self.setTimeout("runslideshow()", 2500);
    opacity_runs = 100;
    pic_el.style.opacity = opacity_runs / 100;
    pic_el.style.filter = "alpha(opacity=" + opacity_runs + ")";
    
    
  } else {
    pic_el.style.opacity = opacity_runs / 100;
    pic_el.style.filter = "alpha(opacity=" + opacity_runs + ")";
    opacity_runs = opacity_runs - 3;
    timerID = self.setTimeout("runslideshow()", 5);
  }
	slideruns = slideruns + 1;		
}

function menuon(id) {
	if (id) {
			altmenuon(id);
	}
	else {
	}
}
function menuoff(id) {
	if (id) {
		id.className='menuoff';
	}
	else {
	}
}
function altmenuon(id) {
	if (id) {
		var idname = id.id;
		id.className='menuon';
		var x=document.getElementById('submenutext').rows[0].cells;
		if (idname=="mservices") {
			x[0].innerHTML=smtservices;
		}
		else if (idname=="mreferences") {
			x[0].innerHTML=smtreferences;
		}
		else if (idname=="mprofile") {
			x[0].innerHTML=smtprofile;
		}
		else if (idname=="mmission") {
			x[0].innerHTML="&nbsp;";
		}
		else if (idname=="mestimate") {
			x[0].innerHTML=smtestimate;
		}
		else if (idname=="mcontact") {
			x[0].innerHTML=smtcontact;
		}
		else if (idname=="mhome") {
			x[0].innerHTML=smthome;
		}
		else {
			x[0].innerHTML="&nbsp;";
		}
	}
	else {
	}
}
function menuselect(page) {
	if (page) {
		window.location=page;
	}
	else {
	}
}
function svcmenuon(id) {
	if (id) {
		id.className='svcmenuon';
	}
	else {
	}
}
function svcmenuoff(id) {
	if (id) {
		id.className='svcmenuoff';
	}
	else {
	}
}
function slideon(id) {
	if (id) {
		id.className='homeslideon';
	}
	else {
	}
}
function slideoff(id) {
	if (id) {
		id.className='homeslide';
	}
	else {
	}
}
function confirmcontact () {
	try
	{
		var findid = "sendername"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			alert("Please enter your full name");
			return false;
		}
		var findid = "phone1"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var phoneerr=true;
		}
		var findid = "phone2"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var phoneerr=true;
		}
		var findid = "phone3"
		var x=document.getElementById(findid).value;		
		if (x.length<4) {
			var phoneerr=true;
		}
		var findid = "senderemail"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var emailerr=true;
		}
		if (phoneerr && emailerr) {
			alert("A phone number or email address is required.");
			return false;
		}
		var findid = "sendercomment"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			alert("Please enter a comment or question.");
			return false;
		}
		return true;
	}
	catch(err) {
	//	alert("error");
		return false;
	}
	//alert("Unknown");
	return false;
}

function confirmestimate() {
//	try
//	{
		var findid = "sendernameid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			alert("Please enter your full name");
			return false;
		}
		var findid = "addressid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var adderr=true;
		}
		var findid = "cityid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var adderr=true;
		}
		var findid = "stateid"
		var x=document.getElementById(findid).value;		
		if (x.length<2) {
			var adderr=true;
		}
		var findid = "zipcodeid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var adderr=true;
		}
		if (adderr) {
			alert("Please enter your full address.");
			return false;
		}
		var findid = "dayphoneacid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var dayphoneerr=true;
		}
		var findid = "dayphonefid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var dayphoneerr=true;
		}
		var findid = "dayphonelid"
		var x=document.getElementById(findid).value;		
		if (x.length<4) {
			var dayphoneerr=true;
		}
		var findid = "evephoneacid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var evephoneerr=true;
		}
		var findid = "evephonefid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var evephoneerr=true;
		}
		var findid = "evephonelid"
		var x=document.getElementById(findid).value;		
		if (x.length<4) {
			var evephoneerr=true;
		}
		var findid = "from_emailid"
		var x=document.getElementById(findid).value;		
		if (x.length<3) {
			var emailerr=true;
		}
		if (dayphoneerr && evephoneerr && emailerr) {
			alert("A phone number or email address is required.");
			return false;
		}
		var findid = "type_estimateid"
		var x=document.getElementById(findid).selectedIndex;
		if (x==0) {
			alert("Please choose the type of estimate you require.");
			return false;
		}
		return true;
//	}
//	catch(err) {
	//	alert("error");
//		return false;
//	}
	//alert("Unknown");
	return false;
}