function viewDetails() {
	document.getElementById('Content_Details').style.display='block';
	linkRef = document.getElementById('Content_Details_Link');
	linkRef.blur();
	linkRef.style.backgroundImage='url(../images/Main_Arrow_Open.gif)';
}

function openQuestionPanel() {
	return false;
}
function showDirections(fromPanelName) {
	document.getElementById(fromPanelName+'_Directions').style.display = 'block';
	//document.getElementById(fromPanelName+'_Panel').style.top = '50px';
	document.getElementById(fromPanelName+'_Directions_Link').blur();
}
function hideDirections(fromPanelName) {
	document.getElementById(fromPanelName+'_Directions').style.display = 'none';
}

//---------------------------------------------------------------------------------------------------------------------
// Function to open a Printer-Friendly popup page
// Added  : 2008.01.28
// Author : Bob H.
//---------------------------------------------------------------------------------------------------------------------
function printFriendlyPopup( strTargetPage, strPageTitle )
{
	var strWindowAttributes = 'width=725,height=700,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no';
	window.open( strTargetPage, strPageTitle, strWindowAttributes );
}

//---------------------------------------------------------------------------------------------------------------------
// Function to show a hidden section of content based on the container tag's ID
// Added  : 2008.01.28
// Author : Bob H.
//---------------------------------------------------------------------------------------------------------------------
function showHidden( strID )
{
	document.getElementById( strID ).style.display = 'block';
}

$(document).ready(function(){
	$('#Panel_Contact').jqm({width:656,height:635,trigger:'a.contactOverlay'});
	$('#Panel_Whitepapers').jqm({width:656,height:635,trigger:'a.whitepapersOverlay'});
	$('#Panel_Question').jqm({width:656,height:635,trigger:'input.questionOverlay'});
	$('#Panel_Jobs').jqm({width:656,height:635,trigger:'a.jobsOverlay'});
	switch (panelName) {
		case 'question': $('#Panel_Question').jqmShow(); break;
		case 'contact': $('#Panel_Contact').jqmShow(); break;
		case 'whitepapers': $('#Panel_Whitepapers').jqmShow(); break;
		case 'jobs': $('#Panel_Jobs').jqmShow(); break;
	}
	
});

function swapDirections(sto,sfrom) {
	document.getElementById(sfrom).style.display = 'none';
	document.getElementById(sto).style.display = 'block';
	linkto = sto+"link";
	linkfrom = sfrom+"link";
	document.getElementById(linkfrom).className = '';
	document.getElementById(linkto).className = 'Active';
}

// validate contact form input
// keep consistent with unitz-contact.cgi
function validateForm(formName,ftype) {
    var emailPat = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,5}|[0-9]{1,3})(\]?)$/;
    var phonePat = /^\+{0,1}(\d|-|\/| )*(\((\d|-|\/| )+\)){0,1}(\d|-|\/| )+/;

    if (formName.length > 0) {
	var errorText = "";
	var nameError = "";
		var companyError = "";
	var emailError = "";
	var phoneError = "";
	var commentsError = "";
	var questionsError = "";

	document.getElementById('nameError').innerHTML = "";
	document.getElementById('phoneError').innerHTML = "";
	document.getElementById('emailError').innerHTML = "";
	document.getElementById('companyError').innerHTML = "";
	if (ftype == 1) {
		document.getElementById('commentsError').innerHTML = "";
	} 
	
	else {
		document.getElementById('questionError').innerHTML = "";
			}

	var nameMax = 32;
	var companyMax = 64;
	var emailMax = 64;
	var phoneMax = 32;
	var commentsMax = 1024;
	var questionMax = 1024;

	if (formName.inpName.value.length < 1) {
	    errorText += "Please enter your name in the appropriate field.<br/>\n";
	    nameError += "Please enter your name.\n";
	}
	if (formName.inpName.value.length > nameMax) {
	    errorText += "Your name entry was too long.  It must be " + nameMax + " characters or less.<br/>\n";
	    emailError += "Your name entry was too long.\n";
	}
	if ((formName.inpEmail.value.length < 1)) {
	    errorText += "Please supply your email address.<br/>\n";
	    emailError += "Please supply your email address.\n";
	}
	if ((formName.inpEmail.value.length > 0) && !emailPat.test(formName.inpEmail.value)) {
	    errorText += "Please check your email address entry to make sure it's correct.<br/>\n";
	    emailError += "Please check your email address entry.\n";
	}
	if (formName.inpEmail.value.length > emailMax) {
	    errorText += "Your email address entry was too long.  It must be " + emailMax + " characters or less.<br/>\n";
	    emailError += "Your email address entry was too long.\n";
	}
	if ((formName.inpPhone.value.length < 10)) {
	    errorText += "Please check your phone number entry.<br/>\n";
	    phoneError += "Please check your phone number entry.\n";
	}
	if ((formName.inpPhone.value.length > 0) && !phonePat.test(formName.inpPhone.value)) {
	    errorText += "Your phone number entry doesn't look like a valid phone number.<br/>\n";
	    phoneError += "Your phone number entry doesn't look valid.\n";
	}
	if (formName.inpPhone.value.length > phoneMax) {
	    errorText += "Your phone number entry was too long.  It must be " + phoneMax + " characters or less.<br/>\n";
	    phoneError += "Your phone number entry was too long.\n";
	}
	if (formName.inpCompany.value.length > companyMax) {
			   errorText += "Your \n";
		    companyError += "Your company entry was too long.\n";
		}
	if (ftype == 1) {
		if (formName.inpComments.value.length > commentsMax) {
	    	errorText += "Your \n";
		    commentError += "Your comment entry was too long.\n";
		}
		
	} 
	else {
		if (formName.inpQuestion.value.length > questionMax) {
	    	errorText += "Your \n";
		    commentError += "Your question was too long.\n";
		}
	}

	if (errorText.length > 0) {
		if (ftype == 1) {
			document.getElementById('companyError').innerHTML = companyError;
			document.getElementById('nameError').innerHTML = nameError;
			document.getElementById('phoneError').innerHTML = phoneError;
			document.getElementById('emailError').innerHTML = emailError;
			document.getElementById('commentsError').innerHTML = commentsError;
		} 
		
		else {
			document.getElementById('companyError2').innerHTML = companyError;
			document.getElementById('nameError2').innerHTML = nameError;
			document.getElementById('phoneError2').innerHTML = phoneError;
			document.getElementById('emailError2').innerHTML = emailError;
			document.getElementById('questionError').innerHTML = commentsError;
		}
		
		return false;
	}
	return true;
    } else {
	return false;
    }
}

function submitQQOnEnter(fieldObj, formObj, e) {
    var keycode = 0;

    if (window.event) {
        keycode = window.event.keyCode;
    } else if (e) {
        keycode = e.which;
    }

    if (keycode == 13) {
        if (document.quickquestionform.onsubmit()) {
            document.quickquestionform.submit();
            return false;
        }
    }
    return true;
}

function submitQQ(isinternet) {
	if (isinternet != undefined) {
		//alert('a');
		document.getElementById('isinternet').value = 1;
	}
	document.getElementById('inpQuestion').value = document.getElementById('Sidebar_Question_Input').value;
	$('#Panel_Question').jqmShow();
}

function showAlert(thisForm) {
	//var thisForm = document.getElementById('inpFName').innerHTML;
	//alert(thisForm);
	if (thisForm.inpFName.value.length < 1) {
	    document.getElementById('fnameError2').innerHTML = "Please enter your first name.";
		return false;
	}
	if (thisForm.inpLName.value.length < 1) {
	    document.getElementById('lnameError2').innerHTML = "Please enter your last name.";
		return false;
	}
	if (thisForm.inpURL.value.length < 1) {
	    document.getElementById('urlError2').innerHTML = "Please enter your URL.";
		return false;
	}
	else {
		return true;
	}
}
