function colorizeHeader() {
	$('h2, h3').each(function() {
		var text = $(this).text();
		var lastIndex = text.lastIndexOf(' ');
		if(lastIndex>0) {
			var part1 = text.slice(0, lastIndex);
			var part2 = text.slice(lastIndex);
			if($(this).parent().attr('class')=='iInformation') {
				$(this).html(part1+' <span class="highlight">'+part2+'</span>');
			} else {
				$(this).html(part1+' <span class="highlight">'+part2+'</span>');
			}
		} else {
			var part1 = text.slice(0, lastIndex);
			var part2 = text.slice(lastIndex);
			$(this).html(part1+'<span class="highlight">'+part2+'</span>');
		}
	});
}


$(document).ready( function() {
  // PNG FIX für IE6
  $(document).pngFix();
  
  //IMG ohne alt Text füllen
  $("img[alt='']").attr('alt','Eurolife - together on the top');
  
  //minheit 4 content
  var content = $('#cUpperContent');
  if(content.height()<367) {
  	content.height(367);
  }
  
  //fancybox automator
  $("a[href$='jpg'], a[href$='jpeg'], a[href$='png'], a[href$='gif']").fancybox();
  
  //Animate Menu
  if ($.browser.msie && $.browser.version<8) {
  	$("div.navigationField").hover(function () {
  		$(this).find('div.navigationFieldSub').show();
  	}, function() {
  		$(this).find('div.navigationFieldSub').hide();
  	});
  } else {
  	$("div.navigationField").animateMenu();
  }

  
  //dropdown language in metanav
  if($("div.dropdown > ul.metanavSub").size()>0) {
    $("div.dropdown").hover(function() {
      $(this).find("ul.metanavSub").show();
    }, function() {
      $(this).find("ul.metanavSub").hide();
    });
  }
  
  // last call: | => metanav & hr in members index
  $('#metanav > span:last').remove();
  $('div.mContentColumn').each(function() {
    $(this).find('hr:last').remove();
  });
  
  // make a pretty nice unordered list
  $("ul > li").prepend("<span class='liBlue'>&gt; </span>");
  $("ul > li").each(function() {
    var liHeight = $(this).height()-2;
    $(this).find('span').height(liHeight);
  });
  $('span.liBlue, span.liBlack').each(function() {
    var liHeight = $(this).parent().height();
    $(this).height(liHeight);
    if($(this).parent().height()>liHeight) {
    	var liHeight = $(this).parent().height();
   		$(this).height(liHeight);
    }
  });

  //greybacken up
  $(".greyBackground li").each(function() {
    $(this).wrapInner('<span class="greyBackground"></span>');
  });
  
  // headlines make them red and blue
  colorizeHeader();
  
  // make DOWNLOADS pretty
  $('#mDownloadBlock > p:even').css('background-color','#f5f5f5');
  
  //FAQ
  $('div.faqEntry').toggle(function() {
    $(this).find('p.faqAnswer').show();
  },function() {
    $(this).find('p.faqAnswer').hide();
  });
  
  // ---------- SHOP -------------
  $('#shoppingCart').load('/_include/site/shoppingCart.php');
  
  $("a.orderItem").bind('click', function() {
    $('#shoppingCart:hidden').show();
    var produktHTML = $(this).parent().parent();
    var pID   = produktHTML.find('span.pID').text();
    var pTitel = produktHTML.find('span.pTitel').text();
    var pPrice = produktHTML.find('span.pPrice').text();
    $('#shoppingCart').load('/_include/site/shoppingCart.php', {id: pID, titel:pTitel, price:pPrice});
  });
  
  $("#addItem, #removeItem, #emptyItem").live('click', function(e) {
    var pID = parseInt($(this).attr('title'));
    
    if(e.currentTarget.id=='addItem') {
      $('#shoppingCart').load('/_include/site/shoppingCart.php', {addID: pID});
    }
    if(e.currentTarget.id=='removeItem') {
      $('#shoppingCart').load('/_include/site/shoppingCart.php', {removeID: pID});
    }
    if(e.currentTarget.id=='emptyItem') {
      $('#shoppingCart').load('/_include/site/shoppingCart.php', {emptyID: pID});
    }
    
  });
  
});
