function mainmenu(){
$("#nav ul ul").css({display: "none"}); // Opera Fix
$("#nav ul li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

function bloglink(){
$(".blogbox ul li").hover(function(){
		$(this).animate({backgroundColor: "#fff", paddingLeft: "30px"},300);
		},function(){
		$(this).animate({backgroundColor: "#f6f6f6", paddingLeft: "15px"},300);
		});
}

function rightcolumn(){
$("#rightcolumn ul.norm li a").hover(function(){
		$(this).animate({backgroundColor: "#fff", textIndent: "10px",backgroundPosition: ("20px 12px")},300);
		},function(){
		$(this).animate({backgroundColor: "#f1f1f1", textIndent: "0px", backgroundPosition: ("10px 12px")},300);
		});
$("#rightcolumn ul li a").hover(function(){
		$(this).animate({textIndent: "10px",backgroundPosition: ("20px 12px")},300);
		},function(){
		$(this).animate({textIndent: "0px", backgroundPosition: ("10px 12px")},300);
		});
}
$(document).ready(function(){
		mainmenu();
		rightcolumn();
		$("#portfolio li a[title]").tooltip({effect: "fade"});
		$("img.tool[title]").tooltip({effect: "fade"});
		$(".fancybox").fancybox({});
			$("a.mapajax").fancybox({ 
			'frameWidth': 600, 'frameHeight': 360,
			'hideOnContentClick': false,
			'callbackOnClose': function() {
       $("#fancy_content").empty();
       } 
			});
			$(".external").fancybox({
  'width': 640,  //or whatever
  'height': 400,
  'type': 'iframe' // see this?
 }); 
			$(".portfoliopage").fancybox({
  'width': 1020,  //or whatever
  'height': 700,
  'type': 'iframe' // see this?
 }); 
		$("a#videolink").fancybox({});
		$("#contact-btn").hover(function(){
		$(this).stop().animate({paddingTop: "5px"},300);
		},function(){
		$(this).stop().animate({paddingTop: "0px"},300);
		});
		$(".link").hover(function(){
		$(this).find("span").stop().animate({opacity: 0},300);
		},function(){
		$(this).find("span").stop().animate({opacity: 1},300);
		});
		$(".blogbox ul > :nth-child(5n)").css({borderBottom: "none"});
		$("#footer > :nth-child(4n)").css({margin: "0"});
			$("#nav ul li ul").each(function(i){
      $(this).hover(function(){
        $(this).parent().find("a").slice(0,1).addClass("active");
      },function(){
        $(this).parent().find("a").slice(0,1).removeClass("active");
      });
    });	
		$('.bannerslide').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500,
		pauseTime:3000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
      controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:1, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
		$(".widgets").scrollable({
onBeforeSeek: function(e, i) {
$('.next').css('display', i>=this.getSize()-3 ? 'none':'block');
}
}); 
});
$(document).ready(function() {
		$('#submitform').ajaxForm({
			target: '#error',
			success: function() {
			$('#error').fadeIn('slow');
			}
		});
});



$(function() {

    //cache the ticker
    var ticker = $("#ticker");

    //wrap dt:dd pairs in divs
    ticker.children().filter("dd").each(function() {

        var dd = $(this),
		    container = $("<div>");

        dd.next().appendTo(container);
        dd.prependTo(container);

        container.appendTo(ticker);
    });

    //hide the scrollbar
    ticker.css("overflow", "hidden");

    //animator function
    function animator(currentItem) {

        //work out new anim duration
        var distance = currentItem.height();
        duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.0200;

        //animate the first child of the ticker
        currentItem.animate({ marginTop: -distance }, duration, "linear", function() {

            //move current item to the bottom
            currentItem.appendTo(currentItem.parent()).css("marginTop", 0);

            //recurse
            animator(currentItem.parent().children(":first"));
        });
    };

    //start the ticker
    animator(ticker.children(":first"));

    //set mouseenter
    ticker.mouseenter(function() {

        //stop current animation
        ticker.children().stop();

    });

    //set mouseleave
    ticker.mouseleave(function() {

        //resume animation
        animator(ticker.children(":first"));

    });
});

