
/**
* These Javascript functions drives many of the main abstract functions.
*
* Page assembled by C. West 10/24/07
*
*/
 
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_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];}}
}

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

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_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style)
    {
		obj=obj.style;v=(v=='show')?'visible':(v=='hide')?'hidden':v;
	}
    obj.visibility=v;
    obj.display='inline';
    }
}


function MM_showHideLayers2() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3)
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style)
    {
		obj=obj.style;v=(v=='show')?'inline':(v=='hide')?'none':v;
	}
    //obj.visibility=v;
    obj.display=v;
    }
}


/*
function MM_changeProp(objId,x,theProp,theValue) {
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}

if (navigator.appName == "Microsoft Internet Explorer")
{ } else {
MM_changeProp('absleft','','margin-right','420','DIV')
}
*/



function simple_actionSubmitA()
{
	  var bname = navigator.appVersion;
	  if (bname.indexOf("Safari")<0)
	  {
		  document.myforma.target='_blank'
	  }
	  document.myforma.submit();
	  return false;
}


function simple_actionDeterminatorA()
{

	  if(document.myforma.fn.value == ""){
			alert ("Please select an Article Option");
			return false;
	  } else if(document.myforma.fn.options[0].selected == true ) {
			document.myforma.target = "Scitation";
			myArt=window.open('','Scitation','height=600,width=660,scrollbars=yes,resizable=yes,top=30,left=150');
			myArt.focus();
			document.myforma.submit();
			return true;
	  }

	  var bname = navigator.appVersion;
	  if (bname.indexOf("Safari")<0)
	  {
	  	document.myforma.target='_blank'
	  }
	  document.myforma.submit();
	  return false;
}

function simple_actionDeterminatorB()
{

	  if(document.myformb.fn.value == ""){
			alert ("Please select an Article Option");
			return false;
	  }
	  
	  var bname = navigator.appVersion;
	  if (bname.indexOf("Safari")<0)
	  {
		  document.myformb.target='_blank'
	  }
	  document.myformb.submit();
	  return false;
}


function simple_actionDeterminatorC()
{

	  if(document.myformc.fn.value == ""){
			alert ("Please select an Article Option");
			return false;
	  }
	  if(document.myformc.fn.value == "view_coins"){
			var cvips = document.myformc.SelectCheck.value;
			var directurl = "/journals/help_system/getabs/actions/viewCOinS.jsp?cvips=" + cvips;
			myArt=window.open(directurl,'COinS','height=600,width=700,scrollbars=yes,resizable=yes,top=30,left=150');
			myArt.focus();
			return false;
	  }
	  
	  var bname = navigator.appVersion;
	  if (bname.indexOf("Safari")<0)
	  {
		  document.myformc.target='_blank'
	  }
	  document.myformc.submit();
	  return false;
}



function howManyChecked(whichForm,whichCheckBoxArray,myMax,myMin)
{
	document.myform.action = '/getabs/servlet/GetCitation';
	var _countChecked = 0;
	var err = 0;
	var selections = new Array;
	selections = document.myform.SelectCheck; //document[whichForm][whichCheckBoxArray];
	//alert("selections: " + selections + " | size: " + selections.length);
	
	/* iterate through all the elements in the checkbox array */
	for(i=0;i<document[whichForm][whichCheckBoxArray].length;i++)
	{
		/* and check to see if each is checked */
		if(document[whichForm][whichCheckBoxArray][i].checked==true)
			/* if it is, increment a counter */
			{ _countChecked++; }
	}

	/* in case there is only 1 checkbox */
	var docLength = eval("document."+[whichForm]+"."+[whichCheckBoxArray]+".length");
	if (typeof docLength == 'undefined') {
		if (eval("document."+[whichForm]+"."+[whichCheckBoxArray]+".checked")) {
			_countChecked = 1;
			//alert(_countChecked)
		}
	}
	
	
	
	
	
	/* is the count too high? */
	if(_countChecked > myMax)
		{ alert('You have selected '+ _countChecked + ' articles.  Please select no more than '+myMax+ ' articles at a time.');
			err = 1;}
	/* of is the count too low */
	else if(_countChecked < myMin)
		{ alert('You must select at least '+myMin+' article.');
			err = 1;}
	if (err == 1) { return false; }


	
	if( (document.myform.fn.value == "" ) || (document.myform.fn.value == "multi" ) ){
	alert ("Please select an Article Option");
	return false;
	} 
	
	
	
	if(document.myform.fn.options[3].selected == true ) {

	document.myform.action = '/myscitation/addToMyArticles-submit.do';
	
	document.myform.target = "Scitation";
	myArt=window.open('','Scitation','height=600,width=660,scrollbars=yes,resizable=yes,top=50,left=50,toolbar=yes,location=yes,menubar=yes');
	myArt.focus(); 
	document.myform.submit();
	
	return false;
	}
	
	
	var bname = navigator.appVersion;
	if (bname.indexOf("Safari")<0)
	{
		document.myform.target='_blank'
	}
	document.myform.submit();
	return false;
	

}

function PrintPage(){

if (window.print) {  window.focus(); window.print(); }
else {  alert('This script does not work in your browser');  }
//history.back();
//return false;
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
        
        
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 




function load_focus_window(pagetoLoad)
{
	rewritePageElement('/journals/help_system/getabs/actions/loading.jsp', '', 'popup_viewingpane', '');
	
	rewritePageElement(pagetoLoad, '', 'popup_viewingpane', '');
	
	MM_showHideLayers('popup_backdrop','','show');
	opacity('popup_backdrop', 0,50, 200);
	
	MM_showHideLayers('popup_viewingpane','','show');
	opacity('popup_viewingpane', 0,100, 200);
	
	
}

function close_focus_window()
{
	opacity('popup_backdrop', 50,0, 100);
	setTimeout('MM_showHideLayers(\'popup_backdrop\',\'\',\'hide\')',300);
	
	opacity('popup_viewingpane', 100,0, 200);
	setTimeout('MM_showHideLayers(\'popup_viewingpane\',\'\',\'hide\')',200);
	
	rewritePageElement('/journals/help_system/getabs/actions/loading.jsp', '', 'popup_viewingpane', '');
}


function clickAbstract(citid) {

	if (document.getElementById("abs_sci")) { document.getElementById("abs_sci").style.backgroundColor = "#f8f8f8"; }
	if (document.getElementById("abs_cross")) { document.getElementById("abs_cross").style.backgroundColor = "#f8f8f8"; }
	if (document.getElementById("abs_all")) { document.getElementById("abs_all").style.backgroundColor = "#f8f8f8"; }
	if (document.getElementById("citid")) { document.getElementById(citid).style.backgroundColor = "#e9e9e9"; }
}


function clickTab(citid) {

	if (document.getElementById("abs_tab"))
	{
		document.getElementById("abs_tab").className = "nav_unselected";
	}
	if (document.getElementById("refs_tab"))
	{
		document.getElementById("refs_tab").className = "nav_unselected";
	}
	if (document.getElementById("cit_tab"))
	{
		document.getElementById("cit_tab").className = "nav_unselected";
	}
	if (document.getElementById("supp_tab"))
	{
		document.getElementById("supp_tab").className = "nav_unselected";
	}
	
	document.getElementById(citid).className = "nav_selected";

}

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}


function convertToMobileCSS()
{
	document.getElementById("absbottom_stand").style.display="inline";
	document.getElementById("absbottom_refs").style.display="inline";
	document.getElementById("absbottom_citings").style.display="inline";
	MM_showHideLayers2('absbottom_refs','','show');
	MM_showHideLayers2('absbottom_stand','','show');
	MM_showHideLayers2('absbottom_citings','','show');
	setActiveStyleSheet('abs_mobile');
}

function convertBackToStandardCSS()
{
	document.getElementById("absbottom_stand").style.display="inline";
	document.getElementById("absbottom_refs").style.display="none";
	document.getElementById("absbottom_citings").style.display="none";
	/*
	MM_showHideLayers('absbottom_refs','','show');
	MM_showHideLayers('absbottom_stand','','hide');
	MM_showHideLayers('absbottom_citings','','hide');
	*/
	setActiveStyleSheet('default');
	clickTab('abs_tab')
}

function keyclosewindow(e) 
{
	if (e.keyCode==27) 
	{
		close_focus_window();
	}
}

function initializeObjects()
{
	/*
	document.getElementById("absbottom_refs").style.display="inline";
	document.getElementById("absbottom_citings").style.display="inline";
	document.getElementById("absbottom_stand").style.display="inline";
	*/
}

function addOpenSearch(name,ext,cat,pid,meth)
{
  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
    } else {
      window.external.AddSearchProvider(
        "http://mycroft.mozdev.org/installos.php/" + pid + "/" + name + ".xml");
    }
  } else {
    alert("You will need a browser which supports OpenSearch to install this plugin.");
  }
}


function open_printversion(url)
{
	window.open(url,'_blank','width=800,height=900,status=1,scrollbars=1,resizable=1');
}


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



function return_to_emailcolleague(cvips, title, soc)
{
	var emailuri = "/journals/help_system/getabs/actions/email_colleague_formB.jsp?cvips="+cvips+"&title="+title+"&soc="+soc;
	$("#colleagueemailaction").load(emailuri);
	return false;
}

function howManyCheckedB(whichForm,whichCheckBoxArray,myMax,myMin)
{
	document.myform.action = '/getabs/servlet/GetCitation';
	var _countChecked = 0;
	var err = 0;

	alert("SIZE (document."+whichForm+"."+whichCheckBoxArray+"): " + document[whichForm][whichCheckBoxArray].length);
	alert("SIZE2: " + document.myform.SelectCheck.length);

	/* iterate through all the elements in the checkbox array */
	for(i=0;i<document[whichForm][whichCheckBoxArray].length;i++)
	{
		/* and check to see if each is checked */
		if(document[whichForm][whichCheckBoxArray][i].checked==true)
			/* if it is, increment a counter */
			{ _countChecked++; }
	}

	/* in case there is only 1 checkbox */
	var docLength = eval("document."+[whichForm]+"."+[whichCheckBoxArray]+".length");
	if (typeof docLength == 'undefined') {
		if (eval("document."+[whichForm]+"."+[whichCheckBoxArray]+".checked")) {
			_countChecked = 1;
			//alert(_countChecked)
		}
	}



	/* is the count too high? */
	if(_countChecked > myMax)
		{ alert('You have selected '+ _countChecked + ' articles.  Please select no more than '+myMax+ ' articles at a time.');
			err = 1;}
	/* of is the count too low */
	else if(_countChecked < myMin)
		{ alert('You must select at least '+myMin+' article.');
			err = 1;}
	if (err == 1) { return false; }



	if( (document.myform.fn.value == "" ) || (document.myform.fn.value == "multi" ) ){
	alert ("Please select an Article Option");
	return false;
	}



	if(document.myform.fn.options[3].selected == true ) {

	document.myform.action = '/myscitation/addToMyArticles-submit.do';

	document.myform.target = "Scitation";
	myArt=window.open('','Scitation','height=600,width=660,scrollbars=yes,resizable=yes,top=50,left=50,toolbar=yes,location=yes,menubar=yes');
	myArt.focus();
	document.myform.submit();

	return false;
	}


	var bname = navigator.appVersion;
	if (bname.indexOf("Safari")<0)
	{
		document.myform.target='_blank'
	}
	document.myform.submit();
	return false;


}

function highlightterm(mysearchterm,divid, color)
{
	var htmlinobj = $(divid).html();
	var varName = new RegExp(mysearchterm, "gi");
	if (color=="") color="yellow";
	for (i = 0; i < $(divid).length; i++)
	{
		var htmlinobj = $(divid+":nth("+i+")").html(); 
		htmlinobj = htmlinobj.replace(varName,"<span style=\"background-color:"+color+";\">"+mysearchterm+"</span>");
		$(divid+":nth("+i+")").html(htmlinobj);
	}
}





/* **********************************************************************************
	Function that manages downloading or viewing a citation from
	selected articles. renders a DHTML popup based on selection passed though.
	C.West 12.15.08
*********************************************************************************** */
function constructDLbox(action, cvips) {

	var allDialogs = [];
	options = $.extend({title: action + " Citation"}, {});
	var domBody = "";
	var onsubmitlocation = "downloadarts_action()"; 
	if (action=="View") { onsubmitlocation = "viewarts_action()";  }
	var formname = "myformb"; 
	if (action=="View") { formname = "myformc";  }
	
	domBody = "<table style=\"margin-left:20px\" width=\"525\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">" + 
	"<tr><td valign=\"top\" width=\"175\">" + 
		"<form name=\"myforma\" action=\"/myscitation/addToMyArticles-submit.do\" method=\"get\" onsubmit=\"return simple_actionSubmitA()\">" + 
		"Add Citation to:<br/>"+
		"<input type=\"image\" src=\"/journals/help_system/getabs/images/myscilogo.gif\" border=\"0\" alt=\"Submit to MyScitation\" />" +
		"<input type=\"hidden\" name=\"fn\" value=\"Add_myArticles\" />" +
		"<input type=\"hidden\" name=\"source\" value=\"scitation\" />" +
		"<input type=\"hidden\" name=\"PrefType\" value=\"ARTICLE\" />" +
		"<input type=\"hidden\" name=\"PrefAction\" value=\"Add Selected\" />" +
		"<input type=\"hidden\" name=\"SelectCheck\" value=\""+cvips+"\" />" +
		"</form>" +
	"</td>"; 
	
	domBody += "<td valign=top width=\"175\">" +
		"<form name=\"myformb\" action=\"/getabs/servlet/GetCitation\" method=\"get\" onsubmit=\"return simple_actionDeterminatorB()\">"+

		"<INPUT type=\"HIDDEN\" name=\"source\" value=\"scitation\">" +

		"<INPUT type=\"HIDDEN\" name=\"downloadcitation\" value=\" Go \">" + 

		"<INPUT type=\"HIDDEN\" name=\"source\" value=\"scitation\">" + 

		"<INPUT type=\"hidden\" name=\"SelectCheck\" value=\"" + cvips +"\" />" + 
		"<select name=\"fn\" class=\"art-opt-select\">" + 

			"<option value=\"open_bibtex2\">BibTeX</option>" + 

			"<option value=\"open_endnote\">EndNote &reg; (generic)</option>" + 

			"<option value=\"open_isi\">EndNote &reg; (RIS)</option>" + 

			"<option value=\"open_medline\">Medline</option>" + 

			"<option value=\"open_aip\">Plain Text</option>" + 

			"<option value=\"open_refworks\">RefWorks</option>" + 

		"</select>" + 

		"<br/><input type=\"submit\" name=\"Submit\" value=\"Download\" /></form></td>";


	domBody += 	"<td valign=top width=\"175\">" +  
		"<form name=\"myformc\" action=\"/getabs/servlet/GetCitation\" method=\"get\" onsubmit=\"return simple_actionDeterminatorC()\">"+

		"<INPUT type=\"HIDDEN\" name=\"source\" value=\"scitation\">" +

		"<INPUT type=\"HIDDEN\" name=\"downloadcitation\" value=\" Go \">" + 

		"<INPUT type=\"HIDDEN\" name=\"source\" value=\"scitation\">" + 

		"<INPUT type=\"hidden\" name=\"SelectCheck\" value=\"" + cvips +"\" />" + 
		"<select name=\"fn\" class=\"art-opt-select\">" + 

			"<option value=\"view_coins\">COinS</option>" + 

			"<option value=\"view_bibtex2\">BibTeX</option>" + 

			"<option value=\"view_endnote\">EndNote &reg; (generic)</option>" + 

			"<option value=\"view_isi\">EndNote &reg; (RIS)</option>" + 

			"<option value=\"view_medline\">Medline</option>" + 

			"<option value=\"view_aip\">Plain Text</option>" + 

			"<option value=\"view_refworks\">RefWorks</option>" + 
		"</select><br/>" + 

		"<input type=\"submit\" name=\"Submit\" value=\"View\" /></form></td>" + 

		"</tr></table>";
	
	/* creates the boxy		*/
	var dialog = new Boxy(domBody, options);
	allDialogs.push(dialog);
	
	return false;
}

function downloadarts_action()
{
	// IE detection
	if(navigator.userAgent.toLowerCase().indexOf("msie") != -1) { isIE = true; } else { isIE = false; }
	var bname = navigator.appVersion;
	if (bname.indexOf("Safari")<0)
	{
	  document.myformb.target='_blank'
	}
	document.myformb.submit();
	return false;
}


function colleague_formcheck2(thisform, cvips)
{
	var ce = thisform.colleagueemail.value;
	var cn = thisform.colleaguename.value;
	var se = thisform.senderemail.value;
	var sn = thisform.sendername.value;
	var mes =thisform.sendermessage.value;

	if ((ce == null) || (ce == "")) {
		alert("Please enter your colleague's email.");
		return false;
	}
	if ((ce.indexOf(".") < 0) || (ce.indexOf("@") < 0)) {
		alert("Please enter a valid colleague email address.");
		return false;
	}

	if ((cn == null) || (cn == "")) {
		alert("Please enter your colleague's name.");
		return false;
	}
	if ((sn == null) || (sn == "")) {
		alert("Please enter your name, so that your colleague knows who sent this email.");
		return false;
	}

	if ((se == null) || (se == "")) {
		alert("Please enter your (the sender) email.");
		return false;
	}
	if ((se.indexOf(".") < 0) || (se.indexOf("@") < 0)) {
		alert("Please enter a valid email address for yourself.");
		return false;
	}
	if (mes.length > 200) {
		alert("Message cannot be larger than 200 pixels. You have " + mes.length);
		return false;
	}

    var appendcvips = ""; 
	appendcvips = "/journals/help_system/getabs/actions/submit_emailcolleague_jquery.jsp?cvips=" + cvips;
	$(thisform).html("<div style=\"text-align:center;\"><img src=\"/journals/journal_images/ajax-loader.gif\"></div>");
	$.post(appendcvips, { colleagueemail:ce, colleaguename:cn, sendername:sn, senderemail:se, sendermessage:mes }, 

		   function(data){
		   		$(thisform).html("<div style=\"text-align:center;\">" + data + "</div>");
	} ); 

return false;
}


function emailAbstracts(cvips) {
	var allDialogs = [];
	options = $.extend({title: "Email Articles"}, {});
	domBody = "<form name=\"emailform\" onSubmit=\"return colleague_formcheck2(this, '"+cvips+"');\">";

	domBody += "<INPUT type=\"hidden\" name=\"cvips \" value=\"" + cvips +"\" />";
	domBody += 	"<table width=\"500\">" +

		"<tr><td width=\"40%\" align=right>Colleague's Email: </td><td width=\"60%\"><input name=\"colleagueemail\" type=\"text\" size=\"35\" /></td></tr>"+

		"<tr><td width=\"40%\" align=right>Colleague's Name: </td><td width=\"60%\"><input name=\"colleaguename\" type=\"text\" size=\"35\" /></td></tr>"+

		"<tr><td width=\"40%\" align=right>Your Name: </td><td width=\"60%\"><input name=\"sendername\" type=\"text\" size=\"35\" /></td></tr>"+

		"<tr><td width=\"40%\" align=right>Your Email: </td><td width=\"60%\"><input name=\"senderemail\" type=\"text\" size=\"35\" /></td></tr>"+

		"<tr><td width=\"40%\" align=right>Message:<br><i>Max: 200 characters</i>&nbsp;</td><td width=\"60%\"><textarea name=\"sendermessage\" cols=\"27\" rows=\"2\" maxlength=\"200\"></textarea></td></tr>"+

		"<tr><td></td><td><input type=\"submit\" name=\"Submit\" value=\"Send Abstract\" /></td></tr>"+

		"</table>"+

		"</form>";

	/* creates the boxy		*/
	var dialog = new Boxy(domBody, options);
	allDialogs.push(dialog);
	return false;
}

function emailErrAlerts(cvips) {
	var allDialogs = [];
	options = $.extend({title: "Email Articles"}, {});
	domBody = "<form name=\"erratasignup\" onSubmit=\"return errata_formcheck2(this, '"+cvips+"');\">" + 
		"<input type=\"hidden\" name=\"cvips\" value=\""+cvips+"\" />" + 
		"<table width=\"100%\"><tr>" + 
			"<td width=\"40%\" align=right>Email Address: </td><td width=\"60%\" align=\"left\"><input name=\"email\" type=\"text\" size=\"35\" /></td>" + 
		"</tr><tr>" + 
			"<td width=\"40%\" align=right>Confirm Email: </td><td width=\"60%\" align=\"left\"><input name=\"email2\" type=\"text\" size=\"35\" /></td>" + 
		"</tr><tr>" + 
			"<td></td><td align=\"left\"><input type=\"submit\" name=\"Submit\" value=\"Submit\" /></td>" + 
		"</tr></table></form>";
	/* creates the boxy		*/
	var dialog = new Boxy(domBody, options);
	allDialogs.push(dialog);
	return false;
}



function errata_formcheck2(thisform, cvips)
{
	var e = thisform.email.value;
	var cvips = thisform.cvips.value;
	var e2 = thisform.email2.value;

	if ((e == null) || (e == "") || isblank(e)) {
		alert("Please enter your email.");
		return false;
	}

	if ((e != e2)) {
		alert("Email Addresses do not match.");
		return false;
	}

	if ((e.indexOf(".") < 0) || (e.indexOf("@") < 0)) {
		alert("Please enter a valid email address.");
		return false;
	}

    var appendcvips = ""; 
	appendcvips = "/journals/help_system/getabs/actions/submit_emailalertsB.jsp?cvips="+cvips;
	$(thisform).html("<div style=\"text-align:center;\"><img src=\"/journals/journal_images/ajax-loader.gif\"></div>");
	$.post(appendcvips, { email:e }, 

		   function(data){
		   		$(thisform).html("<div style=\"text-align:center;\">" + data + "</div>");
	} ); 

	return false;
}

function popupLoginForm(redirecturl) 
{
	var allDialogs = [];
	options = $.extend({title: "Subscribers Log In Here"}, {});
	domBody = 	"<form name=\"theForm\" method=\"post\" action=\"/eRights/servlet/Login\">";
	domBody +=	"<input type=\"hidden\" name=\"badLoginURL\" value=\"/error/badusername.jsp\" />" + 

				"<input type=\"hidden\" name=\"redirectURL\" value=\""+redirecturl+"\" />";

 	domBody +=	"<p>If you are a registered subscriber, please sign in below:</p>" + 

				"<table width=\"500\">" + 
				"<tr><td width=\"40%\" align=right>Username: </td><td width=\"60%\" align=\"left\"><input class=\"SciFormInput\" type=\"text\" name=\"username\" size=\"25\" /></td></tr>" + 

"<tr><td width=\"40%\" align=right>Password: </td><td width=\"60%\" align=\"left\"><input class=\"SciFormInput\" type=\"password\" name=\"password\" size=\"25\" /></td></tr>" + 

				"<tr><td width=\"40%\" align=right></td><td width=\"60%\" align=\"left\"><input border=\"0\" type=\"submit\" name=\"submit1\" value=\"Sign In\" class=\"FormButton_120\" /></td></tr>" + 

				"<tr><td></td><td width=\"60%\" align=\"left\"><a class=\"forgot\" href=\"http://scitation-beta.aip.org/accounts/forgotPassword.jsp\">Forgot your password?</p></td></tr>" + 

				"</table>" + 

				"</form>";

	/* creates the boxy		*/
	var dialog = new Boxy(domBody, options);
	allDialogs.push(dialog);
	return false;
}
