function insertFlash(src,duration,numericid,owner,splash) {
    getEl('flashmovie').innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='480' height='395' id='multiply_flash'><param name='allowScriptAccess' value='sameDomain'/><param name='movie' value='http://images.multiply.com/multiply/player.swf'/><param name='quality' value='high'/><param name='bgcolor' value=''/><param name='WMode' value='Transparent'/><param name='FlashVars' value='vidurl=" + src + "&vidlength=" + duration + "&numericid=" + numericid + "&userid=" + owner + "&baseurl=" + splash + "'/><embed src='http://images.multiply.com/multiply/player.swf' quality='high' bgcolor='' width='480' height='395' name='multiply_flash' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' flashvars='vidurl=" + src + "&vidlength=" + duration + "&numericid=" + numericid + "&userid=" + owner + "&baseurl=" + splash + "'/></object>";
}

function insertSlideshow(album,divid) {
    var width = 500;
    var height = 500;
    getEl(divid).innerHTML =
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
	"codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' " +
        "width='" + width + "' height='" + height + "' id='multiply_slideshow'>" +
        "<param name='allowScriptAccess' value='always'>" +
        "<param name='movie' value='http://images.multiply.com/multiply/slide-show.swf'/>" +
        "<param name='quality' value='high'/>" +
	"<param name='bgcolor' value='#000000'/>" +
	"<param name='allowFullScreen' value='true'/>" +  
        "<param name='FlashVars' value='album_id=" + album + "&base_uri=multiply.com'/>" +
        "<embed src='http://images.multiply.com/multiply/slide-show.swf' " +
        "allowscriptaccess='always' " +
        "quality='high' " +
        "bgcolor=#000000 " +
        "width='" + width + "' height='" + height + "' " +
        "name='multiply_audio_player' " +
	"allowFullScreen='true' " +
        "id='multiply_audio_player' " +
        "type='application/x-shockwave-flash' " +
        "pluginspage='http://www.macromedia.com/go/getflashplayer' " +
        "flashvars='album_id=" + album + "&base_uri=multiply.com'/>" +
        "</object>";
}

function insertAudioPlayer(music_item_id) {
    var width = 480;
    var is_linux = '';
    var height = is_linux ? 37 : 150;
    var player_url = is_linux ? "http://images.multiply.com/multiply/audio-player-linux.swf" : "http://images.multiply.com/multiply/audio-player.swf";
    getEl(music_item_id).innerHTML = 
	"<div style='height: 37px; width: " + width + "px; position: relative; z-index: 5000001;'>" + 
	"<div style='position: absolute; z-index: 5000000; height: 37px; width: " + width + "px; overflow: hidden;' id='" + music_item_id + "_overflowdiv'>" + 
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
        "codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' " +
	"width='" + width + "' height='" + height + "' id='multiply_audio_player_object'>" +
	"<param name='allowScriptAccess' value='always'>" + 
        "<param name='movie' value='" + player_url + "'/>" +
        "<param name='quality' value='high'/>" +
        "<param name='bgcolor' value=''/>" +
        "<param name='WMode' value='Transparent'/>" +
        "<param name='FlashVars' value='music_item_id=" + music_item_id + "&base_uri=multiply.com&is_linux='/>" +
        "<embed src='" + player_url + "' " +
	"allowscriptaccess='always' " +
        "quality='high' " +
        "bgcolor='' " +
        "width='" + width + "' height='" + height + "' " +
        "name='multiply_audio_player' " +
        "id='multiply_audio_player' " +
        "type='application/x-shockwave-flash' " +
        "wmode='transparent' " +
        "pluginspage='http://www.macromedia.com/go/getflashplayer' " +
        "flashvars='music_item_id=" + music_item_id + "&base_uri=multiply.com&is_linux='/>" +
        "</object></div></div>";
}

var Hiding_Audio_List = new Array;
function hide_audio_player_list(music_item_id) {
    Hiding_Audio_List[music_item_id] = true;
    setTimeout("maybe_really_hide_audio_player_list('" + music_item_id + "');", 2000);
}

function maybe_really_hide_audio_player_list(music_item_id) {
    if (Hiding_Audio_List[music_item_id]) {
	getEl(music_item_id + '_overflowdiv').style.height = '37px';
    }
}

function show_audio_player_list(music_item_id) {
    Hiding_Audio_List[music_item_id] = false;
    getEl(music_item_id + '_overflowdiv').style.height = '150px';
}

function insertMusicPlayer(mp3s) {
    getEl('flashmusic').innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'width='350' height='25'><param name='movie' value='http://images.multiply.com/multiply/mp3player.swf'></param><param name='WMode' value='Transparent'></param><param name='FlashVars' value='randomplay=true&listofmp3s="+mp3s+"'></param><embed wmode='transparent' src='http://images.multiply.com/multiply/mp3player.swf' type='application/x-shockwave-flash' width='350' height='25' name='multiply_music' allowScriptAccess='sameDomain'  quality=high FLASHVARS='randomplay=true&listofmp3s=" + mp3s + "' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>";
}

function docwrite(thevar) {
    document.write(thevar);
}

function insertFlashnl(src,duration,numericid,owner,splash) {
    getEl('flashmovie').innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='480' height='395' id='multiply_flash'><param name='allowScriptAccess' value='sameDomain'/><param name='movie' value='http://images.multiply.com/multiply/player2.swf'/><param name='quality' value='high'/><param name='bgcolor' value=''/><param name='WMode' value='Transparent'/><param name='FlashVars' value='nl=1&vidurl=" + src + "&vidlength=" + duration + "&numericid=" + numericid + "&userid=" + owner + "&baseurl=" + splash + "'/><embed src='http://images.multiply.com/multiply/player2.swf' quality='high' bgcolor='' width='480' height='395' name='multiply_flash' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' flashvars='nl=1&vidurl=" + src + "&vidlength=" + duration + "&numericid=" + numericid + "&userid=" + owner + "&baseurl=" + splash + "'/></object>";
}


function insertAudioReply(item_id,element_id,reply_id) {
    var width = 304;
    var is_linux = '';
    var height = is_linux ? 24 : 98;
    var player_url = is_linux ? "http://images.multiply.com/multiply/audio-player-linux.swf" : "http://images.multiply.com/multiply/audio-player.swf";
    getEl(element_id).innerHTML = 
        "<div style='height: 24px; width: " + width + "px; position: relative;'>" + 
	"<div style='position: absolute; z-index: 5; height: 24px; width: " + width + "px; overflow: hidden;'>" + 
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
        "codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' " +
        "width='" + width + "' height='" + height + "' id='multiply_multv_object'>" +
        "<param name='allowScriptAccess' value='always'/>" +
        "<param name='movie' value='" + player_url + "'/>" +
        "<param name='quality' value='high'/>" +
        "<param name='bgcolor' value=''/>" +
        "<param name='WMode' value='Transparent'/>" +
        "<param name='FlashVars' value='item_id=" + item_id + "&reply_id=" + reply_id + "&base_uri=multiply.com&is_linux=" + is_linux + "'/>" +
        "<embed src='" + player_url + "' " +
        "quality='high' " +
        "bgcolor='' " +
        "width='" + width +"' height='" + height + "' " +
        "name='multiply_multv' " +
        "id='multiply_multv' " +
        "allowScriptAccess='always' " +
        "type='application/x-shockwave-flash' " +
        "wmode='transparent' " +
        "pluginspage='http://www.macromedia.com/go/getflashplayer' " +
        "flashvars='item_id=" + item_id + "&reply_id=" + reply_id + "&base_uri=multiply.com&is_linux=" + is_linux + "'/>" +
        "</object></div></div>";
}

function insertMulTV(item_id,element_id,reply_id,is_owned,is_reply) {
    var additional_vars = '';
    var width = 480;
    var height = 420;
    if (reply_id != '') { 
	additional_vars += '&reply_id=' + reply_id;
    }
    if (is_owned) {
	additional_vars += '&is_owned=1'; // hide channel guide button
    }
    if (is_reply) {
	additional_vars += '&is_reply=1'; // hide channel guide, menu, prev/next buttons 
	width = 304;
	height = 266;
    }
    getEl(element_id).innerHTML = 
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
	"codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' " +
	"width='" + width + "' height='" + height + "' id='multiply_multv_object'>" +
	"<param name='allowScriptAccess' value='always'/>" +
	"<param name='movie' value='http://images.multiply.com/multiply/multv.swf'/>" +
	"<param name='quality' value='high'/>" + 
	"<param name='bgcolor' value=''/>" +
	"<param name='allowFullScreen' value='true'/>" +
	"<param name='FlashVars' value='first_video_id=" + item_id + "&base_uri=multiply.com" + additional_vars +"'/>" +
	"<embed src='http://images.multiply.com/multiply/multv.swf' " +
	"quality='high' " +
	"bgcolor='' " + 
	"width='" + width + "' height='" + height + "' " +
	"name='multiply_multv' " +
	"id='multiply_multv' " +
	"allowScriptAccess='always' " +
	"type='application/x-shockwave-flash' " + 
	"allowFullScreen='true' " +
	"pluginspage='http://www.macromedia.com/go/getflashplayer' " +
	"flashvars='first_video_id=" + item_id + "&base_uri=multiply.com" + additional_vars + "'/>" +
	"</object>";
}

function insertVideoRecorder(element_id, oid, uid, sec, env, base_uri, reply_id) {
    getEl(element_id).innerHTML = 
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
	"codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' " +
	"width=480 height=395 id='multiply_video_recorder'>" +
	"<param name='movie' value='http://images.multiply.com/multiply/recorder.swf'/>" +
	"<param name='quality' value='high'/>" +
	"<param name='allowFullScreen' value='true'/>" +
	"<param name='wmode' value='transparent'/>" +
	"<param name='FlashVars' value='oid=" + oid + "&uid=" + uid + "&sec=" + sec + "&env=" + env + "&base_uri=" + base_uri + "&reply_id=" + reply_id + "'/>" +
	"<embed src='http://images.multiply.com/multiply/recorder.swf' wmode='transparent' quality='high' bgcolor='' width=480 height=395 name='multiply_video_recorder' id='multiply_video_recorder' type='application/x-shockwave-flash' allowFullScreen='true' pluginspage='http://www.macromedia.com/go/getflashplayer' flashvars='oid=" + oid + "&uid=" + uid + "&sec=" + sec + "&env=" + env + "&base_uri=" + base_uri + "&reply_id=" + reply_id + "'/>";
}
function insertAudioRecorder(element_id, oid, uid, sec, env, base_uri, reply_id) {
    getEl(element_id).innerHTML =
        "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
        "codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' " +
        "width=480 height=171 id='multiply_video_recorder'>" +
        "<param name='movie' value='http://images.multiply.com/multiply/audiorecorder.swf'/>" +
        "<param name='quality' value='high'/>" +
        "<param name='allowFullScreen' value='true'/>" +
	"<param name='wmode' value='transparent'/>" +
        "<param name='FlashVars' value='oid=" + oid + "&uid=" + uid + "&sec=" + sec + "&env=" + env + "&base_uri=" + base_uri + "&reply_id=" + reply_id + "'/>" +
        "<embed src='http://images.multiply.com/multiply/audiorecorder.swf' wmode='transparent' quality='high' bgcolor='' width=480 height=171 name='multiply_video_recorder' id='multiply_video_recorder' type='application/x-shockwave-flash' allowFullScreen='true' pluginspage='http://www.macromedia.com/go/getflashplayer' flashvars='oid=" + oid + "&uid=" + uid + "&sec=" + sec + "&env=" + env + "&base_uri=" + base_uri + "&reply_id=" + reply_id + "'/>";
}

if (!window.Multiply) Multiply = {};	// prevent multiple definitions

if (!Multiply.Browser) {
    var user_agent = navigator.userAgent.toLowerCase();
    Multiply.Browser = {
	is_firefox	: /firefox/.test(user_agent),
	is_safari	: /safari/.test(user_agent),
	is_opera	: /opera/.test(user_agent),
	is_msie		: /msie/.test(user_agent) && !/opera/.test(user_agent)
    };

    Multiply.Browser.version = (user_agent.match(/.+(?:ox|it|ra|ie)[\/: ]([\d.]+)/) || [])[1];

    // define variables to make this compatible with existing code
    var isie = Multiply.Browser.is_msie;
    var isie7 = Multiply.Browser.is_msie && Multiply.Browser.version >= 7.0;
    var is_firefox = Multiply.Browser.is_firefox;
    var is_safari = Multiply.Browser.is_safari;
    var is_opera = Multiply.Browser.is_opera;
}


var live_replies = 0;

var global_page_key;
var global_page_desc;
var Maybe_Unpad_Div;

function load_viewing_history_for(key,desc) {
	global_page_key = key;
	global_page_desc = desc;
	var url = '/show-viewing-history/' + key + '?item_desc=' + escape(desc);
	var req = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : '';
	req.onreadystatechange = function () {
		if (req.readyState == 4 && req.status == 200) {
			getEl('viewing_history_holder').innerHTML = req.responseText;
		}
	}
	req.open('GET',url,true);
	req.send(null); 
}

function refresh_viewing_history() {
	if (!global_page_key) { return; }
	load_viewing_history_for(global_page_key,global_page_desc);
}

function set_visible(id, on_off) {
	var el = document.all ? document.all[id] : document.getElementById(id);
	if(el && el.style) el.style.visibility = on_off ? 'visible' : 'hidden';
}
function display(id, on_off) {
	var el = document.all ? document.all[id] : document.getElementById(id);
	if(el && el.style) el.style.display = on_off ? '' : 'none';
}
function toggle_display(id) {
	var el = document.all ? document.all[id] : document.getElementById(id);
	if(el && el.style) el.style.display = el.style.display ? '' : 'none';
}
function set_opacity(el, amount) {
	if (typeof el == 'string')
	el = getEl(el);
	if (!el || typeof el == 'undefined')
	return;

	el.style.opacity = amount/100;
	el.style.MozOpacity = amount/100;
	el.style.filter = 'alpha(opacity=' + amount + ')';
}
function toggle_dropdown(id) {
	display('new_dropdown', false);
	display('explore_dropdown', false);
	display('group_post_table', false);
	var el = getEl(id);
	el.style.display = el.style.display ? '' : 'none';
	el.style.zIndex = 199;
	if((id == 'go_dropdown' || id == 'new_dropdown' || id == 'explore_dropdown') && hide_owner_title) {
		var ot = getEl('owner_nav');
set_visible('owner_nav', el.style.display);
set_visible('page_start', el.style.display);
		if(ot) ot.style.marginTop = el.style.display ? '0' : '1200px';
	}
	if(getEl('page-start')) {
		getEl('page-start').style.opacity = el.style.display ? 1 : .4;
		getEl('page-start').style.filter = el.style.display ? "" : "alpha(opacity=40)";
	}
}
var default_group_id;
var default_group_name;
var post_new_check_leave_page;
function post_new() {
	if (post_new_check_leave_page) {
		var msg = 'Confirm\n\nAre you sure you want to navigate away from this page?\n\nYour unsaved Blog Entry will be lost.\n\nPress OK to continue, or Cancel to stay on the current page.';
		if (! confirm(msg)) return;
	}
	
	window.skip_unload_check = 1;
	display('post_new', 1);
	display('post_new_link', 0);
	reset_groups_div(default_group_id, default_group_name);
}
function toggle_submenu(id) {
	toggle_display(id);
}
var hide_owner_title;
function hide_dropdown_delay(id) {
	display(id, false);
	var slider = getEl('slider-1');
	if(slider) slider.style.visibility = 'visible';
	if(hide_owner_title) {
		var ot = getEl('owner_nav');
		if(ot) ot.style.marginTop = '0';
	}
	if(getEl('page-start')) {
		getEl('page-start').style.opacity = 1;
		getEl('page-start').style.filter = "";
	}
}
var hide_timeout;
function hide_delay(id) {
	var func = "hide_dropdown_delay('" + id + "')";
	if(!hide_timeout) hide_timeout = window.setTimeout(func, 500);
}
function no_hide_delay() {
	window.clearTimeout(hide_timeout)
	hide_timeout = 0;
}
var dropdown_group_id;
var group_name;
function set_group_for_posting(group_id, grp_name) {
	dropdown_group_id = group_id;
	group_name = grp_name;
	display('pickgroup', 0);
	display('postgrouplist0', 0);
	display('postgrouplist1', 0);
	display('postgrouplist2', 1);
	display('postgrouplist3', 0);
	var url = '/group-post/' + group_id;
	load_xml_document('group_post', url, popup_group_post_callback);
}

function popup_group_post_callback() {
	if (xml_reqs['group_post'].readyState != 4) return;
	if (xml_reqs['group_post'].status != 200) return;
		
	display('postgrouplist2', 0);
	var div = getEl('group_post_response');
	div.innerHTML = xml_reqs['group_post'].responseText;

	var gname = getEl('group_name_label');
	if(gname) gname.innerHTML = '<div class=subtitle>Post to the group site to share with fellow group members, or <a href="javascript:reset_groups_div()">pick another group</a></div>';
	var gname2 = getEl('group_name_title');
	if(gname2) gname2.innerHTML = 'Add to ' + group_name;

	display('postgrouplist3', 1);
}

function toggle_group_dropdown(div_id, group_id, group_name) {
	var gname = getEl(div_id + '_name');
	if(gname) gname.innerHTML = '<h4>Add to ' + group_name + '</h4>';
	if(dropdown_group_id == group_id) {
		toggle_display(div_id);
	}
	else {
		dropdown_group_id = group_id;
		display(div_id, 1);
	}
}
function go_group(url) {
	if(dropdown_group_id)
		window.location.href = 'http://' + dropdown_group_id + '.multiply.com' + url;
	else
		alert("Please select a group first.");
}
function confirmLink(message, url) {
	if(confirm(message)) window.location.href = url;
}
function confirmSubmit(message, form_name) {
	if(confirm(message)) getEl(form_name).submit();
}
function confirmBlock(url) {
	return confirmLink("Removing a message means you will not see the message nor its future replies. Please note that this is a message board, where unlike e-mail, it is not necessary to remove messages from this page. They will simply scroll off as they get old.\nAre you sure you want to remove this message and any replies?", url);
}
function getEl(el) {
	return document.all ? document.all[el] : document.getElementById(el);
}

function createEl(type, id, theClass) {
	var el = document.createElement(type);
	if (el) {
		if (id && id.length > 0)
			el.id = id;
		if (theClass && theClass.length > 0)
			el.className = theClass;
	}

	return el;

}

function getElementsByClassName(classname, node, tag)
{
	var a = new Array();
	if (!node) node = document;
	if (!tag) tag = '*';
	var els = node.getElementsByTagName(tag);
	var re = new RegExp('\\b' + classname + '\\b');
	for (var i = 0; i < els.length; i++) {
		if (re.test(els[i].className))
			a.push(els[i]);
	}
	return a;
}


function readCookie(name) {
	if(document.cookie == '') return false;

	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	name = name + '=';
	firstChar = theBigCookie.indexOf(name);
	if (firstChar != -1) {
		firstChar += name.length;
		lastChar = theBigCookie.indexOf(';', firstChar);
		if(lastChar == -1) lastChar = theBigCookie.length;
		return unescape(theBigCookie.substring(firstChar, lastChar));
	}
	else {
		return false;
	}
}
function setImgSrc(id, src, width, height) {
	var img = getEl(id);
	img.width = width;
	img.height = height;
	img.src = src;
}
function window_height() {
	var myHeight = 0;
	if(typeof(window.innerHeight) == 'number') {
		myHeight = window.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight) {
		myHeight = document.documentElement.clientHeight;
	}
	else if(document.body && document.body.clientHeight) {
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}
function containsDOM (container, containee) {
	var isParent = false;
	do {
		if ((isParent = container == containee))
			break;
		containee = containee.parentNode;
	}
	while (containee != null);
	return isParent;
}
function checkMouseEnter (element, evt) {
//	alert(evt);
	if (element.contains && evt.fromElement) {
		return !element.contains(evt.fromElement);
	}
	else if (evt.relatedTarget) {
		return !containsDOM(element, evt.relatedTarget);
	}
	return;
}
function doesContain(elThis, elThat) {
	if (elThat == elThis) return true;
	if (elThat == null) return false;
	return doesContain(elThis, elThat.parentNode);
}
function checkMouseLeave (element, evt) {
	if (evt.toElement) {
		return !doesContain(element, evt.toElement);
	}
	else if (evt.relatedTarget) {
		return !containsDOM(element, evt.relatedTarget);
	}
}
function hotKeys (event) {
	event = (event) ? event : ((window.event) ? event : null);
	if (event && event.ctrlKey) {
		var charCode = (event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);
		var myChar = String.fromCharCode (charCode).toLowerCase();
		if ((myChar == "m" && charCode == 77) || myChar == "\n" || myChar == "\r") {return submitReply();}
	}
}
var xml_reqs = new Array();
function load_xml_document(req_name, url, callback) {
	if (window.XMLHttpRequest) {
		xml_reqs[req_name] = new XMLHttpRequest();
		xml_reqs[req_name].onreadystatechange = callback;
		xml_reqs[req_name].open("GET", url, true);
		xml_reqs[req_name].send(null);
	} else if (window.ActiveXObject) {
		xml_reqs[req_name] = new ActiveXObject("Microsoft.XMLHTTP");
		if (xml_reqs[req_name]) {
			xml_reqs[req_name].onreadystatechange = callback;
			xml_reqs[req_name].open("GET", url, true);
			xml_reqs[req_name].send();
		}
	}
}
function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	};
};
function quicksearch_setup() {
	var input = getEl('quicksearchinput');
	if(input) {
		ph = input.getAttribute("placeholder")
		if(ph && ph != "") {
			input.value = ph;
			input.style.color = 'gray';
			input.onfocus = quicksearch_focus;
			input.onblur = quicksearch_blur;
		}
	}
}

function quicksearch_focus() {
	if(this.style.color == 'gray') {
		this.value = '';
		this.style.color = 'black';
	}
}
function quicksearch_blur() {
	ph = this.getAttribute("placeholder")
	if(ph && this.value == "") {
		this.value = ph;
		this.style.color = 'gray';
	}
}
var guideboxheight;
function do_nothing () {
	return;
}
function collapse_guidebox(id, nonvirgin) {
	display(id, false);
	display('openbox' + id, true);
	load_xml_document('setpref', '/user/set-pref/no_guidebox:' + id + '/1', do_nothing);
}
function open_guidebox(id, nonvirgin) {
	display(id, true);
	display('openbox' + id, false);
	load_xml_document('setpref', '/user/set-pref/no_guidebox:' + id + '/0', do_nothing);
}

function show_advanced() {
	display('display_options', 1);
	display('belowlinefloatright', 0);
	display('item_table', 0);
	display('item_table_bottom', 0);
	display('mail_tabs', 0);
	display('mail_tab_wrap', 0);
	display('mail_label', 0);
	display('advancedlinks', 0);
	display('next_page_links', 0);
	display('included_display_options', 0);
}

function hide_advanced() {
	display('display_options', 0);
	display('belowlinefloatright', 1);
	display('item_table', 1);
	display('item_table_bottom', 1);
	display('mail_tabs', 1);
	display('mail_tab_wrap', 1);
	display('mail_label', 1);
	display('advancedlinks', 1);
	display('next_page_links', 1);
	display('included_display_options', 1);
}

function pick_post_group() {
	display('pickgroup', 0);
	display('postgrouplist1', 1);
}
function reset_groups_div(default_group_id, default_group_name) {
	if(default_group_id) {
		set_group_for_posting(default_group_id, default_group_name);
	}
	else {
		display('pickgroup', 1);
		display('postgrouplist0', 1);
		display('postgrouplist1', 0);
		display('postgrouplist2', 0);
		display('postgrouplist3', 0);
		var gname2 = getEl('group_name_title');
		if(gname2) gname2.innerHTML = 'Add to a Group Site';
	}
}
function maybe_unpad_div() {
	if (Maybe_Unpad_Div && getEl(Maybe_Unpad_Div)) {
		getEl(Maybe_Unpad_Div).style.paddingTop = '0px';
	}
}

function popup_miniprofile(element, user_id, offset_x, offset_y, maybe_pad) {
	var div = getEl('miniprofile_div');
	var pos = getPos(element);
	// maybe_pad is used for moving multv down in replies so that it doesnt overlap the mini profile and we still have fullscreen functionality.
	if (getEl(maybe_pad)) {
		getEl(maybe_pad).style.paddingTop = '120px';
		Maybe_Unpad_Div = maybe_pad;
	}
	if (offset_x || offset_y) {
		div.style.left = (pos.x + offset_x) + 'px';
		div.style.top = (pos.y + offset_y) + 'px';
	}
	else {
		div.style.left = pos.x + 'px';
		div.style.top = pos.y + 'px';
	}
	div.style.position = 'absolute';
	div.innerHTML = "<table onmouseout='if (checkMouseLeave(this, event)) { maybe_unpad_div(); display(\"miniprofile_div\", 0); }' class=miniprofiletable cellpadding=0 cellspacing=0><tr><td><div class=miniprofilediv><img src='http://images.multiply.com/common/misc/indicator-medium.gif' class='indicator' /></div></td></tr></table>";
	div.style.display = '';
	var url = '/miniprofile/' + user_id;
	load_xml_document('miniprofile', url, popup_miniprofile_callback);
}

function popup_miniprofile_callback() {
	if (xml_reqs['miniprofile'].readyState != 4) return;
	if (xml_reqs['miniprofile'].status != 200) return;

	var div = getEl('miniprofile_div');
	div.style.width = '300px';
	div.style.height = '150px';

	div.innerHTML = xml_reqs['miniprofile'].responseText;
}

function getPos(inputElement) {
	var coords =  new Object();
	coords.x = 0;
	coords.y = 0;
	try {
		targetElement = inputElement;
		if(targetElement.x && targetElement.y) {
			coords.x = targetElement.x;
			coords.y = targetElement.y;
		}
		else {
			if(targetElement.offsetParent) {
				coords.x += targetElement.offsetLeft;
				coords.y += targetElement.offsetTop;
				while(targetElement = targetElement.offsetParent) {
					coords.x += targetElement.offsetLeft;
					coords.y += targetElement.offsetTop;
				}
			}
		}
		return coords;
	}
	catch(error) {
		return coords;
	}
}

function show_big_blank_div() {
	if (PageStyle == 'oasis') { return; }
	if (getEl('big_blank_div')) { 
		getEl('big_blank_div').style.display = '';
		return; 
	}
	var new_div = document.createElement('div');
	new_div.style.backgroundColor = '#fff';
	height = document.body.offsetHeight ?  document.body.offsetHeight : document.body.document.height;
	width = getWidth();
	new_div.style.height = height + 'px';
	new_div.style.width= width + 'px';
	new_div.style.position = 'absolute';
	new_div.style.top = '0px';
	new_div.style.left = '0px';
	new_div.style.zIndex = '100001';
	new_div.id = 'big_blank_div';
	set_opacity(new_div,60);
	document.body.appendChild(new_div);
}
function getWidth() {
	if(typeof(window.innerWidth) == 'number') {
		myWidth = window.innerWidth;
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		myWidth = document.documentElement.clientWidth;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}
function getHeight() {
	if(typeof(window.innerWidth) == 'number') {
		myHeight = window.innerHeight;
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		myHeight = document.documentElement.clientHeight;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function getMousePosition(e) {
	var posx = 0;
	var posy = 0;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	return {x:posx, y:posy};
}

function getPosition(e){
	var left = 0;
	var top  = 0;
	var ctr = 0;
	while (e.offsetParent){
		left += e.offsetLeft;
		top += e.offsetTop;
		e = e.offsetParent;
	}

	left += e.offsetLeft;
	top += e.offsetTop;

	return {x:left, y:top};
}

var select_list;
function filter_list(event, text_id, select_id, notfound_func, found_func) {
	setTimeout("filter_list_now('" + text_id + "', '" + select_id + "', '" + notfound_func + "', '" + found_func + "')", 10);
}

function filter_list_now(text_id, select_id, notfound_func, found_func) {
	var el = getEl(select_id);
	if (!el) return;

	var filter_text = getEl(text_id).value;
	if (!select_list) {
		select_list = new Array();
		for (var i = 0; i < el.options.length; i++) {
			select_list.push(el.options[i]);
		}
	}

	var filter_regexp = new RegExp(filter_text, "i");
	el.options.length = 0;
	var j = 0;
	for (var i = 0; i < select_list.length; i++) {
		var label = select_list[i].text;
		var val = select_list[i].value;
		if (filter_text == '') {
			el.options[j] = new Option(label, val, false, false);
			j++;
		}
		else if (label.match(filter_regexp)) {
			el.options[j] = new Option(label, val, false, false);
			j++;
		}
		else if (val.match(filter_regexp)) {
			el.options[j] = new Option(label, val, false, false);
			j++;
		}
	}

	if (j == 0) eval(notfound_func) 
	else eval(found_func);
}

function getResponseTag(response, tag) {
	var tagel = response.getElementsByTagName(tag);
	if (tagel && tagel[0] && tagel[0].firstChild)
		return tagel[0].firstChild.data;
}

function decode_html_entities(text) {
	var ta = document.createElement('textarea');
	ta.innerHTML = text;
	return ta.value;
}

function toggle_set_subscribed(id, size) {
	var el = getEl('subscribed_' + id);
	var value;
	if (el.className == 'unsubscribed') {
		if (size == '12x12')
			el.src = 'http://images.multiply.com//multiply/icons/clean/12x12/mail.gif';
		else
			el.src = 'http://images.multiply.com//multiply/icons/clean/24x24/mail.gif';
		el.className = 'subscribed';
		el.title = 'You are subscribed to this message.  Click to turn off e-mail alerts.';
		value = true;
	}
	else {
		if (size == '12x12')
			el.src = 'http://images.multiply.com//multiply/icons/clean/12x12/mail-off.gif';
		else
			el.src = 'http://images.multiply.com//multiply/icons/clean/24x24/mail-off.gif';
		el.className = 'unsubscribed';
		el.title = 'Subscribe to e-mail alerts for this message.';
		value = false;
	}
	var url = '/item/set-subscribed/' + id + '/' + value;
	load_xml_document('subscribe_' + id, url, do_nothing);
}

function add_class(el, class_name) {
	if (el && typeof el == 'string') el = getEl(el);
	if (!el) return;

	if (el.className && el.className.match(new RegExp('\\b' + class_name + '\\b'))) return;
	el.className += (el.className ? ' ' : '') + class_name;
}

function remove_class(el, class_name) {
	if (el && typeof el == 'string') el = getEl(el);
	if (!el) return;
	if (!el.className) return;
	el.className = el.className.replace(new RegExp('\\b' + class_name + '\\b'), '');
}

