var bHold = false;
var xmlHTTPFilter = GetXmlHttpObject();
var xmlHTTPSearch = GetXmlHttpObject();
var xmlHTTPNotify = GetXmlHttpObject();
var xmlHTTPNotifyTime = GetXmlHttpObject();
var xmlHTTPResults = GetXmlHttpObject();
var playerwindow;
var selectedText;
var rollout_interval;
var rollin_interval;
var moveoutstep = 25.0;
var moveinstep = 50.0;
var all_container;
var all_flyout;
var bMovingOut = false;
var bMovingIn = false;
var containerheight = 10.0;
var flyouttop = -325.0;
var currentPosition = 1.0;
var currentPlayState = true;
var player;
var descrpos;
var descrinterval;
var description;
var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page
var myWidth = 0;
var myHeight = 0;
var ScrollTop = 0;
var PercX = 0;
var PercY = 0;
var playVideo;
var favVideo;
var bPublic;
var publiclist;
var editplaylistid;
var editvideoid;
var subseries;
var bQueueSeries;
var queuedSeries;
var bQueueVideo;
var queuedVideo;
var bReloadOnRemove = false;

var showinfo = false;

var radioplayer;

function playerReady(obj)
{
  	var id = obj['id'];
  	var version = obj['version'];
  	var client = obj['client'];
  	if(obj['id'] == 'mediaplayer')
	  	player = document.getElementById(obj.id);
  	if(obj['id'] == 'mpl')
	{
		alert("Player!");
	  	radioplayer = document.getElementById(obj.id);
	}

  	/*player.addModelListener("TIME","handleTimeUpdate");
  	player.addControllerListener("PLAY","handlePlayState");
  	player.addControllerListener("SEEK","handleSeekState");

	enablePlayerButtons();*/

	addPlayerListeners();

};

function GetXmlHttpObject()
{
  		var xmlHttp1 = null;
  			try
  			{
    				// Firefox, Opera 8.0+, Safari
    				xmlHttp1=new XMLHttpRequest();
    			}
  			catch (e)
  			{
    				// Internet Explorer
		try
		{
      				xmlHttp1=new ActiveXObject("MSXML2.XMLHTTP");
    				}
  				catch (e)
  				{
    					try
    					{
      					xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
    					}
    					catch (e)
    					{
      					alert("Couldn't Get XMLHttpRequest Object");
    					}
    				}
  			}
  			return xmlHttp1;
}


function handleTimeUpdate(obj)
{
 	currentPosition = obj.position;
}

function handlePlayState(obj)
{
	currentPlayState = obj.state;
}

function handleSeekState(obj)
{
	currentPlayState = true;
}

function playerReady(obj)
{
  	var id = obj["id"];
  	var version = obj["version"];
  	var client = obj["client"];
  	player = document.getElementById(obj.id);

	addPlayerListeners();
}

function addPlayerListeners()
{
	if(player)
	{
		player.addModelListener("TIME","handleTimeUpdate");
	  	player.addControllerListener("PLAY","handlePlayState");
	  	player.addControllerListener("SEEK","handleSeekState");
	}
	else
	{
		setTimeout("addPlayerListeners()",100);
	}
}

function tearoff(id)
{
  	if(player)
		pausePlayer();
  	playerwindow = window.open("simplevideo.php?v="+id+"&t=" + (currentPosition-1),"videowindow","width=960,height=545,resizable=yes,scrollbars=yes");
  	playerwindow.focus();
}
  
function pausePlayer()
{
	if(currentPlayState)
	{
		player.sendEvent("PLAY",false);
	}
}
  
function startPlayer()
{
	if(!currentPlayState)
	{
		player.sendEvent("PLAY",true);
	}
}


function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}


/*function getDescription(descr,elem)
{
	description = descr;
	outer = elem;
	descrinterval = setTimeout("showDescription(description,outer)",1500);
} */

function getDescription(descr,outer)
{
	var elem = document.getElementById("descr");
	var elemtext = document.getElementById("descr_text");
	elemtext.innerHTML = descr;
	elem.style.display = "block";
	descrpos = findPosY(outer) - elem.offsetHeight - 104;
	elem.style.top = descrpos + "px";
	bHold = false;
}

function killDescription()
{
	if(descrinterval)
		clearInterval(descrinterval);
	var elem = document.getElementById("descr");
	elem.style.display = "none";
}


var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
	|| this.searchVersion(navigator.appVersion)
	|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++)	{
	var dataString = data[i].string;
	var dataProp = data[i].prop;
	this.versionSearchString = data[i].versionSearch || data[i].identity;
	if (dataString) {
		if (dataString.indexOf(data[i].subString) != -1)
			return data[i].identity;
	}
	else if (dataProp)
		return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
	string: navigator.userAgent,
	subString: "Chrome",
	identity: "Chrome"
},
{ 	string: navigator.userAgent,
	subString: "OmniWeb",
	versionSearch: "OmniWeb/",
	identity: "OmniWeb"
},
{
	string: navigator.vendor,
	subString: "Apple",
	identity: "Safari",
	versionSearch: "Version"
},
{
	prop: window.opera,
	identity: "Opera"
},
{
	string: navigator.vendor,
	subString: "iCab",
	identity: "iCab"
},
{
	string: navigator.vendor,
	subString: "KDE",
	identity: "Konqueror"
},
{
	string: navigator.userAgent,
	subString: "Firefox",
	identity: "Firefox"
},
{
	string: navigator.vendor,
	subString: "Camino",
	identity: "Camino"
},
{		// for newer Netscapes (6+)
	string: navigator.userAgent,
	subString: "Netscape",
	identity: "Netscape"
},
{
	string: navigator.userAgent,
	subString: "MSIE",
	identity: "Explorer",
	versionSearch: "MSIE"
},
{
	string: navigator.userAgent,
	subString: "Gecko",
	identity: "Mozilla",
	versionSearch: "rv"
},
{ 		// for older Netscapes (4-)
	string: navigator.userAgent,
	subString: "Mozilla",
	identity: "Netscape",
	versionSearch: "Mozilla"
}
],
dataOS : [
{
	string: navigator.platform,
	subString: "Win",
	identity: "Windows"
},
{
	string: navigator.platform,
	subString: "Mac",
	identity: "Mac"
},
{
	   string: navigator.userAgent,
	   subString: "iPhone",
	   identity: "iPhone/iPod"
    },
{
	string: navigator.platform,
	subString: "Linux",
	identity: "Linux"
}
]

};
BrowserDetect.init();


/* if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}

function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        myHeight = window.innerHeight;
        myWidth = window.innerWidth;
        ScrollTop = window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
        myHeight =document.body.clientHeight;
        myWidth = document.body.clientWidth;
        ScrollTop = document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        myHeight = window.innerHeight;
        myWidth = window.innerWidth;
        ScrollTop = window.pageYOffset;
    }
    PercX = ((yMousePos - ScrollTop) / myHeight);
    PercY = (yMousePos / myWidth);
//document.getElementById("mouseXY").innerHTML = ((yMousePos - ScrollTop) / myHeight);
} */


/* function favoriteVideo(video)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			favVideo = video;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_favorite_video.php?ks=1&video=" + video, true);
  			xmlHTTPFilter.onreadystatechange = handleFavorite;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use favorites.");
	 }
}

function handleFavorite()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var elem = document.getElementById("fav");
		if(elem)
		{
			elem.title = "Remove Video From Your Favorites";
			elem.onclick = function(){removeFavoriteVideo(favVideo)};
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/fav_remove_vid.gif)";
		}
		var elemlist = document.getElementById("fav_" + favVideo);
		if(elemlist)
		{
			elemlist.title = "Remove From Favorites";
			elemlist.onclick = function(){removeFavoriteVideo(this.id.substr(4))};
			elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/fav_remove_icon.gif)";
		}

		var menuelem = document.getElementById("subFavTotal");
		if(menuelem)
			menuelem.innerHTML = xmlHTTPFilter.responseText;
		bHold = false;
	}
}


function removeFavoriteVideo(video,bReload)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			favVideo = video;
			bReloadOnRemove = bReload;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_favorite_video_remove.php?ks=1&video=" + video, true);
  			xmlHTTPFilter.onreadystatechange = handleFavoriteRemove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use favorites.");
	 }
}

function handleFavoriteRemove()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(bReloadOnRemove)
			location.reload();
		var elem = document.getElementById("fav");
		if(elem)
		{
			elem.title = "Add video to your favorites";
			elem.onclick = function(){favoriteVideo(favVideo);};
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/fav_vid.gif)";
		}
		var elemlist = document.getElementById("fav_" + favVideo);
		if(elemlist)
		{
			elemlist.title = "Add video to your favorites";
			elemlist.onclick = function(){favoriteVideo(this.id.substr(4));};
			elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/fav_icon.gif)";
		}

		var menuelem = document.getElementById("subFavTotal");
		if(menuelem)
			menuelem.innerHTML = xmlHTTPFilter.responseText;
		bHold = false;
	}
}

function moveFavoriteVideo(videoid,position)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_favorite_move.php?ks=1&video=" + videoid + "&pos=" + position, true);
  			xmlHTTPFilter.onreadystatechange = handleFavoriteMove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use favorites.");
	 }
}

function handleFavoriteMove()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			location.reload();
		}
	}
}

function clearFavoriteVideos()
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bReloadOnRemove = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_favorite_video_clear.php?ks=1", true);
  			xmlHTTPFilter.onreadystatechange = handleFavoriteRemove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use favorites.");
	 }
}


function playlistVideo(playlist,video)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			playVideo = video;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_video.php?ks=1&list=" + playlist + "&video=" + video, true);
  			xmlHTTPFilter.onreadystatechange = handlePlaylist;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handlePlaylist()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var elem = document.getElementById("playlist");
		if(elem)
		{
			elem.title = "Video Is In Playlist";
			elem.onclick = function(){};
			elem.style.cursor = "default";
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/playlist_remove_vid.gif)";
		}
		var elemlist = document.getElementById("play_" + playVideo);
		if(elemlist)
		{
			elemlist.title = "Video Is In Playlist";
			elemlist.onclick = function(){};
			elemlist.style.cursor = "default";
			elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/playlist_check_icon.gif)";
		}
		bHold = false;
	}
}


function removePlaylistVideo(playlist,video,bReload)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			playVideo = video;
			bReloadOnRemove = bReload;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_video_remove.php?ks=1&list=" + playlist + "&video=" + video, true);
  			xmlHTTPFilter.onreadystatechange = handlePlaylistRemove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handlePlaylistRemove()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(bReloadOnRemove)
			location.reload();
		
		bHold = false;
	}
}

function movePlaylistVideo(playlist,videoid,position)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_move.php?ks=1&list=" + playlist + "&video=" + videoid + "&pos=" + position, true);
  			xmlHTTPFilter.onreadystatechange = handlePlaylistMove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handlePlaylistMove()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			location.reload();
		}
	}
}

function clearPlaylistVideos(playlist)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bReloadOnRemove = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_clear.php?ks=1&list=" + playlist, true);
  			xmlHTTPFilter.onreadystatechange = handlePlaylistClear;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handlePlaylistClear()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=" + viewurl;
	}
}

function makePlaylistPublic(playlist,public)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bPublic = public;
			publiclist = playlist;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_public.php?ks=1&list=" + playlist + "&public=" + public, true);
  			xmlHTTPFilter.onreadystatechange = handlePlaylistPublic;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handlePlaylistPublic()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(bPublic == "1")
		{
			var elem = document.getElementById("public_" + publiclist);
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/list_public_check_icon.gif)";
			elem.name = "0";
			elem.onclick = function(){makePlaylistPublic(this.id.substr(7),this.name);};
			elem.title = "Make This Playlist Private";
		}
		else
		{
			var elem = document.getElementById("public_" + publiclist);
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/list_public_icon.gif)";
			elem.name = "1";
			elem.onclick = function(){makePlaylistPublic(this.id.substr(7),this.name);};
			elem.title = "Make This Playlist Public";
		}

		var menuelem = document.getElementById("subPubTotal");
		if(menuelem)
			menuelem.innerHTML = xmlHTTPFilter.responseText;

		bHold = false;
	}
}

function createPlaylist()
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			var videos = "";
			var elems = getElementsByName_iefix("input", "chkVideo");
			var bSelected = false;
			for(i=0;i<elems.length;i++)
			{
				if(elems[i].checked)
					bSelected = true;
			}
			if(bSelected)
			{
				var playlist = document.getElementById("playtitle").value;
				if(playlist != "")
				{
					for(i=0;i<elems.length;i++)
					{
						if(elems[i].checked)
							videos += "," + elems[i].id.substr(4);
					}
					playlist = fixPlus(playlist);
					xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_create.php?ks=1&list=" + escape(playlist) + "&videos=" + escape(videos.substr(1)), true);
		  			xmlHTTPFilter.onreadystatechange = handleCreatePlaylist;
		  			xmlHTTPFilter.send(null);
		  		}
				else
				{
					alert("You must enter a name");
					bHold = false;
				}
	  		
			}
			else
			{
				alert("No videos selected");
				bHold = false;
			}
		}
	}
} */

function fixPlus(title)
{
	if(title.indexOf("+") != -1)
	{
		 title = title.replace("+","%2B");
		 title = fixPlus(title);
	}
	
	return title;
}

/* function addToPlaylist()
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			var videos = "";
			var elems = getElementsByName_iefix("input", "chkVideo");
			var bSelected = false;
			for(i=0;i<elems.length;i++)
			{
				if(elems[i].checked)
					bSelected = true;
			}
			if(bSelected)
			{
				var playlist = document.getElementById("playselect").value;
				if(playlist != "")
				{
					for(i=0;i<elems.length;i++)
					{
						if(elems[i].checked)
							videos += "," + elems[i].id.substr(4);
					}
					playlist = fixPlus(playlist);
					xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_create.php?ks=1&list=" + escape(playlist) + "&videos=" + escape(videos.substr(1)), true);
		  			xmlHTTPFilter.onreadystatechange = handleCreatePlaylist;
		  			xmlHTTPFilter.send(null);
		  		}
				else
				{
					alert("No Existing Playlists");
					bHold = false;
				}
	  		
			}
			else
			{
				alert("No videos selected");
				bHold = false;
			}
		}
	}
}

function handleCreatePlaylist()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			location.href="?view=playlists&lid=" + xmlHTTPFilter.responseText;
		}
		bHold = false;
	}
}


function editPlaylistDescription(playlistid)
{
	document.getElementById("view_" + playlistid).style.display = "none";
	document.getElementById("edit_" + playlistid).style.display = "block";
	document.getElementById("input_" + playlistid).focus();
	limitKeys(playlistid,notelimit);
}

function savePlaylistDescription(playlistid)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			editplaylistid = playlistid;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_description_edit.php?ks=1&list=" + playlistid + "&descr=" + escape(document.getElementById("input_" + playlistid).value), true);
  			xmlHTTPFilter.onreadystatechange = handleSavePlaylistDescription;
  			xmlHTTPFilter.send(null);
		}
	}
}

function handleSavePlaylistDescription()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			var descr = xmlHTTPFilter.responseText;
			if(descr == "")
			{
				document.getElementById("view_" + editplaylistid).style.color = "#999999";
				document.getElementById("view_" + editplaylistid).innerHTML = "Click to enter description...";
			}
			else
			{
				document.getElementById("view_" + editplaylistid).style.color = "#000000";
				document.getElementById("view_" + editplaylistid).innerHTML = descr;
			}
			document.getElementById("view_" + editplaylistid).style.display = "block";
			document.getElementById("edit_" + editplaylistid).style.display = "none";
		}
		bHold=false;
	}
}

var bookmarklist;
var bBookmark;

function bookmarkPlaylist(playlist)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bookmarklist = playlist;
			bBookmark = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_bookmark.php?ks=1&list=" + playlist, true);
  			xmlHTTPFilter.onreadystatechange = handleBookmarkPlaylist;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function removeBookmarkPlaylist(playlist)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bookmarklist = playlist;
			bBookmark = false;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_bookmark_remove.php?ks=1&list=" + playlist, true);
  			xmlHTTPFilter.onreadystatechange = handleBookmarkPlaylist;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handleBookmarkPlaylist()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(bBookmark)
		{
			var elem = document.getElementById("mark_" + bookmarklist);
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/list_mark_check_icon.gif)";
			elem.onclick = function(){removeBookmarkPlaylist(this.id.substr(5));};
			elem.title = "Remove This Playlist From Your Bookmarks";
		}
		else
		{
			var elem = document.getElementById("mark_" + bookmarklist);
			elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/list_mark_icon.gif)";
			elem.onclick = function(){bookmarkPlaylist(this.id.substr(5));};
			elem.title = "Bookmark This Playlist";
		}

		bHold = false;
	}
}

function clonePlaylist(playlist)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			clonelist = playlist;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_playlist_clone.php?ks=1&list=" + playlist, true);
  			xmlHTTPFilter.onreadystatechange = handleClonePlaylist;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use playlists.");
	 }
}

function handleClonePlaylist()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var elem = document.getElementById("clone_" + clonelist);
		elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/list_clone_check_icon.gif)";
		elem.onclick = function(){};
		elem.title = "This Playlist Has Been Cloned";

		bHold = false;
	}
}

var videoViewDescriptions = new Array;
var videoEditDescriptions = new Array;

function editVideoDescription(type,videoid)
{
	videoViewDescriptions[videoid] = document.getElementById("view_" + videoid).innerHTML;
	videoEditDescriptions[videoid] = document.getElementById("input_" + videoid).value;
	document.getElementById("view_" + videoid).style.display = "none";
	document.getElementById("edit_" + videoid).style.display = "block";
	document.getElementById("input_" + videoid).focus();
	if(type != "admin")
		limitKeys(videoid,notelimit);
}

function cancelVideoDescription(type,videoid)
{
	if(videoViewDescriptions[videoid])
		document.getElementById("view_" + videoid).innerHTML = videoViewDescriptions[videoid];
	else
		document.getElementById("view_" + videoid).innerHTML = "Click to enter note...";
	if(videoViewDescriptions[videoid])
		document.getElementById("input_" + videoid).value = videoEditDescriptions[videoid];
	else
		document.getElementById("input_" + videoid).value = "";
	document.getElementById("view_" + videoid).style.display = "block";
	document.getElementById("edit_" + videoid).style.display = "none";
}

function saveVideoDescription(type,videoid)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			editvideoid = videoid;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_video_description_edit.php?ks=1&type=" + type + "&video=" + videoid + "&descr=" + escape(document.getElementById("input_" + videoid).value), true);
  			xmlHTTPFilter.onreadystatechange = handleSaveVideoDescription;
  			xmlHTTPFilter.send(null);
		}
	}
}

function handleSaveVideoDescription()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			var descr = xmlHTTPFilter.responseText;
			if(descr == "")
			{
				document.getElementById("view_" + editvideoid).style.color = "#999999";
				document.getElementById("view_" + editvideoid).innerHTML = "Click to enter a note...";
			}
			else
			{
				document.getElementById("view_" + editvideoid).style.color = "#000000";
				document.getElementById("view_" + editvideoid).innerHTML = descr;
			}
			document.getElementById("view_" + editvideoid).style.display = "block";
			document.getElementById("edit_" + editvideoid).style.display = "none";
		}
		bHold=false;
	}
} */

function limitKeys(id,limit)
{
	var limitField = document.getElementById("input_" + id);
	var limitCount = document.getElementById("char_" + id);
	if (limitField.value.length > limit)
	{
		limitField.value = limitField.value.substring(0, limit);
	}
	else
	{
		limitCount.innerHTML = limit - limitField.value.length;
	}
}

function limitTwitterKeys(id,limit)
{
	var limitField = document.getElementById(id);
	var limitCount = document.getElementById("char_" + id);
	if (limitField.value.length > limit)
	{
		limitField.value = limitField.value.substring(0, limit);
	}
	else
	{
		limitCount.innerHTML = limit - limitField.value.length;
	}
}

/* function subscribeSeries(group)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			subseries = group;
			group = fixPlus(group);
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_subscribe_series.php?ks=1&group=" + escape(group), true);
  			xmlHTTPFilter.onreadystatechange = handleSubscribe;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use subscriptions.");
	 }
}

function handleSubscribe()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var elemlist = document.getElementById("sub_" + subseries);
		if(elemlist)
		{
			elemlist.title = "You Are Subscribed";
			elemlist.onclick = function(){};
			elemlist.style.cursor = "auto";
			elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/notify_series.gif)";
		}
		bHold = false;
	}
}

function removeSubscribeSeries(group)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			subseries = group;
			group = fixPlus(group);
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_subscribe_series_remove.php?ks=1&group=" + escape(group), true);
  			xmlHTTPFilter.onreadystatechange = handleSubscribeRemove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use subscriptions.");
	 }
}

function handleSubscribeRemove()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			location.reload();
		}
		bHold = false;
	}
}


function queueSeries(group)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			queuedSeries = group;
			bQueueSeries = true;
			group = fixPlus(group);
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_series.php?ks=1&group=" + escape(group), true);
  			xmlHTTPFilter.onreadystatechange = handleQueueSeries;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function removeQueueSeries(group)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			queuedSeries = group;
			bQueueSeries = false;
			group = fixPlus(group);
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_series_remove.php?ks=1&group=" + escape(group), true);
  			xmlHTTPFilter.onreadystatechange = handleQueueSeries;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function handleQueueSeries()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var arr = xmlHTTPFilter.responseText.split(",");
		if(arr[0] == "clear")
		{
			location.reload();
		}
		else if(arr[0] == "overflow")
		{
			alert("This series will not fit in your queue. (Max 999 videos)");
		}
		else if(arr[0] != "failed")
		{
			for(i=1;i<arr.length;i++)
			{
				if(bQueueSeries)
				{
					var elemlist = document.getElementById(arr[i]);
					if(elemlist)
					{
						elemlist.title = "Remove Video From Your Queue";
						elemlist.onclick = function(){removeQueueVideo(this.id);};
						elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_remove_icon.gif)";
					}

					document.getElementById("queueTotal").innerHTML = arr[0];
				}
				else
				{
					var elemlist = document.getElementById(arr[i]);
					if(elemlist)
					{
						elemlist.title = "Add Video To Your Queue";
						elemlist.onclick = function(){queueVideo(this.id);};
						elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_icon.gif)";
					}

					document.getElementById("queueTotal").innerHTML = arr[0];
				}
			}
		}
		bHold = false;
	}
}


function queueVideo(videoid)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			queuedVideo = videoid;
			bQueueVideo = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_video.php?ks=1&video=" + videoid, true);
  			xmlHTTPFilter.onreadystatechange = handleQueue;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function moveQueueVideo(videoid,position)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_move.php?ks=1&video=" + videoid + "&pos=" + position, true);
  			xmlHTTPFilter.onreadystatechange = handleQueueMove;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function handleQueueMove()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText != "failed")
		{
			location.reload();
		}
	}
}


function removeQueueVideo(videoid,bReload)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bReloadOnRemove = bReload;
			queuedVideo = videoid;
			bQueueVideo = false;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_video_remove.php?ks=1&video=" + videoid, true);
  			xmlHTTPFilter.onreadystatechange = handleQueue;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function handleQueue()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "duplicate")
		{
			//alert("This video is already in your queue.");
		}
		else if(xmlHTTPFilter.responseText == "failed")
		{
			//alert("An error occured");
		}
		else if(xmlHTTPFilter.responseText == "overflow")
		{
			alert("This video will not fit in your queue. (Max 999 videos)");
		}
		else
		{
			if(bQueueVideo)
			{
				var elem = document.getElementById("queue");
				if(elem && queuedVideo == videourl)
				{
					elem.title = "Remove Video From Your Queue";
					elem.onclick = function(){removeQueueVideoMain(videourl);};
					elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_remove_vid.gif)";
				}

				var elemlist = document.getElementById(queuedVideo);
				if(elemlist)
				{
					elemlist.title = "Remove Video From Your Queue";
					elemlist.onclick = function(){removeQueueVideo(this.id);};
					elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_remove_icon.gif)";
				}

				var elemmain = document.getElementById("main_" + queuedVideo);
				if(elemmain)
				{
					elemmain.title = "Remove Video From Your Queue";
					elemmain.onclick = function(){removeQueueVideo(this.id.substr(5));};
					elemmain.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/main_queue_remove_icon.gif)";
				}

				document.getElementById("queueTotal").innerHTML = xmlHTTPFilter.responseText;
				var menuelem = document.getElementById("subQueueTotal");
				if(menuelem)
					menuelem.innerHTML = xmlHTTPFilter.responseText;
			}
			else
			{
				if(bReloadOnRemove)
					location.reload();
				else
				{
					var elem = document.getElementById("queue");
					if(elem && queuedVideo == videourl)
					{
						elem.title = "Add Video To Your Queue";
						elem.onclick = function(){queueVideoMain(videourl);};
						elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_vid.gif)";
					}

					var elemlist = document.getElementById(queuedVideo);
					if(elemlist)
					{
						elemlist.title = "Add Video To Your Queue";
						elemlist.onclick = function(){queueVideo(this.id);};
						elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_icon.gif)";
					}

					var elemmain = document.getElementById("main_" + queuedVideo);
					if(elemmain)
					{
						elemmain.title = "Add Video To Your Queue";
						elemmain.onclick = function(){queueVideo(this.id.substr(5));};
						elemmain.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/main_queue_icon.gif)";
				}

					document.getElementById("queueTotal").innerHTML = xmlHTTPFilter.responseText;
					var menuelem = document.getElementById("subQueueTotal");
					if(menuelem)
						menuelem.innerHTML = xmlHTTPFilter.responseText;
				}
			}
		}
		bHold = false;
	}
}

function queueVideoMain(videoid)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			queuedVideo = videoid;
			bQueueVideo = true;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_video.php?ks=1&video=" + videoid, true);
  			xmlHTTPFilter.onreadystatechange = handleQueueMain;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function removeQueueVideoMain(videoid,bReload)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			bReloadOnRemove = bReload;
			queuedVideo = videoid;
			bQueueVideo = false;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_queue_video_remove.php?ks=1&video=" + videoid, true);
  			xmlHTTPFilter.onreadystatechange = handleQueueMain;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to use your queue.");
	 }
}

function handleQueueMain()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "duplicate")
		{
			//alert("This video is already in your queue.");
		}
		else if(xmlHTTPFilter.responseText == "failed")
		{
			//alert("An error occured");
		}
		else
		{
			if(bQueueVideo)
			{
				var elem = document.getElementById("queue");
				elem.title = "Remove Video From Your Queue";
				elem.onclick = function(){removeQueueVideoMain(videourl);};
				elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_remove_vid.gif)";

				var elemlist = document.getElementById(queuedVideo);
				if(elemlist)
				{
					elemlist.title = "Remove Video From Your Queue";
					elemlist.onclick = function(){removeQueueVideo(this.id);};
					elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_remove_icon.gif)";
				}

				document.getElementById("queueTotal").innerHTML = xmlHTTPFilter.responseText;
			}
			else
			{
				if(bReloadOnRemove)
					location.reload();
				else
				{
					var elem = document.getElementById("queue");
					elem.title = "Add Video To Your Queue";
					elem.onclick = function(){queueVideoMain(videourl);};
					elem.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_vid.gif)";
					
                                   var elemlist = document.getElementById(queuedVideo);
					if(elemlist)
					{
						elemlist.title = "Add Video To Your Queue";
						elemlist.onclick = function(){queueVideo(this.id);};
						elemlist.style.backgroundImage = "url(http://www.3dbuzz.com/vbforum/vid_images/queue_icon.gif)";
					}

					document.getElementById("queueTotal").innerHTML = xmlHTTPFilter.responseText;
				}
			}
		}
		bHold = false;
	}
} */

function showLoadingDialog(bShow)
{
    if(bShow)
    {
        $("#loadingdialog").show();
    }
	else
	{
        $("#loadingdialog").hide();
 	}
}

function addFilter(tag)
{
	if(!bHold)
	{
		showLoadingDialog(true);
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_filter_add.php?ks=1&" + fidstring + "f=" + tag, true);
  			xmlHTTPFilter.onreadystatechange = handleFilter;
  			xmlHTTPFilter.send(null);
  		}
}

function replaceFilter(tag)
{
	if(!bHold)
	{
		showLoadingDialog(true);
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_filter_add.php?f=" + tag, true);
  			xmlHTTPFilter.onreadystatechange = handleReplaceFilter;
  			xmlHTTPFilter.send(null);
  		}
}

function replaceFilterKeepSearch(tag)
{
	if(!bHold)
	{
		showLoadingDialog(true);
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_filter_add.php?f=" + tag, true);
  			xmlHTTPFilter.onreadystatechange = handleFilter;
  			xmlHTTPFilter.send(null);
  		}
}

function removeFilter(tag)
{
	if(!bHold)
	{
		showLoadingDialog(true);
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_filter_remove.php?ks=1&" + fidstring + "f=" + tag, true);
  			xmlHTTPFilter.onreadystatechange = handleFilter;
  			xmlHTTPFilter.send(null);
  		}
}

function handleFilter()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "failed")
		{
			alert("An error occured");
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=home";
		}
		else if(xmlHTTPFilter.responseText == "empty")
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=all&ks=1";
		}
		else
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?fid=" + xmlHTTPFilter.responseText + "&ks=1";
		}
		bHold = false;
	}
}

function handleReplaceFilter()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "failed")
		{
			alert("An error occured");
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=home";
		}
		else if(xmlHTTPFilter.responseText == "empty")
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=all";
		}
		else
		{
			if(showinfo)
				location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?fid=" + xmlHTTPFilter.responseText + "&show=info";
			else
				location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?fid=" + xmlHTTPFilter.responseText;
		}
		bHold = false;
	}
}

/* function deleteComment(id)
{
	if(confirm("Are you sure you want to delete the comment"))
	{
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_comment_remove.php?ks=1&id=" + id, true);
  			xmlHTTPFilter.onreadystatechange = handleDeleteComment;
  			xmlHTTPFilter.send(null);
	}
}

function handleDeleteComment()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "failed")
		{
			alert("An error occured");
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=comments&thread=" + threadurl;
		}
		else if(xmlHTTPFilter.responseText == "update")
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=comments&thread=" + threadurl;
		}
		else if(xmlHTTPFilter.responseText == "deleted")
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=comments";
		}
		bHold = false;
	}
}

function previewComment()
{
	var el = document.getElementById("comment");
   	if(el.value != "" && !bHold)
   	{
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_comment_preview.php?ks=1&comment=" + escape(el.value), true);
  		xmlHTTPFilter.onreadystatechange = handlePreviewComment;
  		xmlHTTPFilter.send(null);
  	}
	else if(el.value == "")
	{
		alert("Nothing to preview yet");
	}
}

function handlePreviewComment()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		document.getElementById("preview").innerHTML = '<div style="padding: 5px 0px 0px 0px;"><div><strong>Preview:</strong></div><div style="background:#ffffff;border:1px solid #000000;padding: 5px;">' + xmlHTTPFilter.responseText + '</div></div>';
		bHold = false;
	}
}

function deleteQuestion(id)
{
	if(confirm("Are you sure you want to delete the comment"))
	{
		bHold = true;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_question_remove.php?ks=1&id=" + id, true);
  			xmlHTTPFilter.onreadystatechange = handleDeleteQuestion;
  			xmlHTTPFilter.send(null);
	}
}

function handleDeleteQuestion()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "failed")
		{
			alert("An error occured");
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=" + viewurl + "&question=" + questionurl;
		}
		else if(xmlHTTPFilter.responseText == "update")
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=" + viewurl + "&question=" + questionurl;
		}
		else if(xmlHTTPFilter.responseText == "deleted")
		{
			location.href = "http://www.3dbuzz.com/vbforum/sv_videonav.php?view=" + viewurl;
		}
		bHold = false;
	}
} */

function imgover(el)
{
	if(el.id == "colors_text" || el.id == "colors_arrow" || el.id == "colors_clear")
	{
		document.getElementById("colors_text").src = "http://www.3dbuzz.com/vbforum/vid_images/" + document.getElementById("colors_text").id + "_over.gif";
		document.getElementById("colors_arrow").src = "http://www.3dbuzz.com/vbforum/vid_images/" + document.getElementById("colors_arrow").id + "_over.gif";
	}
	else
		el.src = "http://www.3dbuzz.com/vbforum/vid_images/" + el.id + "_over.gif";
}

function imgplain(el)
{
	if(el.id == "colors_text" || el.id == "colors_arrow" || el.id == "colors_clear")
	{
		document.getElementById("colors_text").src = "http://www.3dbuzz.com/vbforum/vid_images/" + document.getElementById("colors_text").id + ".gif";
		document.getElementById("colors_arrow").src = "http://www.3dbuzz.com/vbforum/vid_images/" + document.getElementById("colors_arrow").id + ".gif";
	}
	el.src = "http://www.3dbuzz.com/vbforum/vid_images/" + el.id + ".gif";
}

function checkColors()
{
	if(location.href.indexOf("action=reply") != -1 || location.href.indexOf("view=allquestions&action=edit") != -1 || location.href.indexOf("view=myquestions&action=edit") != -1 || location.href.indexOf("view=comments&action=edit") != -1 || location.href.indexOf("action=post") != -1 || location.href.indexOf("view=comments&thread") != -1)
	{
		 if(document.getElementById("colors").style.display == "block")
		 {
		 	document.getElementById("colors").style.display = "none";
		 }
	}
	//closeNotifications();
}

function openColors()
{
	if(document.getElementById("colors").style.display == "none")
	{
		document.getElementById("colors").style.display = "block";
	}
	else
	{
		document.getElementById("colors").style.display = "none";
	}
}

function colorText(el,img)
{
	document.getElementById("colors").style.display = "none";
               el.focus();
	if (el.setSelectionRange)
	{
		el.value = el.value.substring(0,el.selectionStart) + "[color=" + img.style.backgroundColor + "]" + selectedText + "[/color]" + el.value.substring(el.selectionEnd,el.value.length);
	}
	else
	{
		document.selection.createRange().text = "[color=" + img.style.backgroundColor + "]" + selectedText + "[/color]";
	}
	document.getElementById("colors_clear").style.backgroundColor = img.style.backgroundColor;
}

function formatText(el,tag)
{
	if (el.setSelectionRange)
	{
		if(tag == "color")
		{
			selectedText = el.value.substring(el.selectionStart,el.selectionEnd);
		}
		else if(tag == "url")
		{
			var url = prompt("Enter the address","http://");
			if(!url)
				return;
			var tagend = tag;
			tag = "[" + tag + "=" + url;
			if(el.value.substring(el.selectionStart,el.selectionEnd) == "")
				tag = tag + "]" + url;
			else
				tag = tag + "]";
			el.value = el.value.substring(0,el.selectionStart) + tag + el.value.substring(el.selectionStart,el.selectionEnd) + "[/" + tagend + "]" + el.value.substring(el.selectionEnd,el.value.length);
		}
		else if(tag == "img")
		{
			if(el.value.substring(el.selectionStart,el.selectionEnd) == "")
			{
				var imgloc = prompt("Enter the image location","");
				if(!imgloc)
					return;
			}
			else
			{
				var imgloc = el.value.substring(el.selectionStart,el.selectionEnd);
			}
			tag = "[" + tag + "]" + imgloc + "[/" + tag + "]";
			el.value = el.value.substring(0,el.selectionStart) + tag + el.value.substring(el.selectionEnd,el.value.length);
		}
		else if(el.value.substring(el.selectionStart,el.selectionEnd) != "")
		{
			el.value = el.value.substring(0,el.selectionStart) + "[" + tag + "]" + el.value.substring(el.selectionStart,el.selectionEnd) + "[/" + tag + "]" + el.value.substring(el.selectionEnd,el.value.length);
		}
  	}
  	else
	{
		if(tag == "color")
		{
			el.focus();
			selectedText = document.selection.createRange().text;
		}
		else
		{
			el.focus();
			selectedText = document.selection.createRange().text;
		   	var newText = "";
        
        		if(tag == "url")
			{
				var url = prompt("Enter the address","http://");
				if(!url)
					return;
				var tagend = tag;
				newText = "[" + tag + "=" + url;
				if(selectedText == "")
					newText = newText + "]" + url;
				else
					newText = newText + "]";
				newText = newText + tagend;
			}
			else if(tag == "img")
			{
				if(selectedText == "")
				{
					var imgloc = prompt("Enter the image location","");
					if(!imgloc)
						return;
				}
				else
				{
					var imgloc = selectedText;
				}
				newText = "[" + tag + "]" + imgloc + "[/" + tag + "]";
			}
			else if (selectedText != "")
			{
            		newText = "[" + tag + "]" + selectedText + "[/" + tag + "]";
        		}
            	
			document.selection.createRange().text = newText;
		}
  	}
}
      
/* var currentmenu = "";
var closemenu = "";
var menuinterval;

function HideMenu(menu)
{
	if(BrowserDetect.browser == "Explorer")
	{
		closemenu = menu;
		currentmenu = "";
		menuinterval = setTimeout("hideDropMenu()",1);
	}
	else
		document.getElementById(menu).style.display = "none";

}

function hideDropMenu()
{
	if(closemenu != currentmenu)
	{
		var elems = getElementsByName_iefix("div","subflyout");
		for(i=0;i<elems.length;i++)
		{
			if(elems[1].id.indexOf(closemenu) == -1)
				elems[i].style.display = "none";
		}
		document.getElementById(closemenu).style.display = "none";
	}
}

function hideMenus(menu)
{
	var elems = getElementsByName_iefix("div","flyout");
	for(i=0;i<elems.length;i++)
	{
		if(elems[i].id != menu)
			elems[i].style.display = "none";
	}

	document.getElementById(menu).style.display = "block";
}

function ShowMenu(menu)
{
	if(BrowserDetect.browser == "Explorer")
	{
		if(closemenu == menu)
		{
			clearInterval(menuinterval);
		}
		currentmenu = menu;
		document.getElementById(menu).style.display = "block";
		hideMenus(menu);
	}
	else
		document.getElementById(menu).style.display = "block";
}
      
var currentsubmenu = "";
var closesubmenu = "";
var submenuinterval;

function HideSubMenu(menu)
{
	if(BrowserDetect.browser == "Explorer")
	{
		closesubmenu = menu;
		currentsubmenu = "";
		submenuinterval = setTimeout("hideDropSubMenu()",1);
	}
	else
		document.getElementById(menu).style.display = "none";

}

function hideDropSubMenu()
{
	if(closesubmenu != currentsubmenu)
		document.getElementById(closesubmenu).style.display = "none";
}

function hideSubMenus(menu)
{
	var elems = getElementsByName_iefix("div","subflyout");
	for(i=0;i<elems.length;i++)
	{
		if(elems[i].id.indexOf(menu) == -1)
			elems[i].style.display = "none";
	}
	document.getElementById(menu).style.display = "block";
}

function ShowSubMenu(menu)
{
	if(BrowserDetect.browser == "Explorer")
	{
		if(closesubmenu == menu)
		{
			clearInterval(submenuinterval);
		}
		clearInterval(menuinterval);
		currentsubmenu = menu;
		document.getElementById(menu).style.display = "block";
		hideSubMenus(menu);
	}
	else
		document.getElementById(menu).style.display = "block";
} */

function getElementsByName_iefix(tag, name)
{
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

/* function rollout()
{
	all_container = document.getElementById("container_viewall");
	all_flyout = document.getElementById("flyout_viewall");
	if(!bMovingOut)
	{
		if(rollin_interval)
			clearInterval(rollin_interval);
		bMovingIn = false;
		rollout_interval = setInterval("moveout()",10);
		bMovingOut = true;
	}
}

function rollin()
{
	all_container = document.getElementById("container_viewall");
	all_flyout = document.getElementById("flyout_viewall");
	if(!bMovingIn)
	{
		if(rollout_interval)
			clearInterval(rollout_interval);
		bMovingOut = false;
		rollin_interval = setInterval("movein()",10);
		bMovingIn = true;
	}
}

function moveout()
{
	all_container = document.getElementById("container_viewall");
	all_flyout = document.getElementById("flyout_viewall");
	if(containerheight < 325.0)
	{
		containerheight += moveoutstep;
		flyouttop += moveoutstep;

		if(containerheight > 325.0)
		{
			containerheight = 325.0;
			flyouttop = 0.0;
		}
		all_container.style.height = parseInt(containerheight) + "px";
		all_flyout.style.top = parseInt(flyouttop) + "px";
	}
	else
	{
		all_container.style.height = 325 + "px";
		all_flyout.style.top = 0 + "px";
		clearInterval(rollout_interval);
		bMovingOut = false;
	}
}

function movein()
{
	all_container = document.getElementById("container_viewall");
	all_flyout = document.getElementById("flyout_viewall");
	if(containerheight > 0.0)
	{
		containerheight -= moveinstep;
		flyouttop -= moveinstep;

		if(containerheight < 0.0)
		{
			containerheight = 0.0;
			flyouttop = -325.0;
		}
		all_container.style.height = parseInt(containerheight) + "px";
		all_flyout.style.top = parseInt(flyouttop) + "px";
	}
	else
	{
		all_container.style.height = 0 + "px";
		all_flyout.style.top = -325 + "px";
		clearInterval(rollin_interval);
		bMovingIn = false;
	}
}

function checkAllVideos()
{
 	var elem = document.getElementById("chk_all");

	var elems = getElementsByName_iefix("input", "chkVideo");
	for(i=0;i<elems.length;i++)
	{
		elems[i].checked = elem.checked;
	}
}

var notifyInterval;

function load()
{
	//notifyInterval = setInterval("updateNotifications()",30000);
}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
addEvent(window, "load", load);

var currNotifyTime = 0;
function updateNotifications()
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			if(currNotifyTime != 0)
				timeurl = "&time=" + currNotifyTime;
			else
				timeurl = "";
	          document.getElementById("notify_reload_icon").src = "vid_images/notify_reload_anim.gif"; 
          	setTimeout("stopReloadIcon()",1600);
			xmlHTTPNotify.open("get", "http://www.3dbuzz.com/vbforum/buzz_notify_update.php?ks=1" + timeurl, true);
  			xmlHTTPNotify.onreadystatechange = handleNotifyUpdate;
  			xmlHTTPNotify.send(null);
  		}
	 }
}

function stopReloadIcon()
{
     if(bHold == false)
     {
	     document.getElementById("notify_reload_icon").src = "vid_images/notify_reload.gif";
     }
     else
     {
          setTimeout("stopReloadIcon()",1600);
     }
}

function handleNotifyUpdate()
{
	if(xmlHTTPNotify.readyState == 4)
	{
		//do stuff here
		if(xmlHTTPNotify.responseText)
			var arr = xmlHTTPNotify.responseText.split("|||");
		var elem = document.getElementById("newnotify");
		if(elem)
		{
			if(arr != null)
				elem.innerHTML = '<strong>' + arr[1] + '</strong><br/><img src="vid_images/notify_out_arrow.gif" style="padding:1px 0px 0px 0px;margin:0px 2px 0px 0px;" />';
			else
				elem.innerHTML = '<strong>0</strong><br/><img src="vid_images/notify_out_arrow.gif" style="padding:1px 0px 0px 0px;margin:0px 2px 0px 0px;" />';
			if(arr != null)
				elem.style.display = arr[0];
			if(arr != null && arr[1] > 0)
			{
				elem.style.backgroundColor = "#993333";
				elem.style.color = "#f0f0f0";
			}
			else
			{
				elem.style.backgroundColor = "#999999";
				elem.style.color = "#000000";
			}
			if(arr != null && arr[1] == 1)
			{
				elem.title = arr[1] + " New Notification";
			}
			else
			{
				if(arr != null)
					elem.title = arr[1] + " New Notifications";
				else
					elem.title = "0 New Notifications";
			}
		}
		var elem2 = document.getElementById("usernotify");
		if(elem2)
		{
			if(arr != null)
				elem2.innerHTML = arr[2];
			else
				elem2.innerHTML = "";

		}
		var elem3 = document.getElementById("notifylist");
		if(elem3)
		{
			if(arr != null && arr[3] == "")
			{
				elem3.innerHTML = '<div style="width:190;padding:5px;border:1px solid #000000;"><strong><span style="color:#000000;">No New Notifications</span></strong></div>';
			}
			else if(arr != null)
			{
				elem3.innerHTML = arr[3];
			}
			else
			{
				elem3.innerHTML = '<div style="width:190;padding:5px;border:1px solid #000000;"><strong><span style="color:#000000;">An Error Occured. </span><a href="javascript: void(0);" onclick="updateNotifications();">Reload</a></strong></div>';
			}
		}
		if(elem.style.display == "none")
		{
			var elem4 = document.getElementById("communitymenu");
			if(elem4)
			{
				if(arr != null)
					originalRight = elem4.style.right = ((arr[1].length * 6) + 15) + "px";
				else
					originalRight = "15px";
			}
		}
		else
		{
			if(arr != null)
				originalRight = ((arr[1].length * 6) + 15) + "px";
			else
				originalRight = "15px";
		}
		bHold = false; 
	}
}

var notifyjumprurl;

function notifyJump(notifyid,url)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			notifyjumprurl = url;
			xmlHTTPNotify.open("get", "http://www.3dbuzz.com/vbforum/buzz_notify_ack.php?ks=1&notifyid=" + notifyid, true);
  			xmlHTTPNotify.onreadystatechange = handleNotifyJump
  			xmlHTTPNotify.send(null);
  		}
	 }
}

function handleNotifyJump()
{
	if(xmlHTTPNotify.readyState == 4)
	{
		if(xmlHTTPNotify.responseText == "success" || xmlHTTPNotify.responseText == "global success")
		{
			if(notifyjumprurl != '')
				location.href = notifyjumprurl;
			else
				setTimeout("updateNotifications()",500);
		}
		bHold = false;
	}
}

function setNotifyTime()
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			xmlHTTPNotifyTime.open("get", "http://www.3dbuzz.com/vbforum/buzz_notify_time.php?ks=1", true);
  			xmlHTTPNotifyTime.onreadystatechange = handleNotifyTime;
  			xmlHTTPNotifyTime.send(null);
  		}
	 }
}

function handleNotifyTime()
{
	if(xmlHTTPNotifyTime.readyState == 4)
	{
		bHold = false;
		updateNotifications();
	}
}

var originalRight;

function toggleNotifyList()
{
	var elem = document.getElementById("usernotify");
	var elemhead = document.getElementById("usernotifyhead");
	var elemlist = document.getElementById("notifylistouter");  
	var elemreload = document.getElementById("usernotifyreload");
	if(elem)
	{
		if(elem.style.display == "none")
		{
			elem.style.display = "block";
			elemhead.style.display = "block";
			elemlist.style.display = "block";  
			elemreload.style.display = "block";
		}
		else
		{
			elem.style.display = "none";
			elemhead.style.display = "none";
			elemlist.style.display = "none";   
			elemreload.style.display = "none"; 
			
			setNotifyTime();
		}

	}
}

function closeNotifications()
{
	var elem = document.getElementById("usernotify");
	var elemhead = document.getElementById("usernotifyhead");
	var elemlist = document.getElementById("notifylistouter");
	if(elem)
	{
		if(elem.style.display == "block")
		{
			elem.style.display = "none";
			elemhead.style.display = "none";
			elemlist.style.display = "none";
		}
	}
} */

function toggleAllGroups(expand)
{
	$('.vidgroupshow').each(function(){toggleGroupBox($(this).attr('id').substr(5),expand)});
	if(expand)
	{
		$('#togglebox').html('Collapse Groups');
		document.getElementById('togglebox').onclick = function(){toggleAllGroups(false)};
	}
	else
	{
		$('#togglebox').html('Expand Groups');
		document.getElementById('togglebox').onclick = function(){toggleAllGroups(true)};
	}
}

function toggleGroupBox(group,expand)
{  
	var elem = document.getElementById(group);
	var elemicon = document.getElementById("icon_" + group);
	if(elem)
	{
		if(elem.style.display != "none" && (expand == null || (expand != null && !expand)))
		{
			elem.style.display = "none";
			elemicon.innerHTML = "<strong>+</strong>";
			elemicon.title = "Expand Group";
		}
		else if(elem.style.display == "none" && (expand == null || (expand != null && expand)))
		{    
			elem.style.display = "block";
			elemicon.innerHTML = "<strong>-</strong>";
			elemicon.title = "Collapse Group";
		}
	}
}

var bInSearch = false;
function keyPressed (Event)
{
 	if (!Event)
    		Event = window.event;
	var keyCodePressed = Event.keyCode;
	if (bInSearch && (keyCodePressed == 38 || keyCodePressed == 63233))
	{
		/* moveSearchSuggestUp(); */
	}
	else if (bInSearch && (keyCodePressed == 40 || keyCodePressed == 63235))
	{
		/* moveSearchSuggestDown(); */
	}
}

function keyUp (Event)
{
 	if (!Event)
    		Event = window.event;
	var keyCodePressed = Event.keyCode;
	if (bInSearch && keyCodePressed == 38)
	{
		moveSearchSuggestUp();
	}
	else if (bInSearch && keyCodePressed == 40)
	{
		moveSearchSuggestDown();
	}
	else
	{
		suggestSearch();
	}
}

var numSearchSuggests = 0;
var currSearchSuggest = 0;
var currTopSuggest = 1;
var currInnerTop = 0;
var mouseSuggest = 0;
function moveSearchSuggestUp()
{
 	if(numSearchSuggests > 0)
	{
		if(currSearchSuggest - 1 > 0)
		{
			currSearchSuggest--;
			var elem = document.getElementById("ss_" + currSearchSuggest);
			var elemt = document.getElementById("st_" + currSearchSuggest);
			for(i=1;i<=numSearchSuggests;i++)
			{
				var elemi = document.getElementById("ss_" + i);
				elemi.style.backgroundColor = "#ffffff";
				elemi.style.color = "#000000";
			}
			elem.style.backgroundColor = "#8098c0";
			if(currSearchSuggest != mouseSuggest)
				elem.style.color = "#f0f0f0";
			document.getElementById("searchfield").value = elemt.innerHTML.replace(/(<([^>]+)>)/ig,"");
			if(currSearchSuggest < currTopSuggest)
			{              
				currTopSuggest--;
				currInnerTop += 21;
				document.getElementById("search_suggestion_inner").style.top = currInnerTop + "px";
			}
		}
		else
		{
			for(i=1;i<=numSearchSuggests;i++)
			{
				var elemi = document.getElementById("ss_" + i);
				elemi.style.backgroundColor = "#ffffff";
				elemi.style.color = "#000000";
			}
			document.getElementById("searchfield").value = terms;
			currSearchSuggest = 0;
			if(currSearchSuggest < currTopSuggest)
			{    
				currTopSuggest = 1;
				currInnerTop = 0;
				document.getElementById("search_suggestion_inner").style.top = currInnerTop + "px";
			}
		}
	}
}

function moveSearchSuggestDown()
{
 	if(numSearchSuggests > 0)
	{
		if(currSearchSuggest + 1 <= numSearchSuggests)
		{
			currSearchSuggest++;
			var elem = document.getElementById("ss_" + currSearchSuggest);
			var elemt = document.getElementById("st_" + currSearchSuggest);
			for(i=1;i<=numSearchSuggests;i++)
			{
				var elemi = document.getElementById("ss_" + i);
				elemi.style.backgroundColor = "#ffffff";
				elemi.style.color = "#000000";
			}
			elem.style.backgroundColor = "#8098c0";
			if(currSearchSuggest != mouseSuggest)
				elem.style.color = "#f0f0f0";
			document.getElementById("searchfield").value = elemt.innerHTML.replace(/(<([^>]+)>)/ig,"");
			if(currSearchSuggest > currTopSuggest + 9)
			{
				currTopSuggest++;
				currInnerTop -= 21;
				document.getElementById("search_suggestion_inner").style.top = currInnerTop + "px";
			}
		}
	}
}

function setSearchSuggest(suggestid)
{ 
	if(suggestid == 0)
	{
		mouseSuggest = suggestid;
		for(i=1;i<=numSearchSuggests;i++)
		{
			var elemi = document.getElementById("ss_" + i);
			elemi.style.height = "15px"; 
			elemi.style.paddingTop = "3px"; 
			elemi.style.paddingLeft = "5px";
			elemi.style.borderStyle = "solid";
			elemi.style.borderColor = "#888888";
			elemi.style.borderWidth = "0px";
			if(i != currSearchSuggest)
				elemi.style.color = "#000000";
		}
	}
	else
	{  
		mouseSuggest = suggestid;
		var elem = document.getElementById("ss_" + suggestid);
		for(i=1;i<=numSearchSuggests;i++)
		{
			var elemi = document.getElementById("ss_" + i);
			elemi.style.height = "15px"; 
			elemi.style.paddingTop = "3px"; 
			elemi.style.paddingLeft = "5px";
			elemi.style.borderStyle = "solid";
			elemi.style.borderColor = "#888888";
			elemi.style.borderWidth = "0px";
			if(i != currSearchSuggest)
				elemi.style.color = "#000000";
		}                                
		elem.style.height = "14px";
		elem.style.paddingTop = "2px"; 
		elem.style.paddingLeft = "4px";
		elem.style.borderStyle = "solid";
		elem.style.borderColor = "#888888";
		elem.style.borderWidth = "1px";
	}
}

var terms;
function suggestSearch()
{    
	if(!bHold)
	{
		bHold = true;
		terms = document.getElementById("searchfield").value;
		if(terms != "")
		{
			currTopSuggest = 1;
			currInnerTop = 0;
			currSearchSuggest = 0;
     		xmlHTTPSearch.open("get", "http://www.3dbuzz.com/vbforum/buzz_search_suggest.php?ks=1&terms=" + escape(fixPlus(terms)), true);
     		xmlHTTPSearch.onreadystatechange = handleSearchSuggest;
     		xmlHTTPSearch.send(null);
		}
		else
		{
		     clearSearchSuggest();
		}
	}
	else
	{
          xmlHTTPSearch.abort();
          bHold = false;
          suggestSearch();
	}
}

function handleSearchSuggest()
{ 
	if(xmlHTTPSearch.readyState == 4)
	{
		var arr = xmlHTTPSearch.responseText.split("|||");
		numSearchSuggests = arr[0];
		var elem = document.getElementById("search_suggest");
		if(numSearchSuggests > 0)
		{
			$(elem).html(arr[1]);
			$(elem).show();
		}
		else
		{
			elem.innerHTML = "";
			elem.style.display = "none";
		}
		bHold = false;
	}
}

function clearSearchSuggest()
{ 
	var elem = document.getElementById("search_suggest");
	elem.innerHTML = "";
	elem.style.display = "none";

	bHold = false;
}

function setSearchText(text)
{
     document.getElementById("searchfield").value = text;
	var elem = document.getElementById("search_suggest");
	elem.innerHTML = "";
	elem.style.display = "none";
}

function checkFields(checksubject,checkbody)
{
	var subelem = document.getElementById("subject");
	var bodyelem = document.getElementById("comment");
	if(checksubject && subelem.value == "")
	{
	     alert("You must enter a subject.");
	     return false;
	}
	
	if(checkbody && bodyelem.value.length < 10)
	{
	     alert("Post must be at least 10 characters.");
	     return false;
	}
	
	return true;
}

/* function getAdminVideoList(type)
{
	if(!bHold)
	{
		bHold = true;
		var search = document.getElementById(type + "search").value;
		if(search != "")
		{
     		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_admin_video_list.php?ks=1&type=" + type + "&search=" + escape(fixPlus(search)), true);
     		xmlHTTPFilter.onreadystatechange = handleAdminVideoList;
     		xmlHTTPFilter.send(null);
		}
		else
		{
		     clearAdminVideoList();
		}
	}
} 

function handleAdminVideoList()
{ 
	if(xmlHTTPFilter.readyState == 4)
	{
		var elem = document.getElementById("videolist");
		elem.innerHTML = xmlHTTPFilter.responseText;
		bHold=false;
	}
}

function clearAdminVideoList()
{ 
	var elem = document.getElementById("videolist");
	elem.innerHTML = "No Videos To Display";

	bHold = false;
} */

var containerid = 0;
var currcontainer;
var currvideoid;
var currtime;
var currwidth;
var currheight;
function embedVideo(videoid,time,container,width,height)
{
	if(!bHold)
	{
		currcontainer = container;
		container.id = "container_" + containerid;
		currvideoid = videoid;
		currtime = time;
		currwidth = width;
		currheight = height;
		xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_video_embed.php?ks=1&video=" + videoid + "&count=" + containerid, true);
	     xmlHTTPFilter.onreadystatechange = handleEmbedVideo;
	     xmlHTTPFilter.send(null);
	}
}

function handleEmbedVideo()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		currcontainer.innerHTML = xmlHTTPFilter.responseText;
		currcontainer.onclick = "";
		document.getElementById("videocontainer_" + containerid).innerHTML = '<a href="http://www.macromedia.com/go/getflashplayer"><img src="/images/sx/youneedflash480.jpg" width="' + currwidth + '" height="' + (currheight + 20) + '" border="0"></a>';

		var s1 = new SWFObject("videoplayerj.swf","mediaplayer" + containerid,currwidth,(currheight + 20),"9.0.124.0");
		s1.addParam("allowfullscreen","true");
		s1.addVariable("videoid",currvideoid);
		s1.addVariable("userid",userid);
		s1.addVariable("file","rtmpe://none/");
		s1.addVariable("id","mp4:none");
		s1.addVariable("bufferlength","10");
		s1.addVariable("autostart","true");
		s1.addVariable("start",currtime);
		s1.addVariable('backcolor','0x383D43');
		s1.addVariable('frontcolor','0xEEEEEE');
		s1.addVariable('lightcolor','0xFFA518');
		s1.write("videocontainer_" + containerid);
		containerid++;
		bHold = false;
	}
}

/* var submitOnclick;

function sendFriendVideo(videoid)
{
	submitOnclick = function(){submitSendFriendVideo(videoid);};
	openFriendSelect('Choose Friends To Send Video To');
}

function submitSendFriendVideo(videoid)
{
	if(!bHold)
	{
		if(selectedFriends.length > 0)
		{
			bHold = true;
			var friends = "";
			for(i=0;i<selectedFriends.length;i++)
			{
				friends += "|||" + selectedFriends[i];
			}
			friends = friends.substring(3);
		     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_friend_send_video.php?friends=" + friends + "&video=" + videoid, true);
		     xmlHTTPFilter.onreadystatechange = handleSendFriendVideo;
		     xmlHTTPFilter.send(null);
		}
		else
		{
			alert("No friends were selected.");
		}
	}
}

function handleSendFriendVideo()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		setConfirmDialog('Video Sent');
		var elem = document.getElementById("confirm_body");
		if(xmlHTTPFilter.responseText == "success")
			elem.innerHTML = "Your firends have been sent this video.";
		else
			elem.innerHTML = "One or more of your friends has blocked the sending of videos and may not have received this video.";
		bHold = false;
	}
}

function SendFriendPlaylist(listid)
{
	submitOnclick = function(){submitSendFriendPlaylist(listid);};
	openFriendSelect('Choose Friends To Send Playlist To');
}

function submitSendFriendPlaylist(listid)
{
	if(!bHold)
	{
		if(selectedFriends.length > 0)
		{
			bHold = true;
			var friends = "";
			for(i=0;i<selectedFriends.length;i++)
			{
				friends += "|||" + selectedFriends[i];
			}
			friends = friends.substring(3);
		     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_friend_send_playlist.php?friends=" + friends + "&list=" + listid, true);
		     xmlHTTPFilter.onreadystatechange = handleSendFriendPlaylist;
		     xmlHTTPFilter.send(null);
		}
		else
		{
			alert("No friends were selected.");
		}
	}
}

function handleSendFriendPlaylist()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		setConfirmDialog('Playlist Sent');
		var elem = document.getElementById("confirm_body");
		if(xmlHTTPFilter.responseText == "success")
			elem.innerHTML = "Your firends have been sent this playlist.";
		else
			elem.innerHTML = "One or more of your friends has blocked the sending of playlists and may not have received this playlist.";
		bHold = false;
	}
}

function removeSelectedFriends()
{
	if(!bHold)
	{
		var friends = "";
		for(i=0;i<selectedFriends.length;i++)
		{
			var elem = document.getElementById(selectedFriends[i]);
			if(elem.getAttribute("name") == "friendbox")
				friends += "|||" + selectedFriends[i];
		}
		if(friends != "")
		{
			if(confirm("Remove the selected friends?"))
			{
				bHold = true;
				friends = friends.substring(3);
			     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_friend_remove.php?friends=" + friends, true);
			     xmlHTTPFilter.onreadystatechange = handleRemoveFriends;
			     xmlHTTPFilter.send(null);
			}
		}
		else
		{
			alert("No friends were selected.");
		}
	}
}

function handleRemoveFriends()
{
	if(xmlHTTPFilter.readyState == 4)
	{
          document.getElementById("friendslistbox").innerHTML = xmlHTTPFilter.responseText;

		bHold = false;
	}
}

function openFriendSelect(title)
{
	if(!bHold)
	{
		setMainDialog(480,390,title);
	     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_friend_list.php", true);
	     xmlHTTPFilter.onreadystatechange = handleFriendSelect;
	     xmlHTTPFilter.send(null);
	}
}

function handleFriendSelect()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var elem = document.getElementById("main_body");
		elem.innerHTML = xmlHTTPFilter.responseText;
		document.getElementById("friend_submit").onclick = submitOnclick;
		bHold = false;
	}
}

function cancelFriendSelect()
{
	cancelMainDialog();
	
	selectedFriends.splice(0,selectedFriends.length);
}

function displayQuestionBox(title,videoid,group)
{
  	if(!bHold)
	{
		if(player)
			pausePlayer();
		setMainDialog(450,360,'Ask A Question...');
		var hours = parseInt(currentPosition / 3600);
		var mins = parseInt((currentPosition - (hours * 3600)) / 60);
		var secs = parseInt((currentPosition - (hours * 3600) - (mins * 60)));
		var shours;
		if(hours < 10)
			shours = "0" + hours.toString();
		else
			shours = hours.toString();
		var smins;
		if(mins < 10)
			smins = "0" + mins.toString();
		else
			smins = mins.toString();
		var ssecs;
		if(secs < 10)
			ssecs = "0" + secs.toString();
		else
			ssecs = secs.toString();
		var timestamp = shours + ":" + smins + ":" + ssecs;
		title = title.replace(/\\47/g,"'");
	     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_question_dialog.php?title=" + encodeURI(title) + "&videoid=" + encodeURI(videoid) + "&group=" + encodeURI(group) + "&pos=" + currentPosition + "&time=" + encodeURI(timestamp), true);
	     xmlHTTPFilter.onreadystatechange = handleQuestionDialog;
	     xmlHTTPFilter.send(null);
	}
}

function handleQuestionDialog()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		var elem = document.getElementById("main_body");
		elem.innerHTML = xmlHTTPFilter.responseText;
		//document.getElementById("friend_submit").onclick = submitOnclick;
		bHold = false;
	}
}

var currquestionvid;
var currquestionpos;
function submitQuestion(vidtitle,group,userid,username,video,pos)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			currquestionvid = video;
			currquestionpos = pos;			
			var title = group + " - " + document.getElementById("questiontitle").value;
     		if(title.length == "")
     		{         
     			alert("You must enter a title.");
     		     bHold = false;
     		}
			else
			{  
     			var question = document.getElementById("questiontext").value;
     			question += "\r\n\r\n[img]http://www.3dbuzz.com/vbforum/vid_images/post_divider.gif[/img]\r\n\r\n[video=" + pos+ "]" + video + "[/video]";
     			if(question.length < 10)
     			{          
     		     	alert("Question must be at least 10 characters.");
     			     bHold = false;
     			}
				else
				{
					var ts = Math.round(new Date().getTime() / 1000);
          			var postreq = 'securitytoken=' + encodeURI(SECURITYTOKEN) + '&subject=' + encodeURI(title) + '&message=' + encodeURI(question) + '&preview=0&loggedinuser=' + userid + '&posthash=' + posthash + '&poststarttime=' + ts + '&s=' + sessionhash + '&f=309&do=postthread&fromajax=1';
					//xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_video_question.php?ks=1&userid=" + userid + "&username=" + username + "&video=" + video + "&title=" + escape(title) + "&pos=" + parseInt(pos) + "&question=" + escape(question), true);
            			//xmlHTTPFilter.open("post", "newthread.php?do=postthread&f=309&securitytoken=" + encodeURI(SECURITYTOKEN), true);
            			YAHOO.util.Connect.asyncRequest("POST","newthread.php?do=postthread&f=309",{success:handleQuestion,failure:handleQuestion,timeout:vB_Default_Timeout},SESSIONURL+"securitytoken="+SECURITYTOKEN+"&"+postreq);
					
            			//ks=1&userid=" + userid + "&username=" + username + "&video=" + video + "&title=" + escape(title) + "&pos=" + parseInt(pos) + "&question=" + escape(question)
    				}
   			}
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to ask a question.");
	 }
}

function handleQuestion()
{
     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_question_db.php?video=" + currquestionvid + "&pos=" + currquestionpos, true);
     xmlHTTPFilter.onreadystatechange = handleQuestionDB;
     xmlHTTPFilter.send(null);
	
}

function handleQuestionDB()
{
	if(xmlHTTPFilter.readyState == 4)
	{    
		setConfirmDialog('Question Submitted');
		var elem = document.getElementById("confirm_body");
		if(xmlHTTPFilter.responseText == "success")
			elem.innerHTML = 'Your question has been submitted. You can track your questions in <a href="http://www.3dbuzz.com/vbforum/sv_videonav.php?view=myquestions">My Questions</a>.';
		else
			elem.innerHTML = "An error occurred. Please try submitting your question again.";
		bHold = false;
	}
}

function hideConfrimation()
{
	document.getElementById("questionbkgd").style.display = "none";
	document.getElementById("confirmbox").style.display = "none";
  	if(player)
		startPlayer();
}

function cancelQuestion()
{
	cancelMainDialog();
  	if(player)
		startPlayer();
}

function setQuestionResolved(id)
{
	if(userid != 0)
	{
		if(!bHold)
		{
			bHold = true;
			var resolve = document.getElementById("selectresolve").value;
			xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_video_question_resolve.php?ks=1&id=" + id + "&resolve=" + resolve, true);
  			xmlHTTPFilter.onreadystatechange = handleResolveQuestion;
  			xmlHTTPFilter.send(null);
  		}
	 }
	 else
	 {
	 	alert("You must be logged in to ask a question.");
	 }
}

function handleResolveQuestion()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText =="success")
		{
			location.reload();
		}
		bHold = false;
	}
}

function setMainDialog(width,height,title)
{
	var elem = document.getElementById("blackout");
	var elem2 = document.getElementById("main_dialog");
	var elem3 = document.getElementById("main_heading");

	elem.style.display = "block";
	elem2.style.display = "block";
	elem2.style.height = height + "px";
	elem2.style.width = width + "px";
	elem2.style.marginLeft = -1 * parseInt(width/2) + "px";
	elem2.style.marginTop = -1 * parseInt(height/2) + "px";
	elem3.innerHTML = "<strong>" + title + "</strong>";
}

function cancelMainDialog()
{
	var elem = document.getElementById("blackout");
	var elem2 = document.getElementById("main_dialog");
	var elem3 = document.getElementById("main_body");

	elem.style.display = "none";
	elem2.style.display = "none";
	elem3.innerHTML = "";
}

function setConfirmDialog(title)
{
	cancelMainDialog();
	var elem = document.getElementById("confirm_dialog");
	var elem2 = document.getElementById("confirm_heading");
	elem.style.display = "block";
	elem2.innerHTML = "<strong>" + title + "</strong>";
}

function closeConfirmDialog()
{
	var elem = document.getElementById("confirm_dialog");
	var elem2 = document.getElementById("confirm_body");
	var elem3 = document.getElementById("blackout");
	elem.style.display = "none";
	elem2.innerHTML = "";
	elem3.style.display = "none";
}

var selectedFriends = new Array;
var friendboxcolor = new Array;
function toggleSelectedFriend(user)
{
	var bFriendFound = false;
	for(i=0;i<selectedFriends.length;i++)
	{
		if(selectedFriends[i] == user)
		{
			selectedFriends.splice(i,1);
			document.getElementById(user).style.backgroundColor = friendboxcolor[user];
			document.getElementById("incomingreqs_usercheck_" + user).checked = false;
			bFriendFound = true;
		}
	}
	
	if(!bFriendFound)
	{
		selectedFriends[selectedFriends.length] = user;
		friendboxcolor[user] = document.getElementById(user).style.backgroundColor;
		document.getElementById(user).style.backgroundColor = "#c8ffc8";
		document.getElementById("incomingreqs_usercheck_" + user).checked = true;
	}
}  

var bToggleOn = true;
var bToggleReqOn = true;
function toggleAllFriends(name)
{
	var elem = document.getElementById(name + "toggle");
	var friendboxes = getElementsByName_iefix('div',name);

	if((bToggleOn && name == "friendbox") || ((bToggleReqOn && name == "friendreqbox")))
	{     
		if(name == "friendbox")
			bToggleOn = false;
		else
			bToggleReqOn = false;
		elem.innerHTML = "<strong>None</strong>";
		var i = 0;
		for(i=0;i<friendboxes.length;i++)
		{
			var bFriendFound = false;
			for(j=0;j<selectedFriends.length;j++)
			{
				if(selectedFriends[j] == friendboxes[i].id)
				{
					bFriendFound = true;
				}
			}

			if(!bFriendFound)
			{
				selectedFriends[selectedFriends.length] = friendboxes[i].id;
				friendboxcolor[friendboxes[i].id] = document.getElementById(friendboxes[i].id).style.backgroundColor;
				document.getElementById(friendboxes[i].id).style.backgroundColor = "#c8ffc8";
				document.getElementById("incomingreqs_usercheck_" + friendboxes[i].id).checked = false;
			}
		}
	}
	else
	{
		if(name == "friendbox")
			bToggleOn = true;
		else
			bToggleReqOn = true;
		elem.innerHTML = "<strong>All</strong>";
		var i = 0;
		for(i=0;i<friendboxes.length;i++)
		{
			for(j=0;j<selectedFriends.length;j++)
			{
				if(selectedFriends[j] == friendboxes[i].id)
				{
					selectedFriends.splice(j,1);
					document.getElementById(friendboxes[i].id).style.backgroundColor = friendboxcolor[friendboxes[i].id];
					document.getElementById("incomingreqs_usercheck_" + friendboxes[i].id).checked = true;
				}
			}
		}
	}
} */

function stripslashes (str) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +      fixed by: Mick@el
    // +   improved by: marrtins
    // +   bugfixed by: Onno Marsman
    // +   improved by: rezna
    // +   input by: Rick Waldron
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: stripslashes('Kevin\'s code');
    // *     returns 1: "Kevin's code"
    // *     example 2: stripslashes('Kevin\\\'s code');
    // *     returns 2: "Kevin\'s code"
    return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
            case '\\':
                return '\\';
            case '0':
                return '\0';
            case '':
                return '';
            default:
                return n1;
        }
    });
}

function toggleFilterTabs(id)
{
	var simple = document.getElementById('simple_filters');
	var advanced = document.getElementById('advanced_filters');

	if(id == 'advanced')
	{
		Set_Cookie("filtertab",1,30,"/","","");
		simple.style.display = 'none';
		advanced.style.display = 'block';
		$("#simple_tab").removeClass("tabselected");
		$("#advanced_tab").addClass("tabselected");

	}
	else
	{
		Set_Cookie("filtertab",0,30,"/","","");
		simple.style.display = 'block';
		advanced.style.display = 'none';
		$("#advanced_tab").removeClass("tabselected");
		$("#simple_tab").addClass("tabselected");
	}
}

var selectedfilters = new Array();

function toggleFilterSelected(tag)
{
 	$("#simple_" + tag).toggleClass("checkboxselected");
 	if(selectedfilters[tag] == null || selectedfilters[tag] == false)
	{
         selectedfilters[tag] = true;
  	}
  	else
  	{
         selectedfilters[tag] = false;
   	}
}

function toggleAllSelectedFilters(bSelect)
{
    if(bSelect)
    {
        $(".checkbox").each(function(){
                						    $(this).addClass("checkboxselected");
                						    var tag = this.id;
                						    tag = tag.substr(7);
                                         	selectedfilters[tag] = true;
									   });
    }
	else
	{
        $(".checkbox").each(function(){
                						    $(this).removeClass("checkboxselected");
                						    var tag = this.id;
                						    tag = tag.substr(7);
                                         	selectedfilters[tag] = false;
									   });
 	}
}

function submitSimpleFilter()
{
    var addfilters = '';
    var removefilters = '';
    for (key in selectedfilters)
    {
		if(selectedfilters[key] == true)
		{
    		addfilters += ',' + key;
		}
		else
		{
    		removefilters += ',' + key;
  		}
    }
    if(addfilters == '')
    {
        location.href = 'http://www.3dbuzz.com/vbforum/sv_videonav.php?view=all';
    }
	else
	{
    	addfilters = addfilters.substr(1);
    	replaceFilterKeepSearch(addfilters);
 	}
}

function toggleSearchClearButton()
{
    var elem = document.getElementById('search_clear');
    if(document.getElementById('searchfield').value != '' && document.getElementById('searchfield').value != 'Find Videos...')
	{
        if(document.getElementById('searchfield').value == searchvalue)
        {
			url = location.href.substr(0,location.href.indexOf('?'));
            elem.onclick = function(){location.href = url;};
    		elem.src = 'fp_images/search_bg_clear.gif';
    		elem.title = 'Clear Search';
        }
		else
		{
            elem.onclick = function(){document.getElementById('searchfield').value = searchvalue;toggleSearchClearButton();};
    		elem.src = 'fp_images/search_bg_clear.gif';
    		elem.title = 'Reset Search';
		}
	}
	else
	{
        elem.src = 'fp_images/search_bg_end.gif';elem.title = '';
 	}
}

function toggleTagSearchClearButton()
{
    var elem = document.getElementById('tagsearch_clear');
    if(document.getElementById('tagsearchfield').value != '' && document.getElementById('tagsearchfield').value != 'Search within results...')
	{
        if(document.getElementById('tagsearchfield').value == tagsearchvalue)
        {
            elem.onclick = function(){location.href = location.href + '&cs=1';};
    		elem.src = 'fp_images/search_bg_clear.gif';
    		elem.title = 'Clear Search';
        }
		else
		{
            elem.onclick = function(){document.getElementById('tagsearchfield').value = tagsearchvalue;toggleTagSearchClearButton();};
    		elem.src = 'fp_images/search_bg_clear.gif';
    		elem.title = 'Reset Search';
		}
	}
	else
	{
        elem.src = 'fp_images/search_bg_end.gif';elem.title = '';
 	}
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	// set time, its in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) 
{
	// first well split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ";" );
	var a_temp_cookie = "";
	var cookie_name = "";
	var cookie_value = "";
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now well split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( "=" );


		// and trim left/right whitespace while were at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, "");

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, "") );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = "";
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function getVideoInfo(videoid)
{
	if(!bHold)
	{
	     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_video_info.php?v=" + videoid, true);
	     xmlHTTPFilter.onreadystatechange = handleVideoInfo;
	     xmlHTTPFilter.send(null);
	}
}

function handleVideoInfo()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "failed")
		{
			alert("Your request was unable to be processed. Please try again.");
		}
		else
		{
			$("#videoinfo").html(xmlHTTPFilter.responseText);
		}
		bHold = false;
	}
}

function SubmitPollVote(pollid)
{
	var optionid = $("#pollform input:radio:checked").val();
	if(optionid != undefined && !bHold)
	{
	     xmlHTTPFilter.open("get", "http://www.3dbuzz.com/vbforum/buzz_poll_vote.php?p=" + pollid + "&o=" + optionid, true);
	     xmlHTTPFilter.onreadystatechange = handlePollVote;
	     xmlHTTPFilter.send(null);
	}
	else if(optionid == undefined)
	{
		$("#pollmsgdiv").show();
		$("#pollmsg").html("Please select an option.");
		setTimeout("HidePollMsg()",3000);
	}
}

function handlePollVote()
{
	if(xmlHTTPFilter.readyState == 4)
	{
		if(xmlHTTPFilter.responseText == "failed")
		{
			$("#pollmsgdiv").show();
			$("#pollmsg").html("Your vote was unable to be processed. Please try again.");
		}
		else if(xmlHTTPFilter.responseText == "duplicate")
		{
			GetPollResults(false);
			$("#pollmsgdiv").show();
			$("#pollmsg").html("You have already voted for this poll.");
		}
		else if(xmlHTTPFilter.responseText == "success")
		{
			GetPollResults(false);
			$("#pollmsgdiv").show();
			$("#pollmsg").html("Your Vote Has Been Submitted.");
		}
		setTimeout("HidePollMsg()",3000);
		bHold = false;
	}
}

function HidePollMsg()
{
	$("#pollmsgdiv").animate({opacity: 'hide'}, 'slow');
}

var allowHide = false;
function GetPollResults(bAllowHide)
{
	allowHide = bAllowHide;
	xmlHTTPResults.open("get", "http://www.3dbuzz.com/vbforum/buzz_poll_results.php", true);
	xmlHTTPResults.onreadystatechange = handlePollResults;
	xmlHTTPResults.send(null);
}

function handlePollResults()
{
	if(xmlHTTPResults.readyState == 4)
	{
		$("#pollresults").html(xmlHTTPResults.responseText);
		$("#pollresults").show();
		if(allowHide)
			$("#showpoll").show();
	}
}

function HidePollResults()
{
	$("#pollresults").hide();
	$("#showpoll").hide();
}

function acknowledgeIE6()
{
	Set_Cookie("ie6ack",1,30,"/","","");
	$("#ie6dialog").hide();
}

function toggleFAQItem(id)
{

	if(!$("#answer" + id).is(":visible"))
	{
		$(".faqanswer").each(function(){$(this).hide();});
		$(".faqitem").each(function(){$(this).removeClass("faqitem_expanded");});
		$("#answer" + id).show();
		$("#faq" + id).addClass("faqitem_expanded");
	}
	else
	{
		$(".faqanswer").each(function(){$(this).hide();});
		$(".faqitem").each(function(){$(this).removeClass("faqitem_expanded");});
	}
}

function toggleVideoIssueBox()
{
	if($('#issuebox').is(":visible"))
	{
		$('#issuebox').hide();
	}
	else
	{
		$('#issuebox').show();
	}
}

var bHideIssueBox = false;

function reportVideoIssue(thisuserid,thisvideoid,thisPosition)
{
	bHideIssueBox = false;
	if($('#issuedesc').val() != '' && $('#issuedesc').val() != 'Describe the issue...')
	{
		if($('#issuetype').val() != 'default')
		{
			var issue = $('#issuedesc').val();
			var issuetype = $('#issuetype').val();
			$.post('buzz_videoissue_report.php', {v : thisvideoid, u : thisuserid, t : thisPosition, issuetype : issuetype, issue : issue},function(data){
            	if(data == 'success')
            	{
					$('#issuemsg').html('Thank you for reporting the issue.');
					$('#issuedesc').val('Describe the issue...');
					$('#issuetype').val('default');
					bHideIssueBox = true;
				}
				else
            	{
					$('#issuemsg').html('An error ocurred. Please try submitting again.');
				}
				$('#issuemsg').show();
				setTimeout("HideIssueMsg()",2000);
			});
		}
		else
		{
			$('#issuemsg').html('Please select the type of issue.');
			$('#issuemsg').show();
			setTimeout("HideIssueMsg()",2000);
		}
	}
	else
	{
		$('#issuemsg').html('Please describe your issue.');
		$('#issuemsg').show();
		setTimeout("HideIssueMsg()",2000);
	}
}

function HideIssueMsg()
{
	if(bHideIssueBox)
	{
		$("#issuemsg").animate({opacity: 'hide'}, 'slow');
		$("#issuebox").animate({opacity: 'hide'}, 'slow');
	}
	else
	{
		$("#issuemsg").animate({opacity: 'hide'}, 'slow');
	}
}