﻿    var maxwidth = 410;
    var maxheight = 270;

function ShowFullVersion(fotoId,imageWidth,imageHeight,alttag, fotoBijschrift)
{    
    $("#fotofull").attr("src","/fotoboekfoto.aspx?id=" + fotoId + "&version=full")
                    .attr("alt",alttag);
                    
    centerImage(imageWidth,imageHeight);
                    //.css("margin-left",(maxwidth - imageWidth) / 2)
                    //.css("margin-top",(maxheight - imageHeight) /2);
    $("#fotofullbijschrift").text(fotoBijschrift);
    
    $("#thumbnails a.active").removeClass("active");
    $("#thumb" +  fotoId).addClass("active");
}      

function centerImage(imageWidth,imageHeight)
{    
    $("#fotofull").css("margin-left",(maxwidth - imageWidth) /2)
                  .css("margin-top",(maxheight - imageHeight) /2);
}

function OpenPics(url, iwidth, iheight) {
    window.open(url, "afbeelding", "width=" + iwidth + ",height=" + iheight + ",left=125,top=100");
}

this.initHoofdmenu = function(){

	xOffset = 30;
	yOffset = 50;
	$('#hoofdmenu a').each(function()
		{
			$(this).parent().append('<div class="tooltip" style="display:none">'+ $(this).attr('title') + '</div>');
			$(this).parent().find('.tooltip').text($(this).attr('title'));
		});
		$("#hoofdmenu a").hover(function(e){
			$(this).parent().find('.tooltip').css("top",(e.pageY - yOffset) + "px")
			$(this).parent().find('.tooltip').css("left",(e.pageX + xOffset) + "px")
			$(this).parent().find('.tooltip').show();
		},
		function(){
			$(this).parent().find('.tooltip').hide();
		}
	);
	$('#hoofdmenu a').attr('title','');
	
	$("#hoofdmenu a").mousemove(function(e){
		$(this).parent().find('.tooltip')
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});		
	
}

var pathExpressInstallFile = escape("/lib/flash/expressInstall.swf");

this.initFlash = function()
{

	var pathFlashFilePortaal = escape("/lib/flash/Home.swf");
	var pathFlashFileMagazine = escape("/lib/flash/megazine.swf");
	var flashHeight = 400;
	var flashVersion = [9,115]
	
	// ExpressInstall werkt alleen bij SWF's met minimale afmeting: 214px width x 137px height
	// Gebruik als er meerdere SWF's op 1 pagina staan, ook maar 1 expressinstaller, anders krijg je vele popups.
	
	if ($('.portaal').length > 0)
	{ 
	    $('body').flashembed(
	    { 
		    src: pathFlashFilePortaal,
		    version: flashVersion,
		    expressInstall: pathExpressInstallFile,
		    onFail: function(version)  { 
			    $('.portaal').append($('.portaal noscript').text());			
		    },    		
		    wmode:'window',
		    scale:'noscale'
	    }, 
	    {
		    prinsenInfoUrl : pathPrinsenPak,
		    prinsInfoUrl: pathPrinsenFoto,
		    hoofdmenuUrl: pathHoofdmenu,
		    magazineUrl: pathMagazine,
		    mooswiefUrl: '/lib/xml/content.ashx?id=105',
		    momusUrl: '/lib/xml/content.ashx?id=106',
		    geisUrl: '/lib/xml/content.ashx?id=107',
		    _taal: language
	    });
	}
	
	if ($('.magazine').length > 0)
	{ 
	    $('body').flashembed(
	    { 
		    src: pathFlashFileMagazine,
		    version: flashVersion,
		    expressInstall: pathExpressInstallFile,   		
		    wmode:'window',
		    scale:'noscale'
	    }, 
	    {
	        magazineId: magazineId,
	        xmlFile:    '../../lib/xml/magazine.ashx',
		    uiFile:     '../../lib/flash/interface.swf',
		    taal:       language
	    });
	}
	

}

// starting the script on page load
$(document).ready(function(){

    try
    {
	    initHoofdmenu();
	    initFlash();
	}
	catch(err)
	{
	    alert(err.message);
	}
});

function fixPng()
{
	$.ifixpng('/lib/images/pixel.gif'); 
	$('#balloonright').ifixpng();
	$('#balloonleft').ifixpng();
	$('#footer .ballonlinks').ifixpng();
	$('#footer .ballonrechts').ifixpng();
	$('#logo img').ifixpng();
	$('#image .vlag').ifixpng();
	$('#toolmenu ul.utils').ifixpng();
	$('#toolmenu ul.taal li a.ms').ifixpng();
	$('#toolmenu ul.taal li a.nl').ifixpng();
	$('#left .photobook .openen').ifixpng();
	$('#logoportaal').ifixpng();	
	$('#magazineafbeelding').ifixpng();	
	$('#websiteafbeelding').ifixpng();	
}

$(document).ready(function() {
    fixPng();

});



$(document).ready(function() {

    jQuery.extend(jQuery.validator.messages, {
        required: "Dit is een verplicht veld.",
        maxlength: jQuery.format("Please enter no more then {0} characters."),
        minlength: jQuery.format("Please enter at least {0} characters."),
        rangelength: jQuery.format("U dient minimaal {0} en maximaal {1} karakters in te voeren."),
        email: "Geen correct emailadres."
    });


    $('form.inschrijfformulier').validate();



   });



function emptyContactControls()
{
    $("#txtNaam").attr("value","");
    $("#txtAdres").attr("value","");
    $("#txtEmail").attr("value","");
    $("#txtTelefoon").attr("value","");
    $("#txtBericht").html("");
    
    return false;
}

function validateContact()
{

    var correct = true;

    if ($("#txtNaam").attr("value") == "")
    {
        $("#txtNaam").addClass("faulty");
    }
    else
    {
        $("#txtNaam").removeClass("faulty");
    }
    if ($("#txtEmail").attr("value") == "")
    {
        $("#txtEmail").addClass("faulty");
        correct = false;
    }
    else
    {
        $("#txtEmail").removeClass("faulty");
    }
    if ($("#txtTelefoon").attr("value") == "")
    {
        $("#txtTelefoon").addClass("faulty");
        correct = false;
    }
    else
    {
        $("#txtTelefoon").removeClass("faulty");
    }
    if ($("#txtBericht").attr("value") == "")
    {
        $("#txtBericht").addClass("faulty");
        correct = false;
    }
    else
    {
        $("#txtBericht").removeClass("faulty");
    }
    
    if (!correct)
    {
        $("#divErrorField").css({'display' : 'block'});
        $("#frm_error").html("Niet alle velden zijn correct ingevuld.");
    }
    else
    {
        $("#divErrorField").css({'display' : 'none'});
        $("#frm_error").html("");
    }    
    return correct;
}

