function clearText(txt)
{
	txt.value = "";
/*	if(txt.value == "email")
	{
		txt.value = "";
	}
	if(txt.value == "password")
	{
		txt.value = "";
	}
	if(txt.value == "Search...")
	{
		txt.value = "";
	}*/
}

function delete_thread_confirm(ID,Name)
{
        var answer = confirm("Are you sure you want to delete "+Name+" ?")
        if(answer)
        {
                return true; //window.location = "http://www.google.com"; "/admin.php?action=delete_thread&thread_id="+ID;
        }
        else
        {
        	return false;       //window.location = "/index.php";
        }
}


function delete_email_confirm(ID,Name) 
{
	var answer = confirm("Are you sure you want to delete "+Name+" ?")
	if (answer)
	{
		//window.location = "admin.php?action=delete_email&email_id="+ID;
		return true;
	}
	else
	{
		return false;
	}
}

function spam_email_confirm(ID,Name) 
{
	var answer = confirm("Are you sure you want to move "+Name+" to spam?")
	if (answer)
	{
		//window.location = "admin.php?action=delete_spam&email_id="+ID;
		return true;
	}
	else
	{
		return false;
	}
}

function inbox_email_confirm(ID,Name) 
{
	var answer = confirm("Are you sure you move "+Name+" to inbox?")
	if (answer)
	{
		//window.location = "admin.php?action=move_to_nolist&email_id="+ID;
		return true;
	}
	else
	{
		return false;
	}
}


function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(url) {
    http.open('get', url);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function sndReq_reload(url) {
    http.open('get', url);
    http.onreadystatechange = handleResponse;
    http.send(window.location.reload());
}
function sndSpamReq(url) {
    http.open('get', url);
    http.onreadystatechange = handleSpamResponse;
    http.send(null);
}

function getStatus() {
    http.open('get', 'status.php');
    http.onreadystatechange = handleResponse;
    http.send(null);
	setTimeout(getStatus, 60000);
}
function handleSpamResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}

function DialogBox(title, htmlContents) {

	var dialogBackground = document.getElementById('dialogBackground');
	dialogBackground.className = "dialogBackgroundOn";
	var dialogBox = document.createElement('div');
	dialogBox.className = "dialogBox";
	dialogBox.setAttribute("id", "dialogBox");
	// create contents of the dialog box
	var dialogBoxContents = "";
	dialogBoxContents += "<table width='100%'><tr>";
	dialogBoxContents += "<td align='center' width='100%'><div class='confirmation_title'>" + title + "</div></td>";
	dialogBoxContents += "<td><a href='' onclick='closeDialogBox();return false'>X</a></td>";
	dialogBoxContents += "</tr>";
	dialogBoxContents += "<tr>";
	dialogBoxContents += "<td height='100' align='center'><div class='confirmation_content'>" + htmlContents + "</div></td>";
	dialogBoxContents += "</tr>";
	dialogBoxContents += "<tr>";
	dialogBoxContents += "<td height='250' align='center'><a href onClick='javascript:closeDialogBox(); return false;'>[Close]</td></tr>";
	dialogBoxContents += "</table>";
	dialogBox.innerHTML = dialogBoxContents;
	document.body.appendChild(dialogBox);
	document.body.appendChild(dialogBackground);

}

function closeDialogBox() {
	var dialogBackground = document.getElementById('dialogBackgroundOff');
	dialogBackground.className = "dialogBackgroundOff";
	document.body.removeChild(document.getElementById('dialogBox'));
}


