﻿
// designed by iFactory, Würzburg, Germany       //

// Copyright 2000-2006 by iFactory               //
// All rights reserved.                          //
// Duplication in any form or any use of this    //
// script or parts of it are strictly prohibited //
// for private and commercial use.               //


/****************************************************************
 * global constants
 ****************************************************************/
recommend = false;
contact = false;
mail = false;
join = false;


/****************************************************************
 * functions
 ****************************************************************/

/**
 * xmlHttp functionality for IE
 */
/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
function XMLHttpRequest () {
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
			xmlHttp = false;
		}
	}
	return xmlHttp;
}
@end @*/


/****************************************************************
 * classes
 ****************************************************************/

/**
 * acces key functionality
 */
var AccessKey = {
	akl: new Array(),   // access key list
	alt: false,         // alt key state

	// init access keys
	init: function () {
		link = document.getElementsByTagName("a");

		if (link) {
			for(l=0,a=0; l<link.length; l++) {
				akey = link[l].getAttribute("accesskey");
				if (akey)
					AccessKey.akl[a++] = new Array(akey.charCodeAt(0), link[l].getAttribute("href"));
			}
		}

		if (AccessKey.akl.length) window.document.onkeydown = AccessKey.onKeyDown;
	},

	// handle key event
	onKeyDown: function (evt) {

		if (AccessKey.akl.length) {

			if (evt)
				key = parseInt(evt.keyCode);
			else if (window.event)
				key = parseInt(window.event.keyCode);

			if(key == 18)
				// get alt key
				AccessKey.alt = true;

			else {
				// get command key
				for(a=0; a<AccessKey.akl.length; a++) {
					if(AccessKey.akl[a][0]==key && AccessKey.alt) {
						document.location.href = AccessKey.akl[a][1];
						break;
					}
				}
				AccessKey.alt = false;
			}
		}
	}
};


/**
 * global initialization
 */
function init (evt) {
	// init access keys
	AccessKey.init();

	// init modules
	if (recommend) initRecommend();
	if (contact) initContact();
	if (mail) initMail();
	if (join) initJoin();
}

// set init handler
window.onload = init;