//function setCookie(name, value, expires)
//{
//    alert("setting cokie to "+value);
//	// no expiration date specified? use this date and it will expire in a year
//    //if (!expires) expires = (new Date() + 31536000000); 
//	//document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
//	//document.cookie = name + "=" + value + "; expires=" + expires.toGMTString() + "; path=/";
//	//document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" );
//}


function setCookie(cookieName,cookieValue,nDays) 
{
    var today = new Date();
    var expire = new Date();
    if (nDays==null || nDays==0) nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    //test write follows
    //alert("function SetCookie is setting cookie "+cookieName+" to "+cookieValue);
    document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}


function setState(abcd)
{
    //alert("setting cookie to "+abcd);
	setCookie("userState", abcd, 365);
}


/*
//USAGE
var expdate = new Date ();                         // pre-set to the current time and date
expdate.setTime(expdate.getTime() + 31536000000);  // add one year to expiration
//365 days * 24 hours * 60 minutes * 60 seconds * 1000 milliseconds = milliseconds in a year
setCookie("userState","true",expdate);
 */

function getCookie(name)
{
	var cookies = document.cookie;
    //alert(cookies);
	if (cookies.indexOf(name) != -1)
	{
		var startpos = cookies.indexOf(name)+name.length+1;
		var endpos = cookies.indexOf(";",startpos)-1;
		if (endpos == -2) endpos = cookies.length;
		return unescape(cookies.substring(startpos,endpos));
	}
	else
	{
		window.location="setstate.htm";
		return false; // the cookie couldn't be found! it was never set before, or it expired.
	}
}



function checkState()
{
        var userState = "false";
        userState = getCookie("userState");
        //test write follows
        //alert("function checkState returned state of "+userState);
        //if (userState == "Michigan")
        //    { 
        //    return userState;
        //    }
        if (userState == "false")
            { 
            window.location="setstate.htm";
            }
        return userState;
}



function LicensedState()
{
        var licState = "undefined";
        licState = getCookie("userState");
        document.write("<p><br />Welcome visitor from "+licState+"! &nbsp<font size=-3><a href=setstate.htm>change state</a></font></p>");
        // ****************************************************************************************
        // ****************************************************************************************
        // **                                                                                    **
        // ** ADD LICENSED STATES TO THE LIST BELOW AND ALSO TO THE STATIC TEXT IN SETSTATE.HTM  **
        // **                                                                                    **
        // ****************************************************************************************
        // ****************************************************************************************
        
        if (licState == "California")
            { 
            return true;
            }
        if (licState == "Indiana")
            { 
            return true;
            }
        if (licState == "Florida")
            { 
            return true;
            }
        if (licState == "Michigan")
            { 
            return true;
            }
        if (licState == "Missouri")
            { 
            return true;
            }
        if (licState == "Pennsylvania")
            { 
            return true;
            }
        if (licState == "Texas")
            { 
            return true;
            }
        if (licState == "the District of Columbia")
            { 
            return true;
            }
            
            
        document.write("<p><br /><strong>Information contained on this web site is intended for use only by residents ");
        document.write("of the states in which we are registered.  <i>Securities related services may not be ");
        document.write("provided to individuals residing in "+licState+".</i></strong></p><p><br /><strong>Please note that we can become ");
        document.write("licensed in "+licState+" within a short period of time, contact us for more ");
        document.write("information.  We invite you to explore this informative and educational website.  By ");
        document.write("doing so, you acknowledge that you have read this disclosure.</strong></p>");
        return false;
}

function siteFooter()
{
        document.write("<p>&copy; 2008 <b>Covenant Financial Planning</b> - ");
        document.write("48380 Van Dyke Suite 200 - Shelby Township, Michigan  48317 - (586) 739-3550<br class=spacer />");
        document.write("Web site template provided by ");
        document.write("<a href='http://www.free-css-templates.com/' onClick='externalsite(this.href); return false;'>Free CSS Templates</a> ");
        document.write("and maintained by <a href='http://www.nightowlonline.com' onClick='externalsite(this.href); return false;'>Night Owl Online</a></p>");
}


function xxxxxxxxxheaderMenu()
{
        document.write("<ul>");
        document.write("  <li><a href=contact.htm title=CONTACT>CONTACT</a></li>");
        document.write("  <li><a href=news.htm title=NEWS>NEWS</a></li>");
        document.write("  <li><a href=tools.htm title=TOOLS>TOOLS</a></li>");
        document.write("  <li><a href=services.htm title=SERVICES>SERVICES</a></li>");
        document.write("  <li><a href=products.htm title=PRODUCTS>PRODUCTS</a></li>");
        document.write("  <li><a href=company.htm title=COMPANY>COMPANY</a></li>");
        document.write("  <li><a href=about.htm title=ABOUT>ABOUT US</a></li>");
        document.write("  <li><span>HOME</span></li>");
        document.write("</ul>");
}


 var newwindow;
 function externalsite(url)
 {
   alert("You are about to be transferred to an external web site over which Covenant Financial Planning has no control. Covenant Financial Planning assumes no responsibility for the content of the material contained at that site or for the accuracy of any information that is found there. This link will open in a new window, closing this window will return you to the Covenant Financial Planning web site.");   
   newwindow=window.open(url,'name','height=600, width=800, left=1, top=1, resizable=yes, scrollbars=yes, toolbar=yes, status=yes');
   if (window.focus) {newwindow.focus()}
 }


