function focusForm() {

  // If there is a form in the doc...
  if (document.forms) {

    theElems = document.forms[0].elements

    // loop over the elements until finding a non-hidden one
    for (i = 0; i < theElems.length; i++) {
      theElem = theElems[i];
      if (theElem.type && theElem.type == "hidden" ) {
        continue;
      }
      // focus on the first non-hidden element
      theElem.focus();
      break;
    }
  }
}

function AdInfo(page) {
	var NewWindow=open('','AdInfo','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=525, height=500, left=200, top=30');
	NewWindow.focus();
	window.open(page,target="AdInfo");
}


function TemplatePop(page, page_w) {
	if (page_w == null)
	{
		page_w = 693
	}
	var NewWindow=open('','TempPop','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=' + page_w + ', height=630, left=200, top=20');
	NewWindow.focus();
	window.open(page,target="TempPop");
}

function OpenPop(page, page_w, page_h) {
	if (page_w == null)
	{
		page_w = 300
	}
	if (page_h == null)
	{
		page_h = 300
	}
	var NewWindow=open('','ThePop','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=' + page_w + ', height=' + page_h + ', left=200, top=20');
	NewWindow.focus();
	window.open(page,target="ThePop");
}


function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}
