//------------------- OPEN NEW WINDOW -------------------//
var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable=no,toolbar=no,location=no,scroll=yes,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}


//------------------- Button Switcher ------------//
var bottomPanelOpen=false;
var btnStatus=new Array();
//function scrollToBottom() {
function ChangeButtons(btnID) {
	
	if (btnStatus[btnID]=='open'||btnStatus[btnID]==null) {
		$(btnID).src='images/contract.gif';
		btnStatus[btnID]='closed';
	}
	else {
		$(btnID).src='images/expand.gif';
		btnStatus[btnID]='open';
	}
}

function ChangePrompt(btnID) {
	
	if (btnStatus[btnID]=='open'||btnStatus[btnID]==null) {
		$(btnID).innerHTML='Close Description';
		btnStatus[btnID]='closed';
	}
	else {
		$(btnID).innerHTML='More Info...';
		btnStatus[btnID]='open';
	}
}


//------------------- Quote Form Validation ------------//
function checkQuote() {
    var emailRegxp = new RegExp(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$/);
    var phoneLRRegxp = /^\d{10}$/;
    var errors = false;

  if($F('email').length < 2 || !emailRegxp.test($F('email'))) {
        $('email').style.background = '#f2d6a0';
				$('email').focus();
				errors = true;
    } else {
        $('email').style.background = '#ffffff';
  }

  if($F('phone').length < 10) {
				$('phone').style.background = '#f2d6a0';
				$('phone').focus();
				errors = true;
    } else {
        $('phone').style.background = '#ffffff';
  }

	
	 
	if( $('company') )
	{
		if($F('zip').length < 2) {
			$('zip').style.background = '#f2d6a0';
			$('zip').focus();
			errors = true;
		} else {
			$('zip').style.background = '#ffffff';
		}
		if($F('state').length < 2) {
			$('state').style.background = '#f2d6a0';
			$('state').focus();
			errors = true;
		} else {
			$('state').style.background = '#ffffff';
		}
		if($F('city').length < 2) {
			$('city').style.background = '#f2d6a0';
			$('city').focus();
			errors = true;
		} else {
			$('city').style.background = '#ffffff';
		}
		if($F('address').length < 2) {
			$('address').style.background = '#f2d6a0';
		  $('address').focus();
			errors = true;
		} else {
			$('address').style.background = '#ffffff';
		}
		//if($F('company').length < 2) {
		//	$('company').style.background = '#f2d6a0';
		//	$('company').focus();
		//	errors = true;
		//} else {
		//	$('company').style.background = '#ffffff';
		//}
	}
	if( $('name') )
		{
			if($F('name').length < 2) {
				$('name').style.background = '#f2d6a0';
				$('name').focus();
				errors = true;
			} else {
				$('name').style.background = '#ffffff';
			}
	}
	
  if( $('firstname') )
	{
		if($F('lastname').length < 2) {
			$('lastname').style.background = '#f2d6a0';
			$('lastname').focus();
			errors = true;
		} else {
			$('lastname').style.background = '#ffffff';
		}
		if($F('firstname').length < 2) {
			$('firstname').style.background = '#f2d6a0';
			$('firstname').focus();
			errors = true;
		} else {
			$('firstname').style.background = '#ffffff';
		}
	}
   
	
  if(errors) {
        alert('Please fix the highlighted fields');
        return false;
  }
    
  document.theform.submit();
}

