function confirmPurge(sFolder){

	if(confirm('Are you sure? This action will delete every message in this folder with no ability to recover them. Click OK if you wish to proceed.')){
	                                
		window.location='index.php?paws=purge&folder='+sFolder;
	
	}

}

function showHide(sItem){
	oItem = document.getElementById(sItem);
	if(oItem.style.display!='inline'){
		oItem.style.display='inline';
	} else {
		oItem.style.display='none';
	}
}

function showToggle(sItem1,sItem2){
	oItem1 = document.getElementById(sItem1);
	oItem2 = document.getElementById(sItem2);	
	if(oItem1.style.display!='inline'){
		oItem1.style.display='inline';
		oItem2.style.display='none';
	} else {
		oItem2.style.display='inline';
		oItem1.style.display='none';
	}
}

function perPage(sFolder,iMsgStart){
	oPer = document.getElementById('perpage');
	iPerPage = oPer.options[oPer.selectedIndex].innerHTML;
	window.location = 'index.php?paws=folder&folder='+sFolder+'&page=1&msgstart='+iMsgStart+'&perpage='+iPerPage;
}

function jumpPage(sFolder,iMsgStart){
	oPer = document.getElementById('jump');
	iJump = oPer.options[oPer.selectedIndex].innerHTML;
	window.location = 'index.php?paws=folder&folder='+sFolder+'&page='+iJump;
}


function toggleSelectAll(){
	o = document.getElementById('MainList');
	oItems = o.getElementsByTagName('input')
	for(i=0;i<oItems.length;i++){
		oItem = oItems[i];
		if(oItem.name=='selItem[]'){
			oItem.checked=document.getElementById('masterCheck').checked;
		}
	}
}

function validateCompose(oButton){
	oForm = document.getElementById('CompForm');
	oSplash = document.getElementById('sendSplash');
	if(oForm.to.value==''){
		alert('Please specify one or more recipients');
	} else {
		oSplash.style.display = 'inline';
		oButton.disabled = true;
		oForm.submit();
	}
}

//Prevent multiple delete clicks
function doDelete(oButton){
	oButton.disabled=true;
	doAction('delete');
}

function doAction(s){
	oForm = document.getElementById('MainForm');
	oForm.paws.value=s;
	oForm.submit();
}

function doActionCompForm(s){
	oForm = document.getElementById('CompForm');
	oForm.paws.value=s;
	oForm.submit();
}

function doMove(sFolder){
		oForm = document.getElementById('MainForm');
		oForm.paws.value='move';
		oForm.foldertarget.value=sFolder;
		oForm.submit();
}

function doAttach(){
	oAtt = document.getElementById('attachments');
	oForm = document.getElementById('CompForm');
	if(oAtt.style.display!='inline'){
		oAtt.style.display = 'inline';
		oForm.msgbody.style.display = 'none';
		document.getElementById('contacts').style.display = 'none';
	} else {
		oAtt.style.display = 'none';
		oForm.msgbody.style.display = 'inline';
	}
}

function doFolderDelete(){
	if(confirm('Are you sure? Messages cannot be recovered. Click \'OK\' to delete')){
		oForm = document.getElementById('MainForm');
		oForm.foldermgt.value='delfolder';
		oForm.submit();
	}
}

function doContactDelete(){
	if(confirm('Are you sure? Click \'OK\' to proceed.')){
		oForm = document.getElementById('CompForm');
		oForm.contacts.value='delcontact';
		oForm.submit();
	}
}

function gotoContacts(iType){
	s = 'addtype'+iType;
	o = document.getElementById('addtype0');
	o.checked=true;
	document.getElementById('attachments').style.display='none';
	document.getElementById('msgbody').style.display='none';
	document.getElementById('contacts').style.display='inline';
}

function addContact(){
	oContacts = document.getElementById('contactlist');
	oCompForm = document.getElementById('CompForm');	
	oAdd0 = document.getElementById('addtype0');	
	oAdd1 = document.getElementById('addtype1');	
	oAdd2 = document.getElementById('addtype2');	

	var i = oContacts.options[oContacts.selectedIndex].innerHTML;
	i = i.replace(/\&lt;/g,"<");
    i = i.replace(/\&gt;/g,">");

	if(oAdd0.checked){o=oCompForm.to;}
	if(oAdd1.checked){o=oCompForm.cc;}
	if(oAdd2.checked){o=oCompForm.bcc;}
	if(o.value.indexOf(i)==-1){
		if(o.value!=''){
			o.value = o.value + '; ' + i;
		} else {
			o.value = i;
		}
	}
}

function gotoCompose(){
	oForm = document.getElementById('CompForm');
	oCon = document.getElementById('contacts');
	oForm.msgbody.style.display='inline';
	oCon.style.display='none';
	document.getElementById('attachments').style.display='none';	
}

function splashNav(url){
	o = document.getElementById('refreshSplash');
	o.style.display='inline';
	window.location = url;
}

/* Flex */

function navOver(o){
	o.className='navButton2Sel';
}

function navOut(o){
	o.className='navButton2';
}

function doResize(){

	//Select browser
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		bIE = true;
	} else {
		bIE = false;
	}
	
	if (bIE){
		//Height + Width
		iH = document.body.offsetHeight;	
	} else {
		//Resize colTable
		iH = window.innerHeight;
		document.body.style.height=iH+'px';
	}
	
	//Defaults
	oleft = false;
	ocenter = false;
	oright = false;
	
	//Refs
	//oleft = document.getElementById('leftColInner');
	ocenter = document.getElementById('centerColInner');
	//oright = document.getElementById('rightColInner');
	//oNewFile = document.getElementById('newfile');			
	oMsgbody=document.getElementById('msgbody');	
				
	//Resize dynamic columns
	//if (oleft!=null) {oleft.style.height = (iH - oleft.offsetTop - 4)+'px';}
	if (!bIE && ocenter!=null) {ocenter.style.height = (iH - ocenter.offsetTop - 2)+'px';}
	//if (oright!=null) {oright.style.height = (iH - oright.offsetTop - 4)+'px';}
	//if (oNewFile!=null) {oNewFile.style.width="180px";}
	if (oMsgbody!=null) {
		iNewHeight = iH-oMsgbody.offsetTop-25;
		if(iNewHeight>0){
			oMsgbody.style.height=iNewHeight+'px';
		}
	}

	
}

function printerFriendlyFrame(){
	oFrame = document.getElementById('printMessageBodyHTML');
}