// JavaScript Document

//DataTable_oddrow
//DataTable_evenrow

var browser = navigator.appName;
if(browser == "Netscape"){
displayString = "table-row";
} else {
displayString = "block";
}

function ShowHideDataRow(rowid) {
	if (document.getElementById("Row_"+rowid+"b").style.display!='none') {
	document.getElementById('DTC_'+rowid).src=document.getElementById('DTC_'+rowid).src.replace('open','closed');
	document.getElementById('DTC_'+rowid).alt='Show';	
	document.getElementById('DTC_'+rowid).title='Show';	
	document.getElementById("Row_"+rowid+"b").style.display='none';
	} else {
	document.getElementById('DTC_'+rowid).src=document.getElementById('DTC_'+rowid).src.replace('closed','open');
	document.getElementById('DTC_'+rowid).alt='Hide';	
	document.getElementById('DTC_'+rowid).title='Hide';	
	document.getElementById("Row_"+rowid+"b").style.display=displayString;		
	}
}




function RowOn(rowid,rowstyle) {
if (document.getElementById("Row_"+rowid+"a") || document.getElementById("Row_"+rowid+"b")) {	
	document.getElementById("Row_"+rowid+"a").className='DataTable_HighlightRow';
	document.getElementById("Row_"+rowid+"b").className='DataTable_HighlightRow';
	} else {
	document.getElementById("Row_"+rowid).className='DataTable_HighlightRow';
	}
}

function RowOff(rowid,rowstyle) {
if (document.getElementById("Row_"+rowid+"a") || document.getElementById("Row_"+rowid+"b")) {	
	document.getElementById("Row_"+rowid+"a").className='DataTable_'+rowstyle+'row';
	document.getElementById("Row_"+rowid+"b").className='DataTable_'+rowstyle+'row';
	} else {
	document.getElementById("Row_"+rowid).className='DataTable_'+rowstyle+'row';
	}
}



function confirmDelete(etitle) {
var agree=confirm("Are you sure you wish to delete the record: "+etitle+"?");
if (agree) {
	return true ;
}
else {
	return false ;
}
}





		
function countRecipients () {
	var recips=0;
    var myForm = document.forms.form1;
     for( var i=0; i < myForm.length; i++ ) { 
          if(myForm.elements[i].checked && myForm.elements[i].id!="CheckUncheckAll" && myForm.elements[i].type=="checkbox") {
               // = "checked";
			   recips++;
          } 
     }
	return recips;
	}
	
	
	function selectToggle(toggle, form) {
     var myForm = document.forms[form];
     for( var i=0; i < myForm.length; i++ ) { 
          if(toggle) {
               myForm.elements[i].checked = "checked";
          } 
          else {
               myForm.elements[i].checked = "";
          }
     }
}

	function CheckUncheck() {
		if (document.getElementById('CheckUncheckAll').checked==true) {
			document.getElementById('CheckText').innerHTML='All Selected';
			   selectToggle(true, 'form1');
		} else {
			document.getElementById('CheckText').innerHTML='All Deselected';
			   selectToggle(false, 'form1');
			}}
			
function checkEmail(mailvalue) {
var email = mailvalue;
var filter = /^[a-z0-9\._-]+@([a-z0-9_-]+\.)+[a-z]{2,6}$/i;
if (filter.test(email)==false) {
return false;
} else {
	return true;
}
}

			
	function confirmSend() {
var NumSent=countRecipients();
var FileToSend=document.forms.form1.wFile.value;
if (NumSent==0) {alert('No Recipients Selected');return false;}
if (!FileToSend) {alert('No File Selected');return false;}
var agree=confirm("Are you sure you wish to send the file \""+FileToSend+"\" to "+NumSent+" addresses?");
if (agree) {
	return true ;
	document.forms.form1.submit.value="Please Wait..."
} else {
	return false ;
}}


	function confirmTestSend() {
var TestRecip= checkEmail(document.forms.form1.TestMailTo.value);
//var TestRecip=document.forms.form1.TestMailTo.value;
var FileToSend=document.forms.form1.wFile.value;
if (!TestRecip) {alert('No Test Recipient Selected');return false;}
if (!FileToSend) {alert('No File Selected');return false;}
}



function onSubscribeclick(event) {
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     

     if (key == 13){return onSubscribe ();};
}

function onSubscribe () {
var TestRecip= checkEmail(document.forms.subscriptionform.email.value);
if (!TestRecip) {alert('Please enter a valid email address');return false;}	
}



function FillBillingAddress() {
if (document.getElementById('PasteBillInfoCB').checked) {
document.getElementById('BillFirstName').value=document.getElementById('FirstName').value;
document.getElementById('BillLastName').value=document.getElementById('LastName').value;
document.getElementById('BillAddress1').value=document.getElementById('Address1').value;
document.getElementById('BillAddress2').value=document.getElementById('Address2').value;
document.getElementById('BillCity').value=document.getElementById('City').value;
document.getElementById('BillState').value=document.getElementById('StateProvince').value;
document.getElementById('BillZIP').value=document.getElementById('ZIP').value;
document.getElementById('BillCountry').value=document.getElementById('Country').value;
} else {
document.getElementById('BillFirstName').value="";
document.getElementById('BillLastName').value="";
document.getElementById('BillAddress1').value="";
document.getElementById('BillAddress2').value="";
document.getElementById('BillCity').value="";
document.getElementById('BillState').value="";
document.getElementById('BillZIP').value="";
document.getElementById('BillCountry').value="";}
}






function blockshow(rowid,blockid) {
document.getElementById("block"+blockid+"_"+rowid).style.visibility='visible';
}

function blockhide(rowid,blockid) {
document.getElementById("block"+blockid+"_"+rowid).style.visibility='hidden';
}


function ShowHideBox(boxid) {
if (document.getElementById(boxid).style.display=='block') {
document.getElementById(boxid).style.display='none'
} else {
document.getElementById(boxid).style.display='block'
}
}





var SendMailTo=""

function changeMailAdr(mailadr) {
	if (mailadr=="") {
	document.getElementById('TestMailLink').innerHTML="none";
	} else {
	document.getElementById('TestMailLink').innerHTML=mailadr;
	}
	SendMailTo=mailadr;
}

function openLinkPage() {
	if (SendMailTo=="") {alert('No File Selected');}else{
	window.open("/massmailer/materials/"+SendMailTo,'TestPage',"scrollbars=1,menubar=0, status=0,resizable=1,width=580,height=600");
	}}
