


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function undisableSelective(which1, which2){	
	var whichform=eval(which1);
	var whichform2=eval(which2);
	if(whichform2.value==""){
	
	whichform.disabled=false;
	}
	
}


function undisable(which1, which2){	
	var whichform=eval(which1);
	whichform.disabled=false;
	var whichform=eval(which2);
	whichform.disabled=false;
}

function disable(which){
	var whichform=eval(which);
	whichform.disabled=true;
}


function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//function deleteCookie(thelocation){
//	var lastYear=new Date();
//	lastYear.setFullYear(lastYear.getFullYear()-1);
//	document.cookie = "ids=12345;expires="+lastYear.toGMTString();
//	document.location=thelocation;
//}

						function validForm(){
							var emailAddress=MM_findObj('email_addy').value;
							var first_name=MM_findObj('first_name').value;
							var last_name=MM_findObj('last_name').value;
							if(emailAddress.indexOf(".")==-1||emailAddress.indexOf("@")==-1||emailAddress.length<7){
								alert("Please enter a valid email address");
								return false;
							}
							if(first_name==null||first_name==""){
								alert("Please enter your first name");
								return false;
							}
							if(last_name==null||last_name==""){
								alert("Please enter your last name");
								return false;
							}
						}

function Entry(ID, Name)
{
	this.ID = ID;
	this.Name = Name;
}


function PopulatePane(currentPane, paneToPopulate) {
theForm = currentPane.form;

	var selectedArray, i;
	var selected = currentPane.options[currentPane.selectedIndex].value
	
	
	if (selected == 0) {
		if (currentPane.selectedIndex != 0)
			selected = currentPane.options[--currentPane.selectedIndex].value;
		else {
			currentPane.selectedIndex = -1;
			return false;
		}
	}
		
			
		
	if (paneToPopulate == "none")
		selectedSubCat = selected;
	else
	{selectedCat = selected;
	 selectedSubCat = ' ';}
	

	 if (paneToPopulate != "none")
	 {
		selectedArray = eval(paneToPopulate + selected);
	
		paneToPopulate = eval("currentPane.form." + paneToPopulate)
	

	
		paneToClear = currentPane.form.elements[1];
	
	if (paneToClear.name == "subcat"){

			for (i = paneToClear.options.length; i != 0; i--) {
				paneToClear.options[i - 1] = null;
			}
		}
	while (selectedArray.length < paneToPopulate.options.length) {
		paneToPopulate.options[(paneToPopulate.options.length - 1)] = null;
	}
	for (i = 0; i < selectedArray.length; i++) {
		if ( selectedArray[i] == null || selectedArray[i] == "" ) {
			//alert("There is no " + paneToPopulate.Name + " associated with this " + currentPane.Name);
		} else {
			
			var tempsar = selectedArray[i].Name;
			tempsar = tempsar.replace(/\'/g,"\\'");
			
			var tempsarID = selectedArray[i].ID;
			tempsarID = tempsarID.replace(/\'/g,"\\'");
			
			eval("paneToPopulate.options[i] = new Option('" + tempsar + "')");
			eval("paneToPopulate.options[i].value = '" + tempsarID + "'");
		}
	}
	
	}
	
	
}

function P7_Snap() { //v2.63 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}

function validateFormInput(){
	if(document.forms[0].firstname.value=="" || document.forms[0].lastname.value==""){
		alert("Please enter your full name");
		return false;
	}
	else if(document.forms[0].email.value=="" || document.forms[0].email.value.indexOf('@')==-1 || document.forms[0].email.value.indexOf('.')==-1){
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}

function validateFormInputInvContact(){
	if(document.forms[0].firstname.value=="" || document.forms[0].lastname.value==""){
		alert("Please enter your full name");
		return false;
	}
		if(document.forms[0].address.value=="" || document.forms[0].city.value=="" || document.forms[0].state.value=="" || document.forms[0].zip.value==""){
		alert("Please enter your address");
		return false;
	}

	return true;
}

function validateFormInputMTF1(){
	if(document.forms[0].username.value==""){
		alert("Please enter your username");
		return false;
	}
	else if(document.forms[0].user_email.value=="" || document.forms[0].user_email.value.indexOf('@')==-1 || document.forms[0].user_email.value.indexOf('.')==-1){
		alert("Please enter a valid email address");
		return false;
	}
	else if(document.forms[0].password.value==""){
		alert("Please enter your password");
		return false;
	}
	else if(document.forms[0].verify_password.value==""){
		alert("Please verify your password");
		return false;
	}
	return true;
}
function resetFields(select1, select2, select3, select4, select5, select6, select7, select8, select9, select10, select11){
	select1.options[0].selected=true;
	if(select2){
	select2.options[0].selected=true;
	}
	if(select3){
	select3.options[0].selected=true;
	}
	if(select4){
	select4.options[0].selected=true;
	}
	if(select5){
	select5.options[0].selected=true;
	}
	if(select6){
	select6.options[0].selected=true;
	}
	if(select7){
	select7.options[0].selected=true;
	}
	if(select8){
	select8.options[0].selected=true;
	}
	if(select9){
	select9.options[0].selected=true;
	}
	if(select10){
	select10.options[0].selected=true;
	}
	if(select11){
	select11.options[0].selected=true;
	}
}

function changeIt(which,which1,which2){
	var newform=eval(which+".options[0]");
	if(newform.selected==true){
		var whichform=eval(which1);
		whichform.disabled=false;
		var whichform=eval(which2);
		whichform.disabled=false;
	}
}

function print_page(){
if(navigator.platform.indexOf('Mac')>-1){
alert("Select 'Print' from the menu")}
else{
	window.print();
}
}


(function(){
	//tests for specified version of flash
	//plugin==0 -they don't have latest, plugin==1 -they do have latest.
	var plug = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	//alert('plug '+plug);
	if ( plug ) {
		//put version to test for...
		var descript = plug.description;
		var searchString =  'Shockwave Flash ';
		var len = searchString.length;
		var versString = descript.substring(descript.indexOf(searchString)+len);
		var versionNumber = parseInt(versString);
		//plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 6;
		plugin = Number(versionNumber) >= Number(6);
	/*	var arr=[];
		for(var i in plug){
			arr.push(i);
			arr.push(plug[i]);
			
		}*/
		
	}

	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	   && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
		document.write('<SCRIPT LANGUAGE=VBScript> \n');
		document.write('on error resume next \n');
		//put version to test for...
		document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
		document.write('</SCRIPT\>\n');
	}
}());
//end flash detect

//-->


// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

function goToWhere(){
	var where=document.formhelp.select.value;
	document.location.href=where;
}

function launchWhich(){
	var selectedModelNum=document.forms[0].subcat.value;

if(document.forms[0].subcat.value!=""){
	thechar=selectedModelNum.indexOf("|");
	
	
	selectedModelNum=selectedModelNum.substring(0,thechar);
	
	thelength=document.forms[0].subcat.options.length;
	
	for(i=0;i<thelength;i++){
		
		if(document.forms[0].subcat.options[i].selected){
		var selectedModelName=document.forms[0].subcat.options[i].text;
		
		}
	}
	
	selectedModelName=selectedModelName.toLowerCase();
	selectedModelName=selectedModelName.replace(/\s/g, "_");
	selectedModelName=selectedModelName.replace(/\./g, "");
	selectedModelNum=selectedModelNum.replace(/\s/g, "");

	thechar2=selectedModelName.indexOf(":");
	thech=thechar2-1;
	selectedModelName=selectedModelName.substring(0,thechar2);
	
	
	var folder=(""+selectedModelName+"_"+selectedModelNum+"_");
	folder=folder.replace(/_+/g, "_");
	var dyohpath=("http://www.tollbrothers.com/DYOH/DYOH.swf?plan="+folder);
	}
	
   if(plugin && document.forms[0].subcat.value!=""){
	popUp(dyohpath);
	}
   else if(!plugin){
	alert("You need to get the latest version of Flash. Click the icon below.");
	}
   else if(document.forms[0].subcat.value==""){
	alert("Please select a model before launching Design Your Own Home");
	}
}	
function popUp(theURL){
	//assigning the function call to a var prevents ugly window BUG in netscape.
	//var x=window.open(theURL,'','location=1,resizable=1,status=0,toolbar=0,scrollbars=0,directories=0,menubar=0');
	//ie has biggest chrome borders so other browsers may be slightly smaller than window but not bigger.
	var ieTitle = 25;
	var ieAddress = 25;
	var ieThinBorder = 50;
	var w = window.screen.availWidth-(ieThinBorder*2);
	var h = window.screen.availHeight-(ieTitle+ieAddress+ieThinBorder);
	//unfortunately sets the inside w and h of window, not outside.
	var x=window.open(theURL,'','width='+w+',height='+h+',left=0,top=0,location=1,resizable=1,status=0,toolbar=0,scrollbars=0,directories=0,menubar=0');
}	

function filterIt(what){
}

function turnon(){
	if(document.all){
		document.all.filter.style.visibility="visible";
	}
	else if(document.getElementById){
		document.all.filter.style.visibility="visible";
	}
}


function reloadPage(){
	var thelength=document.forms[0].region_num.options.length;
	for(i=0;i<thelength;i++){
		
		if(document.forms[0].state.options[i].selected){
		var selectedRegionNum=document.forms[0].state.options[i].value;
		
		}
	}
	//thechar=thechar+1;
	//alert(thechar)
	//selectedRegionNum=selectedRegionNum.substring(thechar);
	//alert(selectedRegionNum);
	document.location="http://www.tollbrothers.com/DYOH/dyoh_main.shtml?region_num="+selectedRegionNum;
}
	
	
function P7_JumpMenu(selObj,restore){ //v1.4 by Project Seven
	var theFullString = selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
	var theLength = theFullString.length;
	var endPos = theFullString.lastIndexOf("~");
	var theUrl, theTarget, theParent;
	if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
	else {theUrl = theFullString;}
	endPos++
	if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
	else {theTarget = "window:Main";}
	if (theTarget == "window:New") {window.open(theUrl);}
	else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
	else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}





//Tooltip Scripts

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// This portion of the code should be placed in the head section of the document.
// Script tags for the external JavaScipt files should be placed just before the end of the document.

// leave in page to avoid errors if onmouseovers/outs before page completely loaded
function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}

// preload images that will be displayed in tooltip
// put images to preload in this array
var preload_list = new Array("tooltip_qdh.gif","tooltip_action1.gif","tooltip_action2.gif","tooltip_action3.gif");
var path_to_images = "/images/";

if (document.images) {
	var image_list = new Array();
	for (var preload_counter=0; preload_counter<preload_list.length; preload_counter++) {
  	image_list[preload_counter] = new Image();
		image_list[preload_counter].src = path_to_images + preload_list[preload_counter];
  }
}

// variables for tooltip content
// name them whatever you want, add as many as you need
var tip1 = '<img src="/images/tooltip_qdh.gif" width="144" height="50" alt="" border="0">';
var tip2 = '<img src="/images/tooltip_action1.gif" width="144" height="39" alt="" border="0">';
var tip3 = '<img src="/images/tooltip_action2.gif" width="144" height="39" alt="" border="0">';
var tip4 = '<img src="/images/tooltip_action3.gif" width="144" height="39" alt="" border="0">';

//End Tooltip Scripts





//My Toll Favorites Scripts

function hideIt() {
 timer=setTimeout("MM_showHideLayers('nav1menu','','hide')",2000);
}

var timer

function closeMenus(){
	if (document.all){
	document.all.nav1menu.style.visibility="hidden"
	}
	else if(document.getElementById){
	document.getElementById("nav1menu").style.visibility="hidden"
	}
	else{
	document.nav1menu.visibility="hide"
	}}

function startTimer(){
	timer=setTimeout("closeMenus()",4500)
	}

function MaintainMenu(){
	clearTimeout(timer)
	timer=setTimeout("closeMenus()",4500)
	}
	
function openMenu(which){
	clearTimeout(timer)
	closeMenus()
	if(document.all){
	thisMenu=eval("document.all."+which+".style")
	thisMenu.visibility="visible"
	}
	else if(document.getElementById){
	thisMenu=document.getElementById(which).style
	thisMenu.visibility="visible"
	}
	else{
	thisMenu=eval("document."+which)
	thisMenu.visibility="show"
	}
	}


function P7_hideDiv(evt) { //v1.3 by PVII
 var b,relT,mT=false; 
 if(document.layers){b=evt.target;if(b.p7aHide){
  b.visibility="hidden";}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){b=event.srcElement;
  while(b!=null){if(b.tagName=="DIV" && b.p7ahD){mT=true;break;}b=b.parentElement;}
  if(!b.contains(event.toElement)){b.style.visibility="hidden";}
 }else if(document.getElementById){b=evt.currentTarget;relT=evt.relatedTarget;
  while(relT!=null){if(b==relT){mT=true;break;}
  relT=relT.parentNode;}if(!mT){b.style.visibility="hidden";}}
}

function P7_autoHide() { //v1.3 by PVII
 var i,g,args=P7_autoHide.arguments;
 for(i=0;i<args.length;i++){if((g=MM_findObj(args[i]))!=null){
  g.p7aHide=true;if(document.layers){
  g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideDiv;g.p7ahD=true;}}
}

/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TR"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(ms, sl) { //check if sl is contained by ms
while (sl.parentNode)
if ((sl = sl.parentNode) == ms)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}

function checkLoginX(){
	array_invalid=new Array();
	array_invalid=["!","@","#","$","%","^","&","*"," ","(",")","{","}","|"];
	var array_len=array_invalid.length;

	if(document.form3.username.value==""){
		alert("Please enter a desired username");
		return false;
		}
	
	for(i=0;i<array_len;i++){
	if(document.form3.username.value.indexOf(array_invalid[i])>-1){
		alert("Please enter username without "+array_invalid[i]+" characters");
		return false;
		}
	}
	for(i=0;i<array_len;i++){
	if(document.form3.password.value.indexOf(array_invalid[i])>-1){
		alert("Please enter password without "+array_invalid[i]+" characters");
		return false;
		}
	}
	if(document.form3.password.value.length<3 || document.form3.password.value.length>8){
		alert("Please enter a password between 3 and 8 characters long");
		return false;
		}
	if(document.form3.user_email.value=="" || document.form3.user_email.value.indexOf('.')==-1 || document.form3.user_email.value.indexOf('@')==-1){
		alert("Please enter a valid email");
		return false;
		}
return true;
}


function checkLoginZ(){
	array_invalid=new Array();
	array_invalid=["!","@","#","$","%","^","&","*"," ","(",")","{","}","|"];
	var array_len=array_invalid.length;

	if(document.email_a_friend.eaf_to.value=="" || document.email_a_friend.eaf_to.value.indexOf('.')==-1 || document.email_a_friend.eaf_to.value.indexOf('@')==-1){
		alert("Please enter a valid email address you wish to send an email to");
		return false;
		}
	
	for(i=0;i<array_len;i++){
	if(document.email_a_friend.eaf_from.value=="" || document.email_a_friend.eaf_from.value.indexOf('.')==-1 || document.email_a_friend.eaf_from.value.indexOf('@')==-1){
		alert("Please enter your email address");
		return false;
		}
	}

return true;
}


function checkLoginForgotPass(){
	array_invalid=new Array();
	array_invalid=["!","@","#","$","%","^","&","*"," ","(",")","{","}","|"];
	var array_len=array_invalid.length;

	if(document.formfp.email.value=="" || document.formfp.email.value.indexOf('.')==-1 || document.formfp.email.value.indexOf('@')==-1){
		alert("Please enter a valid email address");
		return false;
		}
return true;
}


function validateEmail(){
	if(document.form6.email.value=="" || document.form6.email.value.indexOf('@')==-1 || document.form6.email.value.indexOf('.')==-1){
		alert("Please enter a valid email");
		return false;
	}
	return true;
}


					
						function validateThisForm(obj)
						{
							var org = "The following items are required:     \n\n";
							var msg = org;
							
							if(obj.firstname.value == "")
								msg += "- First name\n";
							if(obj.lastname.value == "")
								msg += "- Last name\n";
							if(obj.address1.value == "")
								msg += "- Address\n";
							if(obj.city.value == "")
								msg += "- City\n";
							if(obj.state.value == "")
								msg += "- State\n";
							if(obj.zip.value == "")
								msg += "- Zip\n";
							
							if(msg != org)
								alert(msg);
							else
								obj.submit();
						}
// End My Toll Favorites Scripts

