
var closeMenuTimer;
var menuHoverTimer;
var main_menu_open;
var test;
$(document).ready(function(){
	sdinit();
	
	$("#searchbar_menu_link").click(function () { 
		$("#searchbar_menu").slideToggle("normal");
	});

	$(".settings_button").click(function () { 
		$(".settings_box").slideToggle("fast");
	});
	
	$(".settings_close").click(function () {
		$(".settings_box").slideUp("fast"); 
		return false;
	});

	$("#search_box").focus( function() {
		if  (this.value =='Keywords') {this.value='';}
	});
	
	$("#search_box").blur( function() {
		if  (this.value =='') {this.value='Keywords';}
		$("#searchbar_menu").slideUp("normal");
	});

	$("#global_search_form").submit(function() {
		try
		{
			pageTracker._trackEvent('globalsearch', 'search', $("#search_box").val());
		}
		catch(err)
		{
			return true;
		}
	});

	if ($("#sharethislinkthread").length == 1)
	{
		$("#sharethislinkthread").click(function () {
			toggle_firstpost_tab("#sharethistab");
			return false;
		});
	}

	$("#showfeedback").click(function () {
		toggle_firstpost_tab("#publicfeedback");
		var sdfirstptab = fetch_cookie("sdfirstptab");
		sdfirstptab = (sdfirstptab == 0) ? 1 : 0;
		createCookie("sdfirstptab",sdfirstptab,365);
		return false;
	});

	$(".voteselected").click(function() {
		$("#vote_feedback").fadeOut();
		return false;
	});

	$(".showwikipost").click(function () {
		$("#wikipost").slideToggle("normal");
		return false;
	});

	$("#editwiki").click(function () {
		$("#wikipost:hidden").show();
		return false;
	});

	$(".blackarrow img").attr("src","http://i.slickdeals.net/images/slickdeals/arrow_down.gif")


	$(".notice_tan_close").click(function () {
		notice_close("tan");
		return false;
	});

	$(".notice_blue_close").click(function () {
		notice_close("blue");
		return false;
	});
});

function notice_close(notice)
{
	$(".notice_" + notice).slideUp();
	var d = new Date();
	var t = parseInt(d.getTime() / 1000);
	createCookie("sdnotice" + notice, t, 365);
}

function sdinit() 
{
  setUserOptions(); 
  menu_bind();
//  if (!($.browser.msie || $.browser.safari))
//  {
//    $(".tdHover").mouseover(tdHover).mouseout(tdHoverOut).click(tdHoverClick);
//    $(".tdPostDate").mouseover(tdThreadHover).mouseout(tdThreadHoverOut).click(tdPostDateClick);
//    $(".tdThread").mouseover(tdThreadHover).mouseout(tdThreadHoverOut);
//  }
  
}

function displayExtra(layer_name, expand_name) 
{
  layerObject = getObject(layer_name);
  expandObject = getObject(expand_name);

  if (layerObject.style.display == "none") 
  {
    layerObject.style.display = "";
    expandObject.innerHTML = "";
  }
  else
  {
    layerObject.style.display = "none";
    expandObject.innerHTML = "<span class=small><a href=\"javascript:displayExtra('"+layer_name+"','"+expand_name+"')\">Expand</a> <img src=images/expand.jpg width=7 height=7></span>";
  }
}

function toggledeal(id, state) 
{ 
  var headerid = id.replace("deal_","deal_header_");

  switch(state)
  { 
    case 'ca':
      $("#" + id).slideUp("fast");
      $("#" + headerid).removeClass("deal_header_expand");
      break;
    case 'c':
      $("#" + id).hide();
      $("#" + headerid).removeClass("deal_header_expand");
      break;
    case 'ea':
      $("#" + id).slideDown("fast");
      $("#" + headerid).addClass("deal_header_expand");
      break;
    case 'e':
      $("#" + id).show();
      $("#" + headerid).addClass("deal_header_expand");
      break;
    default:
      $("#" + id).slideToggle("fast");
      $("#" + headerid).toggleClass("deal_header_expand");
      break;
  }
} 

function toggle(obj) 
{
	if ( obj.style.display != 'none' ) 
	{
		obj.style.display = 'none';
	}
	else {
		obj.style.display = '';
	}
}

function toggleimg(img)
{
  img_re = new RegExp("_collapsed\\.gif$");
  if (img.src.match(img_re))
  {
    img.src = img.src.replace(img_re, '.gif');
  }
  else
  {
    img_re = new RegExp("\\.gif$");
    img.src = img.src.replace(img_re, '_collapsed.gif');
  }
}

function togglewelcome(id) 
{
  $("#"+id).slideUp();
  createCookie(id,1,365);
}

function toggledeal_array() 
{ 
  var img = $("#"+arguments[0]);
  var deals = $("nonexistant");
  var dealheaders = $("nonexistant");
  var len = arguments.length;
  for (i=1;i<len;i++)
  {
    deals = deals.add("#" + arguments[i]); 
    dealheaders = dealheaders.add("#" + arguments[i].replace("deal_","deal_header_")); 
  }

  if (img.attr("src").match("plus.gif")) 
  {	//hide all
    img.attr("src", "/images/slickdeals/minus.gif");
    deals.filter(":first").slideDown("fast", function() {
      deals.filter(":not(:first)").show();
      dealheaders.addClass("deal_header_expand");
    });
  }
  else 
  { 
    img.attr("src", "/images/slickdeals/plus.gif");
    deals.filter(":not(:first)").hide();
    dealheaders.removeClass("deal_header_expand");
    deals.filter(":first").slideUp("fast");
  }
} 

function toggle_hottopic(id) 
{ 
  if(navigator.appName.indexOf("Microsoft") > -1)
    var canSee = 'block'
  else 
    var canSee = 'table-row';
  obj = sdfetch_object(id);
  if (obj.style.display==canSee) 
  { 
    obj.style.display="none"; 
    var newobj = sdfetch_object(id + "_heading");
    if (newobj.className=="alt4a") 
      newobj.className="alt6"; 
    else 
      newobj.className="alt5"; 
  } 
  else 
  { 
    obj.style.display=canSee; 
    var newobj = sdfetch_object(id + "_heading");
    if (newobj.className=="alt5") 
      newobj.className="alt4"; 
    else 
      newobj.className="alt4a"; 
  } 
} 

function toggleexpandall() 
{
  expandall = (readCookie('expandall') == 1) ? 0 : 1;
  createCookie('expandall',expandall,365);

  state = expandall ? 'e' : 'c';

  if (state == 'e')
  {
    $(".deal_body:first").slideDown("fast", function(){
      $(".deal_body:gt(0)").show();
      $(".deal_header").addClass("deal_header_expand");
      $("#toggleall").text("Collapse All Deals")
      $(".deal_header_date img").attr("src", "/images/slickdeals/minus.gif");
    });
  }
  else
  {
    $(".deal_body:gt(0)").hide();
    $(".deal_header").removeClass("deal_header_expand");
    $(".deal_body:first").slideUp("fast");
    $("#toggleall").text("Expand All Deals")
    $(".deal_header_date img").attr("src", "/images/slickdeals/plus.gif");
  }
}

function getElementsByClass(searchClass,node,tag) 
{
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


function addEvent( obj, type, fn )
{
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

function sdfetch_object(idname)
{
        if (document.getElementById)
        {
                return document.getElementById(idname);
        }
        else if (document.all)
        {
                return document.all[idname];
        }
        else if (document.layers)
        {
                return document.layers[idname];
        }
        else
        {
                return null;
        }
}

function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

function showDiv(e,id)
{
//  if (!e) var e = window.event;
  getdiv = sdfetch_object(id);
  getdiv.style.display = "";
  x = (e.pageX)
    ? e.pageX
    : (e.clientX)
      ? e.clientX
      : 0;
  y = (e.pageY)
    ? e.pageY
    : (e.clientY)
      ? e.clientY
      : 0;
  getdiv.style.left = x + 5 + "px";
  getdiv.style.top = y + 5 + "px";
}

function closeDiv(e,id)
{
  if (!e) var e = window.event;
  getdiv = sdfetch_object(id);
  getdiv.style.display = "none";
}

jQuery.fn.extend({

        sdshowRow: function ()
        {
                var animparam = new Object();
                animparam['opacity'] = 'show';
                if (!jQuery.browser.msie) animparam['height'] = 'show';
                this.find("td").not(".sdrowwrap").children().wrap("<div></div>").end().addClass("sdrowwrap");
                return this.show().find("div").not(".nosdanim").animate(animparam,"fast");
        },

        sdhideRow: function ()
        {
                var animparam = new Object();
                animparam['opacity'] = 'hide';
                if (!jQuery.browser.msie) animparam['height'] = 'hide';
                var jqObject = this;
                this.find("td").not(".sdrowwrap").children().wrap("<div></div>").end().addClass("sdrowwrap");
                this.find("div").not(".nosdanim").slice(0).animate(animparam,"fast");
                this.find("div").not(".nosdanim").slice(0,1).animate(animparam,"fast", function()
                {
                        return jqObject.hide();
                });
                return jqObject;

        },

        sdtoggleRow: function ()
        {
                if (this.css("display") == "none")
                        return this.sdshowRow();
                else
                        return this.sdhideRow();
        }
});
function cumulativeOffset(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop	|| 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
}

function startCloseMenuTimer() {
    clearTimeout(menuHoverTimer);
    stopCloseMenuTimer();
    closeMenuTimer=setTimeout('menu_closesub();', 100);
}
function stopCloseMenuTimer() {
  clearTimeout(closeMenuTimer);
}

function menu_showsub(ele)
{
        $("#main_menu_02 table").show().find("li").slideDown("fast");
        $("#main_menu_03 table").show().find("li").slideDown("fast");
        $("#main_menu_05 table").show().find("li").slideDown("fast");
        main_menu_open=true;
}

function menuHover(e) { 
  var elTarget = $(e.target); 
  var menuWait = 450;
  stopCloseMenuTimer();
  clearTimeout(menuHoverTimer);
  while (!elTarget.is("#menu2")) 
  { 
    if (elTarget.is("#main_menu_05, #main_menu_03, #main_menu_02"))
    {
      if(main_menu_open==false)
      {
        clearTimeout(menuHoverTimer);
        menuHoverTimer = setTimeout(function() {menu_showsub(elTarget);},menuWait);
      }
      break;
    }
    else if(elTarget.is("#main_menu_01, #main_menu_04"))
    {
      clearTimeout(menuHoverTimer);
      break;
    }
    else
    {
      elTarget = elTarget.parent();
    }
  } 
} 

function menu_bind(instant)
{
	menu_closesub();
	$("#menu2").mouseover(menuHover).mouseout(startCloseMenuTimer);
}

function menu_closesub() {
	main_menu_open = false;
        $("#main_menu_02 table").hide().find("li").hide();
        $("#main_menu_03 table").hide().find("li").hide();
        $("#main_menu_05 table").hide().find("li").hide();
}

function toggleSearchFilter()
{
	var filtCol = $("#search_left");
	var $sideimg = $("#search_showhidefilter img");
	if (filtCol.filter(":visible").length > 0)
	{
		filtCol.hide().parent().attr("width","0px").siblings().attr("width","100%");
		createCookie("hidefiltercol", 1, 365);
		var $newsrc = $sideimg.attr("src").replace("hide","show");
	}
	else
	{
		createCookie("hidefiltercol", 0, 365);
		filtCol.show().parent().attr("width","150px").siblings().removeAttr("width");
		var $newsrc = $sideimg.attr("src").replace("show","hide");
	}
	$sideimg.attr("src", $newsrc);
}

function cellHover(ele)
{
	ele = $(ele)
	if (ele.hasClass("alt1"))
		ele.removeClass("alt1").addClass("alt1Active");
	else if (ele.hasClass("alt2"))
		ele.removeClass("alt2").addClass("alt2Active");
	if (ele.hasClass("tdClick"))
		ele.addClass("cursor");
}

function cellHoverOut(ele)
{
	ele = $(ele)
        if (ele.hasClass("alt1Active"))
                ele.removeClass("alt1Active").addClass("alt1");
        else if (ele.hasClass("alt2Active"))
                ele.removeClass("alt2Active").addClass("alt2");
	if (ele.hasClass("tdClick"))
		ele.removeClass("cursor");
}

function cellHoverClick(ele,linksel)
{
	var ele = $(ele);
	var loc = "";
        var tdTarget = ele.find("a.tdTarget");
        if (tdTarget.length > 0)
                ele = tdTarget;
	if (ele.is("a"))
		loc = ele.attr("href");
	else
		loc = ele.find("a:" + linksel).attr("href");
	window.location.href=loc;
}

function tdHover()
{
	cellHover(this);
}

function tdHoverOut()
{
	cellHoverOut(this);
}

function tdHoverClick(ev)
{
	if (!(ev.shiftKey || ev.ctrlKey))
		cellHoverClick(this,"last");
}

function tdThreadHover()
{
	cellHover(this);
	cellHover($(this).siblings(".tdPostDate"));
	cellHover($(this).siblings(".tdThread"));
}
function tdThreadHoverOut()
{
	cellHoverOut(this);
	cellHoverOut($(this).siblings(".tdPostDate"));
	cellHoverOut($(this).siblings(".tdThread"));
}
function tdPostDateClick(ev)
{
	if (!(ev.shiftKey || ev.ctrlKey))
	{
		var threadlink = $(this).attr("id");
		threadlink=threadlink.replace("td_postdate_","thread_title_");
		cellHoverClick($("#"+threadlink));
	}
}

function akst_share(id, url, title) {
	var form = sdfetch_object("akst_form");
	var post_id = sdfetch_object("akst_post_id");
	var post_message = sdfetch_object("akst_email_message");
	var post_subject = sdfetch_object("akst_email_subject");
	var post_action = sdfetch_object("akst_form_action");
	var post_link = sdfetch_object("akst_post_permalink");
	var permalink = sdfetch_object("akst_permalink_link");
	
	var post_hidden_url = sdfetch_object("akst_post_hidden_url");
	var post_hidden_t = sdfetch_object("akst_post_hidden_t");
	
	var messagelink = sdfetch_object("atsk_sendmessage_link");
	
	if (form.style.display == 'block' && post_id.value == id) {
		form.style.display = 'none';
		return;
	}
	
	var link = sdfetch_object("akst_link_" + id);
	var offset = cumulativeOffset(link);

	sdfetch_object("akst_delicious").href = akst_share_url("http://del.icio.us/post?url={url}&title={title}", url, title);
	sdfetch_object("akst_digg").href = akst_share_url("http://digg.com/submit?phase=2&url={url}&title={title}", url, title);
	sdfetch_object("akst_furl").href = akst_share_url("http://furl.net/storeIt.jsp?u={url}&t={title}", url, title);
	sdfetch_object("akst_netscape").href = akst_share_url(" http://www.netscape.com/submit/?U={url}&T={title}", url, title);
	sdfetch_object("akst_yahoo_myweb").href = akst_share_url("http://myweb2.search.yahoo.com/myresults/bookmarklet?u={url}&t={title}", url, title);
	sdfetch_object("akst_stumbleupon").href = akst_share_url("http://www.stumbleupon.com/submit?url={url}&title={title}", url, title);
	sdfetch_object("akst_google_bmarks").href = akst_share_url("  http://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}", url, title);
	sdfetch_object("akst_technorati").href = akst_share_url("http://www.technorati.com/faves?add={url}", url, title);
	sdfetch_object("akst_blinklist").href = akst_share_url("http://blinklist.com/index.php?Action=Blink/addblink.php&Url={url}&Title={title}", url, title);
	sdfetch_object("akst_newsvine").href = akst_share_url("http://www.newsvine.com/_wine/save?u={url}&h={title}", url, title);

	sdfetch_object("akst_reddit").href = akst_share_url("http://reddit.com/submit?url={url}&title={title}", url, title);
	sdfetch_object("akst_windows_live").href = akst_share_url("https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={url}&title={title}&top=1", url, title);
	sdfetch_object("akst_tailrank").href = akst_share_url("http://tailrank.com/share/?link_href={url}&title={title}", url, title);

	sdfetch_object("akst_facebook").href = akst_share_url("http://www.facebook.com/share.php?&={url}", url, title);
	sdfetch_object("akst_aim").href = akst_share_url("aim:goim?message={title}{url}", url, title);
	sdfetch_object("akst_magnolia").href = akst_share_url("http://ma.gnolia.com/bookmarklet/add?url={url}&title={title}", url, title);

	messagelink.href = "http://slickdeals.net/forums/sendmessage.php?do=sendtofriend&t=" + id;
	post_action.action = "http://slickdeals.net/forums/sendmessage.php?do=dosendtofriend&t=" + id;
	post_id.value = id;
	post_hidden_url.value = url;
	post_hidden_t.value = id;
	
	post_message.value = "Greetings! This SlickDeal has been shared with you:\n\n'" + decodeURIComponent(title) + "'.\n\nRead more about it at " + decodeURIComponent(url) + "";
	post_subject.value = "Shared from Slickdeals: " + decodeURIComponent(title);
	post_link.value = decodeURIComponent(url);
	permalink.innerHTML = '<a href="'+decodeURIComponent(url)+'">Permalink For This Post</a>';

	form.style.left = offset[0] + 'px';
	form.style.top = (offset[1] + link.offsetHeight + 3) + 'px';
	form.style.display = 'block';
}

function akst_share_url(base, url, title) {
	base = base.replace('{url}', url);
	return base.replace('{title}', title);
}

function akst_share_tab(tab) {
	var tab1 = sdfetch_object('akst_tab1');
	var tab2 = sdfetch_object('akst_tab2');
	var tab3 = sdfetch_object('akst_tab3');
	var body1 = sdfetch_object('akst_social');
	var body2 = sdfetch_object('akst_email');
	var body3 = sdfetch_object('akst_permalink');
	
	switch (tab) {
		case '1':
			tab3.className = '';
			tab2.className = '';
			tab1.className = 'selected';
			body3.style.display = 'none';
			body2.style.display = 'none';
			body1.style.display = 'block';
			break;
		case '2':
			tab3.className = '';
			tab1.className = '';
			tab2.className = 'selected';
			body3.style.display = 'none';
			body1.style.display = 'none';
			body2.style.display = 'block';
			break;
		case '3':
			tab3.className = 'selected';
			tab1.className = '';
			tab2.className = '';
			body3.style.display = 'block';
			body1.style.display = 'none';
			body2.style.display = 'none';
			break;
	}
}

function akst_xy(id) {
	var element = $(id);
	var x = 0;
	var y = 0;
}

function toggle_firstpost_tab(tab)
{
        var allvistabs = $("#sharethistab:visible,#publicfeedback:visible");
        var tabcontainer = $("#firstpost_tabcontainer");
        if ("#" + allvistabs.attr("id") == tab)
        {
                $("#firstpost_tabcontainer").slideToggle("fast");
        }
        else
        {
                if (allvistabs.length==0)
                {
                        $("#firstpost_tabcontainer").hide();
                }
                allvistabs.not(tab).hide();
                $(tab).fadeIn("fast");
                $("#firstpost_tabcontainer:hidden").slideDown();
        }
}

function updateHtmlBits(htmlbits)
{
        htmlbits = $(htmlbits);
        htmlbits.find('htmlbit').each( function()
                {
                        var id_text = $(this).attr('id');
                        var effect = $(this).attr('effect');
			var mode = $(this).attr('mode');
                        var newbit = $($(this).text());
			var bit = $("#"+id_text)

			if (typeof(effect) != "undefined")
			{
	                       	bit.hide();
				newbit.hide();
			}
			if (mode == "append")
			{
				var appendto = $("#" + $(this).attr('appendto'));
				if (appendto.find("tbody"))
				{
					appendto.find("tbody").append(newbit);
				}
				else
					appendto.append(newbit);
			}
			else
	                	bit.replaceWith(newbit);

			if (effect == "slide")
			{
	                       	newbit.slideDown();
			}
                }
        );
        var redir = htmlbits.find('redirecturl');
        if (redir.length > 0)
                window.location = redir.text();
}

function notice_close(notice)
{
	$(".notice_" + notice).slideUp();
	var d = new Date();
	var t = parseInt(d.getTime() / 1000);
	createCookie("sdnotice" + notice, t, 365);
}

function geturlvar(url,varname) 
{ 
  var vars = url.split("&"); 
  for (var i=0;i<vars.length;i++) { 
    var pair = vars[i].split("="); 
    if (pair[0] == varname) { 
      return pair[1]; 
    } 
  } 
  return ""; 
}
 
function errordialog(error)
{
	var errdialog = $("#errordialog");
	if (errdialog.length == 0)
	{
		$("body").append("<div id='errordialog' title='Error'></di>");
		errdialog = $("#errordialog");
		errdialog.dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
	}
	errdialog.html(error);
	errdialog.dialog('open');
}		

// function to confirm delete post
function confirmdelete(postid)
{
  messagebox=confirm('You have chosen to delete Post '+postid+'.\r\rClick OK to delete it, or Cancel to hide this prompt.');
  if (messagebox==true)
  {
    divobj = document.createElement("div");
    divobj.display = "none";
    myform = document.createElement("form");
    myform.action = "editpost.php";
    myform.method = "post";

    sessinput = document.createElement("input");
    sessinput.name = "s";
    sessinput.type = "hidden";
    sessinput.value = fetch_sessionhash();

    doinput = document.createElement("input");
    doinput.name = "do";
    doinput.type = "hidden";
    doinput.value = "deletepost";

    pinput = document.createElement("input");
    pinput.name = "p";
    pinput.type = "hidden";
    pinput.value = postid;

    dinput = document.createElement("input");
    dinput.name = "deletepost";
    dinput.type = "hidden";
    dinput.value = "delete";

    sinput = document.createElement("input");
    sinput.name = "securitytoken";
    sinput.type = "hidden";
    sinput.value = SECURITYTOKEN;

    myform.appendChild(sessinput);
    myform.appendChild(doinput);
    myform.appendChild(pinput);
    myform.appendChild(dinput);
    myform.appendChild(sinput);
    divobj.appendChild(myform);
    bodyobj = document.getElementById("contentbody");
    bodyobj.appendChild(divobj);
    myform.submit();
    return false;
  }
}


// function to confirm filter post
function confirmfilter(postid)
{
  messagebox=confirm('You have chosen to filter Post '+postid+'.\r\rClick OK to filter it, or Cancel to hide this prompt.');

  if (messagebox==true)
  {
    divobj = document.createElement("div");
    divobj.display = "none";
    myform = document.createElement("form");
    myform.action = "editpost.php";
    myform.method = "post";

    sessinput = document.createElement("input");
    sessinput.name = "s";
    sessinput.type = "hidden";
    sessinput.value = fetch_sessionhash();

    doinput = document.createElement("input");
    doinput.name = "do";
    doinput.type = "hidden";
    doinput.value = "filterpost";

    pinput = document.createElement("input");
    pinput.name = "p";
    pinput.type = "hidden";
    pinput.value = postid;

    sinput = document.createElement("input");
    sinput.name = "securitytoken";
    sinput.type = "hidden";
    sinput.value = SECURITYTOKEN;

    myform.appendChild(sessinput);
    myform.appendChild(doinput);
    myform.appendChild(pinput);
    myform.appendChild(sinput);
    divobj.appendChild(myform);
    bodyobj = document.getElementById("contentbody");
    bodyobj.appendChild(divobj);
    myform.submit();
    return false;
  }
}


// function to confirm delete post history
function confirmphdelete(postid, phid)
{
  messagebox=confirm('You have chosen to delete Post History '+phid+' for Post '+postid+'.\r\rClick OK to delete it, or Cancel to hide this prompt.');

  if (messagebox==true)
  {
    divobj = document.createElement("div");
    divobj.display = "none";
    myform = document.createElement("form");
    myform.action = "posthistory.php";
    myform.method = "post";

    sessinput = document.createElement("input");
    sessinput.name = "s";
    sessinput.type = "hidden";
    sessinput.value = fetch_sessionhash();

    doinput = document.createElement("input");
    doinput.name = "do";
    doinput.type = "hidden";
    doinput.value = "delete";

    pinput = document.createElement("input");
    pinput.name = "p";
    pinput.type = "hidden";
    pinput.value = postid;

    phinput = document.createElement("input");
    phinput.name = "phid";
    phinput.type = "hidden";
    phinput.value = phid;

    sinput = document.createElement("input");
    sinput.name = "securitytoken";
    sinput.type = "hidden";
    sinput.value = SECURITYTOKEN;

    myform.appendChild(sessinput);
    myform.appendChild(doinput);
    myform.appendChild(pinput);
    myform.appendChild(phinput);
    myform.appendChild(sinput);
    divobj.appendChild(myform);
    bodyobj = document.getElementById("contentbody");
    bodyobj.appendChild(divobj);
    myform.submit();
    return false;
  }
}

