var ns2;
var ns3;
var ns4;
var op5;
var op6;
var agt;
var mac;
var ie; 
var mac_ie;
var opera;
var popWin;

function sniffBrowsers() 
{
	ns4 = document.layers;
	op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
	op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
	opera = (navigator.userAgent.indexOf("Opera") != -1);
	agt=navigator.userAgent.toLowerCase();
	mac = (agt.indexOf("mac")!=-1);
	ie = (agt.indexOf("msie") != -1); 
	mac_ie = mac && ie;
	if (ie && !mac_ie) { /*perform specific CSS operations */  }
	if (opera) { document.write('<style type="text/css">#container {margin: 0 auto; text-align:left; border-left: 1px solid #000000; border-right:1px solid #000000; width:760 !important; padding:0; position:relative;}</style>');}
}

function newWindowOpen(strURL,wWidth,wHeight)
{
	if(popWin && !popWin.closed){
    	popWin.location.replace(strURL);
	}
	else {
		var strProperties = 'width=' + wWidth + ',height=' + wHeight + ',scrollbars=yes,status=no';
		popWin = window.open(strURL,'popup',strProperties);
	}
	popWin.focus();
}

function writeStyle(cssRule) 
{
	document.write('<style type="text/css">' + cssRule + '</style>');
}

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function JumpMenu(selObj,restore){
 var theFullString = selObj.options[selObj.selectedIndex].value;
 if (restore) selObj.selectedIndex=0;
 var theLength = theFullString.length;
 var endPos = theFullString.indexOf("~");
 var endPos2 = theFullString.lastIndexOf("~");
 var theUrl, theTarget, theParent;
if (endPos==0){ theUrl = theFullString.substring(1,endPos2);}
else if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
 else {theUrl = theFullString;}
 endPos2++
 if (endPos2 < theLength) {theTarget = theFullString.substring(endPos2,theLength)}
 else {theTarget = "window:Main";}
 if (theTarget == "window:New") {window.open(theUrl);}
 else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
}
function JumpMenuGo(selName,restore){
  var selObj = MM_findObj(selName); if (selObj) JumpMenu(selObj,restore);
}

var feedbackPage = "http://www.episcopalchurch.org/forms/question_form.htm";

function goFeedback() {
  newWindowOpen(feedbackPage,'640','480');
}
