startList = function() {
  var inputContent = '';
  if ( $('#nlForm').length ){ 
    $('#search').bind("focus", function(e){
      if (!inputContent){ inputContent = $('#search').attr('value'); }
      $('#search').attr('value','');
    });
    $('#search').bind("blur", function(e){
      if (!$('#search').attr('value').length){
        $('#search').attr('value', inputContent);
      }
    });
  }

  if ( $('#adminmenu').length ) { prepareMenu('adminmenu'); }
  if ( $('#topMenu').length ) { prepareMenu('topMenu'); }
  if ( $('#mycarousel').length) { $('#mycarousel').jcarousel({ scroll: 1, auto: 0, initCallback: mycarousel_initCallback }); }
}
window.onload = startList;

prepareMenu = function(id) {
  if (document.all && document.getElementById) {
  	var sfEls = document.getElementById(id).getElementsByTagName("LI");
  	for (var i = 0; i < sfEls.length; i++) {
  		sfEls[i].onmouseover = function() {
  			this.className += " over";
  		}
  		sfEls[i].onmouseout = function() {
  			this.className = this.className.replace(new RegExp(" over\\b"), "");
		  }
	  }
  }
}

//=====================================================================
// Event Listener
// by Scott Andrew - http://scottandrew.com
// edited by Mark Wubben, <useCapture> is now set to false
//=====================================================================
function addEvent(obj, evType, fn){
	if(obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	} else {
		return false;
	}
}

function tooltip(vLink, e, messageBox){
  if(!vLink.title || !document.createElement){ return; }
  messageParagraph = document.getElementById('offerIconDesc');
  messageParagraph.hide = function(x){ messageParagraph.innerHTML = "&nbsp;"; }
  messageParagraph.innerHTML = vLink.title;
  vLink.onmouseout = messageParagraph.hide;
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

