// JavaScript Document

// Popup mit Overlay aufrufen

$(document).ready(function() {

	/* This is basic - uses default settings */
	
	$("a.iframe").fancybox(	{
		'hideOnContentClick': false,
		'width': 560,
		'height': 440,
		'padding': 0,
		'overlayOpacity':   0.6,
		'overlayColor'  :  '#000'
	});
	
	/* Using custom settings */
	
	$("a.inline").fancybox({
		'hideOnContentClick': false,
		'overlayOpacity':   0.6,
		'overlayColor'  :  '#000'
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'overlayOpacity':   0.6,
		'overlayColor'  :  '#000'
	});
	
});

// Accordion menue

//function initMenu() {
//  $('.menu ul').hide();
//  $('.menu ul:first').hide();
//  $('.menu li a').click(
//    function() {
//      var checkElement = $(this).next();
//      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
//        return false;
//        }
//      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
//        $('.menu ul:visible').slideUp('normal');
//        checkElement.slideDown('normal');
//        return false;
//        }
//      }
//    );
//  }
//$(document).ready(function() {initMenu();});


$(document).ready(function(){
   $('.menu').hoverAccordion({
        keepHeight : true,
        onClickOnly : false,
		speed: 5000
  });
}); 


// Email
$(function(){
  var cont = $('span.mailme');
  var at = / at /;
  var dot = / dot /g;
  var addr = $(cont).text().replace(at,"@").replace(dot,".");
  $(cont).after('<a href="mailto:'+addr+'">'+ addr +'</a>')
  $(cont).remove();
});



// Select box styling

(function($){
 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){
				// selectBoxSpanInner.text($(this).val()).parent().addClass('changed');   This was not ideal
			selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
				// Thanks to Juarez Filho & PaddyMurphy
			});
			
	  });
	  }
	}
 });
})(jQuery);



$(document).ready(function(){
	$('.select').customStyle();
});
