/*
 userMail
 
 This function will be used for administer mails through the site
*/


function sendMail(buttonToSearch,objectForm,userID,replaceRecieveBoxDiv)
{
	passThroughValue = new Array();
	passThroughValue[0] = buttonToSearch;
	passThroughValue[1] = replaceRecieveBoxDiv;
	
	document.getElementById(''+ buttonToSearch).disabled = true;
	ajaxSubmitFormPOST('commonAjax.php?script=sendMail&userID='+userID,objectForm,'procesSendMail',passThroughValue);
}

function procesSendMail(ajaxStatus,ajaxResponse,passThroughValue)
{
	if(ajaxStatus == 202)
	{
		document.getElementById('' + passThroughValue[0]).disabled = false;
		eval(''+ajaxResponse);
	}
	else
	{
		alert('De mail is succesvol verzonden.');
		ajaxCleanInnerXHTML('showMailDiv');
		ajaxInnerXHTML(passThroughValue[1],ajaxResponse);
	}	
}


function deleteMail(buttonToSearch,objectForm,replaceRecieveBoxDiv,userID,send)
{
	passThroughValue = new Array();
	passThroughValue[0] = buttonToSearch;
	passThroughValue[1] = replaceRecieveBoxDiv;
	
	document.getElementById(''+ buttonToSearch).disabled = true;
	ajaxSubmitFormPOST('commonAjax.php?script=deleteMail&userID='+userID+'&send='+send,objectForm,'procesDeleteMail',passThroughValue);
}

function procesDeleteMail(ajaxStatus,ajaxResponse,passThroughValue)
{
	if(ajaxStatus == 202)
	{
		document.getElementById('' + passThroughValue[0]).disabled = false;
	}
	else
	{
		alert('De geselecteerde mails zijn succesvol verwijderd.');
		ajaxInnerXHTML(passThroughValue[1],ajaxResponse);
	}	
}

function newMail(objectForm,userID,replyID)
{
	ajaxPlaceContentInDiv('commonAjax.php?script=newMail&newMail=true&replyID='+ replyID +'&userID='+userID,objectForm);
}

function getMail(objectForm,userID,mailID,urlImage,send)
{
	ajaxPlaceContentInDiv('commonAjax.php?script=getMail&mailID='+ mailID +'&userID='+userID+'&send='+send,objectForm);

	if(send == 0)
    {
        document.getElementById('opImage'+mailID).src = urlImage+'/pmail/pms1.gif';
    }
}
