var itemIdMaster;
var bottomval=0;

function showMenu(itemId, classNm){
    itemIdMaster = itemId;
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var menuFoot_id = document.getElementById(itemId+'_foot');
	   if (nav_id!=null){
	  		nav_id.className = classNm;
	   }
	   	   
	   if (menuFoot_id!=null){	
	     	menuFoot_id.className = 'orangeLower';
	   }
	   
	}
}

function isMouseLeaveOrEnter(e, handler)
{		
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

/*function showQuickSubMenu(itemId){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   		if (nav_id!=null){								
	   			nav_id.className = 'subContainer show';	
	   		}
	  }
}*/

function showQuickSubMenu(itemId){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){								
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				bottomval=maxHeight;
				nav_subId.style.clip="rect(0px,200px,"+maxHeight+"px,0px)";	
	   		}
	  }
}

function showSubMenu(itemId){
	if(bottomval==1){
		bottomval = 0;
	}	
	 if (document.getElementById && bottomval==0) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){	
				nav_subId.style.clip="rect(0px,200px,0px,0px)";							
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				openScrollMenu(""+itemId+'Contents'+"", maxHeight);	
	   		}
	  }
}

function openScrollMenu(subItem, maxHeight){
	var nav_subId = document.getElementById(subItem);
	if(bottomval<maxHeight && bottomval!=1){ 
		bottomval=bottomval+5;
		nav_subId.style.clip="rect(0px,200px,"+bottomval+"px,0px)";
		setTimeout("openScrollMenu('"+subItem+"',"+maxHeight+")",10);
		
	}
}

function hideSubMenu(itemId){
	bottomval = 1;	
	 if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){				
				nav_id.className = 'subContainer hide';
				nav_subId.style.clip="rect(0px,200px,0px,0px)";	   			
	   		}

	  }
}


function hoverMenu(itemId, classNm){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	
	   if (nav_id!=null){
		   	if(itemIdMaster!=itemId){
	  			nav_id.className = classNm;
			}else{
				if(classNm!='menu1'){
					nav_id.className = classNm;	
				}
			}
	   }
	}
}

		function clearAllBoxesQuoteForm(){
				if(document.getElementById){
					document.getElementById("txtAttachedToHouse").value = "";
					
					document.getElementById("txtQuoteName").value = document.getElementById("txtQuoteName").title;
					document.getElementById("txtQuoteName").style.backgroundImage = 'url("images/blueStar.gif")';
					
					document.getElementById("txtQuoteLocation").value = document.getElementById("txtQuoteLocation").title;
					document.getElementById("txtQuoteLocation").style.backgroundImage = 'url("images/blueStar.gif")';
					
					document.getElementById("txtQuoteEmail").value = document.getElementById("txtQuoteEmail").title;
					document.getElementById("txtQuoteEmail").style.backgroundImage = 'url("images/blueStar.gif")';
					
					document.getElementById("txtQuotePhone").value = document.getElementById("txtQuotePhone").title;
					document.getElementById("txtQuotePhone").style.backgroundImage = 'url("images/blueStar.gif")';
					
					document.getElementById("ddQuoteInterested").value = "";
					
					document.getElementById("quoteAttachedYes").checked = false;
					document.getElementById("quoteAttachedNo").checked = false;
					
					document.getElementById("txtQuoteLength").value = document.getElementById("txtQuoteLength").title;
					document.getElementById("txtQuoteLength").style.backgroundImage = 'url("images/blueStar.gif")';
					
					document.getElementById("txtQuoteWidth").value = document.getElementById("txtQuoteWidth").title;
					document.getElementById("txtQuoteWidth").style.backgroundImage = 'url("images/blueStar.gif")';
					
					document.getElementById("txtQuoteComments").value = document.getElementById("txtQuoteComments").title;
					
				}
			}
			
			function clearTextBox(boxId){
				var thisbox;
				if(document.getElementById(boxId)){
					thisbox = document.getElementById(boxId);
					if(thisbox.value == thisbox.title){
						thisbox.value = '';	
						thisbox.style.backgroundImage = '';
					}
				}
			}
			
			function checkTextValue(boxId, backPosition){
				var thisbox;
				if(document.getElementById(boxId)){
					thisbox = document.getElementById(boxId);
					if(thisbox.value == ''){
						thisbox.value = thisbox.title;
						if(boxId!='txtEmail'){
							thisbox.style.backgroundImage = 'url("images/blueStar.gif")';
						}
					}
				}	
			}
			
						
			function checkQuoteForm(){				
				txtQuoteName = document.getElementById("txtQuoteName");
				txtQuoteLocation = document.getElementById("txtQuoteLocation");
				txtQuoteEmail = document.getElementById("txtQuoteEmail");
				txtQuotePhone= document.getElementById("txtQuotePhone");
				ddQuoteInterested= document.getElementById("ddQuoteInterested");
				txtAttachedToHouse = document.getElementById("txtAttachedToHouse");	
				
				if(document.getElementById("quoteAttachedYes").checked){
					document.getElementById("txtAttachedToHouse").value = document.getElementById("quoteAttachedYes").value;
				}
				
				if(document.getElementById("quoteAttachedNo").checked){
					document.getElementById("txtAttachedToHouse").value = document.getElementById("quoteAttachedNo").value;
				}
				
				txtQuoteLength = document.getElementById("txtQuoteLength");
				txtQuoteWidth = document.getElementById("txtQuoteWidth");
	
				if(txtQuoteName.value == txtQuoteName.title)
					{alert("Name must be filled out!");txtQuoteName.focus();return false;}
				if(validate_required(txtQuoteName,"Name must be filled out!")==false)
			  		{txtQuoteName.focus();return false;}
				
				if(txtQuoteLocation.value == txtQuoteLocation.title)
					{alert("Location must be filled out!");txtQuoteLocation.focus();return false;}
				if(validate_required(txtQuoteLocation,"Name must be filled out!")==false)
			  		{txtQuoteLocation.focus();return false;}
				
				if(txtQuoteEmail.value == txtQuoteEmail.title)
					{alert("Email must be filled out!");txtQuoteEmail.focus();return false;}
				if(echeck(txtQuoteEmail.value)==false){
					txtQuoteEmail.focus();return false;
				}
				
				if(txtQuotePhone.value == txtQuotePhone.title)
					{alert("Phone must be filled out!");txtQuotePhone.focus();return false;}
				if(validate_required(txtQuotePhone,"Phone must be filled out!")==false)
			  		{txtQuotePhone.focus();return false;}
				if(isInteger(txtQuotePhone.value)==false)
					{txtQuotePhone.focus();alert("Phone Number must only contain numbers 0-9!");return false;}			  
				if(txtQuotePhone.value.length<10)
					{txtQuotePhone.focus();alert("Phone Number must be 10 characters long. Please include your area code.");return false;}
					
				
				if(validate_required(ddQuoteInterested,"Please tell us what type of enclosure you are interested in!")==false)
			  		{ddQuoteInterested.focus();return false;}
				
				if(validate_required(txtAttachedToHouse,"Please tell us of the enclosure will be attached to your house or not!")==false)
			  		{txtAttachedToHouse.focus();return false;}
			
				document.forms['frmRequestQuote'].action = "mailerQuote.php";
				document.forms['frmRequestQuote'].submit();
			}