///  SLIDERS FOR HOMEPAGE

$(document).ready(function()
{
	$(function() {
		$('#slides a').lightBox();
	});

	// open preview
	$(".thumb").click(function()
	{
		var strContainer = "1";
		if (this.id>6)
			strContainer = "2";

		$("#placeholder" + strContainer).attr("src", "../imgcontent/poster/preview/" + this.id + ".jpg");

		if (!$("#container_preview" + strContainer).is(":visible"))
		{
			$("#container_preview" + strContainer).slideDown("slow");
		}
		return false;
	});
	
	// close preview
	$(".container_preview").click(function()
	{
		$("#" + this.id).slideUp();
		return false;
	});

	// validate contactform
	$("#contactform").ready(function()
	{
		validateOrderForm();
	});

});

function validateOrderForm()
{
	$.validator.setDefaults({
		submitHandler: function()
		{
			submitOrderForm();
			return false;
		}
	});
	$("#orderform").validate({
		rules: {
			naam: "required",
			bedrijf: "required",
			adres: "required",
			plaats: "required",
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			naam: "Uw naam ontbreekt.",
			bedrijf: "Uw bedrijf ontbreekt.",
			adres: "Uw adres ontbreekt.",
			plaats: "Uw plaats ontbreekt.",
			email: "Uw e-mailadres is ongeldig.",
			contact_email: {
				email: "Vul een geldig e-mailadres in.",
				required: "U heeft geen geldig e-mailadres ingevuld."
			}
		}
	});
}

function submitOrderForm()
{
	var strData = $("#orderform").serialize();

	$.ajax(
		{
			type: "POST",
			url: "/processform2mail.pp",
			data: strData + "&submit=1&ajax=1&r=" + getRandom(),
			success: function(html)
			{
				$("#products").fadeOut();

				$("#orderformfeedback").html("Uw bestelling is verzonden.<br><br><br><a href='home_nl.pp'>&raquo; verder</a>");
				$("#container-orderformfeedback").fadeIn("normal");
			}
		});
}

function videoPopup() {
		$("#video-popup").toggle();
		return false;
}

function growDiv(strID) {
		
	var intHeightOutside = $("#" + strID + "_Outside").height();
	var intHeightInside = $("#" + strID + "_Inside").height();
	
	if ( intHeightOutside < intHeightInside )
	{
		$("#" + strID + "_Outside").animate({
				height: intHeightInside
		  }, 400, function() {
			$("#grow_" + strID).html('[-]');
		});
	}
	else
	{
		$("#" + strID + "_Outside").animate({
		    height: 145
		  }, 400, function() {
			$("#grow_" + strID).html('[+]');
		});
	}
}

function init_slides(strPath, strXML)
{
	$.ajax({
		async:false,
	  url: strXML,
	  dataType: 'xml',
	  success: function(data) {
	    var strList='';
	    var strSlide='';
    	$(data).find('item').each(function()
			{
				strList += '<li class="menuItem"><a href=""><img src="' + strPath + '/thumbnails/';
				strList += $(this).find('thumb').text();
				strList += '" alt="thumbnail" /></a></li>';
				
				if ($(this).find('preview').text()!='')
				{
					strSlide += '<div class="slide">';
					strSlide += '<a href="' + strPath + '/superpreviews/' + $(this).find('superpreview').text() + '" title="">';
					strSlide += '<img src="' + strPath + '/previews/' + $(this).find('preview').text() + '" align="left"></a>';
					strSlide += '<p><b>' + $(this).find('title').text() + '</b>';
					strSlide += $(this).find('text').text() + '</p>';
					strSlide += '</div>';
				}
			});
			
			$('#menu').html('<ul>' + strList + '</ul>');
			$('#slides').html(strSlide);
		}
	});

}

function getRandom()
{
	return Math.random() * 99999;
}




