var cMain = new function() {

    this.slideShowNext;
    this.slideShowActive;
    this.randNum;

	this.validateEmptyFields = function(form) {
		var el, errors = 0;
		var elements = form.find(":text:not(\".optional\"), textarea:not(\".optional\")");

        $.each(elements, function() {
            el = $(this);
        
        	if(el.val() === "" || el.val() === null) {
        		el.addClass("form_error").bind("focus", function() {
        		    $(this).removeClass("form_error");
        		});

        		errors++;
        	}
        	else {
                el.removeClass("form_error");
        	}
        });

		return (errors === 0);
	};
	
    this.initSlideShow = function() {
        cMain.randNum = Math.floor(Math.random() * $('div.slideShow a').length + 1);
        $('div.slideShow a').eq(cMain.randNum - 1).addClass('active');
        cMain.slideInterval = setInterval("cMain.slideShow()", 5000);
    };

	this.slideShow = function() {
        cMain.slideShowActive = $('div.slideShow a.active');

        if (cMain.slideShowActive.length == 0) cMain.slideShowActive = $('div.slideShow a').eq(cMain.randNum - 1);

        cMain.slideShowNext = cMain.slideShowActive.next().length ? cMain.slideShowActive.next() : $('div.slideShow a:first');

        cMain.slideShowActive.addClass('last-active');

        cMain.slideShowNext.css({opacity: 0.0})
            .addClass('active')
            .animate({ opacity: 1.0 }, 1000, function() {
                cMain.slideShowActive.removeClass('active last-active');
            });
	};

}
