function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
	var idx = carousel.index(i, mycarousel_itemList.length);
	carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
	carousel.remove(i);
};

function mycarousel_getItemHTML(item)
{
	return '<a href=\"'+ item.link +'\"><img src=\"' + item.url + '\" width=\"120\" height=\"60\" alt=\"' + item.title + '\" /></a>';
};

function mycarousel_initCallback(carousel)
{
	carousel.buttonNext.bind('mouseover', function() {
		carousel.startAuto(1);
	});
	carousel.buttonPrev.bind('mouseover', function() {
		carousel.startAuto(1);
	});
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};


function InEnUitKlappen(id)
{
	if(document.getElementById(id).style.display == 'none')
    {
        document.getElementById(id).style.display = 'block';
    }
    else
    {
        document.getElementById(id).style.display = 'none';
    }
}

function plaatjeWisselen(id,httppad,kleur)
{
	if(document.getElementById(id).src == httppad+'images/iconen/btn_maxi'+kleur+'.gif')
    {
        document.getElementById(id).src = httppad+'images/iconen/btn_mini'+kleur+'.gif';
    }
    else
    {
        document.getElementById(id).src = httppad+'images/iconen/btn_maxi'+kleur+'.gif';
    }
}

function plaatjeWisselen2(obj,httppad) {
	var pad = jQuery(obj).find('img').attr('src');
	if(pad == httppad + 'images/iconen/btn_maxi.gif') {
		jQuery(obj).find('img').attr('src', httppad + 'images/iconen/btn_mini.gif');
	} else {
		jQuery(obj).find('img').attr('src', httppad + 'images/iconen/btn_maxi.gif')
	}
}

function vullingtonen(naam,menunaam,nr,aantal)
{
	for (i=1;i<=aantal;i++)
	{
		document.getElementById(naam+i).style.display = 'none';
		document.getElementById(menunaam+i).className = 'BLOGsubmenuNietActief';
	}
    document.getElementById(naam+nr).style.display = 'block';
    document.getElementById(menunaam+nr).className = 'BLOGsubmenuActief';
}

function vullingtonentype(naam,menunaam,nr,aantal,type)
{
	for (i=1;i<=aantal;i++)
	{
		document.getElementById(naam+i).style.display = 'none';
		document.getElementById(menunaam+i).className = type+'submenuNietActief';
	}
    document.getElementById(naam+nr).style.display = 'block';
    document.getElementById(menunaam+nr).className = type+'submenuActief';
}

/* Profiel functies */
function profileAddItem(name)
{
	option = jQuery("#profiel" + name + " .other input").val();

	if(option != "")
	{
		jQuery("#profiel" + name + " .other").before("<label><input class=\"checkbox\" type=\"checkbox\" name=\"data[" + name + "][]\" value=\"" + option.replace(/\"/g, '&quot;') + "\" checked=\"checked\" />" + option + "</label>");
		jQuery("#profiel" + name + " .other input").val("");
	}
}

function profileRemoveAvatar()
{
	jQuery.get("http://localhost/horses/site/ajax/profiel/profiel.ajax.php", {"action": "deleteThumbnail"},
			function(data)
			{
				jQuery("#avatar").html(data);
			}
		);
}

function profileRemoveHorseAvatar(id)
{
	jQuery.get("http://localhost/horses/site/ajax/paarden/paarden.ajax.php", {"action": "deleteThumbnail", "pid": id},
			function(data)
			{
				jQuery("#avatar").html(data);
			}
		);
}

function horseRemove(id)
{
	if(confirm('Weet je het zeker?'))
	{
		profileRemoveHorseAvatar(id)
		jQuery(".notice").hide();
		jQuery.get("http://localhost/horses/site/ajax/paarden/paarden.ajax.php", {"action": "deleteHorse", "id": id},
				function(data)
				{
					jQuery("#horse" + id).hide("slow");
				}
			);
	}
}

function profileSearch(p)
{
	if(!p) {
		p = 1;
	}
	var strExtraOpties = '';
	var extraopties = jQuery('#extraopties').find('input:checkbox');
	for(var i=0; i<extraopties.length;i++) {
		if(jQuery(extraopties[i]).attr('checked')) {
			strExtraOpties += '&extraopties[]='+jQuery(extraopties[i]).attr('value');
		}
	}

	jQuery.ajax({
		type: "GET",
		url: "http://localhost/horses/site/ajax/profiel/profiel.ajax.php",
		data: "action=search&s="+jQuery('#profileSearch').val()+'&p='+p+strExtraOpties,
		success: function(msg) {
			//alert('Bedankt, er is een melding gemaakt van deze reactie.');
			jQuery("#searchResults").html(msg);
		}
	});

	/*jQuery.get("http://project2.exed.nl/rbi/horses/site/ajax/profiel/profiel.ajax.php", {"action": "search", "s": jQuery('#profileSearch').val(), "p": p, 'e' : strExtraOpties},
		function(data) {
			jQuery("#searchResults").html(data);
		}
	);*/
}

function areYouSure(message,link) {
	if(confirm(message)) {
		document.location = link;
	} else {
		return false;
	}
}

function textCounter(field, countfield, limit)
{
    if (field.value.length > limit)
    {
        field.value = field.value.substring(0, limit);
    }
    else
    {
        document.getElementById(countfield).innerHTML = limit - field.value.length + "/"+limit+" karakters over";
    }
}

function copyQuote(reactieid) {
	jQuery('#userreactietxt').append('[quote]'+jQuery('#reactietxt'+reactieid).html()+'[/quote]');
}

function meldReactie(reactieid) {
	jQuery.ajax({
		type: "POST",
		url: "/horses/site/ajax/vraagbaak/vraagbaak.ajax.php",
		data: "act=meldReactie&reactieid="+reactieid,
		success: function(msg) {
			alert('Bedankt, er is een melding gemaakt van deze reactie.');
		}
	});
}
function printContent(content) {
	var disp_setting =  "toolbar=yes,location=no,directories=yes,menubar=yes,";
		disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25";

	var docprint = window.open("","",disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head><title>Horses.nl</title>');
	docprint.document.write('</head><body onload="self.print()">');
	docprint.document.write(content);
	docprint.document.write('</body></html>');
	docprint.document.close();
	docprint.focus();
}

function stuurdoorEmail() {
	jQuery('.alertBox').css('display','none');
	var inputVelden = jQuery('#stuurdoorform :input.formVeld');
	var opmerking = jQuery('#opmerking').val();
	var urlString = '';
	var doorgaan = true;
	for(var i=0;i<inputVelden.length;i++) {
		if(inputVelden[i].value == '') {
			doorgaan = false;
		}
		urlString += '&'+inputVelden[i].name+'='+inputVelden[i].value+'&opmerking='+opmerking;
	}
	if(doorgaan) {
		jQuery.ajax({
			type: "POST",
			url: "/horses/site/ajax/algemeen/algemeen.ajax.php",
			data: "act=stuurdoor"+urlString,
			success: function(msg) {
				if(msg == 'go') {
					jQuery('.doorsturen')
					.fadeOut('slow', function(){
						jQuery('.doorsturen').html('<p>Uw e-mail is met succes verzonden.</p>');
					})
					.fadeIn('slow')
					.animate({opacity: 1.0}, 2000)
					.fadeOut('slow');
				} else {
					jQuery('.alertBox');
					jQuery('.alertBox').html(msg);
				}
			}
		});
	} else {
		jQuery('.alertBox').fadeIn('slow').css('display','block');
		jQuery('.alertBox').html('Vergeet niet alle velden in te vullen');
	}
}

function showHoefje(hoefjeid,hoeveel) {
	jQuery.ajax({
			type: "POST",
			url: "/horses/site/ajax/algemeen/algemeen.ajax.php",
			data: "act=showmorehoefje&idbericht="+hoefjeid+'&hoeveel='+hoeveel,
			success: function(msg) {
				jQuery('#hoefje'+hoefjeid).html(msg);
			}
		});
}

function sendHoefje() {
	var ontvanger_idgebruikers = jQuery('#ontvanger_idgebruikers option:selected').val();
	var text = jQuery('#text').val();
	jQuery.ajax({
		type: "POST",
		url: "/horses/site/ajax/algemeen/algemeen.ajax.php",
		data: "act=sendhoefje&ontvanger_idgebruikers="+ontvanger_idgebruikers+'&text='+text,
		success: function(msg) {
			jQuery('.bericht').fadeIn('slow').css('display','block')
			.animate({opacity: 1.0}, 2000)
			.fadeOut('slow');
		}
	});
}

function vriendAanmelden(idvriend) {
	jQuery.ajax({
		type: "POST",
		url: "/horses/site/ajax/algemeen/algemeen.ajax.php",
		data: "act=vriendaanmelden&idvriend="+idvriend,
		success: function(msg) {
			jQuery('.bericht')
			.fadeOut('slow', function(){
				jQuery('.bericht').html('<p>Het vriendenverzoek is verstuurd.</p>');
			})
			.fadeIn('slow')
			.animate({opacity: 1.0}, 2000);
		}
	});
}

function keurVriend(idgebruikerskoppel,status) {
	jQuery.ajax({
		type: "POST",
		url: "/horses/site/ajax/algemeen/algemeen.ajax.php",
		data: "act=keurvriend&idgebruikerskoppel="+idgebruikerskoppel+'&status='+status,
		success: function(msg) {
			var strStatus = (status == 'goed') ? 'toegevoegd aan vriendenlijst' : 'afgekeurd';
			jQuery('#statuskeur'+idgebruikerskoppel)
			.fadeOut('slow', function(){
				jQuery('#statuskeur'+idgebruikerskoppel).html(strStatus);
			})
			.fadeIn('slow').animate({opacity: 1.0}, 2000);
		}
	});
}

function reactievraagenaanbod() {
	var naam = jQuery('#reactievraagenaanbod input[name=naam]').val();
	var email = jQuery('#reactievraagenaanbod input[name=email]').val();
	var captcha = jQuery('#reactievraagenaanbod input[name=captcha]').val();
	var reactie = jQuery('#reactievraagenaanbod textarea[name=reactie]').val();
	var idvraagenaanbod = jQuery('#reactievraagenaanbod input[name=idvraagenaanbod]').val();

	jQuery.ajax({
		type: "POST",
		url: "/horses/site/ajax/algemeen/algemeen.ajax.php",
		data: "act=reactievraagenaanbod&naam="+naam+'&email='+email+'&captcha='+captcha+'&reactie='+reactie+'&idvraagenaanbod='+idvraagenaanbod,
		success: function(msg) {
			if(msg == 'go') {
				jQuery('#melding').html('<p>Uw bericht is verstuurd</p>');
			} else {
				jQuery('#melding').html(msg);
			}
			/*var strStatus = (status == 'goed') ? 'toegevoegd aan vriendenlijst' : 'afgekeurd';
			jQuery('#statuskeur'+idgebruikerskoppel)
			.fadeOut('slow', function(){
				jQuery('#statuskeur'+idgebruikerskoppel).html(strStatus);
			})
			.fadeIn('slow').animate({opacity: 1.0}, 2000);*/
		}
	});
}

function showBlok(blokid) {
	jQuery('.headline').css('display','none');
	jQuery('.blok'+blokid).css('display','block');
	jQuery('.pageLink').css('font-weight','normal');
	jQuery('.link'+blokid).css('font-weight','bold');
}

function showPage(pageid) {
	jQuery('.pageScroller').css('display','none');
	jQuery('.page'+pageid).css('display','block');
	jQuery('.pageLink').css('font-weight','normal');
	jQuery('.link'+pageid).css('font-weight','bold');
}

function FMBChangeVid(videoid) {
	jQuery('#vidContent').html(jQuery('#video'+videoid).html());
	jQuery('#vidTitle').html(jQuery('#videotitle'+videoid).html());
	jQuery('#videotext').html(jQuery('#videotext'+videoid).html());
	jQuery('#videoimage').attr('src',jQuery('#videoimage'+videoid).attr('src'));
}

function openWindow(url,hoogte,breedte) {
	var disp_setting =  "toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,width="+breedte+", height="+hoogte+"";
	window.open(url,"",disp_setting);
	return false;
}

function rateMouseover(id)
{
	for(i = 0; i <= 5; i++)
	{
		if(i <= id)
		{
		jQuery('#rate' + i).attr('src', 'http://localhost/horses/site/images/iconen/waardering_groen.gif');
		}
		else
		{
		jQuery('#rate' + i).attr('src', 'http://localhost/horses/site/images/iconen/waardering_creme.gif');
		}
	}
}

function rateMouseout()
{
	for(i = 0; i <= 5; i++)
	{
		jQuery('#rate' + i).attr('src', 'http://localhost/horses/site/images/iconen/waardering_creme.gif');
	}
}

function doRating(rating, mediaId, targetId)
{
	jQuery.get("/horses/site/ajax/media/media.ajax.php?action=dorate&mediaid="+mediaId+"&rating="+rating, function(data) {
			jQuery("#"+targetId).html(data);
	});
}

function doBlogRating(rating, blogId, targetId)
{
	jQuery.get("/horses/site/ajax/blog/blog.ajax.php?action=dorate&blogid="+blogId+"&rating="+rating, function(data) {
			jQuery("#"+targetId).html(data);
	});
}

function doTopicRating(rating, topicId, targetId)
{
	jQuery.get("/horses/site/ajax/vraagbaak/vraagbaak.ajax.php?action=dorate&topicid="+topicId+"&rating="+rating, function(data) {
			jQuery("#"+targetId).html(data);
	});
}