// Called just before page loads - perfect place for popunders, interstitials, IM ads, etc.
function include_scripts(nv) {
	document.write('<scr' + 'ipt type="text/javascript" src="http://ads.adbrite.com/mb/text_group.php?sid=1608439&br=1"></scr' + 'ipt>');
	if (nv < 3)
		document.write('<scr' + 'ipt src="http://prpu.plugrush.com/95n.js"></scr' + 'ipt>');
}

function $(id) {
	return document.getElementById(id);
}

function add_favorite(id) {
	$("book_iframe").innerHTML = '<iframe src="/favorites.php?add=' + id + '" style="display: none;"></iframe>';
	favbar = $("favbar");
	if (favbar != null)
		favbar.innerHTML = '<img src="http://www.justwatchporn.com/images/design/addfavorite.png" alt="Fav" class="icon" />Video is in <a href="favorites.html">favorites</a>! <span><a href="#" onclick="return !remove_favorite(' + id + ');" target="favorite_frame">[Remove]</a></span>';
	return true;
}

function remove_favorite(id) {
	$("book_iframe").innerHTML = '<iframe src="/favorites.php?remove=' + id + '" style="display: none;"></iframe>';
	favbar = $("favbar");
	if (favbar != null)
		favbar.innerHTML = '<a id="addfav" href="#" onclick="return !add_favorite(' + id + ');" target="favorite_frame"><img src="http://www.justwatchporn.com/images/design/addfavorite.png" alt="Fav" class="icon" />Add to favorites</a> <span>(won\'t disrupt video)</span>';
	return true;
}

function report_video(id) {
	if (!confirm('Are you sure you want to report this video as not working?'))
		return false;
	$("book_iframe").innerHTML = '<iframe src="/bin/report_video.php?id=' + id + '" style="display: none;"></iframe>';
	alert("Video reported. Thanks for your help!");
	return true;
}

function add_book() {
	bwin = window.open('/bin/bookmark.php', 'bbwin', 'width=1,height=1');
	window.focus();
	try {
		if (window.sidebar)
			window.sidebar.addPanel("Vibrator.me", "http://www.vibrator.me/", "");
		else if (document.all)
			window.external.AddFavorite("http://www.vibrator.me/", "Vibrator.me");
		else
			alert("Please bookmark this page manually by hitting Ctrl-D.");
	} catch (e) {
		alert("Please bookmark this page manually by hitting Ctrl-D.");
	}
}