//------------------- 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('name').length < 2) {
        $('name').style.background = '#f2d6a0';
        errors = true;
    } else {
        $('name').style.background = '#ffffff';
    }
    
    if($F('phone').length < 10) {
		$('phone').style.background = '#f2d6a0';
		errors = true;
    } else {
        $('phone').style.background = '#ffffff';
    }
    
    if($F('email').length < 2 || !emailRegxp.test($F('email'))) {
        $('email').style.background = '#f2d6a0';
        errors = true;
    } else {
        $('email').style.background = '#ffffff';
    }
	
    if(errors) {
        alert('Please fix the highlighted fields');
        return false;
    }
    
    document.theform.submit();
}