/* js library */

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("mainmenu");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" hover";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" hover", "");
   }
   }
  }
 }
}
window.onload=startList;

function Swap(which,state)
{
	var elm=document.getElementById(which);
	switch (state)
	{
		case 'over':
			elm.src='/img/'+which+'-image-'+state+'.png';
		break;
		case 'out':
			elm.src='/img/'+which+'-image.png';
		break;
	}
}

function Change(which,state)
{
	var elm=document.getElementById('href'+which);
	switch (state)
	{
	case 'over':
		elm.style.color='#c3dc3c';
	break;
	case 'normal':
		elm.style.color='#8caec5';
	break;
	}
}

$(document).ready(function() {

// Open links in new window
$("a[rel='external']").click(function(){window.open(this.href); return false;});

// Activate Selectbox
$(function() {
	$('select').selectbox();
});

});//End document ready

(function($) {
$.selectbox = function() {
var elem = $(this).hide().change(onchange_select),
selectbox = elem.wrap('<div class="selectbox" />').parent('.selectbox'),
list_visible = false;

// Wrap select tag and provide a default option
selectbox.append(
$.selectbox.options.current_html.replace('%default_content%', $.selectbox.options.default_content));

var dropdown = selectbox.append('<ul />').children('ul');
$(this).find('option').each(function() {
var option = $(this);
dropdown.append($('<li>' +
' <div class="title">' + option.text() + '</div>' +
'</li>').data('boxvalue', option.val()));
});

selectbox.find('.current').click(function(event) {
if (list_visible) {
dropdown.hide();
list_visible = false;
} else {
list_visible = true;
dropdown.slideDown('slow');
selectbox.siblings('.selectbox').find('ul:visible').hide();
selectbox.find('li').one('click', function() {
elem.val($(this).data('boxvalue')).change();
});
}
});

return;

function onchange_select() {
var title = $(this).val() || $.selectbox.options.default_content;
selectbox.children('ul').slideUp('fast');
selectbox.find('.current .title').text(title);
}
};

$.extend($.selectbox, {
options: {
default_content: 'Vyberte',
current_html: '<div class="current">' +
' <span class="title">%default_content%</span>' +
'</div>'
}
});

$.fn.selectbox = function() {
this.each($.selectbox);
return this;
};

})(jQuery);
