function checkall_box(e){
	if (!e.form.articles[1]) {
		e.form.articles.checked = e.checked;
	} else {
		for(i=0;i<e.form.articles.length;i++)
    		e.form.articles[i].checked = e.checked;
    }
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=150');");
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function realTop(obj) {
	var arr = findPos(obj);
	return arr[1];
}	
function realLeft(obj) {
	var arr = findPos(obj);
	return arr[0];
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";
  obj.style.KHTMLOpacity = opacity/100;
  obj.style.MozOpacity = opacity/100;
  obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
	obj = document.getElementById(objId);
	if (opacity <= 100) {
		setOpacity(obj, opacity);
		opacity += 20;
		window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 40);
	}
}
function fadeOut(objId,opacity) {
	obj = document.getElementById(objId);
	if (opacity >= 0) {
		setOpacity(obj, opacity);
		opacity -= 20;
		window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 40);
	} else {
		obj.style.visibility = 'hidden';
	}
}

function showhideOcis(oid) {
	var odiv = document.getElementById(oid).style;
	odiv.display = (odiv.display == 'none') ? 'block' : 'none';
}

function submitbasic() {
	if (document.basicsearchform.fullrecord.value == "") {
		alert('Please enter a search before continuing');
		return false;
	} else {
		var searchwhere = document.basicsearchform.journalList[document.basicsearchform.journalList.selectedIndex].value;
		if (searchwhere == 'GoogleScholar') {
			document.location.href = 'http://scholar.google.com/scholar?q=site:www.opticsinfobase.org+' + document.basicsearchform.fullrecord.value;
			return false;
		} else if (searchwhere == '') {
			document.basicsearchform.action = '/search2.cfm';
		}
		return true;
	}
}
function vipLookup() {
	var f = document.vipsearchform;
	if ((f.volume.value == "" || f.volume.value == "Vol")
		 && (f.issue.value == "" || f.issue.value == "Issue")
		 && (f.page.value == "" || f.page.value == "Page")) {
			alert("Please enter a volume, issue, and/or page number.");
			return false;
	}
 	if (f.volume.value == "Vol") f.volume.value = "";
 	if (f.issue.value == "Issue") f.issue.value = "";
 	if (f.page.value == "Page") f.page.value = "";
 	
 	jarray = f.journal_select.value.split(",");
 	if (jarray[0] != "") {
 		f.journalList.value = jarray[0];
 		if (jarray[1] && jarray[1] == "JON")
 			f.action = "/JOCN/search.cfm";
 		else if (jarray[1] && jarray[1] != "OPN" && jarray[1] != "ON")
		 	f.action = "/" + jarray[1] + "/search.cfm";
		else
			f.action = "/search.cfm";
	 }
 	
	return true;
}
function sessionLookup() {
	if (document.sessionsearchform.meetingsession.value == ""
		&& document.sessionsearchform.selectedmeetings.value == "") {
		alert("Please select a conference and enter a conference session number.");
		return false;
	}

	document.getElementById('sessionnumbutton').style.filter = 'alpha(opacity=20)';
	document.getElementById('sessionnumbutton').style.opacity = '.2';
	document.sessionsearchform.submit();
	document.getElementById('sessionnumbutton').disabled = true;
}
function journalBrowse() {
	if (document.browseform.browsejournal.selectedIndex == 0
		|| document.browseform.browseyear.value == "") {
			alert("Please select a journal and enter a year.");
			return false;
	}

	document.getElementById('browsebutton').style.filter = 'alpha(opacity=20)';
	document.getElementById('browsebutton').style.opacity = '.2';
	document.browseform.submit();
}
