
/**
* These Javascript functions drives many of the main abstract functions.
*
* Page assembled by C. West 10/24/07
*
*/
 
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


var panelobj = document.getElementById("popup_viewingpane");
var backdropobj = document.getElementById("popup_backdrop");

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.display=v;
    }
}


/* **********************************************************************************
	Main selection mechanism for DBT article actions
	C.West 5.1.08
*********************************************************************************** */
function submitDbt(action) {

	if (action == "showall")
	{
		document.articleactionform.viewonly.value="0"
	}
	else if (action == "hideabstracts")
	{
		document.articleactionform.showabstracts.value="0"
	}
	else
	{
		document.articleactionform[action].value="1";
	}
	
	document.articleactionform.submit();
}



/* **********************************************************************************
	Function that calculates how many articles are selected.
	C.West 6.9.08
*********************************************************************************** */
function countSelected() {
	var countChecked = 0;
   	for(s=0;s<20;s++)
	{
		var selector = "artsel_" + s;
		if (document.articleactionform[selector])
		{
			if (!document.articleactionform[selector].length)
			{
				if (document.articleactionform[selector].checked==true)
				{
					countChecked++;
				}
			}
			for(i=0;i<document.articleactionform[selector].length;i++)
			{
				if (document.articleactionform[selector][i].checked==true)
				{
					countChecked++;
				}
			}
		}
	} 
	return countChecked;
}


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

	var allDialogs = [];
	options = $.extend({title: action + " Selected Articles"}, {});
	var domBody = "";

	if (countSelected() == 0)
	{
		domBody = "<p>Please Select at least one article</p>";
	}
	else if (countSelected() > 20)
	{
		domBody = "<p>You cannot select more then 20 articles.</p>";
	}
	else 
	{
		var onsubmitlocation = "downloadarts_action()"; 
		if (action=="View") { onsubmitlocation = "viewarts_action()";  }
		var formname = "myformb"; 
		if (action=="View") { formname = "myformc";  }

		domBody = "<form name=\""+formname+"\" action=\"/getabs/servlet/GetCitation\" method=\"get\" onsubmit=\"return "+onsubmitlocation+"\">"+

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

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

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


		for(s=0;s<20;s++)
		{
			var selector = "artsel_" + s;
			if (document.articleactionform[selector])
			{
				if (!document.articleactionform[selector].length)
				{
					if (document.articleactionform[selector].checked==true)
					{
						domBody += "<INPUT type=\"hidden\" name=\"SelectCheck\" value=\"" + document.articleactionform[selector].value +"\" />";
					}
				}
				for(i=0;i<document.articleactionform[selector].length;i++)
				{
					if (document.articleactionform[selector][i].checked==true)
					{
						domBody += "<INPUT type=\"hidden\" name=\"SelectCheck\" value=\"" + document.articleactionform[selector][i].value +"\" />";
					}
				}
			}
		} 

		if (action=="Download")
		{
			domBody += 	"<tr><td>" +  
						"<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>" + 
							
							"<option value=\"mysci\">myScitation</option>" + 

						"</select>" + 

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

						"</form>";
		}
		if (action=="View")
		{
			domBody += 	"<tr><td>" +  
						"<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>" + 

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

						"</form>";
		}
		
	}

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



function showAbstracts()
{
	var selectcount = countSelected();
	for(s=0;s<20;s++)
	{
		var selector = "artsel_" + s;
		if (document.articleactionform[selector])
		{
			if (document.articleactionform[selector].length)
			{
				for(i=0;i<document.articleactionform[selector].length;i++)
				{
					if (document.articleactionform[selector][i].checked==true || selectcount == 0)
					{
						dbt_showAbstract(document.articleactionform[selector][i].value);
					}
				}

			} else { 
				dbt_showAbstract(document.articleactionform[selector].value);
			}
		}
	}	

	return false;
}

function hideTOCItem(action)
{
	var selectcount = countSelected();
	for(s=0;s<20;s++)
	{
		var selector = "artsel_" + s;
		var hidethissect = document.getElementById("section_" + s);
		if (document.articleactionform[selector])
		{
				
				if (document.articleactionform[selector].length)
				{
						var stick = 0;
						for(i=0;i<document.articleactionform[selector].length;i++)
						{
							var hidethisid = document.getElementById("art" + document.articleactionform[selector][i].value + "_" + s);
							//alert(hidethisid + " | art" + document.articleactionform[selector][i].value + "_" + s);
							if (hidethisid && action=="hide" && document.articleactionform[selector][i].checked==false && selectcount > 0)
							{
								hidethisid.className = "hiderow";
							} else { stick++; } 
							
							if (hidethisid && action=="show") {
								hidethisid.className="noselectrow";
								if (document.articleactionform[selector][i].checked==true)
								{
									hidethisid.className = "selectedrow";
								}
							}
						}
						
						if (stick==0)
						{
							hidethissect.className = "hiderow";
						}
				// This is the conditional to render a single item under a header ********************
				} else if (document.articleactionform[selector]) {
						var stick = 0;
						var hidethisid = document.getElementById("art" + document.articleactionform[selector].value + "_" + s);
						//alert("DOING THE SINGLE:" + document.articleactionform[selector].value);
						if (hidethisid && action=="hide" && document.articleactionform[selector].checked==false && selectcount > 0)
						{
							hidethisid.className = "hiderow";
						} else { stick++; } 
						
						if (hidethisid && action=="show") {
							hidethisid.className="noselectrow";
							if (document.articleactionform[selector].checked==true)
							{
								hidethisid.className = "selectedrow";
							}
						}

						if (hidethissect && stick==0)
						{
							hidethissect.className = "hiderow";
						}
						
				
				}				
		}
		
		if (action=="show") {
			if (hidethissect)
			{
			hidethissect.className = "articlesectionlisting";
			}
		}
	}	

	
}





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'
	}
	
	if(document.myformb.fn.value == "mysci"){
		document.myformb.action = '/myscitation/addToMyArticles-submit.do';
	}
	



	document.myformb.submit();
	return false;
}

function viewarts_action()
{
	// IE detection
	document.myformc.action = '/getabs/servlet/GetCitation';
	if(navigator.userAgent.toLowerCase().indexOf("msie") != -1) { isIE = true; } else { isIE = false; }
	var bname = navigator.appVersion;
	if (bname.indexOf("Safari")<0)
	{
	  document.myformc.target='_blank'
	}

	if(document.myformc.fn.value == "view_coins"){
		document.myformc.action = '/journals/help_system/getabs/actions/viewCOinS.jsp';
	}
	  
	document.myformc.submit();
	return false;
}




function loadbrowsedata(coden, selectedaction, browsevalue)
{


	// if year is selected, it will then find out all the volumes for that year, and populate it to the DOM.
	/*
	if (selectedaction=="year")
	{
		$.post('/journals/help_system/dbt/modules/requestDbtInfo.jsp', { coden:coden, selectedaction:selectedaction, value:browsevalue }, 

		   function(data){

		       alert("A");
		       var dataadd = "<option value=\"\" selected=\"selected\">---- Select Volume ----</option>" + data;
		       $("#browse_vol").html(dataadd);
		} );
	} */

	// if volume is selected, it will then find out all the issues for that year, and populate it to the DOM.
	if (selectedaction=="volume")
	{
		$.post('/journals/help_system/dbt/modules/requestDbtInfo.jsp', { coden:coden, selectedaction:selectedaction, value:browsevalue }, 

		   function(data){
		   		var idtopop = "#issuelisting-" + browsevalue;
		   		alert(idtopop);
		       	$(idtopop).html(data);
		} );
	}

	return false;
	
}





/* **********************************************************************************
	Function that adds a collection of articles to the cart
	Executes the post to cart through an AJAX call.
	C.West 6.23.08
*********************************************************************************** */
function addAbsToCart(cartserver) {


	var allDialogs = [];
	options = $.extend({title: "Add Selected Articles to Your Cart"}, {});
	var domBody = "";
	var artcount = countSelected();

	if (artcount == 0)
	{
		domBody = "<p>Please Select at least one article</p>";
		var dialog = new Boxy(domBody, options);
		allDialogs.push(dialog);
	}
	else if (artcount > 20)
	{
		domBody = "<p>You cannot select more then 20 articles.</p>";
		var dialog = new Boxy(domBody, options);
		allDialogs.push(dialog);
	}
	else 
	{

		var ticktock = 0;
		var appendform = "<input name=\"productVariationCount\" value=\""+artcount+"\" type=\"hidden\" />";

		for(s=0;s<20;s++)
		{
			var selector = "artsel_" + s;
			if (document.articleactionform[selector])
			{
				if (!document.articleactionform[selector].length)
				{
					if (document.articleactionform[selector].checked==true)
					{
						appendform+="<input name=\"cartItem["+ticktock+"].remoteSite\" value=\"QAB\" type=\"hidden\" />";
						appendform+="<input name=\"cartItem["+ticktock+"].quantity\" value=\"1\" size=\"2\" maxlength=\"3\" type=\"hidden\" />";
						appendform+="<input name=\"cartItem["+ticktock+"].skuID\" value=\""+document.articleactionform[selector].value+"\" type=\"hidden\" />";
						ticktock++;
					}
				}
				for(i=0;i<document.articleactionform[selector].length;i++)
				{
					if (document.articleactionform[selector][i].checked==true)
					{
						appendform+="<input name=\"cartItem["+ticktock+"].remoteSite\" value=\"QAB\" type=\"hidden\" />";
						appendform+="<input name=\"cartItem["+ticktock+"].quantity\" value=\"1\" size=\"2\" maxlength=\"3\" type=\"hidden\" />";
						appendform+="<input name=\"cartItem["+ticktock+"].skuID\" value=\""+document.articleactionform[selector][i].value+"\" type=\"hidden\" />";
						ticktock++;
					}
				}
			}
		} 

		appendform+="<input name=\"refURL\" value=\""+document.location.href+"\" type=\"hidden\" />";
		$("#addToCartFormelement").append(appendform);
		document.addToCartForm.submit();
	}



	return false;
}


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 that manages forwarding the request to send an email out
	based on how many articles were clicked.
	C.West 6.9.08
*********************************************************************************** */
function emailAbstracts() {
	

	var allDialogs = [];
	options = $.extend({title: "Email Articles"}, {});

	if (countSelected() == 0)
	{
		domBody = "<p>Please Select at least one article</p>";
	}
	else if (countSelected() > 20)
	{
		domBody = "<p>You cannot select more then 20 articles.</p>";
	}
	else 
	{ 
		domBody = "<div id=\"emaildiv\" style=\"width:500px;\">";

		/*	
		for(s=0;s<20;s++)
		{
			var selector = "artsel_" + s;
			if (document.articleactionform[selector])
			{
					for(i=0;i<document.articleactionform[selector].length;i++)
					{
						if (document.articleactionform[selector][i].checked==true)
						{
							domBody += "<INPUT type=\"hidden\" name=\"cvips \" value=\"" + document.articleactionform[selector][i].value +"\" />";
						}
					}
			}
		}
		*/
		domBody += 	"<table width=\"500\">" +

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

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

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

			"<tr><td width=\"40%\" align=right>Your Email: </td><td width=\"60%\"><input id=\"senderemail\" 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 id=\"sendermessage\" name=\"sendermessage\" cols=\"27\" rows=\"2\" maxlength=\"200\"></textarea></td></tr>"+

			"<tr><td></td><td><input type=\"button\" name=\"Submit\" onclick=\"return colleague_formcheck();\" value=\"Send Email\" /></a></td></tr>"+

			"</table>"+

			"</div>";

		
	}

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


function colleague_formcheck(thisform)
{
	var ce = $("#colleagueemail").val();//thisform.colleagueemail.value;
	var cn = $("#colleaguename").val();//				thisform.colleaguename.value;
	var se = $("#senderemail").val();//				thisform.senderemail.value;
	var sn = $("#sendername").val();//				thisform.sendername.value;
	var mes =$("#sendermessage").val();//				thisform.sendermessage.value;
	
	if ((ce == null) || (ce == "") || isblank(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 == "") || isblank(cn)) {
		alert("Please enter your colleague's name.");
		return false;
	}
	if ((sn == null) || (sn == "") || isblank(sn)) {
		alert("Please enter your name, so that your colleague knows who sent this email.");
		return false;
	}

	if ((se == null) || (se == "") || isblank(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 = ""; 
    
	for(s=0;s<20;s++)
	{
		var selector = "artsel_" + s;
		if (document.articleactionform[selector])
		{
				if (document.articleactionform[selector].length)
				{
						for(i=0;i<document.articleactionform[selector].length;i++)
						{
							if (document.articleactionform[selector][i].checked==true)
							{
								appendcvips += "&cvips=" + document.articleactionform[selector][i].value;
							} 						
						}
				} else if (document.articleactionform[selector]) {
						if (document.articleactionform[selector].checked==true)
						{
							appendcvips += "&cvips=" + document.articleactionform[selector].value;
						}
				}				
		}
	}
	$("#emaildiv").html("<div style=\"text-align:center;\"><p><img src=\"/journals/journal_images/ajax-loader.gif\" alt=\"Loading\" /></p><p>Sending...</p></div>");
	appendcvips = "/journals/help_system/dbt/modules/submit_emailcolleague.jsp?" + appendcvips.substring(1,appendcvips.length);
	$.post(appendcvips, { colleagueemail:ce, colleaguename:cn, sendername:sn, senderemail:se, sendermessage:mes }, 

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


return false;

}


























function dbt_showAbstract(artcvips) {
	var butop = null; 
	var butcl = null; 
	var absop = null; 
	var abscl = null; 
	butop = document.getElementById("butop"+artcvips); 
	butcl = document.getElementById("butcl"+artcvips); 
	absop = document.getElementById("absop"+artcvips); 
	abscl = document.getElementById("abscl"+artcvips); 
	
	if (butop.style.display=="none")
	{
		butop.style.display="block";
		absop.style.display="block";
		butcl.style.display="none";
		abscl.style.display="none";
	} else {
		butop.style.display="none";
		absop.style.display="none";
		butcl.style.display="inline";
		abscl.style.display="inline";
		butcl.style.display="block";
		abscl.style.display="block";
	}
}


function dbt_showPACS(artcvips) {
	var butop = null; 
	var butcl = null; 
	var absop = null; 
	var abscl = null; 
	butop = document.getElementById("pbutop"+artcvips); 
	butcl = document.getElementById("pbutcl"+artcvips); 
	absop = document.getElementById("pacsop"+artcvips); 
	abscl = document.getElementById("pacscl"+artcvips); 
	
	if (butop.style.display=="none")
	{
		butop.style.display="block";
		absop.style.display="block";
		butcl.style.display="none";
		abscl.style.display="none";
	} else {
		butop.style.display="none";
		absop.style.display="none";
		butcl.style.display="inline";
		abscl.style.display="inline";
		butcl.style.display="block";
		abscl.style.display="block";
	}
}

// Function that will upfate the number of selected articles in real time to the front-end
function updateShowCounts() {
	var howmany = ""; 
	if (countSelected()<1) { howmany = 0; } else { howmany = countSelected();}
	$(".selectednum").html(howmany);
}


function hightlightrowaction(rowid) {
	var thisrow = null; 
	thisrow = document.getElementById(rowid); 
	if (thisrow)
	{
		if (thisrow.className=="noselectrow")
		{	
			thisrow.className="selectedrow";
		} else {
			thisrow.className="noselectrow";
		}
	}	
	updateShowCounts();
	
}

function hightlightsecaction(checkid, sectioncheckboxid) {
	// div id = art<%=article.getCvips()%>_<%=maj%>
	// checkid = artsel_<%=maj%>
	// sectiopn checkbox = secsel<%=maj%>
	// article checkbox name = artsel_<%=maj%>
	//alert("checkid: " + checkid + " | " + "sectioncheckboxid: " + sectioncheckboxid);

	var secel = null; 
	secel = document.getElementById(sectioncheckboxid); 

	if (document.articleactionform[checkid].length)
	{
		for(i=0;i<document.articleactionform[checkid].length;i++)
		{
			var highlightid = "art" + document.articleactionform[checkid][i].value + checkid.substring(6);
			thisrow = document.getElementById(highlightid); 
			
			if(secel.checked==true)
			{
				document.articleactionform[checkid][i].checked=true;
				thisrow.className="selectedrow";
			}
			else
			{
				document.articleactionform[checkid][i].checked=false;
				thisrow.className="noselectrow";
			}
		}

	} else {
		var highlightid = "art" + document.articleactionform[checkid].value + checkid.substring(6);
		thisrow = document.getElementById(highlightid); 
		if(secel.checked==true)
		{
			document.articleactionform[checkid].checked=true;
			thisrow.className="selectedrow";
		}
		else
		{
			document.articleactionform[checkid].checked=false;
			thisrow.className="noselectrow";
		}
			
	}
	
	
	updateShowCounts();
}





function simple_load_focus_window()
{
	
	MM_showHideLayers('popup_backdrop','','show');
	opacity('popup_backdrop', 0,50, 200);
	
	MM_showHideLayers('popup_viewingpane','','show');
	opacity('popup_viewingpane', 0,100, 200);
	
}

function simple_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);
}







function howManyChecked(whichForm,whichCheckBoxArray,myMax,myMin)
{
	document.myform.action = '/getabs/servlet/GetCitation';
	var _countChecked = 0;
	var err = 0;
	/* 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, windowheight)
{
	if (windowheight)
	{
		panelobj.style.height= windowheight +"px";
	} else {
		panelobj.style.height= "350px";
	}
	
	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 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');
}

/*
Renders an Issue list on a pop-up box
*/
function loadIssue(volnumber, idpaint)
{
	var idcontents = $(idpaint).html().trim();
	if (idcontents == "")
	{
		$(idpaint).html("<p style=\"padding:20px; text-align:center;\">Loading...</p>")
		$(idpaint).load("/dbt/dbt.jsp?KEY=APPLAB&Volume=" + volnumber + "&render=issbrowser");
	}
	
	javascript:$(idpaint).toggle('drop');
	
	/*
	$("#volumepanel-pop .volisslist_selected").addClass("volisslist");
	$("#volumepanel-pop .volisslist_selected").removeClass("volisslist_selected");
	
	//$("#volumepanel-pop p").addClass("volisslist");
	$("#v"+volnumber).addClass("volisslist_selected");
	*/
	return false;
}


function showVolumeSection()
{
	var startvolrange = $("#volyears").attr("value");
	//alert(startvolrange);
	
	if (startvolrange==null || startvolrange == "") { startvolrange = "2008"; }
	var divselector = "#show" + startvolrange;
	$(".volumeshowsections").hide();
	$(divselector).show();

	return false;
}

