var isIE = false;

$(document).ready(function(){
  // Checks the browser type for IE
  jQuery.each(jQuery.browser, function(i, val) {
    if(i=="msie" && val == true) {
		  isIE = true;
	  }
  });
	
	var navHtml = $('#nav').clone().wrap('<div></div>').parent().html();
	$('#nav').remove();
	$("#wrap").before(navHtml);
});



$(function() {
	$(window).scroll(function(){
		var scrollTop = $(window).scrollTop();
		
		if(isIE==true) {
			$("#nav").css("top", scrollTop + "px");
		}
		
		if(scrollTop != 0) {
			$('#nav').stop().animate({'opacity':'0.4'},400);
		} else {	
			$('#nav').stop().animate({'opacity':'1'},400);
		}
	});

	$('#nav').hover(
		function (e) {
			var scrollTop = $(window).scrollTop();
			if(scrollTop != 0){
				$('#nav').stop().animate({'opacity':'1'},400);
			}
		},
		function (e) {
			var scrollTop = $(window).scrollTop();
			if(scrollTop != 0){
				$('#nav').stop().animate({'opacity':'0.4'},400);
			}
		}
	);
});


function tb_addfriend() {
  window.location.href="http://friends.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID="+MySpaceClientContext.DisplayFriendId;
}

function tb_message() {
  window.location.href="http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID="+MySpaceClientContext.DisplayFriendId;
}

function tb_comment() {
  window.location.href="http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID="+MySpaceClientContext.DisplayFriendId;
}


function tb_share(target) {
  if(target=='myspace') {
	  window.open('http://www.myspace.com/Modules/PostTo/Pages/?u=' + encodeURIComponent("http://www.myspace.com/"+vanityURL),'ptm','height=450,width=440').focus();
	
	} else if(target=='facebook') { 
		var targetUrl = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent("http://www.myspace.com/"+vanityURL);
		window.open(targetUrl,'ptf','height=450,width=560').focus();
					
	} else if(target=='mail') { 
	  var targetUrl = 'mailto:name@email.com?' + 'subject=' + encodeURIComponent(title) + '&body=' + encodeURIComponent("http://www.myspace.com/"+vanityURL);
		location.href = targetUrl;
						
	} else if(target=='twitter') { 
	  var targetUrl = 'http://twitter.com/home?' + 'status=' + encodeURIComponent(title) + '%0A' + encodeURIComponent("http://www.myspace.com/"+vanityURL);
		window.open(targetUrl);
	} 
}

