function resetForm (formName) {
	fName = (formName == null) ? 0 : formName;
	if (document.forms[fName] == null) {
		alert('Error while trying to reset the FORM.\n\nPlease contact website administrator.\nThank you!');
	}
	else if(confirm('Are you sure that you want to RESET form?')) document.forms[fName].reset();
}

function paCreateRollOvers(){
	if(document.getElementById){
		var paImages = document.getElementsByTagName('IMG');
		var paButtons = document.getElementsByTagName('INPUT');
	}else if(document.all && navigator.userAgent.indexOf('Mac')==-1){
		var paImages = document.all['mouseovers'].all.tags('IMG');
		var paButtons = document.all['mouseovers'].all.tags('INPUT');
	}else return;
	paPreloads = new Object();

	for (var i = 0; i < paImages.length; i++){
		var paImageOffSrc = paImages[i].src + "";
		if(paImageOffSrc.indexOf("_off.") != -1){
			var paImageOnSrc = paImageOffSrc.replace(/_off\./g, "_on.");
			paPreloads['paImageOff_' + i] = new Image();
			paPreloads['paImageOff_' + i].src = paImageOffSrc;
			paPreloads['paImageOn_' + i] = new Image();
			paPreloads['paImageOn_' + i].src = paImageOnSrc;
			/*paPreloads['paImageOn_' + i].onerror = function(){this.src='/images/blank.gif';}*/
			paImages[i].onmouseover = function(){this.src = this.src.replace(/_off\./g, "_on.");}
			paImages[i].onmouseout = function(){this.src = this.src.replace(/_on\./g, "_off.");}
		}
	} 

	for (var i = 0; i < paButtons.length; i++){
		if(paButtons[i].src){
		var paImageOffSrc = paButtons[i].src + "";
		if(paImageOffSrc.indexOf("_off.") != -1){
			var paImageOnSrc = paImageOffSrc.replace(/_off\./g, "_on.");
			paPreloads['paImageOff_' + i] = new Image();
			paPreloads['paImageOff_' + i].src = paImageOffSrc;
			paPreloads['paImageOn_' + i] = new Image();
			paPreloads['paImageOn_' + i].src = paImageOnSrc;
			/*paPreloads['paImageOn_' + i].onerror = function(){this.src='/images/blank.gif';}*/
			paButtons[i].onmouseover = function(){this.src = this.src.replace(/_off\./g, "_on.");}
			paButtons[i].onmouseout = function(){this.src = this.src.replace(/_on\./g, "_off.");}
		}
		}
	} 
}

window.onload = paCreateRollOvers;

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}


function showhide(id){ 
	if (document.getElementById) { 
		obj = document.getElementById(id); 
		if (obj.style.display == "none") { 
			obj.style.display = ""; 
		} else { 
			obj.style.display = "none"; 
		} 
	} 
} 

function hide(id){ 
	if (document.getElementById){ 
	obj = document.getElementById(id); 
	obj.style.display = "none"; 
	} 
} 
function show(id){ 
	if (document.getElementById){ 
	obj = document.getElementById(id); 
	obj.style.display = ""; 
	}
}

function submenu(obj) {
	a = new Array("menuProducts", "menuDesign", "menuGallery", "menuNews", "menuStairs101", "menuAbout");
	objID = (obj.id.indexOf("menu") == -1) ? "menu" + obj.id : obj.id;
	for (i=0; i < a.length; i++) {
		if (a[i] == objID) show(a[i]);
		else hide(a[i]);
	}
	stopTime();
}

var timerID = null; 
var timerOn = false; 
var timecount = 140; 
var what = null; 
var newbrowser = true; 
var check = false; 

function stopTime() { 
 if (timerOn) { 
 clearTimeout(timerID); 
 timerID = null; 
 timerOn = false; 
 } 
 } 
 
function startTime(obj) { 
	objID = (obj.id.indexOf("menu") == -1) ? "menu" + obj.id : obj.id;
	if (timerOn == false) { 
		timerID=setTimeout( "hide('"+ objID +"')" , timecount); 
		timerOn = true; 
	} 
} 

//Copyright 2006 Bontrager Connection, LLC
	var cX = 0; var cY = 0;
	function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
	function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
	if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
	else { document.onmousemove = UpdateCursorPosition; }
	function AssignPosition(d) {
	d.style.left = (cX+10) + "px";
	d.style.top = (cY+10) + "px";
	}
	function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
	}
	function ShowContent(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	dd.style.display = "block";
	}
	function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	if(dd.style.display == "none") { dd.style.display = "block"; }
	else { dd.style.display = "none"; }
	}
	
function toggleDescription() {
	if (document.getElementById) { 
		obj = document.getElementById("moreDescription");
		objMore = document.getElementById("readMore");
		objLess = document.getElementById("readLess");
		if (obj.style.display == "none") { 
			obj.style.display = objLess.style.display = "";
			objMore.style.display = "none"; 
		} else { 
			obj.style.display = objLess.style.display = "none"; 
			objMore.style.display = ""; 
		} 
	} 
}



function photoID() {
	//hash = document.location.hash;
	//return hash.substring(1, hash.length);
	href = document.location.href;
	return href.substring(href.indexOf('?id=')+4,href.length);
}


function photoUrl() {
	photoID = parseInt(photoID());
	if (photoID < 100) {
		document.getElementById('galleryTitle').innerHTML = "Staircase #" + photoID;
		document.write('<img src="../images/gallery/photo_' + photoID + '.jpg" width="600" height="450" alt="" id="photo" />');
	}
	else if (photoID < 200) {
		document.getElementById('galleryTitle').innerHTML = "Millwork #" + (photoID-100);
		document.write('<img src="../images/gallery/photo_' + photoID + '.jpg" width="600" height="450" alt="" id="photo" />');
	}
	else if (photoID < 300) { 
		document.getElementById('galleryTitle').innerHTML = "Old World Tudor #" + (photoID-200);
		document.write('<img src="../images/gallery/photo_' + photoID + '.jpg" width="308" height="450" alt="" id="photo" />');
	}
	else if (photoID < 400) { 
		document.getElementById('galleryTitle').innerHTML = "Custom Build #" + (photoID-300);
		document.write('<img src="../images/gallery/photo_' + photoID + '.jpg" width="308" height="450" alt="" id="photo" />');
	}
	else if (photoID < 500) { 
		document.getElementById('galleryTitle').innerHTML = "Custom Remodel #" + (photoID-400);
		document.write('<img src="../images/gallery/photo_' + photoID + '.jpg" width="308" height="450" alt="" id="photo" />');
	}
}

maxStairPhotos = 22;
maxMillworkPhotos = 8;
maxTudorPhotos = 10;
maxCustomBuildPhotos = 6;
maxCustomRemodelPhotos = 6;

function previousPhoto() {
	photoID = parseInt(photoIDUrl());
	if (photoID < 100) {
		prevPhoto = (photoID == 1) ? maxStairPhotos : (photoID-1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + prevPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Staircase #" + prevPhoto;
	}
	else if (photoID < 200) {
		prevPhoto = (photoID == 101) ? maxMillworkPhotos+100 : (photoID-1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + prevPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Millwork #" + (prevPhoto-100);
	}
	else if (photoID < 300) {
		prevPhoto = (photoID == 201) ? maxTudorPhotos+200 : (photoID-1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + prevPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Old World Tudor #" + (prevPhoto-200);
	}
	else if (photoID < 400) {
		prevPhoto = (photoID == 301) ? maxCustomBuildPhotos+300 : (photoID-1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + prevPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Custom Build #" + (prevPhoto-300);
	}
	else if (photoID < 500) {
		prevPhoto = (photoID == 401) ? maxCustomRemodelPhotos+400 : (photoID-1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + prevPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Custom Remodel #" + (prevPhoto-400);
	}
	
}

function nextPhoto() {
	photoID = parseInt(photoIDUrl());
	if (photoID < 100) {
		nxtPhoto = (photoID == maxStairPhotos) ? 1 : (photoID+1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + nxtPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Staircase #" + nxtPhoto;
	}
	else if (photoID < 200) {
		nxtPhoto = (photoID == maxMillworkPhotos+100) ? 101 : (photoID+1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + nxtPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Millwork #" + (nxtPhoto-100);
	}
	else if (photoID < 300) {
		nxtPhoto = (photoID == maxTudorPhotos+200) ? 201 : (photoID+1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + nxtPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Old World Tudor #" + (nxtPhoto-200);
	}
	else if (photoID < 400) {
		nxtPhoto = (photoID == maxCustomBuildPhotos+300) ? 301 : (photoID+1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + nxtPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Custom Build #" + (nxtPhoto-300);
	}
	else if (photoID < 500) {
		nxtPhoto = (photoID == maxCustomRemodelPhotos+400) ? 401 : (photoID+1) ;
		document.getElementById('photo').src = '../images/gallery/photo_' + nxtPhoto + '.jpg';
		document.getElementById('galleryTitle').innerHTML = "Custom Remodel #" + (nxtPhoto-400);
	}
}

function photoIDUrl() {
	//hash = document.location.hash;
	//return hash.substring(1, hash.length);
	src = document.getElementById('photo').src;
	return src.substring(src.indexOf('photo_') + 6 , src.indexOf('.jpg'));
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
	if ((obj=MM_findObj(objName))!=null) with (obj)
	if (document.layers) {document.write(unescape(newText)); document.close();}
	else innerHTML = unescape(newText);
}

//Products
allrows=new Object();
allcols=new Object();
woodscolsrows=new Object();
function get_itemsh_val(obj){
	if(!obj) return("");
	if(obj.options) return(obj.options[obj.options.selectedIndex].value);
	else return(obj.value);
}
function setopts(form_name, prefix, item_id, set_row, set_col, set_layers){
	f=document.forms[form_name];
	newwood=get_itemsh_val(f['comb_wood'+prefix]);
//Set rows
	if(set_row && f['comb_row'+prefix].options){
		currrowval=-1;
		if(f['comb_row'+prefix].options) currrowval=f['comb_row'+prefix].options[f['comb_row'+prefix].options.selectedIndex].value;
//Clear options
		if(f['comb_row'+prefix].options) for(i=f['comb_row'+prefix].options.length;i>-1;i--) f['comb_row'+prefix].options[i]=null;
		n=0;
		for(var i in woodscolsrows[item_id][newwood]){
			no = document.createElement("OPTION");
			no.text=allrows[item_id][i];
			no.value=i;
			if(i==currrowval) no.selected=1;
			f['comb_row'+prefix].options[n]=no;
			n++;
		}
	}
//Set cols
	if(set_col && f['comb_col'+prefix].options){
		currrowval=-1;
		if(f['comb_col'+prefix].options) currcolval=f['comb_col'+prefix].options[f['comb_col'+prefix].options.selectedIndex].value;
//Clear options
		if(f['comb_col'+prefix].options) for(i=f['comb_col'+prefix].options.length;i>-1;i--) f['comb_col'+prefix].options[i]=null;
		newrowval=get_itemsh_val(f['comb_row'+prefix]);
		n=0;
		for(var i in woodscolsrows[item_id][newwood][newrowval]){
			no = document.createElement("OPTION");
			no.text=allcols[item_id][i];
			no.value=i;
			if(i==currcolval) no.selected=1;
			f['comb_col'+prefix].options[n]=no;
			n++;
		}
	}
	if(set_layers){
		newwoodval=get_itemsh_val(f['comb_wood'+prefix]);
		newrowval=get_itemsh_val(f['comb_row'+prefix]);
		newcolval=get_itemsh_val(f['comb_col'+prefix]);
//Set price and shipps in
		MM_setTextOfLayer('pricelayer'+prefix,'',woodscolsrows[item_id][newwoodval][newrowval][newcolval]['price']);
		tmpl_pricesale='';
		if(woodscolsrows[item_id][newwoodval][newrowval][newcolval]['price_sale']>0) tmpl_pricesale='Sale Price:&nbsp;&nbsp;$'+woodscolsrows[item_id][newwoodval][newrowval][newcolval]['price_sale'];
		MM_setTextOfLayer('pricesalelayer'+prefix,'',tmpl_pricesale);
		MM_setTextOfLayer('invstatlayer'+prefix,'',woodscolsrows[item_id][newwood][newrowval][newcolval]['invstatus']);
	}
}