function empty(mixed_var) {
	var key;
	if (mixed_var === "" || mixed_var === 0 || mixed_var === "0" || mixed_var === null || mixed_var === false || typeof mixed_var === 'undefined') { return true; }
	if (typeof mixed_var == 'object') {
		for (key in mixed_var) {
			return false;
		}
		return true;
	}
	return false;
}

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
	});
}

$(document).ready(function(){
	
	/* SLIDESHOW LITE */
	$("#imageBasket").slideshow({
		pauseSeconds: 4,
		width: 890,
		height: 140
	});

	$("div#imageBasket").show(5000,function(){
		$(this).css("visibility", "visible");
	});
	
	
	$("div#bannerTexts").slidetexts({
		pauseSeconds: 7
	});
	
	$("div#bannerTexts").show(5000,function(){
		$(this).css("visibility", "visible");
	});
	
    /*JQUERY LightBOX */ 
	/*
	$("div#content p img[title!=noA]").wrap(document.createElement("a"));
	$("div#content p a img[id!=noA]").parent().addClass("ltbox");

	$("a.ltbox img").each(function(){
		sSource = $(this).attr("src");
		$(this).parent().attr("href", sSource);
	});
	
	
   	$("a.ltbox").lightBox({
		overlayBgColor: '#000',
		overlayOpacity: 0.8,
		imageLoading: '/template/images/lightbox-ico-loading.gif',
		imageBtnClose: '/template/images/lightbox-btn-close.gif',
		imageBtnPrev: '/template/images/lightbox-btn-prev.gif',
		imageBtnNext: '/template/images/lightbox-btn-next.gif',
		containerResizeSpeed: 250,
		txtImage: 'Foto',
		txtOf: 'van'
   	});
   	*/

	i = 0;
	$("div.gallaryTable").each(function(){
		$(this).addClass("myClass_" + i);
		i++; 
	});	
   
	a = 0;

	$("div.gallaryTable").each(function(){

	    $("div.myClass_" + a + " a[rel*=ltbox]").lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.8,
			imageLoading: '/template/images/lightbox-ico-loading.gif',
			imageBtnClose: '/template/images/lightbox-btn-close.gif',
			imageBtnPrev: '/template/images/lightbox-btn-prev.gif',
			imageBtnNext: '/template/images/lightbox-btn-next.gif',
			containerResizeSpeed: 250,
			txtImage: 'Foto',
			txtOf: 'van'
	   	});
		a++;
	
	});
	
	// 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'));
			}
		});
	});
});
