jQ = jQuery
jQ(document).ready(init);
ss = new Object();

function init() {

    // clear all for input boxes
    jQ('.reqd').each(
		     function(){
			 if (this.type == 'checkbox') {
			     this.checked = null;
			 } else {
			     this.value = '';
			 }
		     }
		     );

    // load news on front page
    jQ('#newnews').each(
	function(){
	    jQ(this).hide();
	    jQ(this).addClass('newnews');
	    jQ.get('../news.txt', {}, 
		   function(data) {
		       if (data.length > 5) {
			   jQ('#newnews').html(
                             '<div class="nn">Latest news:</div>');
			   jQ('#newnews').append(data);
			   jQ('#newnews').animate({opacity: 1.0}, 3200).show(3000);
		       }
		   }
		   );
	}
			);

    // slide show at bottom
    
    ss.images = new Array(
			   'images/prod/md/dsc_7153.jpg',
			   'images/prod/md/dsc_7156.jpg',
			   'images/prod/md/dsc_7158.jpg',
			   'images/prod/md/dsc_7159.jpg',
			   'images/prod/md/dsc_7162.jpg',
			   'images/prod/md/dsc_7163.jpg',
			   'images/prod/md/dsc_7164.jpg',
			   'images/prod/md/dsc_7165.jpg',
			   'images/prod/md/dsc_7167.jpg',
			   'images/prod/md/dsc_7169.jpg',
			   'images/prod/md/dsc_7171.jpg',
			   'images/prod/md/dsc_7172.jpg',
			   'images/prod/md/dsc_7173.jpg',
			   'images/prod/md/dsc_7174.jpg',
			   'images/prod/md/dsc_7175.jpg',
			   'images/prod/md/dsc_7176.jpg',
			   'images/prod/md/dsc_7178.jpg',
			   'images/prod/md/dsc_7179.jpg');
    ss.image = 0;
    ss.frame = '#ss0';

    function slideshow() {
        oframe = '#ss1';
        if (ss.frame == '#ss1') {
	    oframe = '#ss0';
	}
	n = ss.image + 1;
	if (n == ss.images.length) { n = 0; }
	jQ(oframe).html('<img src="'+ss.images[n]+'"/>');
	jQ(oframe).fadeIn(3000);
	jQ(ss.frame).fadeOut(3000);//.fadeTo(2000,0);
	jQ('#ss0').queue('fx', slideshow);
	ss.frame = oframe;
	ss.image = n;
	jQ('#ss0').dequeue();
    }

    jQ(ss.frame).html('<img src="'+ss.images[0]+'"/>');

    jQ(ss.frame).fadeIn(3000);//.fadeTo(2000,1);
    jQ(ss.frame).queue('fx', slideshow);

    function pulse() {
	var x = jQ('#nekwa');
	x.after('a');
	x.queue('fx', pulse);
	x.fadeOut(2000);
	x.fadeIn(2000);
	x.dequeue();
    }
    var x = jQ('#newa');
    // x.fadeIn(2000);
    // x.fadeOut(2000);
    // x.queue('fx', pulse);
    // pulse();

    jQ('.din .nlms').each(
	function() {
            var bg = jQ('<div class="bkgnd"></div>');
	    bg.hide();
            jQ(this).after(bg);  
            jQ(this).hover(
	    		   function() {
	    		       var x = bg.queue('fx');
	    		       while (x.length > 0) {
	    			       x.pop();
	    			   }
	    		       bg.fadeIn();
	    		   },
	    		   function() { bg.fadeOut(); }
            );
            // jQ(this).mouseover(
	    // 		   function() {
	    // 		       bg.show();
	    // 		       // var x = bg.queue('fx');
	    // 		       // while (x.length > 0) {
	    // 		       // 	       x.pop();
	    // 		       // 	   }
	    // 		       // bg.fadeIn();
	    // 		   });
	    // jQ(this).mouseout(
	    // 		   function() { bg.fadeOut(2000); }
	    // 
            // );
	}
    );
}
