function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function limitLength(element, maxLength) {	
  if (element.value.length > maxLength)
	{
	element.value = element.value.substring(0, maxLength);
	alert('You have reached the maximum response length');
	return 0;
	}
}

function selectQCPhyCode(qid)
{
	return hDoPopup('QCPhyCodeSheet.aspx?QID=' + qid, '700px', '600px');
}

function selectQCEmpCode(qid)
{
	return hDoPopup('QCEmpCodeSheet.aspx?QID=' + qid, '700px', '600px');
}

function selectQCAssocCode(qid)
{
	return hDoPopup('QCAssocCodeSheet.aspx?QID=' + qid, '700px', '600px');
}

function selectHSTMEmpCode(qid)
{
	return hDoPopup('HSTMEmpCodeSheet.aspx?QID=' + qid, '700px', '600px');
}

function selectCode_SurvID_1044(qid)
{
	return hDoPopup('SurvID_1044_CodeSheet.aspx?QID=' + qid, '700px', '600px');
}

function selectCode(qid, qlabel, listName, format)
{
	if (format.toLower() == 'b')
		return hDoPopup('/CodeSheetB.aspx?QID=' + qid + '&QLabel=' + qlabel + '&ListName=' + listName, '700px', '600px');
	else
		return hDoPopup('/CodeSheet.aspx?QID=' + qid + '&QLabel=' + qlabel + '&ListName=' + listName, '700px', '600px');
}

function hDoPopup(pageUrl, width, height)
{
	var features = "left=" + window.screenLeft + ", " + 
				"top=" + window.screenTop + ", " +
				"width=" + width + ", " +
				"height= " + height + ", " +
				"status=no, scrollbars=yes, resizable=yes";

	var hWnd = window.open(pageUrl, "CodeSheet", features);
	if (hWnd == null)
	{
		var strPopupErr = 'There was a problem opening a survey window.  You may be attempting to open ' +
						  'the window using a browser with pop-up blocking software installed, ' +
						  'which may prevent you from accessing all or part of the online survey. ' +
						  'If you have pop-up blocking software enabled, try holding down the "CTRL" key ' +
						  'while clicking the selected link. If that does not work, you may need to ' +
						  'contact your local Information Systems department help desk to disable pop-up ' +
						  'blocking software for this site or go to a computer where pop-ups are not blocked. ' +
						  '\n\r\n\r' +
						  'If you continue to have difficulty, please contact our Web Support department.';
		alert(strPopupErr);	
	}
	else
	{
		if ((document.window != null) && (!hWnd.opener))
			hWnd.opener = document.window;
	}
}

function SelectWkGrp(elemIdx)
{
	var elemTxt;

	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		elemTxt = document.forms["Form1"].WkGrpIdx;
	}
	else {
		elemTxt = document.Form1.WkGrpIdx;
	}

	elemTxt.value = elemIdx.selectedIndex;
}

function SelectWkGrpValue(elemIdx)
{
	var elemTxt;

	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		elemTxt = document.forms["Form1"].WkGrpValue;
	}
	else {
		elemTxt = document.Form1.WkGrpValue;
	}

	for (i=0; i < elemIdx.options.length; i++)
	{
		if (elemIdx.options[i].selected)
		{
			elemTxt.value = elemIdx.options[i].value;
			break;
		}
	}
}

function SelectSpecialty(elemIdx)
{
	var elemTxt;

	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		elemTxt = document.forms["Form1"].ListIdx;
	}
	else {
		elemTxt = document.Form1.ListIdx;
	}

	elemTxt.value = elemIdx.selectedIndex;
}
