// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function _nextbio_getParam(str, param)
{
if (str == null)
return null;
var paramHead = param + "=";
var begin = str.indexOf(paramHead);
if (begin < 0)
return null;
if (begin > 0)
{
begin = str.indexOf("&" + paramHead);
if (begin < 0)
return null;
begin++;
}
var end = str.indexOf("&", begin);
if (end < 0)
{
end = str.length;
}
var result = str.substring(begin + paramHead.length, end);
return result;
}
function _nextbio_setParam(str, param, value)
{
if (param == null)
return str;
var result;
if (value == null || value.length == 0)
result = "";
else
result = param + "=" + value;
if (str == null)
return result;
var begin = str.indexOf(param + "=");
if (begin < 0)
{
if (result.length > 0)
{
result += "&" + str;
return result;
}
return str;
}
if (begin > 0)
{
begin = str.indexOf("&" + param + "=");
if (begin < 0)
{
if (result.length > 0)
{
result += "&" + str;
return result;
}
return str;
}
begin++;
}
var end = str.indexOf("&", begin);
if (end < 0)
{
if (begin == 0)
return result;
if (result.length > 0)
{
result += "&" + str.substring(0, begin);
return result;
}
return str.substring(0, begin);
}
if (begin == 0)
{
if (result.length > 0)
{
result += "&" + str.substring(end + 1, str.length);
return result;
}
return str.substring(end + 1, str.length);
}
if (result.length > 0)
{
result += "&" + str.substring(0, begin) + str.substring(end + 1, str.length);
return result;
}
return str.substring(0, begin) + str.substring(end + 1, str.length);
}
function _nextbio_encodeParams(str)
{
return str;
}
function _nextbio_addParams(str, params, urlEncode)
{
if (params == null)
return str;
if (str == null)
return params;
var pair;
var valueArray;
var paramArray = params.split("&");
for (var i = 0; i < paramArray.length; i++)
{
pair = paramArray[i];
valueArray = pair.split("=");
if (valueArray.length > 1)
{
if (urlEncode == true)
valueArray[1] =  encodeURIComponent(valueArray[1]);
str = setParam(str, valueArray[0], valueArray[1]);
}
if (valueArray.length == 1)
{
str = setParam(str, valueArray[0], null);
}
}
return str;
}
function _nextbio_cancelEvent(event)
{
if (!event)
event = window.event;
if (event)
{
event.cancelBubble = true;
if (event.stopPropagation)
{
event.stopPropagation();
}
}
}
function _nextbio_adjustPosition(element, top, left, rightBound, bottomBound)
{
if (element == null)
return;
_nextbio_moveElement(element, document.body);
var bottom = bottomBound, right = rightBound;
if (bottom == null)
bottom = nbApi.getWindowHeight();
if (right == null)
right = nbApi.getWindowWidth();
var deltaY = bottom - (top + element.offsetHeight);
var deltaX = right - (left + element.offsetWidth);
scrollTop = nbApi.getScrollTop();
top += scrollTop;
if (deltaY < 0)
{
top +=  deltaY;
if (top < scrollTop)
top = scrollTop;
}
element.style.top = top + "px";
scrollLeft = nbApi.getScrollLeft();
left += scrollLeft;
if (deltaX < 0)
{
left += deltaX;
if (left < scrollLeft)
left = scrollLeft;
}
element.style.left = left + "px";
}
function _nextbio_moveElement(element, newParent)
{
if (element == null || newParent == null)
return;
if (element.parentNode != null)
element.parentNode.removeChild(element);
newParent.appendChild(element);
}
function _nextbio_getAdjustedPosition(element, y, x, rightBound, bottomBound)
{
if (element == null)
return;
var left = x;
var top = y - element.offsetHeight;
var bottom = bottomBound, right = rightBound;
if (bottom == null)
bottom = nbApi.getWindowHeight();
if (right == null)
right = nbApi.getWindowWidth();
var deltaY = top;
var deltaX = right - (left + element.offsetWidth);
scrollTop = nbApi.getScrollTop();
top += scrollTop;
if (deltaY < 0)
{
top -=  deltaY;
if (top < scrollTop)
top = scrollTop;
}
var newY = top + element.offsetHeight;
scrollLeft = nbApi.getScrollLeft();
left += scrollLeft;
if (deltaX < 0)
{
left += deltaX;
if (left < scrollLeft)
left = scrollLeft;
}
return {x: left, y: newY};
}
function _nextbio_hideAndCleanup(targetId)
{
var elements = document.getElementsByName(targetId);
if (elements == null)
return;
for (i = 0; i < elements.length; i++)
{
elements[i].style.display = "none";
if (i > 0)
elements[i].parentNode.removeChild(elements[i]);
}
}
function _nextbio_truncateWithEllipses(str, maxSize, terminator)
{
if (str == null || maxSize == null)
return null;
if (terminator == null)
terminator = "...";
var out = str.substr(0, maxSize);
if (maxSize < str.length)
{
out += terminator;
}
return out;
}
function _nextbio_showSection(targetId, bShow)
{
var element = document.getElementById(targetId);
if (element != null)
element.style.display = bShow?"block":"none";
}
// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

var nbRsh = {
disabled:false,
init: function() {
self.dhtmlHistory.setBlank(nb.root+"/s/js3/3rd/rsh0.6/blank.html")
self.dhtmlHistory.create( {
toJSON: function(o) {return Object.toJSON(o);},
fromJSON: function(s) {return s.evalJSON();}
});
if (dhtmlHistory.isSafari) {
this.disabled = true;
}
Event.observe(self,'load',this.loaded);
},
loaded: function() {
if (nbRsh.disabled) return;
dhtmlHistory.initialize();
if (!dhtmlHistory.isFirstLoad()) {
nbRsh.map2 = historyStorage.get("map2")||{};
nbRsh.mergeMap2();
} else {
nbRsh.listener(location.hash.replace(/^#/,""));
}
dhtmlHistory.addListener(nbRsh.listener);
document.fire("nb:historyLoaded",{firstLoad:dhtmlHistory.isFirstLoad()});
},
listener: function(loc) {
nbRsh.start();
nbRsh.setArgs(loc);
var map = nbRsh.getMap();
var omap = nbRsh.getOldMap();
document.fire("nb:historyChanged1",{map:map,oldMap:omap});
document.fire("nb:historyChanged2",{map:map,oldMap:omap});
nbRsh.finish(true);
},
add: function(loc) {
if (nbRsh.disabled) return;
loc=loc||"_";
dhtmlHistory.add(loc);
},
depth: 0,
map: {},
map2: {},
oldArgs: "",
start: function() {
this.depth++;
},
finish: function(noUpd) {
if (--this.depth <= 0) {
if (noUpd) {
this.mark();
} else {
this.update();
}
this.depth = 0;
}
},
put: function(key,val) {
this.map[key] = val;
if (key.charAt(0) == '$') {
this.map2[key] = val;
historyStorage.put("map2",this.map2);
}
},
get: function (key) {
return this.map[key];
},
remove: function(key) {
delete this.map[key];
if (key.charAt(0) == '$') {
delete this.map2[key];
historyStorage.put("map2",this.map2);
}
},
putIfSet: function(key,val) {
val?this.put(key,val):this.remove(key);
},
getArgs: function(args) {
var a = args.split(",");
var s="";
for (var i=0; i<a.length; i++) {
var arg = a[i];
var b = arg.split(":");
var v = this.get(b[0]);
if (v) {
s += "&"+(b[1]||b[0])+"="+encodeURIComponent(v);
}
}
s = s.replace(/^&/,'');
return s;
},
getString:function() {
var a=[];
for (var o in this.map) {
if (o.charAt(0) != '$') {
a.push(o);
}
}
a.sort();
var s="";
for (var i=0; i<a.length; i++) {
s+= (i==0?"":"&") + a[i] + "=" + encodeURIComponent(this.map[a[i]]);
}
return s;
},
mark: function() {
this.oldArgs = this.getString();
},
changed: function() {
return this.getString() != this.oldArgs;
},
getMap: function() {
return this.map;
},
update: function() {
if (this.changed()) {
var args = this.getString();
if (args != this.oldArgs) {
this.add(args);
}
}
this.mark();
},
setArgs: function(s) {
this.mark();
this.map = this.stringToMap(s);
},
getOldMap: function() {
return this.stringToMap(this.oldArgs);
},
stringToMap:function(s) {
s = s || "";
var a=s.split("&");
var map = {};
this.mergeMap2();
for (var i=0; i<a.length; i++) {
var arg = a[i];
if (arg) {
var b = arg.split("=",2);
if (b[0] == '_') {
} else if (b.length == 2) {
map[b[0]] = decodeURIComponentPlus(b[1]||"");
} else {
map[b[0]] = true;
}
}
}
return map;
},
mergeMap2:function() {
for (var o in nbRsh.map2) {
this.map[o] = this.map2[o];
}
}
}
// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function decodeURIComponentPlus(s) {
return decodeURIComponent(s.replace(/\+/g,"%20"));
}
getParam = _nextbio_getParam;
setParam = _nextbio_setParam;
addParams = _nextbio_addParams;
dupReqFlag = false;
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
function checkAboutBox(event, build_date) {
if (event.ctrlKey) {
showAboutBox(build_date);
return false;
}
return true;
}
function showAboutBox(build_date) {
aboutBox = window.open(nb.root+'/s/html/about.html','aboutBox',
'width=400,height=200,toolbar=0,statusbar=0');
setTimeout("updateAbout('" + build_date + "')", 100);
}
function updateAbout(build_date) {
if (aboutBox.document.getElementById('build_span') != null) {
var y = build_date.substring(0, 4);
var m = build_date.substring(4, 6);
var d = build_date.substring(6, 8);
var h = build_date.substring(9, 11);
var i = build_date.substring(11, 13);
var s = build_date.substring(13, 15);
aboutBox.document.getElementById('build_span').innerHTML = y + "-" + m + "-" + d
+ ", " + h + ":" + i + ":" + s;
} else {
setTimeout("updateAbout('" + build_date + "')", 100);
}
}
function entitize(s) {
if (s) {
s = s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
return s;
}
function commaNumber(n) {
n += "";
var re = /(-?\d+)(\d{3})/;
while (re.test(n)) {
n = n.replace(re, "$1,$2");
}
return n;
}
function searchUrl(page,searchTerm,query) {
if (nbApi != null)
return nbApi.searchUrl(nb.root,page,searchTerm,query);
}
function setRegTags(){
var input;
var areasOfInterest = "";
var techniques="";
var interestEl = document.getElementById("areasOfInterest");
var techniqueEl = document.getElementById("techniques");
var interestList = document.getElementsByName("interest");
var techniqueList = document.getElementsByName("technique");
for (i=0; i < interestList.length; i++){
input = interestList[i];
if (input.checked)
areasOfInterest += "," + input.getAttribute("value");
}
for (i=0; i < techniqueList.length; i++){
input = techniqueList[i];
if (input.checked)
techniques += "," + input.getAttribute("value");
}
if (techniques != "" && techniqueEl)
techniqueEl.value = techniques.substring(1);
if (areasOfInterest != "" && interestEl)
interestEl.value = areasOfInterest.substring(1);
}
function setCookie(cookieName, value, time)
{
var cookie=cookieName + "=" + escape(value) + ";path=/;";
if (time != null)
{
var date=new Date();
date.setFullYear(date.getFullYear() + time);
cookie += ";expires=" + date.toGMTString();
}
document.cookie=cookie;
}
function getCookie(cookieName)
{
if (document.cookie.length > 0)
{
var cookieStart = document.cookie.indexOf(cookieName + "=");
if (cookieStart != -1)
{
cookieStart = cookieStart + cookieName.length + 1;
var cookieEnd = document.cookie.indexOf(";", cookieStart);
if (cookieEnd == -1) cookieEnd = document.cookie.length;
return unescape(document.cookie.substring(cookieStart, cookieEnd));
}
}
return "";
}
function saveLoginState(url)
{
setCookie("nbloginstate", url||(window.location.pathname + window.location.search + window.location.hash));
return true;
}
function signInLink(a) {
if (!nb.anon) {
return true;
}
if (!confirm ("The feature that you selected is only available to registered users.  Would you like to sign in or register?  It's free.")) {
return false;
}
if (a && a.href && a.href.length > 1)
saveLoginState(a.href);
else if (a && a.getAttribute("url"))
saveLoginState(a.getAttribute("url"));
else
saveLoginState(null);
window.location = nb.root+"/authentication/login.nb?reg=true";
return false;
}
function show(id)
{
el = document.getElementById('full' + id);
if (el.style.display == 'none')
{
el.style.display = '';
el2 = document.getElementById('short' + id);
el2.style.display = 'none';
el3 = document.getElementById('more' + id);
el3.innerHTML = 'collapse...';
} else {
el.style.display = 'none';
el2 = document.getElementById('short' + id);
el2.style.display = '';
el3 = document.getElementById('more' + id);
el3.innerHTML = 'expand...';
}
}
function postEmessage(url, args, cb, cbArg) {
var ifr = postPup(url, args);
}
function addStudyToProject(sid) {
if (nb.anon) {
signInLink();
} else {
postPup(nb.root+"/mynb/addStudies.nb", "sid="+sid);
}
}
function deleteStudy(sid, goHome) {
function cb(arg) {
if (arg) {
if (goHome) {
location.replace(nb.root+"/nextbio.nb");
} else {
location.reload();
}
}
}
postPup(nb.root+"/mynb/deleteStudy.nb", "studyId="+sid, cb);
}
function escapeParam(param)
{
var str = param;
if (param == null)
return null;
str = str.replace(/&/g, "%26");
str = str.replace(/#/g, "%23");
str = str.replace(/\x3a/g, "%3A");
str = str.replace(/\x2f/g, "%2F");
str = str.replace(/\x3f/g, "%3F");
return str;
}
function appendParam(linkId, paramName, paramValue, encode)
{
if (linkId == null || paramName == null || paramValue == null)
return;
var link = $(linkId);
if (link == null || link.href == null)
return;
var delimiter = "&";
if (link.href.indexOf("?") < 0)
delimiter = "?";
var param;
if (encode)
param = encodeURIComponent(paramValue);
else
param = escapeParam(paramValue);
if(link.href.match(paramName) == null)
{
var href = link.href;
href = href + delimiter + paramName + "=" + param;
link.href = href;
}
}
function appendUrl(linkId, paramName, bAbsolute)
{
var url;
if (bAbsolute == true){
url = window.location.href;
}
else{
if(!dupReqFlag){
url = window.location.pathname + window.location.search + window.location.hash;
dupReqFlag=true;
}
}
appendParam(linkId, paramName, url, false);
}
function appendTitle(linkId, paramName)
{
appendParam(linkId, paramName, document.title, true);
}
function makeAjaxCall(el, url, queryStr, flag)
{
loadFromServer({target:el, url:nb.root+url, query:queryStr, noResize: flag});
}
function showDownloadPopup() {
postPup(nb.root+"/about/download.nb");
}
function showAdvQPopup() {
postPup(nb.root+"/about/advQ.nb");
}
function logExtLinkClick(redirectLink,type){
var funcArgs = "uuid=" + getCookie('nbTagUuid') + "&link=" + escape(redirectLink) + "&type=" + type;
jsonFromServer(nb.root+"/search/logExtLinkClick.nb",funcArgs,finishLinkLog);
}
function finishLinkLog(result) {
return true;
}
hideAndCleanup = _nextbio_hideAndCleanup;
showSection = _nextbio_showSection;
function csrf(query) {
var c = getCookie("csrf");
if (c) {
query = query || "";
query += (query?"&":"") + "csrf="+c;
}
return query;
}
function displaySWF(flashCapsule)
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if ((browser=="Microsoft Internet Explorer"))
{
document.getElementById(flashCapsule).innerHTML = document.getElementById(flashCapsule).innerHTML + '<param name="movie" value="${root}/communityphoto?pth=${imgPath}"  width="192">';
}
else
{
document.getElementById(flashCapsule).innerHTML = document.getElementById(flashCapsule).innerHTML + '<param name="movie" value="${url}"  width="192">'	;
}
}
function sessionTo() {
setCookie("nbtimedout","1");
saveLoginState();
location.reload();
}
function expandSection(section, bShow, expandImg, collapseImg)
{
var sectionId = section + "SectionId";
var buttonId = section + "ButtonId";
showSection(sectionId, bShow);
var button = document.getElementById(buttonId);
if (button)
button.src = bShow?collapseImg:expandImg;
return !bShow;
}
function cancelBubble(e)
{
if(!e) e = window.event;
e.cancelBubble = true;
if(e.stopPropagation) e.stopPropagation();
}
function switchSearchBoxes (form, link) {
$(form).radioShow();
$(link).radioShow();
if (form == 'seqSearchBx')
getChromosomesOpt(1);
}
function updateChromosomeOpt () {
var specieId = $F('organisms');
getChromosomesOpt(specieId);
}
function updateMaxChrRange(max, chrName){
var cStop = document.getElementById('chStop');
cStop.value = max;
var cStart = document.getElementById('chStart');
cStart.value = 1;
var maxField = document.getElementById('maxRange');
maxField.value = max;
if (chrName){
var chrNameField = document.getElementById('chName');
chrNameField.value = chrName;
}
}
function updateChrRange(){
var chrOpts = $('chromosome').getElementsByTagName('option');
var opts = $A(chrOpts);
opts.each(function(opt){
if (opt.selected){
var max = opt.max;
var chrName = opt.chrname;
if (!max || !chrName){
max = opt.readAttribute('max');
chrName = opt.readAttribute('chrname');
}
updateMaxChrRange(max, chrName);
}
});
}
function addChromosomesOpt(o, chrId){
var opt = "";
opt = opt + "<select id='chromosome' name='chromosome' style='width:95%;font-size:11px' onchange='updateChrRange()'>";
var selectedIndex = 0;
for(var i=0; i < o.length; i++){
var chr = o[i];
if ((chrId && chrId == chr.chID) || (!chrId && i==0)){
opt = opt + "<option id='chr" + chr.chID +"' value='" + chr.chID + "' chrname='" +  chr.chName + "' selected='selected' max='"+ chr.max+"'>" + chr.chName + "</option>";
selectedIndex = i;
}else{
opt = opt + "<option id='chr" + chr.chID +"' value='" + chr.chID + "' chrname='" +  chr.chName +"' max='"+ chr.max+"'>" + chr.chName + "</option>";
}
}
opt = opt + "</select>";
Element.replace('chromosome', opt);
if (chrId)
updateMaxChrRange(o[selectedIndex].max, o[selectedIndex].chName);
else
updateMaxChrRange(o[0].max, o[0].chName);
}
function getChromosomesOpt(specieId, chrId, chrStart, chrStop) {
jsonFromServer(nb.root+"/search/chromosomes.nb", "specieId="+specieId,
function(o) {
if (o == null) {
alert("We're sorry; there was an error servicing this request.")
}
addChromosomesOpt(o, chrId);
if (chrId && chrStart && chrStop){
var cStop = $('chStop');
cStop.value = chrStop;
var cStart = $('chStart');
cStart.value = chrStart;
}
},
function() {
alert("We're sorry; there was an error contacting the server.  Please try again.")
}
);
}
function checkRegionRange(){
var cStart = $('chStart').value;
var cStop = $('chStop').value;
var max = $('maxRange').value;
var msg = 'Sequence region range out of bound! Please respecify your start and stop points between 1 and ' + max + ' inclusive.';
var maxRange = 10000000;
var range = 0;
if (cStop >= cStart){
range = cStop - cStart;
}
if (cStart && cStop && cStart > 0 && cStop <= max && cStop >= cStart && range <= maxRange){
return true;
}else if (!cStart || !cStop){
alert('Please specify your start and stop points.');
return false;
}else if (cStart > cStop){
alert('Please specify a start point smaller than the stop point.');
return false;
}else if (range > maxRange){
alert('Sequence region range too wide! Please specify your start and stop points within 10 millions range.');
return false;
}else{
alert(msg);
return false;
}
}
function deleteBioset(bid, parent)
{
if (confirm("Delete this bioset?") == false){
return false;
}else {
jsonFromServer(nb.root+"/mynb/deleteBioset.nb", "biosetId="+bid,
function(o) {
if (o != null && o.error){
alert(o.error)
} else if (o != null && o.ok){
alert("The bioset has been scheduled for deletion.  It may take a few minutes before it is deleted.");
if (parent)
$(parent).update("deleting");
} else {
alert("There was an error deleting the bioset.");
}
},
function() {
alert("There was an error deleting the bioset.")
}
);
return false;
}
}
function setImageWidth(imageRef)
{
if ((screen.width) >  1024)
{
$(imageRef).style.width = "";
}
else
{
$(imageRef).style.width = "90%";
}
}
function isPreIe7()
{
var index = navigator.userAgent.indexOf("MSIE 6");
if (index < 0)
index = navigator.userAgent.indexOf("MSIE 5");
if (index < 0)
index = navigator.userAgent.indexOf("MSIE 4");
if (index < 0)
return false;
return true;
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function loadFromServer(o, u, q, tr, cb, highlight)
{
if (Object.isElement(o) || Object.isString(o)) {
loadFromServer({target:o, url:u, query:q, track:tr, callback:cb, highlight: highlight});
return;
}
var el = $(o.target);
var url = o.url;
var query = "";
var ae = $(o.argsElement||el)
if (!url) {
url = ae.getAttribute("nbUrl");
}
query = addParams(query, ae.getAttribute("nbQuery"));
var qf = ae.getAttribute("nbQueryFunc");
if (qf) {
query = addParams(query, eval(qf+"()"));
}
var nr = ae.getAttribute("nbNoResize");
if (nr) {
o.noResize = nr == "true";
}
var rep = ae.getAttribute("nbReplace");
if (rep) {
o.replace = rep == "true";
}
query = addParams(query, o.query);
if (o.csrf) {
query = csrf(query);
}
if (o.replace) {
var p = el.up();
if (p) {
if (!p.hasClassName("Replace")) {
el.insert({before: "<div></div>"});
p = el.previous();
p.appendChild(el);
}
el = p;
}
}
var c0 = url.charAt(0);
if (c0 != '/' && c0 != '.') {
url = nb.root + "/" + url;
}
o.finalQuery = query;
o.finalUrl = url;
el.update("<div class='Loading'" + (o.noResize?" style='min-height:"+(el.offsetHeight>40?el.offsetHeight-40:0)+"px;min-width:"+el.offsetWidth+"px'":"") + "> Loading...</div>")
el.addClassName("LoadFromServer");
new Ajax.Updater(el, url, {
parameters:query,
method:nb.aget?"get":"post",
onComplete:function(xhr){
var logins = el.select("._Login")
if (logins != null && logins.length > 0) {
sessionTo();
return;
}
if (o.callback) {
o.callback(el,true,xhr);
}
var elcb = el.getAttribute("nbCallback");
if (elcb) {
eval(elcb);
}
if (o.highlight)
nbApi.highlight(el);
document.fire("nb:loadFromServer",{target:el});
el.removeClassName("LoadFromServer");
},
onFailure:function(xhr){
if (o.callback) {
o.callback(el,false,xhr);
}
el.removeClassName("LoadFromServer");
}
});
if (o.track && self.pageTracker) {
try {
pageTracker._trackPageview("/ajax/"+url+"?"+encodeURIComponent(query));
} catch (e) {}
}
}
function jsonFromServer(url, query, success, failure, arg, checkCsrf, synch) {
if (checkCsrf) {
query = csrf(query);
}
new Ajax.Request(url, {
parameters:query,
asynchronous: !synch,
method:nb.aget?"get":"post",
onSuccess: function(resp) {
if (success) {
success(resp.responseJSON, arg);
}
},
onFailure: function(resp) {
if (failure) {
failure("There was an error contacting the server.", arg);
}
}
});
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function submitSearch() {
var v = dwTextValue("q").strip();
if (v && v != 'Search...' && v != 'Research a topic here...') {
location = searchUrl("ov",$F("q"));
}
return false;
}
function searchFocus() {
var q=$("q");
if (!q.focused) {
q.select();
q.focused = true;
}
}
function searchBlur() {
var q=$("q");
if(q.value=='')q.value='Search...';
q.focused = false;
}
// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function openDetails(el) {
el = $(el);
var cont = el.up(".DetailsContainer");
var de = cont.detailsEl;
if (de) {
de.toggle();
nbApi.highlight(de);
} else if ((nbDetailsId = el.getAttribute("nbDetailsId")) != null) {
cont.detailsEl = de = $(nbDetailsId);
de.detailsOpener = el;
de.addClassName("DetailsBody");
de.toggle();
} else {
var klass = "";
var dc = el.getAttribute("nbDetailsClass");
if (dc) {
klass = " class='"+dc+"'";
}
var iclass = "";
var ic = el.getAttribute("nbDetailsInClass");
if (ic){
iclass = " class='"+ic+"'";
}
if (cont.tagName == "TR") {
var numCells = cont.getElementsByTagName("td").length;
var bodyTag = el.getAttribute("nbBodyTag");
if(bodyTag){
cont.insert({after: "<tr"+klass+"><td"+iclass+" colspan='"+numCells+"'>" +
"<div class='OpenedBiosetBody'><div class='OpenedBiosetInner'></div></div>" +
"<div></div>" +
"<div class='OpenedBiosetFoot'> <div> <div></div> </div> </div> " +
"</td></tr>"});
}
else{
cont.insert({after: "<tr"+klass+"><td"+iclass+" colspan='"+numCells+"'><div></div></td></tr>"});
}
cont.detailsEl = cont.next();
cont.detailsEl.detailsOpener = el;
de = cont.detailsEl.down("div");
if(bodyTag){
de = de.down("div");
}
} else {
cont.insert({after:"<div"+klass+"></div>"}).down(".Details");
cont.detailsEl = de = cont.next();
}
de.detailsOpener = el;
cont.detailsEl.addClassName("DetailsBody");
var delClass = el.getAttribute("nbRemoveContClass");
if(delClass){
el.removeClassName(delClass);
}
loadFromServer({target:de, trace:true, argsElement:el, highlight:true, callback: function() {
var cb = el.getAttribute("nbPostCb");
if (cb) {
eval(cb);
}
document.fire("nb:details",{el:el});
}});
}
var isVisible = de.visible();
var  biosetClass = el.getAttribute("nbBiosetDetails");
if(biosetClass) {
allElems  = document.getElementsByClassName(biosetClass);
for(i = 0; i < allElems.length; i++) {
isVisible?allElems[i].style.display='none':allElems[i].style.display='';
}
}
var openClass = el.getAttribute("nbOpenLinkClass");
if (openClass) {
isVisible?el.addClassName(openClass):el.removeClassName(openClass);
}
openClass = el.getAttribute("nbOpenContClass");
if (openClass) {
isVisible?cont.addClassName(openClass):cont.removeClassName(openClass);
}
if (el.id) {
nbRsh.putIfSet("$details"+el.id, isVisible)
}
}
function openL2(id,elem){
var el =  document.getElementById(id);
el = $(el)
elem = $(elem);
var cont = elem.up(".DetailsContainer");
var de = cont.detailsEl;
if (de) {
var isVisible = de.visible();
var openClass = elem.getAttribute("nbOpenLiClass");
if (isVisible) {
el.removeClassName("ClosedResult");
el.addClassName("OpenedResult");
}else{
el.removeClassName("OpenedResult");
el.addClassName("ClosedResult");
}
}
}
function toggleSearchBox(el, searchForm) {
el = $(el);
var form = $(searchForm);
var bLabel = $('buttonLabel');
if (el && form && bLabel) {
var isVisible = form.visible();
if (isVisible) {
el.removeClassName('Show');
el.addClassName('Close');
bLabel.update('Show Search');
} else {
el.removeClassName('Close');
el.addClassName('Show');
bLabel.update('Hide Search');
}
form.toggle();
} else {
return;
}
}
function toggleDetails(el,id) {
var elem = document.getElementById(id);
var isVisible = false;
if (elem) {
if (elem.style.display=='none') {
elem.style.display='';
isVisible = true;
} else {
elem.style.display='none';
}
}
el = $(el);
var openClass = el.getAttribute("nbOpenLinkClass");
if (openClass) {
isVisible?el.addClassName(openClass):el.removeClassName(openClass);
}
}
function checkDetails(parent) {
var a = parent?parent.select(".DetailsLink"):$$(".DetailsLink");
a.each(function(el) {
if (el.id && nbRsh.get("$details"+el.id)) {
var cont = el.up(".DetailsContainer");
var de = cont.detailsEl;
if (!de) {
openDetails(el);
}
}
});
}
document.observe("nb:historyLoaded", function(evt) {
if (!evt.memo.firstLoad) {
checkDetails();
}
});
document.observe("nb:loadFromServer", function(evt) {
checkDetails(evt.memo.target);
});// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function pageTo(p, el, xcb) {
var cont;
cont = el = $(el);
if (!el.hasClassName("PageContainer")) {
cont = el.up(".PageContainer");
}
var pageSize = cont.getAttribute("nbPageSize");
var pageHist = cont.getAttribute("nbPageHist");
var preCb = cont.getAttribute("nbPreCb");
var postCb = cont.getAttribute("nbPostCb");
var pageHighlight = cont.getAttribute("nbHighlight");
var savePage = true;
var args =""
var xs = cont.getAttribute("extraState");
if (xs) {
args = setParam(args, "xs",xs);
}
if (p == 0) {
savePage = false;
p = 1;
if (pageHist) {
var ph = nbRsh.get(pageHist+"P");
if (ph) {
var a = ph.split(",",3)
p = a[0];
pageSize=a[1];
if (a[2]) {
args = setParam(args, "xs",a[2]);
}
}
}
}
var first = (p-1)*pageSize;
args = addParams(args,  "fr="+first+"&nr="+pageSize);
if (document.getElementById("hiddenCategories") != null)
{
if (document.getElementById("hiddenCategories").innerHTML.replace("categories=","").length > 2)
{
args = addParams(args,  document.getElementById("hiddenCategories").innerHTML );
}
}
if (preCb) eval(preCb);
var o = {target:cont, query:args, track:true, callback:cb, highlight:pageHighlight != "false"};
loadFromServer(o);
if (pageHist && nbRsh && savePage) {
nbRsh.start();
if (p <= 1) {
nbRsh.remove(pageHist+"P");
} else {
var s=p+","+pageSize;
if (xs) {
s+=","+xs;
}
nbRsh.put(pageHist+"P",s);
}
nbRsh.finish();
}
function cb() {
var a = o.finalQuery.match(/(^|&)xs=([^&]*)(&|$)/);
var xs="";
if (a && a.length >= 3) {
xs = a[2];
}
if (postCb) eval(postCb);
if (xcb) xcb();
document.fire("nb:page",{el:cont,p:p});
}
}
function pageSize(size,el) {
el = $(el);
var cont = el.up(".PageLinks");
if (cont) {
pt = cont.getAttribute("pt");
if (pt) {
jsonFromServer(nb.root+"/mynb/pageSizes.nb", "size="+size+"&type="+pt, function (o){
if (o.ok) {
cont = el.up(".PageContainer");
var url = cont.getAttribute("nbUrl");
var p = cont;
while (p && p.getAttribute("nbUrl") == url) {
p.setAttribute("nbPageSize",size);
p = p.up(".PageContainer");
}
pageTo(1, el);
} else if (o.signIn) {
signInLink();
}
});
}
}
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

var signinBlock=false;
var _nextbio_noFilter = false;
var _nextbio_popupId;
function displayPopup(eventSource, popupId, url, paramList, event, height, width, forceLoad, forwardUrl, title, prefix, bPersistent)
{
var popup = document.getElementById(popupId);
if (popup == null)
return;
_nextbio_popupId = popupId;
popup.style.display = "none";
if (paramList == null)
paramList = "";
var type = _nextbio_getParam(paramList, "type");
var searchTerm = paramList.indexOf("linkOutSearchTerm");
var subTitle;
if (title != null && searchTerm < 0)
{
var titleEnd = title.indexOf(",");
if (titleEnd < 0 )
subTitle = title;
else
subTitle = title.substring(0, titleEnd);
if (subTitle.length > 1)
subTitle = subTitle.replace(/\{comma\}/g, ",");
paramList += "&linkOutSearchTerm=" + escape(subTitle);
}
var query = null;
if (subTitle != null)
{
query = subTitle;
paramList += "&q=" + escape(query);
}
if (query != null && ("treatment" == type || "tissue" == type || "disease" == type))
{
paramList += "&synonym=" + escape(query);
}
var scrollTop = nbApi.getScrollTop();
var scrollLeft = nbApi.getScrollLeft();
var clientY = event.clientY;
var clientX = event.clientX;
var bForceLoad = (forceLoad == "hard") || (forceLoad == "soft" && _nextbio_popupId != popupId);
if (bForceLoad == true || popup.loaded == null || popup.loaded == false)
{
popup.loaded = true;
var modParamList = paramList + "&small=" + popup.getAttribute("small");
loadFromServer(popupId + "_content", url, modParamList, true, function(){
document.body.onclick = function(event){UnTip(true);};
TagToTip(popupId,
BGCOLOR, '',
BORDERWIDTH, 0,
PADDING, 0,
ABOVE, true,
FIX, [clientX + scrollLeft, clientY + scrollTop],
JUMPHORZ, true,
JUMPVERT, true,
FONTSIZE, '',
COPYCONTENT, false,
STICKY, true
);
var pos = _nextbio_getAdjustedPosition(popup, clientY - 10, clientX + 10);
TagToTip(popupId,
BGCOLOR, '',
BORDERWIDTH, 0,
PADDING, 0,
ABOVE, true,
FIX, [pos.x, pos.y],
FONTSIZE, '',
COPYCONTENT, false,
STICKY, true
);
});
}
else
{
document.body.onclick = function(event){UnTip(true);};
TagToTip(popupId,
BGCOLOR, '',
BORDERWIDTH, 0,
PADDING, 0,
ABOVE, true,
OFFSETX, -10,
FONTSIZE, '',
COPYCONTENT, false,
STICKY, true
);
}
if (forwardUrl != null)
{
var forwardText = "complete details";
var html = "";
html =  '<ul class="ResultAct"><li class="Details">';
var modParamList = paramList.replace("type=treatment","type=compound");
if (nb.anon)
html += '<a href="' + forwardUrl + '?' + modParamList + '" onclick="return signInLink(this);">view complete details</a>';
else
html += '<a href="' + forwardUrl + '?' + modParamList + '" >view complete details</a>';
html += '</li></ul>';
nbApi.setInnerHtml(popupId + "_forward" , html);
}
if (title != null)
{
title = title.replace(/,/g, ", ");
title = title.replace(/\{comma\}/g, ",");
title = nbApi.normalizeString(title);
var shortTitle = _nextbio_truncateWithEllipses(title, 50);
nbApi.setAttr(popupId + "_title" , "title", title);
nbApi.setInnerText(popupId + "_title" , shortTitle);
}
if (prefix != null)
{
if (prefix == "feature")
prefix = "gene";
nbApi.setInnerHtml(popupId + "_prefix" , prefix);
}
$(popupId+"_img").src = nbApi.getIcon(prefix, nb.img, null, true);
return popup;
}
function cancelTimeout()
{
if (_nextbio_PopupWindow.pendingTimeoutId != null)
clearTimeout(_nextbio_PopupWindow.pendingTimeoutId);
_nextbio_PopupWindow.pendingTimeoutId = null;
}
function popupItems()
{
var eventSource;
var popupId;
var url;
var itemsList;
var event;
var bNow;
var delay;
eventSource = popupId = url = itemsList = event = bNow = delay = null;
var i = 0;
if (typeof(arguments[0]) == "object")
{
eventSource = arguments[i++];
}
if (i < arguments.length)
{
popupId = arguments[i++];
}
if (i < arguments.length)
{
url = arguments[i++];
}
if (i < arguments.length)
{
itemsList = arguments[i++];
}
if (i < arguments.length)
{
event = arguments[i++];
}
if (i < arguments.length)
{
bNow = arguments[i++];
}
if (i < arguments.length)
{
delay = arguments[i++];
}
_nextbio_cancelEvent(event);
if (delay == null)
delay = 500;
if (bNow != true)
{
cancelTimeout();
document.body.onmouseover = function(event){cancelTimeout();};
var myEvent = new Object();
myEvent.clientX = event.clientX;
myEvent.clientY = event.clientY;
myEvent.nbEvent = true;
_nextbio_PopupWindow.pendingTimeoutId = setTimeout(function(){popupItems(eventSource, popupId, url, itemsList, myEvent, true, null)}, delay);
this.onmouseout = function()
{
cancelTimeout();
};
return;
}
if (popupId == null || url == null || itemsList == null || itemsList.length == 0)
return;
var item;
if (itemsList.length == 1)
{
item =  itemsList[0];
var popup = displayPopup(eventSource, popupId, url, "id=" + item[1] + "&type=" + item[0], event, null, null, "hard", nb.root+"/search/ov.nb", item[2], item[0], false);
return;
}
var html = "<div id='NbPopupListFrameId' class='NbPopupListFrame' onmouseover='_nextbio_cancelEvent(event);' onmousemove='_nextbio_cancelEvent(event);' onclick='_nextbio_cancelEvent(event);' >";
for (i = 0; i < itemsList.length; i++)
{
var item =  itemsList[i];
var itemId = item[1];
var itemType = item[0];
var itemTitle = item[2].replace(/\'/g, "\\x27");
itemTitle = itemTitle.replace(/\"/g, "\\x22");
itemTitle = nbApi.normalizeString(itemTitle);
var image;
var bPopup = true;
image = nbApi.getIcon(itemType, nb.img, true);
var doPopup;
var title = item[2];
if (title.length > 1)
title = title.replace(/\{comma\}/g, ",");
if (bPopup)
{
doPopup = 'displayPopup(null, "' + popupId + '","' + url + '","id=' + itemId + '&type=' + itemType +
'",event,null,null, "hard", nb.root+"/search/ov.nb", "' +  itemTitle + '", "' + itemType + '", false);';
}
else
{
doPopup = 'submitFilter(\"' + itemTitle + '\");';
title = "filter by <b>" + title + "</b>";
}
if (bPopup == false && _noFilter)
break;
if (bPopup == false || i < 10)
{
html += "<div class='NbPopupListEntry' onmouseover='this.className=\"NbPopupListSelected\"' ";
html += "onmouseout='this.className=\"NbPopupListEntry\"' ";
html += "onclick='" + doPopup + "'>";
html += "<img class='LinkIcon' src='" + image + "' alt='' />&nbsp;" + title;
html += "</div>";
}
}
html += "</div>";
var dlg = createPopupWindow(eventSource, "_popupList", "NbPopupList", html);
}
var _nextbio_PopupWindow = new Object;
function createPopupWindow(eventSource, id, className, html)
{
Tip(html,
BGCOLOR, '',
BORDERWIDTH, 0,
PADDING, 0,
ABOVE, true,
OFFSETX, 0,
JUMPHORZ, true,
JUMPVERT, true,
FONTSIZE, '',
COPYCONTENT, false,
STICKY, true,
CLICKCLOSE, true
);
}
// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

Element.addMethods({
loadFromServer: function(el,track) {
loadFromServer({target:el,track:track});
return el
},
ajaxShow: function(el,track) {
function doLoad(e2) {
e2.removeClassName("ALoad").removeClassName("ALoadNR");
e2.loadFromServer(track);
}
el = $(el);
el.show();
if (el.hasClassName("ALoad") || el.hasClassName("ALoadNR")) {
doLoad(el);
} else {
el.select(".ALoad").each(doLoad);
}
return el;
},
radioShow: function(el,track) {
el=$(el);
el.siblings().each(function (e) {e.hide()});
return el.ajaxShow(track);
},
radioClass: function(el, clazz) {
el=$(el);
el.siblings().each(function (e) {e.removeClassName(clazz)});
return el.addClassName(clazz);
},
showing: function (el) {
if (!el.visible()) {
return false;
}
var a = el.ancestors();
for (var i=0; i<a.length; i++) {
if (!a[i].visible()) {
return false;
}
}
return true;
}
});
function $RF(el, radioGroup) {
if($(el).type && $(el).type.toLowerCase() == 'radio') {
var radioGroup = $(el).name;
var el = $(el).form;
} else if ($(el).tagName.toLowerCase() != 'form') {
return false;
}
var checked = $(el).getInputs('radio', radioGroup).find(
function(re) {return re.checked;}
);
return (checked) ? $F(checked) : null;
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function nbTip(s, position) {
Tip(s, BGCOLOR, '#F8F8F8', BORDERCOLOR, '#C9C9C9', FADEIN, 700, FADEOUT, 700, SHADOW, true, ABOVE, position);
}
function nbUnTip() {
UnTip();
}
function nbElTip(e) {
e = $(e);
var tip = e.getAttribute("nbtip");
if (tip) nbTip(tip);
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function validateForm(form) {
form = $(form);
var nErrors = 0;
var isFile,isSelect;
function setError(el) {
if (el.hasClassName("IfVisible") && !el.showing()) {
return;
}
el.addClassName('FormInvalid');
if (nErrors++ == 0) {
el.focus();
if (el.tagName=='INPUT' && el.type == 'file') {
isFile=true;
} else if (el.tagName=='SELECT') {
isSelect=true;
}
}
}
form.select("input,textarea,select").each(function(el){
el.removeClassName('FormInvalid');
});
var captcha = null;
form.select(".Required").each(function(el){
if (el.name == "captcha")
{
captcha = el;
}
if (!el.value.trim() && !formAllEmpty(el)) {
setError(el);
}
});
if (nErrors) {
alert(nErrors>1?'Please enter the highlighted values':isFile?'Please upload a file':isSelect?'Please choose a value for this selection':'Please enter the highlighted value');
return false;
}
if (captcha)
{
var response = null;
jsonFromServer(
nb.root + "/captcha/check.nb",
"text="+captcha.value.trim(),
function(responseObj)
{
response = responseObj;
},
null, null, null, true
);
var captchaImg = $("captchaImg");
if (!response)
{
setError(captcha);
alert("Incorrect code. Please try again.");
if (captchaImg)
{
captchaImg.src='../kaptcha.jpg?time=' + (new Date()).getTime();
}
return false;
}
}
var year = (new Date).getFullYear();
form.select(".Year").each(function(el){
var val = el.value;
if (val) {
var v = parseInt(val);
if (!(v>=1900 && v<=year)) {
setError(el);
}
}
});
if (nErrors) {
alert((nErrors>1?'Please enter years':'Please enter a year')+" between 1900 and "+year);
return false;
}
form.select(".Email").each(function(el){
var val = el.value;
if (val) {
var v = validateEmail(val);
if (v != true) {
setError(el);
}
}
});
if (nErrors) {
alert(v);
return false;
}
form.select(".EmailList").each(function(el){
var instr = el.value;
var sp=" ";
if (instr.indexOf(sp)==-1) {
var v = validateEmail(instr);
if (v != true) {
setError(el);
}
}
value=instr.replace( "[,;:']" , " ");
var a=value.split(" ");
for (var i=0; i<a.length; i++) {
var arg=a[i];
var rt = validateEmail(arg);
if (rt != true) {
setError(el);
}
}
});
if (nErrors) {
alert("This field should be a space separated list of up to 5 e-mail address in the format: \"user1@domain1.com  user2@domain2.com\"");
return false;
}
form.select(".Location").each(function(el){
var val = el.value;
if (val) {
if (val != el.getAttribute("locationString")) {
setError(el);
}
} else {
var hidden = $("id"+el.id);
if (hidden) {
hidden.value = "";
}
}
});
if (nErrors) {
alert("please choose a location from the autocomplete dropdown");
return false;
}
form.select(".University").each(function(el){
var val = el.value;
if (!val || val != el.getAttribute("universityString")) {
var hidden = $("id"+el.id);
if (hidden) {
hidden.value = "";
}
}
});
var cbs={};
form.select(".HasCheck").each(function(el){
var n = el.name;
if (n) {
if (!cbs[n]) {
cbs[n] = 0;
}
if (el.checked) {
cbs[n] = 1;
}
}
});
for (cb in cbs) {
if (!cbs[cb]) {
form.select(".HasCheck").each(function(el){
if (el.name == cb) {
setError(el);
}
});
alert("Please select at least one of the checkboxes");
return false;
}
}
return true;
}
function validateEmail(str)
{
var errorMsg = "This field should be an e-mail address in the format \"user@domain.com\"";
if (str == null)
return errorMsg;
str = str.trim();
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);
if (str.indexOf(at)==-1){
return errorMsg;
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
return errorMsg;
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
return errorMsg;
}
if (str.indexOf(at,(lat+1))!=-1){
return errorMsg;
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
return errorMsg;
}
if (str.indexOf(dot,(lat+2))==-1){
return errorMsg;
}
if (str.indexOf(" ")!=-1){
return errorMsg;
}
return true;
}
function validatePassword(password, confirmation)
{
if (password == confirmation)
return true;
else {
alert('Password and confirmation fields should be identical.');
return false;
}
};
function validateAndSubmit(form) {
form = $(form);
if (validateForm(form)) {
form.submit();
}
}
function formAllEmpty(el) {
el = $(el);
var p = el.up('.AllEmptyOK');
if (p) {
var empty=true;
p.select('input').each(function(c){
if (c.type == 'text' && c.value) {
empty=false;
}
});
return empty;
}
return false;
}
function allCheck(master,slaves,cb) {
function check() {
var allOn=true;
slaves.each(function(e) {
if (!e.checked) {
allOn=false;
}
});
master.checked = allOn;
}
master = $(master);
slaves = $$("."+slaves);
if (master && slaves) {
if (!master.allCheckDone) {
slaves.each(function(e){e.observe('click',check)});
master.observe('click', function() {
var checked = master.checked;
slaves.each(function(e) {
if (e.checked != checked) {
e.checked = checked;
if (cb) {
cb(e);
}
}
});
});
master.allCheckDone = true;
}
check();
}
}
function clearInvalid(el) {
$(el).removeClassName("FormInvalid");
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

function postPup(url, args, cb, cbArg) {
var ifh = 470, ifw=538;
var ww = nbApi.getWindowWidth();
var wh = nbApi.getWindowHeight();
var x = Math.floor((ww - ifw) / 2);
var y = Math.floor((wh - ifh) / 2);
x = x<0?0:x; y=y<0?0:y;
y += nbApi.getScrollTop();
var mask = document.createElement("div");
mask.style.width = ww + "px"; mask.style.height = wh + nbApi.getScrollTop() + "px";
mask.id = "pupIframeMask";
document.body.appendChild(mask);
var ifr = document.createElement("iframe");
ifr.scrolling = 'no'; ifr.frameBorder = 0;
ifr.style.position = 'absolute';
ifr.style.left = x+'px'; ifr.style.top = y+'px';
ifr.width = ifw+40; ifr.height = ifh+100;
ifr.id = 'pupIframe';
ifr.pupCb = cb;
ifr.pupCbArg = cbArg;
ifr.allowTransparency = true;
ifr.style.background='transparent';
ifr.src = url + (args? ('?' + args):'');
document.body.appendChild(ifr);
return ifr;
}
function closePup(arg) {
try {
parent.document.body.removeChild(parent.document.getElementById("pupIframeMask"));
var ifr = parent.document.getElementById("pupIframe")
if (ifr.pupCb) {
ifr.pupCb(arg, ifr.pupCbArg);
}
try {
if (dhtmlHistory.isIE) parent.document.getElementById("q").focus();
} catch (e) {}
parent.document.body.removeChild(ifr);
} catch (e) {}
}
// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights
function popupHelp(el, name) {
jsonFromServer(nb.root+"/help/help.nb", "name="+name+helpContext,
function(o) {
var s = o.popup || "Sorry, no help is available for this topic";
$("helpContent").update(s);
if (o.url) {
$("helpPageDiv").show();
$("helpPageLink").href=o.url;
} else {
$("helpPageDiv").hide();
}
var above=true;
var isLeft=true;
var top = nbApi.getElementTop(el);
var st = nbApi.getScrollTop();
if (top - st < nbApi.getWindowHeight()/2 || top < 300) {
above = false;
}
var left = nbApi.getElementLeft(el);
if (left < nbApi.getWindowWidth()/2) {
isLeft = false;
}
TagToTip("helpPopup",
BGCOLOR, '',
BORDERWIDTH, 0,
PADDING, 0,
ABOVE, above,
LEFT, true,
FIX, [el, isLeft?-340:0, above?-5:5],
JUMPHORZ, true,
JUMPVERT, true,
FONTSIZE, '',
COPYCONTENT, false,
STICKY, true,
CLICKCLOSE, true
);
}
);
}// Copyright (c) 2009 NextBio.  All Rights Reserved
// Additional JavaScript subject to other copyrights

var dwInputs=[];
function dwRadio(form,name) {
if (!$(form)) return;
var inputs = $(form).getInputs('radio',name);
inputs.each(function(r) {
var tr1 = $(r.parentNode);
if(r.checked){
tr1.addClassName('Checked');
}
tr1.observe('click',function(){
unselectAllData();
this.firstChild.checked = true;
tr1.addClassName('Checked');
return false;
});
});
dwInputs = dwInputs.concat(inputs);
function unselectAllData() {
inputs.each(function (r) {
r.checked = false;
var label = $(r.parentNode);
label.removeClassName('Checked');
});
}
}
function dwCb(form) {
if (!$(form)) return;
var inputs = $(form).getInputs('checkbox');
inputs.each(function(cb) {
var tr1 = $(cb.parentNode);
if(cb.checked){
tr1.addClassName('Checked');
}
cb.observe('click',function(){
if (this.checked) {
tr1.addClassName('Checked');
} else {
tr1.removeClassName('Checked');
}
return false;
});
});
dwInputs = dwInputs.concat(inputs);
}
function dwText(el,defaultText,emptyClass) {
el = $(el);
if (el) {
el.defaultText = defaultText;
el.emptyClass = emptyClass;
if (!el.value) {
if (emptyClass) {
el.addClassName(emptyClass);
}
el.value = defaultText;
}
el.observe('focus', function(){
if(el.value==defaultText)el.value='';
if (!el.hasFocus) {
el.select();
el.hasFocus = true;
}
if (emptyClass) {
el.removeClassName(emptyClass);
}
});
el.observe('blur', function(){
if(el.value==''){
if (emptyClass) {
el.addClassName(emptyClass);
}
el.value=defaultText;
}
el.hasFocus = false;
});
dwInputs.push(el);
}
}
function dwTextValue(el) {
el = $(el);
var v = el.value;
if (v == el.defaultText) {
return '';
}
return v;
}
function dwUpdate(el) {
if (el) {
el = $(el);
if (el.type == 'text') {
if (el.value == '') {
if (el.defaultText) {
if (el.emptyClass) {
el.addClassName(el.emptyClass);
}
el.value = el.defaultText;
}
}
} else {
var tr1 = $(el.parentNode);
if (el.checked) {
tr1.addClassName('Checked');
} else {
tr1.removeClassName('Checked');
}
}
} else {
dwInputs.each(function(el) {
dwUpdate(el)
});
}
}