// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

onload=function() {
  fwis_nav_in_motion = 0;
  setTimeout( 'fwis_nav_move()', 3000 ); 
  }
var fwis_nav_in_motion = 1;

function fwis_nav_move() {
  if( fwis_nav_in_motion == 0 ) {
    fwis_nav_in_motion = 1;
    var x = ( $('fwis_nav_listage').style.left == '17px' ) ? -17 : 17;
    Effect.MoveBy( 'fwis_nav_listage', 0, x, { duration:.5, afterFinish:function() { fwis_nav_in_motion = 0; } } );
    }
  }

function toggle( mode ) {
  if( mode == 'comments' ) {
    document.getElementById('comments').style.display = 'block';
    document.getElementById('thumbs').style.display = 'none';
    }
  else {
    document.getElementById('comments').style.display = 'none';
    document.getElementById('thumbs').style.display = 'block';
    }
  }

function clearSearch() {
  if( document.getElementById('keywords').value == 'keywords eg. designer name' ) {
    document.getElementById('keywords').value = null;
    document.getElementById('keywords').style.color = 'black';
    }
  }

function validateComments() {
  pass = 1;
  if( !document.getElementById('comments_input').value ) {
    pass = 0;
    alert('Please enter your comments before posting.');
    }
  else if( !document.getElementById('name').value ) {
    pass = 0;
    alert('Please enter your name.');
    }
  else if( !document.getElementById('link').value ) {
    pass = 0;
    alert('Please enter an email address or url.');
    }
  if( pass == 0 ) return false;
  else return true;
  }

function check_input() {
  if( $('keywords').value == 'enter a title, cover designer or author here' ) {
    $('keywords').value = '';
    }
  else if( $('keywords').value == '' ) {
    $('keywords').value = 'enter a title, cover designer or author here';
    }
  }

//  Replacement for target="_blank" that is XHTML compliant

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external,nofollow")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;
