function showDialog(p_sTitle, p_sHtml, p_iW, p_iH) {
	if (empty(p_sTitle)) {
		p_sTitle = '';
	}
	if (empty(p_sHtml)) {
		p_sHtml = '';
	}
	if (empty(p_iW)) {
		p_iW = 400;
	}
	if (empty(p_iH)) {
		p_iH = 240;
	}

	$("#dialog").attr('title', p_sTitle).html(p_sHtml).dialog({
		height: p_iH,
		width: p_iW,
		modal: true
	});
}

var pointer_inside = false; 

$(document).ready(function() { 
    
	if($('.banner').length){
		$('.banner').cycle({
	    	pager: '.pager',
	    	pagerAnchorBuilder: function(idx, slide){
	    		return '<a href="#"><span>' + idx + '</span></a>';
	    	},
	    	timeout: '4000',
	    	speed: '2000'
	    });
	}
	
	// Galleries added with fck editor
	$(".gallerytable:first a[rel^='prettyPhoto']").prettyPhoto({
		animation_speed: 'normal',
		theme: 'dark_rounded',
		slideshow: 3000, 
		autoplay_slideshow: false,
		social_tools: ''
	});
		
	// Input text field toggle
	// Set default text in attr value and add class to input
	// field with
	// classname: toggle
	$('input:text.toggle').each(function(idx, elem) {
		
		var oInput = $('#' + elem.id);
		oInput.click(function() {
			if (empty(oInput.attr('rel')) || oInput.attr('rel') == oInput.val()) {
				oInput.attr('rel', oInput.val());
				oInput.val('');
			}
		});
		oInput.blur(function() {
			if (oInput.val() == '') {
				oInput.val(oInput.attr('rel'));
			}
		});
	});	

	// Accordion
	if ($("#accordionContent").length) {
		$("#accordionContent").accordion();
	}
	
	// delay popup showing with 2 sec and fadein
	/**
	 * @todo convert to jquery version for popup module
	 */		
	if($('#popupMainContainer').length){
		$('#popupMainContainer').css('display', 'none');
		/*
		var hidePopup = new Fx.Tween('popupContainer');	
		(function(){ hidePopup.start('top', -800, 0); }).delay(1500);	
		$$('.popupClose').addEvent('click', function(){
			$('popupContainer').setStyle('visibility', 'hidden');
			$('popupMainContainer').setStyle('visibility', 'hidden');
		});
		*/	
	}
	
	$('.dealer > a').click(function(){
		$('.dealer .dealer-login-wrap').show();
	});

	$('#dealer-close').click(function(){
		$('.dealer .dealer-login-wrap').hide();
		return false;
	});

    $('.dealer .dealer-login-wrap').hover(function(){ 
        pointer_inside=true; 
    }, function(){
    	pointer_inside=false; 
    });

    $("body").mouseup(function(){ 
        if(! pointer_inside) $('.dealer .dealer-login-wrap').hide();
    });
	
    // explicit request by customer... sorry :(
    $('img').mousedown(function(e) {
    	if(e.which == 3) {
    		alert('(C) Copyright - Windak Dakkapellen');
    		return false;
    	}
    });
	
});
