startList = function() {
  if ( $('#adminmenu').length ) { prepareMenu('adminmenu'); }
  if ( $('#topMenu').length ) { prepareMenu('topMenu'); }
  
  if( $('#getAdvanced')){ 
    $("#getAdvanced").click(function () { $("#bigSearchAdvanced").slideToggle("slow", function(){ $('#getAdvanced').toggle(); $('#getSimple').toggle(); } ); });  
  }
  if( $('#getSimple')){ 
    $("#getSimple").click(function () { $("#bigSearchAdvanced").slideToggle("slow", function(){ $('#getSimple').toggle(); $('#getAdvanced').toggle(); } ); });  
  }
  
}
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") 
		{
			anchor.target = "_blank"; 
		}
	} 
} 
prepareAll = function() {
startList();
externalLinks();
}
window.onload = prepareAll;

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;
  messageParagraph.innerHTML += vLink.className == 'off' ? ' - funkcja nieaktywna w tej ofercie' : '';
  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();
    });
};
