// JavaScript functions

function popupw1(pagename,winw,winh){
	pageToOpen = 'templates/' + pagename;
	winSelect1=window.open(pageToOpen,'pop01','screenX=50,left=50,screenY=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+winw+',height='+winh);
}

function popupw2(unsentid,winw,winh){
	pageToOpen = 'preview.php?unsentid=' + unsentid;
	winSelect1=window.open(pageToOpen,'pop02','screenX=50,left=50,screenY=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+winw+',height='+winh);
}

function popupw4(unsentid,winw,winh){
	// same as popupw2 but sumbits form from opening page
	pageToOpen = 'preview.php?unsentid=' + unsentid;
	document.newform.popup.value=1;
	document.newform.submit();
	winSelect1=window.open(pageToOpen,'pop02','screenX=50,left=50,screenY=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+winw+',height='+winh);
}

function popupw3(sentid,winw,winh){
	pageToOpen = 'review.php?unsentid=' + sentid;
	winSelect1=window.open(pageToOpen,'pop02','screenX=50,left=50,screenY=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+winw+',height='+winh);
}

function alter_boxes(box){
	var elno = document.getElementById(box.name);

	var groupid = elno.value;
	var checkstatus = elno.checked;

	for (var i=0; i<document.recips.elements.length; i++){
		if (document.recips.elements[i].id == groupid){
			document.recips.elements[i].checked = checkstatus;
		}
	}
}

function toggleLayer(whichLayer){
	var elem, vis;
  
	if( document.getElementById ){
		elem = document.getElementById(whichLayer);
	} else if( document.all ){
		elem = document.all[whichLayer];
	} else if( document.layers ){
		elem = document.layers[whichLayer];
	}

	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if (vis.display=='' && elem.offsetWidth!=undefined && elem.offsetHeight!=undefined){
		vis.display = (elem.offsetWidth!=0 && elem.offsetHeight!=0) ? 'block' : 'none';
	}
	vis.display = (vis.display=='' || vis.display=='block') ? 'none' : 'block';
}

