function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function P7_JumpMenu(selObj,restore){ //v1.4 by Project Seven
	var theFullString = selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
	var theLength = theFullString.length;
	var endPos = theFullString.lastIndexOf("~");
	var theUrl, theTarget, theParent;
	if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
	else {theUrl = theFullString;}
	endPos++
	if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
	else {theTarget = "window:Main";}
	if (theTarget == "window:New") {window.open(theUrl);}
	else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
	else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}

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;
}

var inValid = ":|/\\~!#@&*%$\'\" ^";
	function Form_Validator(theForm)
	{
	var alertstr = "Please correct the following\n";
	if (theForm.username.value == "")
	{
	alert(alertstr + "Enter a value for the \"Username\" field.");
	theForm.username.focus();
	return (false);
	}
	for (j = 0; j < theForm.username.value.length; j++)
	{
	if (inValid.indexOf(theForm.username.value.charAt(j)) != -1)
	{
	alert(alertstr + "The \"Username\" contains invalid characters (:|/\\~!#@&*%$\'\" ^)");
	theForm.username.focus();
	return (false);
	}
	}
	}
	function valbutton(form2) {
	myOption = -1;
	for (i=form2.verotel_website.length-1; i > -1; i--) {
	if (form2.verotel_website[i].checked) {
	myOption = i;
	}
	}
	if (myOption == -1) {
	alert("Please select a site");
	return false;
	}
	form2.submit(); 
}
var inValid = "\' \" ";
function Form_Validator(theForm)
	{
	var alertstr = "Please correct the following\n";
	if (theForm.keyword.value == "")
	{
	alert(alertstr + "Enter a value for the \"Keyword\" field.");
	theForm.keyword.focus();
	return (false);
	}
	for (j = 0; j < theForm.keyword.value.length; j++)
	{
	if (inValid.indexOf(theForm.keyword.value.charAt(j)) != -1)
	{
	alert(alertstr + "The \"Keyword\" contains invalid characters \' \" ");
	theForm.keyword.focus();
	return (false);
	}
}
}
var winhandle = null;

function fitWindowOnScreen(aWindow) {

  if (aWindow.outerWidth) {

    if ((aWindow.outerWidth  > screen.availWidth) ||
        (aWindow.outerHeight > screen.availHeight)) {

      lNewWidth  = Math.min(aWindow.outerWidth,  screen.availWidth);
      lNewHeight = Math.min(aWindow.outerHeight, screen.availHeight);

      aWindow.resizeTo(lNewWidth, lNewHeight);

      aWindow.moveTo((screen.availWidth - lNewWidth) / 2, (screen.availHeight - lNewHeight) / 2);

    }

  }
  else
  {

    if ((aWindow.document.body.offsetWidth  + 50  > screen.availWidth) ||
        (aWindow.document.body.offsetHeight + 200 > screen.availHeight)) {

      lOldOffsetWidth  = aWindow.document.body.offsetWidth;
      lOldOffsetHeight = aWindow.document.body.offsetHeight;

      aWindow.resizeTo(lOldOffsetWidth, lOldOffsetHeight);

      lBorderWidth  = lOldOffsetWidth  - aWindow.document.body.offsetWidth;
      lBorderHeight = lOldOffsetHeight - aWindow.document.body.offsetHeight;

      lOldHeight = lOldOffsetHeight + lBorderHeight;
      lOldWidth  = lOldOffsetWidth  + lBorderWidth;

      lNewWidth  = Math.min(lOldWidth,  screen.availWidth);
      lNewHeight = Math.min(lOldHeight, screen.availHeight);

      aWindow.resizeTo(lNewWidth, lNewHeight);

      aWindow.moveTo((screen.availWidth - lNewWidth) / 2, (screen.availHeight - lNewHeight) / 2);

    }
  }
}

function centerWindow(aWindow) {

  if (aWindow.outerWidth) {

    lNewLeft = Math.max(0, (screen.availWidth  - aWindow.outerWidth) / 2);
    lNewTop  = Math.max(0, (screen.availHeight - aWindow.outerHeight) / 2);

    aWindow.moveTo(lNewLeft, lNewTop);

  }
  else
  {
    lOldOffsetWidth  = aWindow.document.body.offsetWidth;
    lOldOffsetHeight = aWindow.document.body.offsetHeight;

    aWindow.resizeTo(lOldOffsetWidth, lOldOffsetHeight);

    lBorderWidth  = lOldOffsetWidth  - aWindow.document.body.offsetWidth;
    lBorderHeight = lOldOffsetHeight - aWindow.document.body.offsetHeight;

    lWindowWidth  = lOldOffsetWidth  + lBorderWidth;
    lWindowHeight = lOldOffsetHeight + lBorderHeight;

    aWindow.resizeTo(lWindowWidth, lWindowHeight);

    lNewLeft = Math.max(0, (screen.availWidth  - lWindowWidth)  / 2);
    lNewTop  = Math.max(0, (screen.availHeight - lWindowHeight) / 2);

    aWindow.moveTo(lNewLeft, lNewTop);

  }

}

function popUp(aURL, aImageWidth, aImageHeight) {

  var lWindowWidth  = Math.min(aImageWidth,  screen.availWidth);
  var lWindowHeight = Math.min(aImageHeight, screen.availHeight);

  if ((winhandle != null) && (! winhandle.closed)) {

    winhandle.document.body.style.overflow = 'hidden';

    winhandle.document.images["arlesimage"].src = aURL;

    if (winhandle.innerWidth) {
      deltaWidth  = lWindowWidth  - winhandle.innerWidth;
      deltaHeight = lWindowHeight - winhandle.innerHeight;
    }
    else {
      deltaWidth  = lWindowWidth  - winhandle.document.body.clientWidth;
      deltaHeight = lWindowHeight - winhandle.document.body.clientHeight;
    }

    winhandle.resizeBy(deltaWidth, deltaHeight);

    fitWindowOnScreen(winhandle);

    centerWindow(winhandle);

    winhandle.document.body.style.overflow = 'auto';

  }
  else
  {
    var lLeft = (screen.availWidth  - lWindowWidth)  / 2;
    var lTop  = (screen.availHeight - lWindowHeight) / 2;
    var lOptions = 'resizable,scrollbars,width=' + lWindowWidth + ', height=' + lWindowHeight + ', left=' + lLeft + ', top=' + lTop;
    winhandle = window.open("", "imagewin", lOptions);

    with (winhandle.document){

      writeln('<html><head>');
      writeln('<title>Image<\/title>');
      writeln('<meta http-equiv="imagetoolbar" content="no" />');
      writeln('<\/head>');
      writeln('<body bgcolor="#000000" topmargin="0" leftmargin="0" style="margin:0px;">');
      writeln('<a href="javascript:window.close();"><img name="arlesimage" src="' + aURL + '" style="display:block" border="0" /> <\/a>');
      writeln('<\/body><\/html>');

      body.style.overflow = 'auto';

      fitWindowOnScreen(winhandle);

      centerWindow(winhandle);

      close();
    }
  }

  winhandle.focus();

}
