 jQuery(document).ready(function() {
   Cufon.DOM.ready(function() {
	  Cufon.replace('h1,#menu ul li a span,h2,h3,.gallery-top-banner .title,.gallery-top-banner .link,.button.button span span,#counter .num');
	});
   
   jQuery('#menu .menu li a').before('<div class ="lefthover">&nbsp;</div>');
   jQuery('#menu .menu li a').wrap('<div class="midhover" />');
   jQuery('#menu  .menu .midhover').after('<div class ="righthover">&nbsp;</div>');
   //jQuery('.readon').html('Læs mere'); 		
   jQuery('#menu .menu li a').each(function(){
	jQuery(this).css('width', jQuery(this).find('span').width() + 'px');
   });
   
   var menuW = 900;
   
   var menuCount = jQuery('#menu .menu > li > div > a').size();
   jQuery('#menu .menu > li > div > a').css('width', parseInt(menuW / menuCount) - 10 + 'px');
   jQuery('#menu .menu a').each(function() {
	jQuery('span', this).wrap('<table onclick="window.location=\''+jQuery(this).attr('href')+'\'"><tr><td></td></tr></table>');
   });
   
   //jQuery('#menu a span').center();
   jQuery('#menu ul ul li').hide();
  
  
   jQuery('#menu2 .menu li a').before('<div class ="lefthover">&nbsp;</div>');
   jQuery('#menu2 .menu li a').wrap('<div class="midhover" />');
   jQuery('#menu2 .menu .midhover').after('<div class ="righthover">&nbsp;</div>');
   
   
   if(!jQuery('#menu3 .menu li').get(0)){
		jQuery('#menu3').css('display','none');
   }
   
   
   jQuery(function(){    jQuery('#menu2 ul li').last().css("border-right","none"); })
  
  jQuery("#slider").easySlider();
  jQuery("a[title='Phoca.cz']").parent().remove();;
 });
 
 
 jQuery.fn.center = function(params) {

		var options = {

			vertical: true,
			horizontal: true

		}
		op = jQuery.extend(options, params);

   return this.each(function(){

		//initializing variables
		var $self = jQuery(this);
		//get the dimensions using dimensions plugin
		var width = $self.width();
		var height = $self.height();
		//get the paddings
		var paddingTop = parseInt($self.css("padding-top"));
		var paddingBottom = parseInt($self.css("padding-bottom"));
		//get the borders
		var borderTop = parseInt($self.css("border-top-width"));
		var borderBottom = parseInt($self.css("border-bottom-width"));
		//get the media of padding and borders
		var mediaBorder = (borderTop+borderBottom)/2;
		var mediaPadding = (paddingTop+paddingBottom)/2;
		//get the type of positioning
		var positionType = $self.parent().css("position");
		// get the half minus of width and height
		var halfWidth = (width/2)*(-1);
		var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder;
		// initializing the css properties
		var cssProp = {
			position: 'absolute'
		};

		if(op.vertical) {
			cssProp.height = height;
			cssProp.top = '50%';
			cssProp.marginTop = halfHeight;
		}
		if(op.horizontal) {
			cssProp.width = width;
			cssProp.left = '50%';
			cssProp.marginLeft = halfWidth;
		}
		//check the current position
		if(positionType == 'static') {
			$self.parent().css("position","relative");
		}
		//aplying the css
		$self.css(cssProp);


   });

};

