var IE7_PNG_SUFFIX = ".png";

$(document).ready(function(){

		// Random DB stuff			
		$("#control a, .back").fadeTo("slow", 0.6);
		
		$("#control a, .back").hover(function(){
			$(this).fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
		},function(){
		   	$(this).fadeTo("slow", 0.6); // This sets the opacity back to 60% on mouseout
		});
		
	
	//	Make the news block clickable
		$('.news li').click(function(){
			window.location=$(this).find("strong a").attr("href");
			return false;
		});
		$('ul.news li').hover(function(){
			$(this).addClass('hover'); // Place a extra class when hover
		},function(){
			$(this).removeClass('hover'); // Remove a class on mouseout
		});			

	//	Footer border-age
		$('#footer li').last().css('border', 'none');		

		$('.newsitem p:first').addClass('italic')	



    $('a[href*=#]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                    
                return false;
                
            }
            
        }
        
    });
    
      //Get our elements for faster access and set overlay width
      var div = $('div.scroll'), ul = $('ul.featured'),
                   // unordered list's left margin
                   ulPadding = 15;
    
      //Get menu width
      var divWidth = div.width();
    
      //Remove scrollbars
      div.css({overflow: 'hidden'});
    
      //Find last image container
      var lastLi = ul.find('li:last-child');
    
      //When user move mouse over menu
      div.mousemove(function(e){
    
        //As images are loaded ul width increases,
        //so we recalculate it each time
        var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
    
        var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
        div.scrollLeft(left);
      });
    
    $('ul.featured li a').append('<img src="/template/theme/default/image/rounded.png" style="position: absolute; z-index:2000; left: 0; top: 0;" />');
    $('.portfolioitems li a').append('<img src="/template/theme/default/image/round.png" style="position: absolute; z-index:2000; left: 0; top: 0;" />');
	
	
	$('#slideshow div.panelcontainer').cycle({ 
	    fx:     'scrollHorz', 
	    prev:   '#right', 
	    next:   '#left', 
	    speed:	800,
	    timeout: 8000,
	    pause: 1
	});

});
