$(document).ready(function () {
	$('li.mail a').each(function () {
		$(this).click(function (e) {
            e.preventDefault();
			popTellAFriend();
		});
	});
	$('li.tw a').each(function () {
			$(this).click(function (e) {
            e.preventDefault();
			window.open('http://www.twitter.com/share?url=' + location.href, 'twitter', 'height=400,width=500,left=250,top=125');
		});
	});
	$('li.fb a').each(function () {
		$(this).click(function (e) {
            e.preventDefault();
			window.open('http://www.facebook.com/sharer.php?u=' + location.href, 'facebook', 'height=400,width=500,left=250,top=125');
		});
	});
	var hoverConfig = {
		interval:50,
		timeout:50,
		over:function(e){ $(this).find('.prodgroupinfo').fadeIn(100); $(this).css('zIndex', '1000'); },
		out:function(e){ $(this).find('.prodgroupinfo').fadeOut(100); $(this).css('zIndex', 'auto');  }
	}
	$('.prodgroups li').hoverIntent(hoverConfig);
	$("#slides").hover(function() {
		stopSlide2();
	}, function() {
		resumeSlide();
	});

});
var firstTime = true;
$('#slides').cycle({
	fx: 'scrollHorz',
	prev: '#prev1',
	next: '#next1',
	timeout: 8000,
	pager: '.imgnav ul',
	before: onBefore,
	after: onAfter,
	pagerAnchorBuilder: function (idx, slide) {
		return '<li><a href="#"></a></li>';
	}
});
	
            
function onBefore(curr, next, opts) {
	var altText = $(this).find('img').attr('alt')
	$('.mainimginfoinner').fadeOut(function() {
    		$('.mainimginfoinner').html(altText);
 	});
}
function onAfter(curr, next, opts) {
	$('.mainimginfoinner').fadeIn();
	
}
var sliderStopped = false;
function stopSlide() {
	sliderStopped = true;
	$('#slides').cycle('pause');
}
function stopSlide2() {
	$('#slides').cycle('pause');
}
function resumeSlide() {
	if (!sliderStopped)
		$('#slides').cycle('resume'); 
	}
      	function removeMovie() {
        	$("#slides a.lnkImage").show();
        	$("#slides div.video").hide();
        }
      	$(function () {
       		$("span.startfilm").click(function (e) {
      		e.preventDefault();
		$("#slides a.lnkImage:visible").hide();
   		$("#slides div.video").show();
      		sliderStopped = true;
        	stopSlide();
	});
});
$('.refimgs').cycle({
	fx: 'fade',
	timeout: 0,
	pager: '.refimgsthumbs ul',
	before: onBefore,
	after: onAfter,
	pagerAnchorBuilder: function (idx, slide) {
		imgsrc = slide.src;
                srcPath = imgsrc.replace(".png", "_80_80_2_thumb.png");
		srcPath2 = srcPath.replace(".jpg", "_80_80_2_thumb.jpg");
                return '<li><a href="#"><img src="' + srcPath2 + '" /></a></li>';
	}
});
$(".refimgsthumbs ul li:nth-child(8n)").addClass("lastthumb")

	
$(function () {
    $(".remember").each(function () {
        $(this).data("placeholder", $(this).val());
    });
    $(".remember").focus(function () {
        if ($(this).val() == $(this).data("placeholder"))
            $(this).val('');
    });
    $(".remember").blur(function () {
        if ($(this).val() == '')
            $(this).val($(this).data("placeholder"));
    });

   // $(".lavaLamp").lavaLamp({ fx: "linear", speed: 250 });

});

$(".newsitem").not(":first").hide();
$("#nextNews").click(function (e) {
    e.preventDefault();
    var activeNews = $(".newsitem:visible");
    activeNews.hide();
    activeNews.next().show();
    if ($(".newsitem:visible").size() == 0) {
        $(".newsitem:first").show();
    }
});
$("#prevNews").click(function (e) {
    e.preventDefault();
    var activeNews = $(".newsitem:visible");
    activeNews.hide();
    activeNews.prev().show();
    if ($(".newsitem:visible").size() == 0) {
        $(".newsitem:last").show();
    }
});
