var popUpWin=0;

function BrowserInfo()
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}

var b = new BrowserInfo();
var bwidth = b.screenWidth;
var bheight = b.screenHeight;

function popUpWindow(URLStr) {

	var width=380;
	var height=200;
	var left=(bwidth-width)/2;
	var top=(bheight-height)/2;
	

	//var URLStr=element.options[element.selectedIndex].value;
	if(URLStr != "0"){
		if(popUpWin){
			if(!popUpWin.closed) popUpWin.close();
			}
		popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	}
}


function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function checkform ( form )
{

    if (form.MM.selectedIndex == 0 | form.DD.value == "" ) {
        alert( "Please select your Move Date" );
        return false ;
    }


    if (form.FirstName.value == "") {
        alert( "Please enter your First Name." );
        form.FirstName.focus();
        return false ;
    }
	
    if (form.LastName.value == "") {
        alert( "Please enter your Last Name." );
        form.LastName.focus();
        return false ;
    }	
	
    if (form.OrigPhoneA.value == "" | form.OrigPhoneB.value == "" | form.OrigPhoneC.value == "" | isNaN(form.OrigPhoneA.value+form.OrigPhoneB.value+form.OrigPhoneC.value) | form.OrigPhoneA.value.length!=3 | form.OrigPhoneB.value.length!=3 | form.OrigPhoneC.value.length!=4) {
        alert( "Please enter your complete Phone Number with area code." );
        form.OrigPhoneA.focus();
        return false ;
    }
	
	
	if (!isEmailAddr(form.email.value)) {
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		form.email.focus();
		return false;
	}
	
    if (form.OrigStateID.selectedIndex == 0) {
        alert( "Please select your origin State." );
        form.OrigStateID.focus();
        return false ;
    }
	
    if (form.DestStateID.selectedIndex == 0) {
        alert( "Please select your destination State." );
        form.DestStateID.focus();
        return false ;
    }

    if (form.comments.value.length > 500) {
        alert( "A maximum of 500 characters is alowed in the comment field." );
		form.comments.value = form.comments.value.substr(1,500); 
		form.comments.focus();
        return false ;
    }

    if (form.automake1.selectedIndex == 0) {
        alert( "Please select the vehicle Make." );
        form.automake1.focus();
        return false ;
    }
	
    //if (form.automodel1.value == 0) {
    //    alert( "Please select the vehicle Model." );
    //    form.automodel1.focus();
    //    return false ;
    //}
	
    if (form.AutoYear.value == "") {
        alert( "Please enter the vehicle Year." );
        form.AutoYear.focus();
        return false ;
    }
	
    if (form.running.selectedIndex == 0) {
        alert( "Please specify the vehicle running condition." );
        form.running.focus();
        return false ;
    }
	
    if (form.typeauto.selectedIndex == 0) {
        alert( "Please specify the type of vehicle." );
        form.typeauto.focus();
        return false ;
    }
			
	return true ;
}



