function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}


function setReplyComment(commentTitle, commentId, userId, commentUser)
{
	document.getElementById('comment_title').innerHTML = commentTitle;
	document.getElementById('comment_id').value = commentId;
	document.getElementById('userId').value = userId;
	if (commentUser != undefined && commentUser != null)
	{
		$('reply_field').value = '@' + commentUser + ': ';
	}
	showLayeredDiv('reply_comment');
	
	var position = $('reply_field').value.length;
	$('reply_field').focus();
	if($('reply_field').createTextRange != null) {
            var range = $('reply_field').createTextRange();
            range.move('character', position);
            range.select();
        }
        else {
            if($('reply_field').selectionStart != null) {
                $('reply_field').focus();
                $('reply_field').setSelectionRange(position, position);
            }
            else
                $('reply_field').focus();
        }
}

function setNewComment(entryTitle, entryId)
{
	document.getElementById('entry_title').innerHTML = entryTitle;
	document.getElementById('entry_id').value = entryId;
	$('comment_field').value = '';
}

function setNewIby(entryTitle, entryId, username)
{
	document.getElementById('iby_entry_title').innerHTML = entryTitle;
	document.getElementById('iby_entry_id').value = entryId;
	$('gift_link').title = 'send ' + username + ' a gift';
	$('gift_link').innerHTML = 'send ' + username + ' a gift';
	$('gift_link').href = '/gifts/to/' + username;
	$('iby_field').value = '';
}

function addCommentFlash(entryId, title)
{
	setNewComment(title, entryId);
	showLayeredDiv('new_comment');
	Form.Element.activate('comment_field');
	if ($('allentries').className != 'tab') changeTab(2);
}

function addAwardFlash(entryId, title, username)
{
	setNewIby(title, entryId, username);
	showLayeredDiv('new_iby');
	Form.Element.activate('iby_field');
}


function checkWelcome(targetUrl, targetTitle) {
	var ref = document.referrer;
	var se = new Array('stumbleupon.com', 'digg.com');
	var sevisitor = false;
	for (var i = 0; i <= se.length-1; i++) {
		if (ref.indexOf(se[i]) !== -1) {
			if (i == 0) {
				$("welcomearea").update('<div class="welcomevisitor"><img src="http://pantherwww.ibeatyou.com/images/socialmedia_icons/stumbleupon.png" border="0" style="vertical-align:middle" /> Hello fellow <strong>Stumbler</strong>!<br/>Don\'t forget to <a href="http://www.stumbleupon.com/submit?url=' + targetUrl + '&title=' + targetTitle + '" rel="nofollow"><strong>give me a thumbs up</strong></a> and <a href="http://feeds.feedburner.com/IbeatyouBlog" rel="nofollow"><strong>subscribe to us</strong></a> if you like this page!</div>');
			} else if (i == 1) {
				$("welcomearea").update('<div class="welcomevisitor"><img src="http://pantherwww.ibeatyou.com/images/socialmedia_icons/digg.png" border="0" style="vertical-align:middle"/> Hello fellow <strong>Digger</strong>!<br/>If you like this page, please help me out by giving me some <a href="http://digg.com/submit?url=' + targetUrl + '&title=' + targetTitle + '" rel="nofollow"><strong>digg love</strong></a>!</div>');
			}
			if ($("winnerbg") != undefined) {
			   $("winnerbg").hide();
		    }
		    if ($("mvpwinnerbg") != undefined) {
			   $("mvpwinnerbg").hide();
		    }
		}
	}
}

