$(document).ready(function()
{
	$("a[rel='colorbox']").colorbox();
    
    $('.innerfade').innerfade({
		speed: 750,
		timeout: 5000,
		type: 'random'
	});
    
    $("a.framebox").colorbox(
    {
        width: 486,
        height: 750,
        iframe: true
	});
    
    $('.changeVideo').click(function() {
        $('#movieContainerLeft').html('<object type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" height="394" width="479" data="http://www.youtube.com/v/' + $(this).attr('rel') + '?fs=1&amp;hl=nl_NL&autoplay=1&rel=0"><param name"allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/' + $(this).attr('rel') + '?fs=1&amp;hl=nl_NL&autoplay=1&rel=0" /><param name="wmode" value="transparent" /></object>');
        return false; 
    });
    
    $(".validateForm").validate({
        errorPlacement: function(error, element) {
			
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
		label.html("&nbsp;").addClass("checked");
		}
    });
    
    $(".validateBox").validate({
        errorPlacement: function(error, element) {
			
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
		label.html("&nbsp;").addClass("checked");
		}
    });
    
    $(".listTitle").click(function() {
        if($(this).hasClass("expanded")) {
            $(this).next('.listText').slideUp("medium");
        } else {
            $(this).next('.listText').slideToggle("medium");
        };
        $(this).toggleClass("expanded").toggleClass("collapsed");
	});
    
    $(".clearInput").focus(function(srcc)
    {
        if ($(this).val() == this.defaultValue)
        {
            $(this).val("");
        }
    });
    
    $(".clearInput").blur(function()
    {
        if ($(this).val() == "")
        {
            $(this).val(this.defaultValue);
        }
    });
    
    $(".clearInput").blur();
    
    $("#passwordText").focus(function()
    {
        if ($(this).val() == this.defaultValue)
        {
            $(this).hide();
            $('#password').val('').show().focus();
        }
    });
    
    $("#password").blur(function()
    {
        
        if ($(this).val() == "")
        {
            $(this).hide();
            $('#passwordText').val('Wachtwoord').show();
        }
    });
    
    $('.packThumbOverlay a').click(function()
    {
        $temp = $(this).parent().siblings('.packThumb').children('img').attr('src').split('../');
        $temp = $temp[1].split('&w=');
        $('#packItemHeaderRight').children('img').attr('src', $temp[0]);
        return false;
    });
    
    $('.tab').click(function() {
        $('.tab').removeClass('active');
        $(this).addClass('active');
        $('.tabContent').hide();
        $($(this).attr('href')).show();
        return false; 
    });
});

function reloadCaptcha()
{
	document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date();
}

function changePic(select, idPhoto) {
	for (var j = 0; j < document.getElementById(select).length; j++) {
		if (document.getElementById(select).options[j].selected == true) {
			var selectedValue = document.getElementById(select).options[j].value;
		}
	}
	switch (selectedValue) {
		case "110845":
			document.getElementById(idPhoto).src = "upload/image/power-unit-zcv845a-full.jpg";
			document.getElementById('photoTekst').innerHTML = '<strong>ZCV845</strong>';
		break;
		case "110855":
			document.getElementById(idPhoto).src = "upload/image/power-unit-zcv855-full.jpg";
			document.getElementById('photoTekst').innerHTML = '<strong>ZCV855</strong>';
		break;
		case "110860":
			document.getElementById(idPhoto).src = "upload/image/power-unit-zcv860-full.jpg";
			document.getElementById('photoTekst').innerHTML = '<strong>ZCV860</strong>';
		break;
		case "110870":
			document.getElementById(idPhoto).src = "upload/image/power-unit-zcv870-full.jpg";
			document.getElementById('photoTekst').innerHTML = '<strong>ZCV870</strong>';
		break;
		case "110350":
			document.getElementById(idPhoto).src = "upload/image/Electrolux-motor-3500.png";
			document.getElementById('photoTekst').innerHTML = '<strong>SC 3500</strong>';
		break;
		default:
			document.getElementById(idPhoto).src = "images/transparent.gif";
			document.getElementById('photoTekst').innerHTML = '';
		break;
	}
	return true;
}

(function ($) {
$.fn.vAlign = function($align) 
{
    return this.each(function(i)
    {
    var ah = $(this).height();
    var ph = $(this).parent().height();
    switch ($align)
    {
        case 'top':
            var mh = 0;
        break;
        case 'middle':
            var mh = Math.ceil((ph-ah) / 2);
        break;
        case 'bottom':
            var mh = Math.ceil(ph-ah);
        break;
   }
   
   $(this).css('margin-top', mh);
   });
};
})(jQuery);
