if (navigator.appName == "Microsoft Internet Explorer") {
document.write ("<link href=/styles_and_js/general.css type=text/css rel=STYLESHEET>")
}
else {document.write ('<link href=/styles_and_js/general_ns.css type=text/css rel=STYLESHEET>')
}

//change images script
function change(name,pic){  if (document.images) { document.images[name].src=pic} return true;}

function go(newloc){location = eval("newloc");  }



function popup(url,name,width,height,scrolls,thisForm)
{
    var extra='';
    if(scrolls==true)   {
    extra='scrollbars=yes';
    }
    else if(scrolls==false) {
      extra='scrollbars=no';
    }
    if (thisForm) {
     //See if we are going to submit the search to Scirus
      if (name == 'ScirusPopUp') {
        url+='?query='+thisForm.query.value;
        //url+='&cl='+thisForm.cl.value;
        if (thisForm.cl.checked)     {
          url+='&cl='+thisForm.cl.value;
        } else {
          url+='&cl=jc108';
        }
        extra+=',menubar,toolbar,location,status';
      }
    }
    //See if we are going to pop up the Science Direct site
    if (name == 'SDPopUp') {
      extra+=',menubar,toolbar,location,status';
    }

    if(width && height) {extra+=',width='+width+',height='+height;}
    extra+=',resizable';

    var win=window.open('',name,extra);

    win.focus();
    win.location.replace(url);

}

function targetopener(mylink, closeme, closeonly)
{   
if (win.opener == null) win.opener = self;
if (! (window.focus && window.opener))return true;window.opener.focus();
if (! closeonly)window.opener.location.href=mylink.href;
if (closeme)window.close();return false;
}

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage() {
  if (pr) // NS4, IE5
    window.print()
  else if (da && !mac) // IE4 (Windows)
    vbPrintPage()
  else // other browsers
    alert("Sorry, your browser does not support this feature.");
  return false;
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}


function AreYouSure (message, y_url) {
    if (confirm(message) ) {
        parent.location=y_url;
    } else {
      return false ;
    }
}

function ECheck(emailform)
{
if (emailform.toAddress.value == "") {
alert("Please type a valid email");
emailform.toAddress.focus(); 
return false;
}
var mail=emailform.toAddress.value
   if (mail.indexOf("@") == -1) 
    {
        alert("Please type a valid email");
        emailform.toAddress.focus(); 
        return false;
    }

return true;
}


// When a user chooses one of their non Elsevier Journals this script
// sends them to the URL for that journal
function jumpToOptionUrl(targ,selObj,restore){ //v3.0
  if (!selObj.selectedIndex == 0) {
     eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
     if (restore) selObj.selectedIndex=0;
  }
}

// This function over rides the form action attribute value. It is meant to fire
// on an onClick event
function dynamicFormPost(targ,formPos,doPost,postName) {
  if (doPost=="N") {
     document.forms[formPos].postName.value = "";
     for(var i = 0; i < document.forms[formPos].length; i++) {
     var e = document.forms[formPos].elements[i];
     if (e.type == "text") {
        e.optional = true;
        continue ;
     }
     }
  } else {
     document.forms[formPos].postName.value = postName ;
  }
  document.forms[formPos].action = targ;
}

// A utility function that returns true if a string contains only
// whitespace characters.
function isblank(s) {
    for(var i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// This is the function that performs form verification. It is invoked
// from the onsubmit event handler. The handler should return whatever
// value this function returns.
function verify(f) {
    var msg;
    var empty_fields = "";
    var errors = "";

    // Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // verify that they are numbers and in the right range.
    // If the element has a "numeric" property defined, verify that
    // it is a number, but don't check its range.
    // Put together error messages for fields that are wrong.
    for(var i = 0; i < f.length; i++) {
    var e = f.elements[i];
    if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {
        // first check if the field is empty
        if ((e.value == null) || (e.value == "") || isblank(e.value)) {
        empty_fields += "\n      " + e.label;
        continue;
        }

        // Now check for fields that are supposed to be numeric.
        if (e.numeric || (e.min != null) || (e.max != null)) {
        var v = parseFloat(e.value);
        if (isNaN(v) ||
            ((e.min != null) && (v < e.min)) ||
            ((e.max != null) && (v > e.max))) {
            errors += "- The field " + e.name + " must be a number";
            if (e.min != null)
            errors += " that is greater than " + e.min;
            if (e.max != null && e.min != null)
            errors += " and less than " + e.max;
            else if (e.max != null)
            errors += " that is less than " + e.max;
            errors += ".\n";
        }
        }
    }
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted.
    // Otherwise return true.
    if (!empty_fields && !errors) return true;

    msg  = "______________________________________________________\n\n"
    msg += "Your request was not submitted because of the following error(s).\n";
    msg += "Please correct these error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
    msg += "The following required field(s) are empty:"
        + empty_fields + "\n";
    if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}


