var current = -1;
var showtime = 7500; 
var headlineCount = 0;
var qTipContent = '';

$(document).ready(function(){ 
	$('.imgPopup').mouseover(function(){
		qTipContent = $(this).attr('qTipSrc');
	});
	
	$('[qTipSrc]').each(function() // Select all elements with the "tooltip" attribute
	{
	   $(this).qtip({ 
			content: { url: '/mod/loadimage.cfm?image='+ $(this).attr('qTipSrc') } 
			,
	   position: {
		  corner: {
			 target: 'topRight',
			 tooltip: 'bottomLeft'
		  }
	   },
	   style: {
			border: { 
				width: 4,
				color: '#CCF102'
			},
		background: '#4A555B',
		width: 334,
		height: 300,
		padding:0
   },
	   show: 'mouseover',
	   hide: 'mouseout'
		}); 
	});

	/* tooltip item 
	$('.imgPopup').qtip({
	   content: 
	   { 
	   	url: qTipContent
	   },
	   position: {
		  corner: {
			 target: 'topRight',
			 tooltip: 'bottomLeft'
		  }
	   },
	   style: {
			border: { 
				width: 4,
				color: '#CCF102'
			},
		background: '#4A555B',
		width: 334,
		height: 300,
		padding:0
   },
	   show: 'mouseover',
	   hide: 'mouseout'
	});*/

	$(".headline-item").hide();
	headlineCount = $(".headline-item").size()-1;
	if(headlineCount == 0){
		fadeLineIn(0);
	}else if(headlineCount > 0){
		gotoNext();
	}
	// This sets the opacity of the thumbs to fade down to 60% when the page loads	
	$("#menu .menuImageFade").fadeTo("slow", 0.5);	
	$("#menu .menuImageFade").hover(function(){		
		$(this).fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
	},function(){   		
		$(this).fadeTo("slow", 0.5); // This sets the opacity back to 60% on mouseout	
	});
	
	$("#topmenu").hoverIntent({
	   sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
	   interval: 50, // number = milliseconds for onMouseOver polling interval
	   over: divSlideDown, // function = onMouseOver callback (required)
	   timeout: 800, // number = milliseconds delay before onMouseOut
	   out: divSlideUp // function = onMouseOut callback (required)
	});
	
	$("#categorymenu").hide();
	
	$("#productGamma").mouseover(function(){	
		$("#categorymenu").slideDown();	
	});
	
	$("#categorymenu").hover(function(){	
	},function(){
		setTimeout("hideMenu()", 5000);	
	});
	
	$("#categorymenu a").click(function(){	
		$("#categorymenu").hide();
	});	
	
});
/************* news item *********************/
function fadeLineIn(counter){
	$(".headline-item:eq("+counter+")").fadeIn("slow");
}
function fadeLineOut(counter){
	$(".headline-item:eq("+counter+")").hide(0, gotoNext());
}
function gotoNext(){
	current++;
	if(current > headlineCount){
		current = 0;
	}	
	fadeLineIn(current);
	setTimeout("fadeLineOut("+current+")", showtime);	
}
/************* end news item *********************/

function switchPaymentButtons(){
	currentValue=document.getElementById('VoorwaardenAkkoord').checked;
	if(currentValue){
		$(".paymentButton").fadeTo("slow", 1);
	}else{
		$(".paymentButton").fadeTo("slow", 0.5);
	}
}
function hideMenu(){
	$("#categorymenu").slideUp("fast");
}
function loadAnimation(action){
	if(action=='show'){
		$("#Loading").show();
	}else{
		$("#Loading").hide();			
	}
}
function highlight1(){
	$("#btnStep2").fadeTo("slow", 0.5);
	$("#btnStep3").fadeTo("slow", 0.5);	
}
function highlight2(){
	$("#btnStep3").fadeTo("slow", 0.5);	
}
function hideInvoiceAddress(){
	$("tr.invoiceAddress").hide();	
	RegForm.InvAddressLine1.value = "";
	RegForm.InvAddressLine2.value = "";
	RegForm.InvAddressLine3.value = "";
	RegForm.InvPostcode.value = "";
	RegForm.InvCity.value = "";	
}
function showInvoiceAddress(){
	$("tr.invoiceAddress").show();	
}

function divSlideDown(){
	$("#topmenu").animate({'top':0}, 'normal'); 
}
function divSlideUp(){
	$('#topmenu').css('top', '-180px');
}

