/***
 Javascript functions for Zander Zoftware weblog
    http://blog.zanderz.net/
 All functions (C) 2008-2009 Zander Zoftware. All rights reserved
***/

function delblog (blogid)
{
	if (confirm('Are you sure you want to delete this blog?') == true) {
		location.href = 'delete.php?blog='+blogid;
	}
}

function delcomm (postid)
{
	if (confirm('Are you sure you want to delete this comment?') == true) {
		location.href = 'delete.php?comment='+postid;
	}
}

/***
 Javascript AJAX functions for BadFellas
    www.badfellas.org  |  www.badfellas.nl
 All functions (C) 2008 Zander Zoftware. All rights reserved
***/

//Set up and AJAX object
function ajaxSetup()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

//Preview post
function PreviewPost (msg)
{
	ajaxRegister=ajaxSetup();
	if (ajaxRegister==null)
	{
		//alert("Your browser does not support AJAX!");
		return;
	}

	var url='previewpost.php';
	var params='msg='+encodeURIComponent(msg); //encodeURI
	ajaxRegister.open("POST",url,true);
	ajaxRegister.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajaxRegister.setRequestHeader("Content-length", params.length);
	ajaxRegister.setRequestHeader("Connection", "close");

	ajaxRegister.onreadystatechange=function()
	{
		if (ajaxRegister.readyState==4)
		{
			document.getElementById('postpreview').style.display='block';
			document.getElementById('postpreview').innerHTML=ajaxRegister.responseText;
		}
	}
	ajaxRegister.send(params);
}
