// JavaScript Document
fsnd_statistics = new Image(1,1);
fsnd_statistics.src = "http://statistics.fsnd.de/add_stats.php?id=2&pwd=martin"+"&refer="+escape(document.referrer)+"&scrd="+screen.colorDepth+"&scrw="+screen.width+"&doc_url="+escape(document.URL);
fsnd_single_page = new Image(1,1);
fsnd_single_page.src="http://statistics.fsnd.de/single_page.php?id=2&pwd=martin&url="+document.URL;


var j = jQuery.noConflict();

/* Slides the Thumbs left or right
 * @author: Andreas Sommer <sommer@belsignum.de>
 * @return: void
 */
function moveThumbs() 
{
	var moveDuration = 1600;
	var width = 590;
	var numOfThumbs = 5;
	var maxW = Math.ceil((j('#topMenu li').get().length) / numOfThumbs) * width;
	j('#topMenu').css({width:maxW+'px'});
	// hide left button on startup
	j('#moveThumbLeft').css( 'display','none' );
	// create event procedure for left arrow
	j('#moveThumbLeft').click(function()
	 {
		if( typeof j != 'function' ) j = jQuery.noConflict();
		var menuLeft = j('#topMenu').css('left').replace('px','');
		
		if( menuLeft % width )
		{
			//alert( 'max width reached' );
		}
		else
		{
			var leftSwing = menuLeft -1+1 + width;
			// j('#menuDebug').html('left: ' + leftSwing);
			if(leftSwing < 1) 
			{
				j('#moveThumbRight').css( 'display','block' );
				j('#topMenu').animate(
					{left:leftSwing},
					moveDuration,
					'swing'
				);
				if( !leftSwing )
				{
					j('#moveThumbLeft').css( 'display','none' );
				}
			}
		}
		
	});
	
	// create event procedure for right arrow
	j('#moveThumbRight').click(function()
	  {
		if( typeof j != 'function' ) j = jQuery.noConflict();
		var menuLeft = j('#topMenu').css('left').replace('px','');
		
		if( menuLeft % width ) 
		{
			//alert( 'max width reached' );
		}
		else
		{
			j('#moveThumbLeft').css( 'display','block' );
			var rightSwing = menuLeft - width;
			var length = j("#topMenu li").each(function(i) {
				var inc = i + 1;
				k = inc / numOfThumbs * (-width);
			});
			var next = (-1)*(k - rightSwing);
			j('#menuDebug').html( 'k: ' + k + ', right: ' + rightSwing + ', next: ' + next + ', width: ' + width );
			if(k < rightSwing) 
			{
				j('#topMenu').animate(
					{left:rightSwing},
					moveDuration,
					'swing'
				);
				if( next <= width )
				{
					j('#moveThumbRight').css( 'display','none' );
				}
			}
		}
		
	});
}

j(document).ready(function() 
 {
   // jQuery(".bdLightbox").colorbox({transition:"fade",scalePhotos:"true",initialWidth:"500px",initialHeight:"500px",maxWidth:"500px",maxHeight:"500px"});
   //alert("we are ready!");
							   // alert( 'document is ready!' );
							   j('#raddress').corner("dog tr 30px");
							   j('#raddress').corner("tl 5px");
							   j('#raddress').corner("tear bottom 20px");
							   j('#footer').corner("curl bottom");
							   j('#logoImg').corner("dog tr 30px");
							   // j('#raddress').fadeOut();
							   
							   moveThumbs();
							   
 });

 j( function (){
			   //alert( 'about to do fancy stuff!' );
			   j('.bdLightbox').each( function() { 
									//alert( this.attr( 'href' ) );		   
									j(this).fancybox({ 'titleShow':false,
													   'type': 'iframe',
													   'autoScale': true,
													   'height': '340', 
													   'padding': '10'
												     });
											   
											   });
			  });
 
