var remote_win = null;

function openNewWindow(URL, windowName, windowFeatures) {
		newWindow=window.open(URL, windowName, windowFeatures);
		}


var newWin = null;

function openIt(dat,Wwidth,Wheight,Wmenu) {

  LeftPosition = (screen.width) ? (screen.width-Wwidth)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-Wheight)/2 : 0;
  settings = 'width='+Wwidth+',height='+Wheight+',top='+TopPosition+',left='+LeftPosition+',scrollbars,resizable';

  if (Wmenu) {
   settings  = settings+',menubar';
  }

  newWin = window.open("","",settings);
  newWin.document.open();

  var _s ="";
          _s+="<html><body>";
          _s+="<form method=post name=frm action='http://www.call4abstracts.com/tools/spell.php'>";
          _s+="<TEXTAREA style=\"DISPLAY: none\"  rows=20 cols=75 WRAP=VIRTUAL name=\"content\">"+dat+"</TEXTAREA>";
          _s+="<"+"script>";
          _s+="document.frm.submit();";
          _s+="</"+"script>";
          _s+="</form>";
          _s+="</body></html>";
  newWin.document.write(_s);
  //newWin.document.close();
}


function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1
var Invalid  = "Your e-mail address does not appear to be valid. Please make sure that your address contains the '@' symbol, that there are no spaces in your address and that you have only entered one address."

// How many '@' signs are there
var numOfAts = 0
for(i = 0; i < Temp.value.length; i++){
    theChar = Temp.value.charAt(i);
    if(theChar == '@'){
        numOfAts = numOfAts + 1
    }
}

if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1) ||                  // No empty spaces permitted
    (numOfAts > 1))                    // No more than one '@' sign
   {
      EmailOk = false
      alert(Invalid)
      Temp.focus()
   }
return EmailOk
}


function checkForBadChars(args) //Can take one or more textareas as arguments
{
   if(parseInt(navigator.appVersion) >= 4 ) //charCodeAt is only supported in the 4.0 browsers
   {
      var theOutput = "";
      var openSpan = "<SPAN STYLE='background-color: yellow'>";
      var closeSpan = "</SPAN>";
      var dataIsOk = true;

      for(var j = 0; j < arguments.length; j++)
      {
         theOutput = theOutput + "<P>"; //Separate each textarea in the preview
         var theText = arguments[j].value;

         for(var i = 0; i < theText.length; i++)
         {
            var theChar = theText.charAt(i);
            var theCharCode = theText.charCodeAt(i);
            if(theCharCode > 127)
            {
               theOutput = theOutput + openSpan + theChar + closeSpan;
               dataIsOk = false;
            }
            else
            {
               theOutput = theOutput + theChar;
            }
         }
      }

      if(!dataIsOk)
      {
         var docHead = "<HTML><HEAD><TITLE>Character Errors</TITLE></HEAD><BODY BGCOLOR='#ffffff' onBlur='window.close();'>";
	     var alertMsg = "<FONT COLOR='red'><H2><I>Submission Error</I></H2></FONT><P><I>The submission program does not recognize the characters highlighted in <SPAN STYLE='background-color: yellow'>yellow</SPAN>.</I></P>" +
	                    "<P><I>All special characters, such as '&#177;', and Greek characters, such as '<FONT FACE='Symbol'>a</FONT>', must be entered using the special bracket codes from the list of supported special characters.</I></P><P><I>You wrote:</I></P></I>";
	     var openBlock = "<BLOCKQUOTE>";
	     var closeBlock = "</BLOCKQUOTE>";
	     var closeLink = "<BR><BR><CENTER><A HREF='javascript:window.close();'>Close window</A></CENTER>";
		 var docFoot = "</BODY></HTML>";

         window.open("../conversions.php","conversions","scrollbars,resizable,height=350,width=600");
         var window2 = window.open("","errorwindow","width=600,height=450,scrollbars");
         window2.document.open();
         window2.document.write(docHead + alertMsg + openBlock + theOutput + closeBlock + closeLink + docFoot);
         window2.document.close();
         return false;
      }
      else
      {
         return true;
      }
   }
}


function checkCCNum(){

   var ccnum = document.ccform.cc_number.value;
   numIsGood = true;

   for(var i = 0; i < ccnum.length; i++){

      var item = ccnum.charAt(i);
      if(isNaN(item) || item == " ") {
         numIsGood = false
      }
   }

   if(!numIsGood){

      alert("Please enter only numbers in this field (do not enter spaces or other non-numeric characters).");
      document.ccform.cc_number.focus();
      return false;
   }
}


function remote(URLpage,URLtitle,Wheight,Wwidth,Wmenu){

 LeftPosition = (screen.width) ? (screen.width-Wwidth)/2 : 0;
 TopPosition = (screen.height) ? (screen.height-Wheight)/2 : 0;
 settings = 'width='+Wwidth+',height='+Wheight+',top='+TopPosition+',left='+LeftPosition+',scrollbars,resizable';
 if (Wmenu) {
  settings  = settings+',menubar';
 }
  remote_win = window.open(URLpage,URLtitle,settings)
}

function SelectOption ( where,which ){
 var f = document.DataForm;

 for ( i = 0; i < f.elements.length; i++ ){
  orderElement = f.elements[i];
  if ( orderElement.name == where ){
   for ( var j=0; j<orderElement.length; j++ ){
    if (eval(orderElement.options[j].value==which)){
     orderElement.options[j].selected = true;
    }
   }
  }
 }
}

function presCheck ( ){
 var f = document.DataForm["au_pres"];
   if (f!=null){
 	for ( i = 0; i < f.length; i++ ){
 	  f[i].checked = false;

  	}
   }
}
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_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 MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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];}}
}


