﻿// etraining_app.js 1.0 20.06.2006
//
// Copyright (c) 2006 CYQUEST GmbH. All Rights Reserved.
//
// History: 20.06.2006 mac Erzeugung

var editing = null;

// Hilfe-Fenster oeffnen
function openHelpWindow() {
	var width = 700;
	var height = 500;
	var posx = ((screen.width - width) / 2);
	var posy = ((screen.height - height) / 2);
	var helpWinUrl = 'help.aspx?helpAccessKey=1';
	if (editing != null) {
	  helpWinUrl += ('&editing=' + editing);
	}
	var helpWin = window.open(helpWinUrl, 'etraining_help',
	  'left=' + posx + ',top=' + posy + ',width=' + width + ',height=' + height
	    + ',menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no'); 
  helpWin.focus();
}

// Fragen-Fenster oeffnen
function openFaqWindow() {
	var width = 700;
	var height = 500;
	var posx = ((screen.width - width) / 2);
	var posy = ((screen.height - height) / 2);
	var faqWinUrl = 'help.aspx?helpAccessKey=2';
	if (editing != null) {
	  faqWinUrl += ('&editing=' + editing);
	}
	var faqWin = window.open(faqWinUrl, 'etraining_faq',
	  'left=' + posx + ',top=' + posy + ',width=' + width + ',height=' + height
	    + ',menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no'); 
  faqWin.focus();
}

// Glossar-Fenster oeffnen
function openGlossaryWindow() {
	var width = 700;
	var height = 500;
	var posx = ((screen.width - width) / 2);
	var posy = ((screen.height - height) / 2);
	var glossaryWinUrl = 'help.aspx?helpAccessKey=3';
	if (editing != null) {
	  glossaryWinUrl += ('&editing=' + editing);
	}
	var glossaryWin = window.open(glossaryWinUrl, 'etraining_glossary',
	  'left=' + posx + ',top=' + posy + ',width=' + width + ',height=' + height
	    + ',menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no'); 
  glossaryWin.focus();
}

// Suchmodus aktiviert?
var searchModeActivated = false;

// Suchmodus aktivireren oder deaktivieren
function activateSearchMode(activated) {
  searchModeActivated = activated;
}

// Formulardaten abschicken oder bei aktiviertem Suchmodus Suche ausfuehren
function submitFormData(searchTextField) {
  if (searchModeActivated) {
    execSearch(searchTextField);
    return false;
  }
  return true;
}

// Suche ausfuehren
function execSearch(searchTextField) {
  var searchText = searchTextField.value;
  if (searchText.length >= 3) {
    openSearchWindow(searchText);
  } else {
    alert('Der Suchtext muss mindestens 3 Zeichen lang sein!');
  }
}

// Suche-Fenster oeffnen
function openSearchWindow(searchText) {
	var width = 600;
	var height = 400;
	var posx = ((screen.width - width) / 2);
	var posy = ((screen.height - height) / 2);
	var searchWinUrl = ('search.aspx?searchText=' + searchText);
	if (editing != null) {
	  searchWinUrl += ('&editing=' + editing);
	}
	var searchWin = window.open(searchWinUrl, 'etraining_search',
	  'left=' + posx + ',top=' + posy + ',width=' + width + ',height=' + height
	    + ',menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no'); 
  searchWin.focus();
}

// Return-Taste sperren und nur fuer Suchfeld zulassen
function disableEnterKey(ev) {
  if (!searchModeActivated) {
    var key;
    if (window.event) {
      key = window.event.keyCode; //IE
    } else {
      key = ev.which; //firefox
    }
    if (key == 13) {
      return false;
    }
  }
  return true;
}

// Kategorie anspringen
function gotoCategory(categoryId) {
  var categoryUrl = ('experience_goto.aspx?categoryId=' + categoryId);
  if (editing != null) {
    categoryUrl += ('&editing=' + editing);
  }
  window.location.href = categoryUrl;
}

// Inhalt anspringen
function gotoContent(contentId) {
  var contentUrl = ('experience_goto.aspx?contentId=' + contentId);
  if (editing != null) {
    contentUrl += ('&editing=' + editing);
  }
  window.location.href = contentUrl;
}

// Inhalt-Eintrag anspringen
function gotoContentItem(contentItemId) {
  var contentItemUrl = ('experience_goto.aspx?contentItemId=' + contentItemId);
  if (editing != null) {
    contentItemUrl += ('&editing=' + editing);
  }
  window.location.href = contentItemUrl;
}

// Kategorie in oeffenendem Fenster anspringen
function goToCategoryInOpener(categoryId) {
  var categoryUrl = ('experience_goto.aspx?categoryId=' + categoryId);
  if (editing != null) {
    categoryUrl += ('&editing=' + editing);
  }
  opener.location.href = categoryUrl;
}

// Inhalt in oeffenendem Fenster anspringen
function gotoContentInOpener(contentId) {
  var contentUrl = ('experience_goto.aspx?contentId=' + contentId);
  if (editing != null) {
    contentUrl += ('&editing=' + editing);
  }
  opener.location.href = contentUrl;
}

// Inhalt-Eintrag in oeffenendem Fenster anspringen
function gotoContentItemInOpener(contentItemId) {
  var contentItemUrl = ('experience_goto.aspx?contentItemId=' + contentItemId);
  if (editing != null) {
    contentItemUrl += ('&editing=' + editing);
  }
  opener.location.href = contentItemUrl;
}

