//COPY FIELDS

function CopyFields(f) {
  if(f.same.checked == true) {
  	if (f.state.value !=='Texas'){
  	alert('We Are Only Licensed To Preform Inspections In Texas');
  	}
    else {
	    f.PAddress.value = f.street.value;
	    f.PCity.value = f.city.value;
	    f.PZip.value = f.zip.value;
	    }
  }
    else if (f.same.checked == false) {
    f.PAddress.value = '';
    f.PCity.value = '';
    f.PZip.value = '';
  }
}


function autoTab(element, nextElement) {
    if (element.value.length == element.maxLength && nextElement != null) {
        element.form.elements[nextElement].focus();
    }
}



//// NEW WINDOWS


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'titlebar=no,toolbar=no,scrollbars=no,directories=no,location=no,statusbar=no,menubar=no,resizable=no,width=350,height=250,left = 515,top = 259');");
}


var newwindow;
function pop(url)
{
	
	newwindow=window.open(url,'name','height=200,width=200');
	if (window.focus) {newwindow.focus()}
}




var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)

if (window.focus) {NewWindow.focus()}


}



///SHOW HIDE DIVS

function showHide(inID) {
     if (document.getElementById(inID).style.display == 'none') {
          document.getElementById(inID).style.display = 'block';
     } else {
          document.getElementById(inID).style.display = 'none';
     }
}

// AGREE SUBMIT

function ButtonCheck(f) {
  if(f.agree.checked == false) {
  	alert('We Are Only Licensed To Preform Inspections In Texas');
  	}
  	}
	
	
var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}