

$(document).ready(function(){
    navHover();
    createMemberDirectoryElements();
    $('#nivoslider').nivoSlider({
    	
    	startSlide:1,
    	controlNav:false,
    	directionNav:true,
    	directionNavHide:false
    	
	});
	placeholder();
    getTwitterWidget();
    forum();
    loginStatus();
	$.localScroll();

});

//Nav Hover
function navHover(){
     $('li.hoverNav').hover(function(){
          $(this).children('.topNavFeature').show();
     },function(){
          $(this).children('.topNavFeature').hide();
     });
     
     $('div.nivoContainer').hover(function(){
         $('.nivo-directionNav').show();
     },function(){
        $('.nivo-directionNav').hide();
     });
     
}

//create the members directory widget
function createMemberDirectoryElements(){

	if (gCompanyList){
		if (gCompanyList.companyList.length > 0) {
			var l_html = "";
			for (var i = 0; i < gCompanyList.companyList.length; i++) {
				l_html += '<a href="';
				l_html += gCompanyList.companyList[i].href;
				l_html += '" title="';
				l_html += gCompanyList.companyList[i].title;
				l_html += '"><img src="';
				l_html += gCompanyList.companyList[i].logo;
				l_html += '" alt="';
				l_html += gCompanyList.companyList[i].title;
				l_html += '" /></a>';
			}
			$("div#nivoslider").html(l_html);
		} else {
			$("div#nivoslider").html("<p>Unable to display members</p>");
		}
	} else {
		$("div#nivoslider").html("<p>Unable to display members</p>");
	}
}


function placeholder(){
	$('.placeholder').live('click',function(){
		$(this).val('').removeClass('placeholder');
	});
}


//Twitter
function getTwitterWidget(){
	if($('.twitterWidget').length > 0) {
		$.get('twitterwidget.obyx',function(data){
			$('.twitterWidget').replaceWith(data);
		});
	}
	
}

//Forum

function forum(){
	$('a.postReply').click(function(){
	
		$('form.postTopic').show();
		$('form#postReply').show();
		$('a.postReply').hide();
	});

	$("a.forumDeleteButton").click(function(){
		
		$.get($(this).attr("href"));
		$(this).parent().slideUp();
		return false;
	});
}

//Login

function loginStatus(){

	if(gLoginStatus == true){
	
		$('#header ul.memberLinks').remove();
		var html='<div id="loginStatus"><span class="loggedin">LOGGED IN AS: <strong>'+gUsername+'</strong></span><a id="logout" href="/members/logout.obyx" >LOGOUT</a></div>';
    	$('span.siteLogo').after(html);
	}
	
	if (gHasExtraSecureAccess == "true") {
		$('span.tPadlock').remove();
	}
}


