// Row Links

function ConvertRowsToLinks(xTableId)
{
var rows = document.getElementById(xTableId).getElementsByTagName("tr");
for(i=0;i<rows.length;i++){
var link = rows[i].getElementsByTagName("a")
if(link.length == 1){
rows[i].onclick = new Function("document.location.href='" + link[0].href + "'");
rows[i].onmouseover = new Function("this.className='highlight'");
rows[i].onmouseout = new Function("this.className=''");
}
}
}

// Sliding Menu

var dhtmlgoodies_slideSpeed = 4;	// Higher value = faster
var dhtmlgoodies_timer = 4;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{
if(dhtmlgoodies_slideInProgress)return;
dhtmlgoodies_slideInProgress = true;
if(!inputId)inputId = this.id;
inputId = inputId + '';
var numericId = inputId.replace(/[^0-9]/g,'');
var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

objectIdToSlideDown = false;

if(!answerDiv.style.display || answerDiv.style.display=='none'){		
if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			
objectIdToSlideDown = numericId;
slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
}else{
			
answerDiv.style.display='block';
answerDiv.style.visibility = 'visible';
			
slideContent(numericId,dhtmlgoodies_slideSpeed);
}
}else{
slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
dhtmlgoodies_activeId = false;
}	
}

function slideContent(inputId,direction)
{
var obj =document.getElementById('dhtmlgoodies_a' + inputId);
var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
height = obj.clientHeight;
if(height==0)height = obj.offsetHeight;
height = height + direction;
rerunFunction = true;
if(height>contentObj.offsetHeight){
height = contentObj.offsetHeight;
rerunFunction = false;
}
if(height<=1){
height = 1;
rerunFunction = false;
}

obj.style.height = height + 'px';
var topPos = height - contentObj.offsetHeight;
if(topPos>0)topPos=0;
contentObj.style.top = topPos + 'px';
if(rerunFunction){
setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
}else{
if(height<=1){
obj.style.display='none'; 
if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);				
}else{
dhtmlgoodies_slideInProgress = false;
}
}else{
dhtmlgoodies_activeId = inputId;
dhtmlgoodies_slideInProgress = false;
}
}
}

function initShowHideDivs()
{
var divs = document.getElementsByTagName('DIV');
var divCounter = 1;
for(var no=0;no<divs.length;no++){
if(divs[no].className=='dhtmlgoodies_question'){
divs[no].onclick = showHideContent;
divs[no].id = 'dhtmlgoodies_q'+divCounter;
var answer = divs[no].nextSibling;
while(answer && answer.tagName!='DIV'){
answer = answer.nextSibling;
}
answer.id = 'dhtmlgoodies_a'+divCounter;	
contentDiv = answer.getElementsByTagName('DIV')[0];
contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
contentDiv.className='dhtmlgoodies_answer_content';
contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
answer.style.display='none';
answer.style.height='1px';
divCounter++;
}		
}	
}

// Zebra Table

// this function is need to work around 
// a bug in IE related to element attributes

function hasClass(obj) {
var result = false;
if (obj.getAttributeNode("class") != null) {
result = obj.getAttributeNode("class").value;
}
return result;
}   

function stripe(id) {
// the flag we'll use to keep track of 
// whether the current row is odd or even
var even = false;
 
// if arguments are provided to specify the colours
// of the even & odd rows, then use the them;
// otherwise use the following defaults:
var evenColor = arguments[1] ? arguments[1] : "#fff";
var oddColor = arguments[2] ? arguments[2] : "#eee";
 
// obtain a reference to the desired table
// if no such table exists, abort
var table = document.getElementById(id);
if (! table) { return; }
    
// by definition, tables can have more than one tbody
// element, so we'll have to get the list of child
// &lt;tbody&gt;s 
var tbodies = table.getElementsByTagName("tbody");

// and iterate through them...
for (var h = 0; h < tbodies.length; h++) {
    
// find all the &lt;tr&gt; elements... 
var trs = tbodies[h].getElementsByTagName("tr");
     
// ... and iterate through them
for (var i = 0; i < trs.length; i++) {

// avoid rows that have a class attribute
// or backgroundColor style
if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
 
// get all the cells in this row...
var tds = trs[i].getElementsByTagName("td");
        
// and iterate through them...
for (var j = 0; j < tds.length; j++) {
        
var mytd = tds[j];

// avoid cells that have a class attribute
// or backgroundColor style
if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
        
mytd.style.backgroundColor = even ? evenColor : oddColor;
              
}
}
}
// flip from odd to even, or vice-versa
even =  ! even;
}
}
}


// Open Center

function MyPopUpWinTravel() {
var iMyWidth;
var iMyHeight;
//half the screen width minus half the new window width.
iMyWidth = (window.screen.width/2) - (400);
//half the screen height minus half the new window height (plus title and status bars).
iMyHeight = (window.screen.height/2) - (370);
//Open the window.
var win2 = window.open("http://www.nature-notes.org/gallery/archive/1319/entry.php","Window2","status=no,height=800,width=800,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
win2.focus();
}

// Activate placeholder text for search boxes

function activatePlaceholders() {
var detect = navigator.userAgent.toLowerCase(); 
if (detect.indexOf(”safari”) > 0) return false;
var inputs = document.getElementsByTagName(”input”);
for (var i=0;i<inputs.length;i++) {
  if (inputs[i].getAttribute(”type”) == “text”) {
   if (inputs[i].getAttribute(”placeholder”) && inputs[i].getAttribute(”placeholder”).length > 0) {
    inputs[i].value = inputs[i].getAttribute(”placeholder”);
    inputs[i].onclick = function() {
     if (this.value == this.getAttribute(”placeholder”)) {
      this.value = “”;
     }
     return false;
    }
    inputs[i].onblur = function() {
     if (this.value.length < 1) {
      this.value = this.getAttribute(”placeholder”);
     }
    }
   }
  }
}
}
window.onload=function() {
activatePlaceholders();
}
