$(document).ready(function(){
	
/* the party starts here */

//function to get random number upto m
function randomXToY(minVal,maxVal,floatVal)
{
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

/*determine random number for front page image*/
$random_img = 'url_'+randomXToY(1,20);
/*set image, see screen.css for definitions*/
$('body#start div#showcase').addClass($random_img);


$('div#content div#showcase div#thumb-wrap *, div#content div#showcase div#thumb-wrap').animate({opacity:0},0);
       
$.fn.hoverscroll.params = $.extend($.fn.hoverscroll.params, {
	vertical : true,
	width: 120,
	height: 460,
	arrows: false
});
         
$('div#content div#showcase ul#thumbnails').hoverscroll();

$.fn.hoverscroll.params = $.extend($.fn.hoverscroll.params, {
	vertical : true,
	width: 430,
	height: 460,
	arrows: false
});

$('#cp').hoverscroll();

$.fn.hoverscroll.params = $.extend($.fn.hoverscroll.params, {
	vertical : true,
	width: 650,
	height: 460,
	arrows: false
});

$('#haftung').hoverscroll();

$('a').not('.active a').hover(function(){

   $(this).animate({ color: '#000'},200);
 
},function(){

   $(this).animate({ color: '#7f7f7f'},200);
	
});



$('div#button-thumb').hover(function(){

   $(this).animate({ opacity:1},200);
 
},function(){

   $(this).animate({ opacity:.5},200);
	
});
                   


$('div#button-thumb').toggle(function(){
   
	$('div#content div#showcase div#thumb-wrap').animate({opacity:1},400);
	$('div#content div#showcase div#thumb-wrap *').animate({opacity:1},400);
	 
},function(){

	$('div#content div#showcase div#thumb-wrap').animate({opacity:0},400);	
	$('div#content div#showcase div#thumb-wrap *').animate({opacity:0},400);
		
});
          

$cnt = $('div#content div#showcase ul#thumbnails li').size();
$cur = 1;
      
$title = $('#item_'+$cur+' img').attr('alt');
$('#title').html($title);

$('#cnt').html($cnt);
                 
$('div#content div#showcase ul#thumbnails li img').click(function(){
	                    
	$getURL = 'url('+$(this).attr('src').replace('thumb','high')+') 50% 0 no-repeat';
	$('div#content div#showcase').css("background",$getURL); 
	
	$cur = $(this).parent().attr('id').replace('item_','');
	$('#cur').html($cur);             

	$title = $(this).attr('alt');
	$('#title').html($title);
	
});

$('a#fwd').click(function(){
	if($cur < $cnt){
	$cur++;
	$('#cur').html($cur);             
	
	$getURL = 'url('+$('#item_'+$cur+' img').attr('src').replace('thumb','high')+') 50% 0 no-repeat';
	$('div#content div#showcase').css("background",$getURL);
	  
	$title = $('#item_'+$cur+' img').attr('alt');
	$('#title').html($title);
 	}
});

$('a#back').click(function(){
	if($cur > 1){
	$cur--;
	$('#cur').html($cur);
	
	$getURL = 'url('+$('#item_'+$cur+' img').attr('src').replace('thumb','high')+') 50% 0 no-repeat';
	$('div#content div#showcase').css("background",$getURL);

	$title = $('#item_'+$cur+' img').attr('alt');
	$('#title').html($title);	
	}
});



});
