
//Select
function checkFetchMail(){
	oForm = document.getElementById('FetchAddForm');
	if(oForm.mailhost.value == ''){
		alert("The hostname field is blank\n")
		return false;
	}
	if(oForm.username.value == ''){
		alert("The username field is blank\n")
		return false;
	}
	if(oForm.passwd.value != oForm.confirmpw.value){
		alert("Password and confirmation do not match")
		return false;
	}

		return true;
}

function doResize(){

	//Select browser
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		bIE = true;
	} else {
		bIE = false;
	}
	
	//Defaults
	oleft = false;
	ocenter = false;
	oright = false;
	
	//Calc Refs, Width and Height
	if (bIE){
		
		//Refs
		if(document.all.leftColInner){oleft=document.all.leftColInner};
		if(document.all.centerColInner){ocenter=document.all.centerColInner};
		if(document.all.rightColInner){oright=document.all.rightColInner};
		
		//Height + Width
		iH = document.body.offsetHeight;
		
	} else {
		
		//Refs
		oleft = document.getElementById('leftColInner');
		ocenter = document.getElementById('centerColInner');
		oright = document.getElementById('rightColInner');
		
		//Resize colTable
		iH = window.innerHeight;
		document.body.style.height=iH+'px';
	}
	
	//Resize dynamic columns
	if (oleft!=false) {oleft.style.height = (iH - oleft.offsetTop - 4)+'px';}
	if (ocenter!=false) {ocenter.style.height = (iH - ocenter.offsetTop - 1)+'px';}
	if (oright!=false) {oright.style.height = (iH - oright.offsetTop - 4)+'px';}
	
}

function statusShowDetails(o,divid){

	o.style.cursor = 'pointer';

	oHelp = document.getElementById('helptext');
	oHelp.style.display = 'none';
	oDiv = document.getElementById(divid);
	oShow = document.getElementById('showdetails');
	oShow.innerHTML = oDiv.innerHTML ;
	
}

function statusHideDetails(){
	oHelp = document.getElementById('helptext');
	oHelp.style.display = 'normal';
	oShow = document.getElementById('showdetails');
	oShow.innerHTML = "" ;
	
}

function goSettings(key){
	oForm = document.getElementById('MailboxForm');
	oForm.settings.name = "settings-"+key;
	oForm.submit();
}

function goAccount(key){
	oForm = document.getElementById('AccountForm');
	oForm.setting.name = "manage-"+key;
	oForm.submit();
}

function doRemoveAlias(key){
	oForm = document.getElementById('AliasForm');
	if(confirm("Are you sure? Click 'OK' to confirm.")){
		oForm.remove.name = "removealias-"+key;
		oForm.submit();
	}
}

function doDeleteMailbox(key){
	oForm = document.getElementById('SubmitForm');
	if(confirm("Are you sure? Click 'OK' to confirm.")){
		oForm.setting.name = "removemailbox-"+key;
		oForm.submit();
	}
}

function navOver(o){
	o.className='navButtonSel';
}

function navOut(o){
	o.className='navButton';
}

function gotoListAllAccounts(){
	o = document.getElementById('ListAllAccountsForm');
	o.submit();
}

function asubmit(formname){
	o = document.getElementById(formname);
	o.submit();
}

function doSubmit(formname,settingname){
	o = document.getElementById(formname);
	o.setting.name = settingname;
	o.submit();
}

function doSubmitConfirm(formname,settingname){
	if(confirm("Are you sure? Click 'OK' to confirm.")){
		doSubmit(formname,settingname);
	}
}

/*
function selectAllMSGID(o){
var i;
var oForm = document.getElementsByTagName('input');

	x = oForm.chkitem.length;

	for (i = 0; i < x; i++){
		if(o.checked){
			oForm.chkitem[i].checked = true;
		} else {
			oForm.chkitem[i].checked = false;
		}
	}

}
*/

function selectAllMSGID(o){
var i;
var oForm = document.getElementsByTagName('input');

	//x = oForm.chkitem.length;
	x = oForm.length;

	for (i = 0; i < x; i++){
		if(o.checked){
			oForm[i].checked = true;
		} else {
			oForm[i].checked = false;
		}
	}

}

function toggleFetchHost(o){
	oRow = document.getElementById('FetchHostRow');
	oHost = document.getElementById('mailhost');
	if(o.selectedIndex==1){
		oRow.style.display = "none";
		oHost.value = "hotmail";
	} else {
		oRow.style.display = "inline";
		oHost.value = "";		
	}
}

function checkPW(){
	oForm = document.getElementById('FetchAddForm');
	if(oForm.passwd.value != oForm.confirmpw.value){
		alert("Password and confirmation do not match")
		return false;
	} else {
		return true;
	}
}

function checkPWMailbox(){
	oForm = document.getElementById('MailboxForm');
	if(oForm.newpassword.value != oForm.confirmpassword.value){
		alert("Password and confirmation do not match")
		return false;
	} else {
		return true;
	}
}

function showhideSpam(o){
	oSpam1 = document.getElementById('spam1');
	oSpam2 = document.getElementById('spam2');
	oSpam3 = document.getElementById('spam3');		
	oSpam4 = document.getElementById('spam4');		
	if(o.selectedIndex==0){
		oSpam1.style.display = 'none';
		oSpam2.style.display = 'none';
		oSpam3.style.display = 'none';				
		oSpam4.style.display = 'none';				
	} else {
		oSpam1.style.display = 'table-row';
		oSpam2.style.display = 'table-row';
		oSpam3.style.display = 'table-row';					
		oSpam4.style.display = 'table-row';					
	}
}

function validateEmail(sEmail){

	if(sEmail.indexOf('@')==-1 || sEmail.indexOf('.')==-1 || sEmail.indexOf(' ')!=-1){
		alert('Invalid email address');
		return false;
	}

	return true;
	
	
}

function validateAutoReply(oForm){

	if(!validateEmail(oForm.from_email.value)){
	
		return false;
	
	} 	
	
	if(oForm.subject.value=='') {
	
		alert('You must provide a subject line');
		return false;
	
	} 

	if(oForm.message.value=='') {
	
		alert('You must provide a message');
		return false;
	
	} 
	
	
}

function confirmBox(){
        if(!confirm("Are you sure?")){
                return false;
        }
        return true;
}




