//Commented for Rel6.0
/*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, formname, y_url) {
    if (confirm(message) ) {
        document.forms[formname].submit();
        //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 = "";
    /*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;
}


function validateEMOPAndSubmit(f){
	var isError = false;
	if ( !verify(f) ) {
		isError = true;
	}
	
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	
	//If any error, reset the form values for GET request 
	if(isError){
		f.isError.value = isError;
		f.postName.value = "";
		f.guid.value = "";
		f.refPage.value = "";
		f.method = "get";
		f.action = sPage;
		f.submit();
		return false;
	}
	else{
		return true;
	}
}

function detectHeader(pubID) {
				if(!opener) {
				header = "<td width=\"21\"><a href=\"/JournalDetail.html?PubID="+
                                                 pubID+
                                                 "&Precis=DESC\">"+
						 "<img src=\"/img/icon_home.gif\" width=\"21\" height=\"20\" alt=\"\" border=\"0\"></a></td>"+
						 "<td width=\"83\"><a href=\"/JournalDetail.html?PubID="+
                                                 pubID+
                                                 "&Precis=DESC\">"+
						 "<img src=\"/img/home_text.gif\" width=\"33\" height=\"11\" vspace=\"5\" hspace=\"5\" alt=\"\" border=\"0\"></a></td>";
						 }
						 else
						 {
						 header = "<td width=\"21\"><img src=\"/img/pixel.gif\" width=\"21\" height=\"1\" alt=\"\"></td>"+
						 		  "<td width=\"83\"><img src=\"/img/pixel.gif\" width=\"83\" height=\"1\" alt=\"\"></td>";
						 }
					document.write(header);
}
						
function detectFooter()	{
				if(!opener){
					footer = "<img src=\"/img/pixel.gif\" width=\"10\" height=\"10\">"
							}
						else
							{
							footer = "<a href=\"#\" onClick=\"parent.opener.focus();parent.close();return false;\"><img src=\"/img/closewindow.gif\" width=\"88\" height=\"19\" border=\"0\" alt=\"close window\" hspace=\"10\" vspace=\"10\" /></a>";
							}
					document.write(footer);
}	

function copyrightYear()	{
					document.write("2004");
}

/* This function is used for mailing AuthorSupport in COntactUs pop-up */

function MailtoSupport(support) {
    var subject = '';
    var body = '';
    subject = 'Author Services - Author request';
    body = 'To help provide you with a faster response, please supply the following information: ' + "\n\n"
           + 'Full journal title: ' + "\n\n"
           + 'Full article title (if applicable): ' + "\n\n"
           + 'Reference number (if applicable): ' + "\n\n"
           + 'Full description of the query/problem (if you have received an error message, please provide ' + "\n"
		   + 'a copy of this message): ' + "\n\n";
   var href = 'mailto:support@elsevier.com?Subject=' + escape(subject) + '&Body=' + escape(body) + '';
    document.location.href = href;
 }

