$(document).ready(function(){
	//target blank
	$("a[href^='http://']").attr('target','_blank');
	$("a[href^='http://']").addClass('extern');
	
	
	$("a[href$=.pdf]").addClass('pdf');
	$("a[href$=.doc]").addClass('doc');
	$("a[href$=.xls]").addClass('xls');
	$("a[href$=.docx]").addClass('docx');
	$("a[href^=mailto]").addClass('mailto');
	
	$("ul li:first-child").addClass('first');
	$("ul li:last-child").addClass('last');


	//for special effects in the navi
	$('#navigation ul ul').parent().addClass('sub');
	
	//fix the corner for hovers
	$('#navigation ul ul').parent().mouseover(function(){
		$(this).children('a').addClass('corner');
	});
	$('#navigation ul ul').parent().mouseout(function(){
		$(this).children('a').removeClass('corner');
	});
		
	
	$('#navigation li.sub').mouseover(function(){
		$(this).addClass('hover');
	});
	
	$('#navigation li.sub').mouseout(function(){
		$(this).removeClass('hover');
	});




	/*if (document.attachEvent)
	{
		// Suckerfish Hovers
		// Hinweis: Wenn es im html kein Element mit id="navigation" gibt, getElementById("navigation") loeschen oder austauschen
		var sfEls = document.getElementById("navigation").getElementsByTagName("UL")[0].getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}*/


	/* runde Ecken für Bilder - siehe auch CSS "Runde Ecken"
	if (jQuery('#prod-pic').width() > 0){
			
			jQuery(this).find('.cornerprodpic').each(function(){
			
				var imgWidth = jQuery(this).find('img').width();
				var imgHeight = jQuery(this).find('img').height();
				*/
				/*if(imgWidth > imgHeight){
					var margin = imgWidth - 385;
					var margin = margin / 2;
					jQuery(this).find('img').css('margin-left','-'+margin+'px');
				} */
				
				/*if(imgHeight > imgWidth){
					var margin = imgHeight - 170;
					var margin = margin / 2;
					jQuery(this).find('img').css('margin-top','-'+margin+'px');
				//}*/
			/*});	
	}*/


	/*if (jQuery('#productmenu ul li:eq(17)').width() > 0){
		jQuery("#productmenu ul").simplyScroll({
			className: 'vert',
			horizontal: false,
			frameRate: 20,
			speed: 13
		});
	}*/
	
	
	
	if (jQuery('#allergynavigator').width() > 0){
		jQuery('#allergynavigator tbody tr:even').addClass('even');
		jQuery('#allergynavigator tbody tr:last-child').addClass('last');
	}
	
	if(jQuery('.simply-scroll-clip').size() > 0){
	
		var activeLi = jQuery('.simply-scroll-clip li.active');
		var position = activeLi.position();	
		var positionTop = parseInt(position.top);
		
		if(positionTop > 370){
			var scrollClip = jQuery('.simply-scroll-clip').get(0);
			scrollClip.scrollTop = positionTop;
			
			jQuery('.simply-scroll-btn').removeClass('disabled');
		}
	}	
	
});
