var $j = jQuery.noConflict();
$j(document).ready(function() {
	
	//IE6 fix for transparant png
	//$('body').supersleight();
	
	//Menu Url
	var supUrl = $j('#suptitle').attr("href");
	var support = $j('<a href="'+supUrl+'" class="new-window">Support</a>');
	$j(".page-item-8").find('a').remove();
	$j(".page-item-8").append(support);
  
  //Open Support link in a new window
  $('a.new-window').click(function(){
    window.open(this.href);
    return false;
  });
	
	//Twitter
	
	$("#twitter").getTwitter({
			userName: "getuniboard",
			numTweets: 3,
			loaderText: "Loading tweets...",
			slideIn: true,
			slideDuration: 750,
			showHeading: true,
			headingText: "",
			showProfileLink: false,
			showTimestamp: true
		});
	
	//Detect OS and change the DL link
	
	if($.client.os === "Mac"){
		$j(".dlfree").attr("href","http://assets.getuniboard.com/installer/Uniboard%204.5.4.dmg")
		$j(".dlfree").click(function(){pageTracker._trackPageview('/downloads/MacVersion/')});
	}	
	if($.client.os === "Windows"){
		$j(".dlfree").attr("href","http://assets.getuniboard.com/installer/Uniboard%204.5.3%20setup.exe")
		$j(".dlfree").click(function(){pageTracker._trackPageview('/downloads/PCVersion/')});
	}	
	
	//Tabbed Gallery
	$j("div.tabs").tabs(".images > div", { 

	        // enable "cross-fading" effect 
	        effect: 'default', 

	        // start from the beginning after the last tab 
	        rotate: true 

	    }).slideshow({
					// Should disable the advance to the next slide by clicking
					clickable: false
				});
	
	var tGallery = $j("div.tabs").tabs();
	
	if($j("div.tabs").length > 0){
		tGallery.onClick(function(){
	
			setTimeout(function(){
				var currentTabIndex = tGallery.getIndex();
							
				for(var i=0; i<4; i++){
					tGallery.getTabs().eq(i).css({
						backgroundImage:"url(v2/wp-content/themes/uniboard/images/tab"+(i+1)+".jpg)"});
				}
			
				tGallery.getTabs().eq(currentTabIndex).css({
					backgroundImage:"url(v2/wp-content/themes/uniboard/images/tab"+(currentTabIndex+1)+"_active.jpg)"});
				tGallery.getTabs().eq(currentTabIndex+1).css({
					backgroundImage:"url(v2/wp-content/themes/uniboard/images/tab"+(currentTabIndex+2)+"_under.jpg)"});
				tGallery.getTabs().eq(currentTabIndex-1).css({
					backgroundImage:"url(v2/wp-content/themes/uniboard/images/tab"+currentTabIndex+"_over.jpg)"});		
			},5);
				
		});
	};
		
	});