var ns4=(document.layers)?1:0;
var dom1=(document.getElementById)?1:0;
var ie4up=(document.all)?1:0;
var mac=(navigator.appVersion.indexOf("Macintosh") > -1)?1:0;

function generalOpenWin(url,winName,winFeatures){
	winName=window.open(url,winName,winFeatures);
	if(window.focus)winName.focus();
}

function checkssl(){
	var thisloc=document.location.href;
	if(thisloc.indexOf("https://")!=0){
		var newloc=thisloc.replace(/http:/,"https:");
		window.location.replace(newloc,true);
	}
}


function getElementRef(id){
	if (dom1) return document.getElementById(id);
	else if (ie4plus) return document.all[id];
	else if (ns4) return document.layers[id];
	else return null;
}

function show1HideLast(id){
	//var thisControlImg=document["control"+id];
	if(id!=this.currentlyVis){
		item2Show=getElementRef(id);
		if(item2Show)if(item2Show.style){
			item2Show.style.display='block';
		}
		item2Hide=getElementRef(this.currentlyVis);
		if(item2Hide)if(item2Hide.style) {
			item2Hide.style.display='none';
			//prevControlImg=document["control"+this.currentlyVis];
		}
		this.currentlyVis=id;
	} else {
		item2Hide=getElementRef(this.currentlyVis);
		if(item2Hide)if(item2Hide.style) item2Hide.style.display='none';
		this.currentlyVis="";
	}
}


/* Set a property of style type of the element */
function setElementProperty(p_elm, p_property, p_value){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if((elm != null) && (elm.style != null)){
		elm = elm.style;
		elm[ p_property ] = p_value;
	}
}



function equalizeColumnHeights(){
	if(document.getElementById('contentcontainer')){
		var nContentHeight=getElementHeight('contentcontainer');
		var oSubmitButt=document.getElementById('submitButton');
		if(oSubmitButt){
			var aOButtPos=findPos(oSubmitButt);
			var nButtonBottomHeight=(getElementHeight(oSubmitButt)+aOButtPos[1]);
			if(nContentHeight < nButtonBottomHeight)nContentHeight=nButtonBottomHeight+10;
		}
		var nNavHeight=getElementHeight('nav');
		var nMinContentHeight=640;
		//alert('B4:\ncontentheight='+nContentHeight+'\nnavheight='+nNavHeight);
		if(nContentHeight != nNavHeight || nContentHeight<nMinContentHeight){
			nTallestHeight=(nContentHeight > nNavHeight)?nContentHeight:nNavHeight;
			if(nTallestHeight<nMinContentHeight)nTallestHeight=nMinContentHeight;
			setElementProperty('contentcontainer', 'height', (nTallestHeight-62)+'px');
			setElementProperty('nav', 'height', nTallestHeight+'px');
		}
		//alert('AFTER: contentheight='+nContentHeight+'\nnavheight='+nNavHeight);
	}
}



function DisplayGroup(initiallyVisMember){
	this.currentlyVis=initiallyVisMember;
	//methods
	this.show1HideLast=show1HideLast;
}	

function writeEmailLink(u,d,txt,subject){
	if(!d) d="saanys.org";
	subjectstr=(!subject)? "" :"?subject="+subject;
	if(!txt) document.write('<a href="mailto:'+u+'@'+d+subjectstr+'">'+u+'@'+d+'</a>');
	else document.write('<a href="mailto:'+u+'@'+d+subjectstr+'">'+txt+'</a>');
}