// <Copyright: Martin Kaiser> <Chili-Site Web Design> <www.chili-site.de> <webdesign@chili-site.de>
// Projekt Initialisierung

// ### Project Locations ###
var RootPath
if (window.location.hostname == "sozialstationen.diakonie-in-augsburg.de")		{RootPath = "http://sozialstationen.diakonie-in-augsburg.de/"}
if (window.location.hostname == "sozialstationen.diakonie-in-augsburg.csw")		{RootPath = "http://sozialstationen.diakonie-in-augsburg.csw/"}

var IndexPath		= RootPath + "dummy-frames/";
var StartPath			= RootPath + "sozialstationen-frames/";
var IndexLoc			= RootPath + "index.html";
var StartLoc			= RootPath + "index.html";
var WelcomeDoc		= RootPath + "sozialstationen/index.html";
var csNoPrintLoc		= RootPath + "_csNoPrint.css";

// ### Browser Check ###
var nc = false;	var nc4 = false;	var nc6 = false;
var ie = false;	var ie4 = false;	var ie5 = false;
var op = false;	var op5 = false;

var browser = navigator.appName
var version = navigator.userAgent

if (browser.indexOf("Netscape")>=0) {nc = true}
if (browser.indexOf("Microsoft Internet Explorer")>=0) {ie = true}
if (browser.indexOf("Opera")>=0) {op = true}

if (ie) {	if (version.indexOf("MSIE 5") >=0) {ie5 = true}
		if (version.indexOf("MSIE 4") >=0) {ie4 = true} }
if (nc) {	if (version.indexOf("Mozilla/4") >=0) {nc4 = true}
		if (version.indexOf("Mozilla/5") >=0) {nc6 = true} }
if (op) {	if (version.indexOf("Opera/5.02") >=0) {op5 = true} }

// ### Document Reload ###
var SelfLoc		= self.location.href
if (SelfLoc.indexOf(".html")<0) {SelfLoc += "index.html"}

var TopLoc		= top.location.href
if (TopLoc.indexOf(".html")<0) {TopLoc += "index.html"}

var SiteIndex	= false;	var SiteIndexFrame	= false
var SiteStart		= false;	var SiteStartFrame	= false
var SiteMain		= false
var DocPrint		= false
var DocLoc		= SelfLoc.replace(RootPath, "")

// Index-Seite
if (SelfLoc.indexOf(IndexLoc) >= 0 || SelfLoc == RootPath || SelfLoc+"/" == RootPath) {
	if (SelfLoc != TopLoc) {top.location.replace(IndexLoc)}
	SiteIndex = true }
// Index-Frames
if (SelfLoc.indexOf(IndexPath) >= 0) {
	if (TopLoc.indexOf(RootPath) < 0 || SelfLoc == TopLoc) {top.location.replace(IndexLoc)}
	SiteIndexFrame = true }
// Start-Seite
if (SelfLoc.indexOf(StartLoc) >= 0) {
	if (SelfLoc != TopLoc) {top.location.replace(StartLoc)}
	SiteStart = true }
// Start-Frames
if (SelfLoc.indexOf(StartPath) >= 0) {
	if (TopLoc.indexOf(RootPath) < 0 || SelfLoc == TopLoc) {top.location.replace(StartLoc)}
	SiteStartFrame = true }
// Main-Seite
if (!SiteIndex && !SiteIndexFrame && !SiteStart && !SiteStartFrame) {SiteMain = true}
if (SelfLoc.indexOf(RootPath) >= 0 && SiteMain) {
	if (nc4 && window.self.innerHeight == 0)	{DocPrint = true}
	if (self.location.href.indexOf("?PRINT") >= 0)	{DocPrint = true}
	if (SelfLoc == TopLoc && !DocPrint || TopLoc.indexOf(RootPath) < 0) {
		top.location.replace(StartLoc + "?" + DocLoc)}
	else if (!DocPrint) {
		window.document.write("<link rel=\"stylesheet\" href=\"" + csNoPrintLoc + "\">")
		parent.DocChange = true}
	}

// ### Document OnLoader ###
function OnLoader() {
	if (SiteIndex) { }
	if (SiteIndexFrame) { }
	if (SiteStart) {
		var StartDoc = WelcomeDoc
		if (TopLoc.indexOf("?") >=0 && TopLoc.indexOf("?PRINT") <0) {
			StartDoc = TopLoc.replace(StartLoc, ""); StartDoc = StartDoc.replace("?", "")}
		main.location.replace(StartDoc)
		WatchingChanges() }
	if (SiteStartFrame) { }
	if (SiteMain && !DocPrint) { }
	if (SiteMain && DocPrint) {window.focus(); window.print()}
	}

// ### Document OnUnLoader ###
function OnUnLoader() {
	if (SiteIndex) { }
	if (SiteIndexFrame) { }
	if (SiteStart) { }
	if (SiteStartFrame) { }
	if (SiteMain && !DocPrint) { }
	if (SiteMain && DocPrint) {window.opener.focus()}
	}

// EOF
