/* ---------------- __js_function.js ----------------- */
/* 													   */
/*	Datei: /js/__js_function.js						   */
/*	Autor: Oliver Wolschke							   */
/*	Datum: 29.06.2008								   */
/*													   */
/* --------------------------------------------------- */
document.write('<link rel="stylesheet" type="text/css" media="screen" href="/css/opacity.css" />');
		
if(!applesearch) var applesearch = {};

if(navigator.userAgent.toLowerCase().indexOf('safari') < 0 && document.getElementById)
{
	this.clearBtn = false;
	document.write('<link rel="stylesheet" type="text/css" media="screen" href="/css/mac.css" />');
}

// called when on user input - toggles clear fld btn
applesearch.onChange = function (fldID, btnID)
{
	// check whether to show delete button
	var fld = document.getElementById( fldID );
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)
	{
		btn.style.background = "white url('/images/srch_r_f2.gif') no-repeat top left";
		btn.fldID = fldID; // btn remembers it's field
		btn.onclick = this.clearBtnClick;
		this.clearBtn = true;
	} else if (fld.value.length == 0 && this.clearBtn)
	{
		btn.style.background = "white url('/images/srch_r.gif') no-repeat top left";
		btn.onclick = null;
		this.clearBtn = false;
	}
}

// clears field
applesearch.clearFld = function (fldID,btnID)
{
	var fld = document.getElementById( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
}

// called by btn.onclick event handler - calls clearFld for this button
applesearch.clearBtnClick = function ()
{
	applesearch.clearFld(this.fldID, this.id);
}

/* Validator
------------------------------------------------------ */
/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* Version 1.5.4.1 (2007-01-05)
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/
var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) {},
			onElementValidate : function(result, elm) {}
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							new Insertion.After(elm, advice);
				    }
					advice = Validation.getAdvice(name, elm);
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
				} else {
					new Effect.Appear(advice, {duration : 1 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte füllen Sie dieses Feld aus.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie nur Ziffern ein.', function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Es sind ausschließlich Buchstaben (a-z) oder Nummern (0-9) erlaubt.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/\W\-/.test(v)
			}],
	['validate-zip', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine korrekte PLZ ein.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  /^[0-9_-]+$/.test(v)
			}],
	['validate-date', 'Please enter a valid date.', function(v) {
				var test = new Date(v);
				return Validation.get('IsEmpty').test(v) || !isNaN(test);
			}],
	['validate-email', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine gültige Emailadresse ein.', function (v) {
				return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
			}],
	['validate-url', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine gültige URL ein. ("http://" muss am Anfang der Domain stehen)', function (v) {
				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
	['validate-selection', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte treffen Sie eine Auswahl.', function(v,elm){
				return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
			}],
	['validate-one-required', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte treffen Sie eine Auswahl.', function (v,elm) {
        var options =  elm.up('form').descendants().collect( function(s) { if (s.tagName == "INPUT" && s.name == elm.name) return s; }).compact();
        return $A(options).any(function(elm) {
          return $F(elm);
        });
      }],
	['validate-phone', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie eine vollständige Telefonnummer ein.', function()
	{
		if(($F('countrycode') == '' && $F('placecode') == '' && $F('number') == '') || ($F('countrycode') != '' && $F('placecode') != '' && $F('number') != ''))		
			return true;	
	}],
	['validate-year-of-construction', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie ein vollständiges Baujahr ein.', function()
	{
		if(($F('month') == '' && $F('year') == '') || ($F('month') != '' && $F('year') != ''))		
			return true;	
	}],
	['validate-minstr', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie mindestens 3 Zeichen ein.', {minLength : 3,include : ['required']}],
	['validate-birthday', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie ein vollständiges Geburtsdatum ein.', function()
	{
		if($F('birthday-day') != '' && $F('birthday-month') != '' && $F('birthday-year') != '')		
			return true;
	}],
	['validate-username', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie mind. 4 Zeichen und maximal 20 Zeichen ein. Es sind ausschließlich alphanumerische Zeichen erlaubt.', {pattern : new RegExp(/^[\d\w]+$/), minLength : 4, maxLength : 20}]
]);

/* Passwortchecker
------------------------------------------------------ */
/**
 * Checks the strength of a password
 * based upon it's length and combination of characters
 * inspired by http://forums.devnetwork.net/viewtopic.php?t=51588
 * thanks to d11wtq -> http://www.w3style.co.uk/~d11wtq/password_checker.html
 * Possibility for german/english added by Petra Stterlin http://www.philognosie.net
 * Made it work in IE by Petra Stterlin http://www.philognosie.net
 */
 
function strengthChecker(outputId)
{
	/**
	 * Id of the node we want to show output in
	 * @var string ID
	 * @private
	 */
	var elementId = outputId;
	/**
	 * An internal timeout.  Gets used in loading
	 * ... possibly pointless.
	 * @var timeout
	 * @private
	 */
	var tm = 0;
	/**
	 * Passwords are given a strength score
	 * @var float score
	 * @private
	 */
	var score = false;
	/**
	 * The current password
	 * @var string password
	 * @private
	 */
	var password = '';
	/**
	 * The actual DOM node for the guage we append
	 * to elementId
	 * @var node gauge
	 * @private
	 */
	var gaugeNode;
	/**
	 * The DOM node for the helper
	 * @var node helper
	 * @private
	 */
	var helperNode;
	/**
	 * The weight given for the various strength enhancers
	 * @var array (float) points
	 * @private
	 */
	var language;
	
	var criteriaPoints = new Array();
	criteriaPoints['CaseChange'] = 3;
	criteriaPoints['Length'] = 1;
	criteriaPoints['SpecialChars'] = 10;
	criteriaPoints['AlphaNum'] = 2.5;
	criteriaPoints['NoNumbers'] = -2;
	criteriaPoints['NoSpecialChars'] = -0.4;
	criteriaPoints['NoLetters'] = -1;
	criteriaPoints['NoCaseChange'] = -0.5;
	criteriaPoints['Duplicates'] = -3;
	criteriaPoints['MinLength'] = -3;
	/**
	 * Passwords should satisfy a minimum length
	 * or they will be penalized
	 * @var int min length
	 * @private
	 */
	var minLength = 8;
	var helperId = false;

	/**
	 * Does the initial loading of the password gauge
	 * upon instantiation if the page is idle
	 * @return void
	 * @private
	 */
	var load = function()
	{
		//The DOM tree may not have finished building yet
		if(document.getElementById(elementId))
		{
			if (score === false) updateOutput();
			if (tm) window.clearTimeout(tm);
		}
		else //If the element doesn't exist, look again in 200ms
			tm = window.setTimeout(function() { load(); }, 200);
	};
	/**
	 * Update what is displayed for the gauge at elementId
	 * @return void
	 * @private
	 */
	var updateOutput = function(language)
	{
		var lgth = '10';
		var txt = '0%';

		if(score < -1 || password.length == 0)
		{
			if( language == 'de' ) txt = '15%';
			else txt = 'Very Weak';
			var lgth = '35';

			if( password.length == 0 )
			{
				txt = '0%';
				var lgth = '10';
			}

		}
		else if (score >= -1 && score < 2.5)
		{
			if( language == 'de' ) txt = '25%';
			else txt = 'Weak';
			var lgth = '65';
		}
		else if (score >= 2.5 && score < 4)
		{
			if( language == 'de' ) txt = '50%';
			else txt = 'Good';
			var lgth = '125';
		}
		else if (score >= 4 && score < 6.75)
		{
			if( language == 'de' ) txt = '75%';
			else txt = 'Strong';
			var lgth = '185';
		}
		else if (score > 6.75)
		{
			if( language == 'de' ) txt = '100%';
			else txt = 'Very Strong';
			var lgth = '250';
		}


		try {
			$(elementId).innerHTML = '';
		} catch (e) {
			//
		}

		//gaugeNode.style.width = '240px';
		//gaugeNode.style.padding= '3px';
		//gaugeNode.style.backgroundColor = color;
		//gaugeNode.style.color = '#FFF';
		//gaugeNode.style.border = '1px solid #CCC';
		//gaugeNode.style.borderTop = '2px solid #666';
		//gaugeNode.style.borderLeft = '2px solid #666';
		$(elementId).style.width = lgth + 'px';
		$(elementId).innerHTML = txt;
	};
	/**
	 * Reads a new password and then gives it a score
	 * The password gauge is then updated
	 * @param string password value
	 * @return float score
	 */
	this.check = function(v,lang)
	{
		password = v;
		language = lang;
		score = 0;
		//Score based upon length
		var lengthPoints = criteriaPoints['Length'];
		var multiplier = lengthPoints;
		for (i = 0; i < v.length; i++) //Non-linear
		{
			score += lengthPoints;
			if (i < minLength) lengthPoints *= 0.8;
			multiplier *= 0.8;
		}
		//Use this as a factor in subsequent point additions
		var multiplier = lengthPoints;

		var collected = new Array();
		var lower = 0;
		var upper = 0;
		var numbers = 0;
		var specialChars = 0;
		var duplicates = 0;
		var lettersOnly = '';
		var numbersOnly = '';
		var charsOnly = '';
		for (var i = 0; i < v.length; i++)
		{
			var letter = v.substr(i, 1);
			if(collected.hasValue(letter)) duplicates++;

			collected.push(letter);
			if(letter.match(/[a-z]/))
			{
				lettersOnly += letter;
				lower++;
			}
			else if(letter.match(/[A-Z]/))
			{
				lettersOnly += letter;
				upper++;
			}
			else if(letter.match(/\d/))
			{
				numbersOnly += letter;
				numbers++;
			}
			else if(letter.match(/\W/))
			{
				charsOnly += letter;
				specialChars++;
			}
		}
		//Points based upon case change
		var caseDiff = Math.abs(upper - lower);
		score += parseFloat((lettersOnly.length - caseDiff) * criteriaPoints['CaseChange'] * multiplier);
		//Alpha Numeric Points
		var alphaNumDiff = Math.abs(upper+lower - numbers);
		score += parseFloat(((lettersOnly.length + numbersOnly.length) - alphaNumDiff) * criteriaPoints['AlphaNum'] * multiplier);
		//Special Character Points
		score += parseFloat(specialChars * criteriaPoints['SpecialChars'] * multiplier);
		//Penalise for lack of numbers
		if(!numbers)
			score += parseFloat(v.length * criteriaPoints['NoNumbers'] * multiplier);
		//Penalise for lack of letters
		if(!lower && !upper)
			score += parseFloat(v.length * criteriaPoints['NoLetters'] * multiplier);
		//Penalise for lack of special chars
		if(!specialChars)
			score += parseFloat(v.length * criteriaPoints['NoSpecialChars'] * multiplier);
		//Penalise for lack of changing case
		if((upper || lower) && (!upper || !lower))
			score += parseFloat(v.length * criteriaPoints['NoCaseChange'] * multiplier);
		//Penalise for duplicate chars
		score += parseFloat(duplicates * criteriaPoints['Duplicates'] * multiplier);
		//Penalise for PW being too short
		score += parseFloat((minLength - v.length) * multiplier * criteriaPoints['MinLength']);

		//Now update the gauge
		updateOutput(language);
		if(helperId) showHelper((v.length >= minLength), numbers, (lower + upper), specialChars, !((upper || lower) && (!upper || !lower)), !duplicates, language);
		return score;
	};
	/**
	 * Show a helper check-list for the user
	 * @param bool length OK
	 * @param bool contains numbers
	 * @param bool contains letters
	 * @param bool contain special chars
	 * @param bool mixed case
	 * @param bool contains duplicates
	 * @return void
	 */
	var showHelper = function(len, numbers, letters, special, caseChange, duplicates, language)
	{
		try {
			document.getElementById(helperId).removeChild(helperNode);
		} catch(e) {
			//
		}

		helperNode = document.createElement('p');
		if( language == 'de' ) var questiontext = document.createTextNode('Sie können Ihr Passwort sicherer machen, indem Sie:');
		else var questiontext = document.createTextNode('Make your password stronger:');
		helperNode.appendChild(questiontext);

		var ul = document.createElement('ul');
		helperNode.appendChild(ul);

		//helperNode = document.createElement('ul');


		var rows = new Array();
		if (!len)
		{
			var li = document.createElement('li');
			if( language == 'de' ) li.innerHTML = 'z.B. mehr als ' + minLength +' Zeichen verwenden';
			else li.innerHTML = 'use not less than' + minLength +' characters)';
			ul.appendChild(li);
		}
		if (!numbers)
		{
			li = document.createElement('li');
			if(language == 'de') li.innerHTML = 'z.B. Zahlen einfügen';
			else li.innerHTML = 'use numbers';
			ul.appendChild(li);
		}
		if (!letters)
		{
			li = document.createElement('li');
			if(language == 'de') li.innerHTML = 'z.B. Buchstaben einfügen';
			else li.innerHTML = 'use letters';
			ul.appendChild(li);
		}
		if (!special)
		{
			li = document.createElement('li');
			if(language == 'de') li.innerHTML = 'z.B. Sonderzeichen einfügen';
			else li.innerHTML = 'use special characters';
			ul.appendChild(li);
		}
		if (!caseChange)
		{
			li = document.createElement('li');
			if( language == 'de' ) li.innerHTML = 'z.B. Groß- und Kleinbuchstaben mischen';
			else li.innerHTML = 'chose different cases';
			ul.appendChild(li);
		}
		if (!duplicates)
		{
			li = document.createElement('li');
			if( language == 'de' ) li.innerHTML = 'z.B. jedes Zeichen nur einmal verwenden';
			else li.innerHTML = 'use characters once only';
			ul.appendChild(li);
		}

		document.getElementById(helperId).appendChild(helperNode);
	};
	/**
	 * Allow the user to change the points weightings
	 * @param string criteria (See criteriaPoints)
	 * @param float points
	 * @return bool successful
	 */
	this.setPoints = function(criteria, pnts)
	{
		if(criteriaPoints[criteria])
		{
			criteriaPoints[criteria] = parseFloat(pnts);
			return true;
		}
		else return false;
	};
	/**
	 * Specify the minimum length of a "strong" password
	 * defaults to 8
	 * @param int length
	 * @return void
	 */
	this.setMinLength = function(len)
	{
		minLength = parseInt(len);
	};
	/**
	 * Display a helper dialog
	 * @param string helperNode id
	 * @return void
	 */
	this.setHelperId = function(helper)
	{
		helperId = helper;
	};

	//At end of instantiation load the gauge
	load();

	//Just comes in useful
	if (!Array.hasValue)
	{
		Array.prototype.hasValue = function(v)
		{
			for(var i in this)
			{
				if(this[i] == v) return true;
			}
			return false;
		}
	}
}

var pw = new strengthChecker('security');
pw.setHelperId('helper');


/* Cookies
------------------------------------------------------ */
function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

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));
}

/* Selectfelder sortieren
------------------------------------------------------ */
function sortSelect(addId,removeId)
{
	var nodeAdd = $(addId);
	var nodeRemove = $(removeId);
	var option = new Array();
	
	this.add = function()
	{	
		for(var i=0;i<nodeRemove.options.length;i++)
		{
			if(nodeRemove.options[i].selected == true)
			{
				option[i] = new Option(nodeRemove.options[i].text,nodeRemove.options[i].value);
				nodeAdd.options[nodeAdd.options.length] = option[i];
				nodeRemove.options[i] = null;
				this.add();
			}
		}
	}
	
	this.remove = function()
	{
		for(var i=0;i<nodeAdd.options.length;i++)
		{
			if(nodeAdd.options[i].selected == true)
			{
				option[i] = new Option(nodeAdd.options[i].text,nodeAdd.options[i].value);
				nodeRemove.options[nodeRemove.options.length] = option[i];
				nodeAdd.options[i] = null;
				this.remove();
			}
		}
	}
}

/* Checkboxen prüfen/checken
------------------------------------------------------ */
function checklist(id,allId)
{
	var fields = $(id).getElementsByTagName('input');
	
	/* Checkt welchen Status eine Checkbox erhält
	*/
	var check = function()
	{
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.disabled != true)
				field.checked = check;
		}
	}
	
	/*  Für die untergeordneten Checkboxen
		Hier wird überprüft, ob alle angeklickt oder nicht angeklickt sind,
		demnach wird entschieden welchen Status die Haupt-Checkbox erhält
	*/
	this.checkbox = function()
	{
		var allchecked = true;
		
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.id != allId && field.disabled != true)
			{
				if(!field.checked)
					allchecked = false;
			}
		}
		$(allId).checked = allchecked;
	}
	
	/* Haupt-Checkbox wählt alle aus oder nicht aus
	*/
	this.checkAll = function(status)
	{
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.id != allId && field.disabled != true)
				field.checked = status;
		}
	}
	
	/*  Prüft ob mind. eine Checkbox aktiv ist, um eine Aktion durchzuführen
		gibt true oder false zurück
	*/
	this.selected = function()
	{
		for(i=0;i<fields.length;i++)
		{
			var field = fields[i];
			if(field.type == 'checkbox' && field.disabled != true)
			{
				if(field.checked)
				{
					return true;
					break;
				}
			}
		}
		return false;
	}
}

/* Slider
------------------------------------------------------ */
/******************************************
* Slider Bar Form Element Script
* 
* Original program copyright David Harrison
*   d_s_h2@hotmail.com
* Version 2 copyright Eric C. Davis
*   eric@10mar2001.com
* 
* Visit http://www.dynamicdrive.com for
*   loads of other scripts.
* 
* This notice MUST stay intact for use.
*
* Modified by Tom Westcott
* http://www.cyberdummy.co.uk
******************************************/

var x, lgap,
	pel = null;

function newValue(value, tag)
{
	el = $(tag);
	var i = (Number(value));
	el2 = $(tag + "out");
	width = (el2.style.width.replace(/\D/g,"") - 11);
	if(i > width) i = width;
	if(i < 0) i = 0;
	el.style.marginLeft = i + "px";
	el.inputElement.value = i;
}

function mousetracker(event)
{
	if(!event)
		event = window.event;
		
	x = event.clientX;
	if(pel != null)
	{
		var width = pel.sliderWidth;
		pel.style.marginLeft = (((lgap + x) > width) ? width : (((lgap + x) < 0) ? 0 : lgap + x )) + 'px'; //>
		pel.inputElement.value = pel.style.marginLeft.replace(/\D/g,'');
		pel.inputElement.onDrag();
	}
}

function track()
{
	pel = this;
	// added this so it mouse strays from the drag tab mouse up still releases it
	if(document.addEventListener)
		document.addEventListener('mouseup', stop, false);
    else
		document.onmouseup = stop;
		
	// pel.inputElement.onDragStart();
	lgap = parseInt(pel.style.marginLeft.replace(/\D/g,""));
	if(isNaN(lgap))
		lgap = 0;
		
	lgap -= x;
}

function stop()
{
	pel.inputElement.onDragStop();
	pel = null;

	if(document.removeEventListener)
		document.removeEventListener('mouseup', stop, false);
    else
		document.onmouseup = null;
}

function form_slider(el,width)
{
	var wid = parseInt(width);
	var newEl = document.createElement("input");
	newEl.type = "hidden";
	var outDiv = document.createElement("div");
	outDiv.className = "move";
	outDiv.style.width = (wid+11) + "px";
	outDiv.id = el.id + "out";
	var inDiv = document.createElement("div");
	inDiv.className = "move2";
	inDiv.id = el.id + "in";
	var slider = document.createElement("div");
	slider.className = el.className;
	slider.id = el.id;
	// convert original form element to new form element
	for(key in el)
	{
		try
		{
			newEl[key] = el[key];
		}
		catch (er)
		{
			// whoops! Can't assign that property.
		}
	}
	newEl.type = "hidden";
	newEl.className = "";
	newEl.name = el.name;
	newEl.id = el.id + "hidden";
	// assign persistent properties to slider div
	slider.inputElement	= newEl;
	slider.sliderWidth 	= wid;
	// assign events
	if(slider.addEventListener)
	{
		slider.addEventListener('mousedown', track, false);
		slider.addEventListener('mouseup', stop, false);
	}
	else
	{
		slider.onmousedown = track;
		slider.onmouseup = stop;
	}
	// put the new elements in the document
	outDiv.appendChild(inDiv);
	outDiv.appendChild(slider);
	value = el.value;
	id = el.id;
	el.parentNode.insertBefore(outDiv, el);
	// remove the old element before inserting the new element
	el.parentNode.removeChild(el);
	outDiv.parentNode.insertBefore(newEl, outDiv);
	if(value > 0)
	{
		newValue(value, id);
	}
}

if(window.addEventListener)
{
	document.addEventListener('mousemove', mousetracker, false);
}
else if(window.attachEvent)
{
	document.attachEvent('onmousemove', mousetracker);
}
else
{
	document.onmousemove = mousetracker;
}

/* Fadeeffekt
------------------------------------------------------ */
/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/

var imgs = new Array(), zInterval = null, current = 0, pause = false;

function fade_init()
{
	if(!$ || !document.createElement)
		return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	imgs = $('fade').getElementsByTagName('img');
	for(i=1;i<imgs.length;i++)
		imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;
	
	setTimeout(fade,7000);
}

function fade()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1] ? current + 1 : 0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity -= .05; 
	nOpacity += .05;
	
	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity <= 0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(fade,7000);
	}
	else
		setTimeout(fade,130);
	
	function setOpacity(obj)
	{
		if(obj.xOpacity > .99)
		{
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity * 100) + ")";
	}
}

/* onclick simulieren
------------------------------------------------------ */
function simulateClick(obj)
{
	var ua = navigator.userAgent;
	
	if(ua.indexOf("MSIE") >=0)
	{
		obj.click();
	}
	else
	{
		var evt = document.createEvent("MouseEvents");
		evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
		var cb = obj; 
		cb.dispatchEvent(evt);
	}
}


/* in_array
------------------------------------------------------ */
Array.prototype.contains = function(elem)
{
  	var i;
  	for(i = 0; i < this.length; i++)
	{
    	if (this[i] == elem)
		{
      		return true;
    	}
  	}

  	return false;
};

/* Array-Wert löschen
------------------------------------------------------ */
Array.prototype.array_value_delete = function(position)
{
	for(var x = 0; x < this.length; ++x)
	{
		if (x >= position)
		{
			this[x] = this[x + 1];
		}
	}
	this.pop();
};

/* Transparenz
------------------------------------------------------ */
var IE = document.all && !window.opera;
var DOM = document.getElementById && !IE

function setTransparency(strID,intWert)
{
	// Objekt holen
	var myObj = (IE)?document.all[strID]:document.getElementById(strID);

	// Falls es sich um den IE handelt
	if(IE)
	{
    	// Transparenz-Wert anpassen
    	intWert *= 100;
    	// Transparenz setzen
    	myObj.style.filter = "alpha(opacity="+intWert+")";
  	}

  	// Falls es sich um einen Mozilla handelt (ohne den Opera)
  	if(DOM && !window.opera)
	{
    	// Transparenz setzen
    	myObj.style.MozOpacity = intWert;
  	}
}

/* Form Hints
------------------------------------------------------ */
Form.Hints=function(){var REG_EXP=/[\r\n]/g;var HINT_COLOR="#999";return Class.create({initialize:function(form,hints){this._form=$(form);this._hints=hints||{};this._events={focus:this._onFocus.bind(this),blur:this._onBlur.bind(this),set:this.setInputs.bind(this),reset:this.resetInputs.bind(this)};this._observeForm();this._observeInputs();this.setInputs();},_observeForm:function(){this._form.observe("reset",this._events.set);this._form.observe("submit",this._events.reset);},_observeInputs:function(){for(var name in this._hints){var input=$(this._form[name]);input.observe("focus",this._events.focus);input.observe("blur",this._events.blur);}},setInputs:function(){for(var name in this._hints){var input=$(this._form[name]);var hint=this._hints[input.name].replace(REG_EXP,"");var value=input.value.replace(REG_EXP,"");if(!value||value==hint){input.setStyle({color:HINT_COLOR});input.value=this._hints[name];this._hints[name]=input.value;}else{input.setStyle({color:""});}}},resetInputs:function(){for(var name in this._hints){var input=$(this._form[name]);var hint=this._hints[input.name].replace(REG_EXP,"");var value=input.value.replace(REG_EXP,"");if(value==hint){input.setStyle({color:""}).clear();}}},restoreHints:function(input){if(!input.present()){input.setStyle({color:HINT_COLOR});input.value=this._hints[input.name];this._hints[input.name]=input.value;}},_onBlur:function(event){this.restoreHints(Event.element(event));},_onFocus:function(event){var input=Event.element(event);if(this._hints[input.name]){var hint=this._hints[input.name].replace(REG_EXP,'');var value=input.value.replace(REG_EXP,'');if(value==hint){input.setStyle({color:""}).clear();}}}});}();

/* Textarea Maxlength
------------------------------------------------------ */
function TxtareaMaxlength(id,len)
{
	var elTextarea = $(id);
	var elCountTarget = $$('.countchars').first();
	var maxLength = Number(len);
		
	elCountTarget.innerHTML = Number(maxLength) + ' ';
		
	elTextarea.observe('keyup', function ()
	{
		if(elTextarea.value.length >= maxLength)
		{
			elTextarea.value = elTextarea.value.substring(0,maxLength);
			elCountTarget.innerHTML = '0';
		}
		else
		{
			elCountTarget.innerHTML = Number(maxLength-elTextarea.value.length) + ' ';
		}
	})
		
	if(elTextarea.value.length >= maxLength)
	{
		elTextarea.value = elTextarea.value.substring(0,maxLength);
		elCountTarget.innerHTML = '0';
	}
	else
	{
		elCountTarget.innerHTML = Number(maxLength - elTextarea.value.length) + ' ';
	}
}

/* Tabs
------------------------------------------------------ */
var Tabs = Class.create({
	initialize: function(element,options)
	{
		this.element = element;
		
		this.options = Object.extend({
			updater: false,
			container: 'container'
		}, options || {});
	},
	href: function(obj,content)
	{
		var menu = $(this.element).select('li');
		menu.each(function(elm)
		{
			if(elm.className != 'option')
				elm.className = '';
		});
		
		var parent = obj.parentNode;
		parent.className = 'select';
		
		new Ajax.Updater(this.options.container,this.options.updater,
		{
			method: 'post',
			parameters: 'content='+content,
			evalScripts: true,
			onCreate: function()
			{
				$(this.options.container).update('<img src="/images/__img_loader.gif" width="16" height="16" alt="lädt..." /><span class="tr"></span><span class="br"></span><span class="bl"></span>');
			}.bind(this)
		});
	}
});

/* Profile
------------------------------------------------------ */
var Profile = Class.create({
	initialize: function(id,options)
	{
		this.id = id;
		
		/*this.options = Object.extend({
			
		}, options || {});*/
	},
	edit: function(id,params)
	{
		new Ajax.Updater(id,'/Profile/'+this.id,
		{
			method: 'post',
			parameters: params+'&id='+id,
			evalScripts: true,
			onCreate: function()
			{
				$(id).update('<img src="/images/__img_loader.gif" width="16" height="16" alt="lädt..." />');
				if($('container-'+id))
					$('container-'+id).setStyle({'background':'#FFFFCC'});
				else
					$(id).setStyle({'background':'#FFFFCC'});
			},
			onSuccess: function()
			{
				$$('.edit').invoke('setStyle',{'visibility':'hidden'});
				$$('.add').invoke('setStyle',{'display':'none'});
			}
		});
	},
	cancel: function(id,params)
	{
		new Ajax.Updater(id,'/Profile/'+this.id,
		{
			method: 'post',
			parameters: params,
			evalScripts: true,
			onCreate: function()
			{
				$(id).update('<img src="/images/__img_loader.gif" width="16" height="16" alt="lädt..." />');
				if($('container-'+id))
					$('container-'+id).setStyle({'background':'#FFF'});
				else
					$(id).setStyle({'background':'#FFF'});
			},
			onSuccess: function()
			{
				$$('.edit').invoke('setStyle',{'visibility':'visible'});
				$$('.add').invoke('setStyle',{'display':'block'});
				$('add-new-business').hide();
				$('add-new-business').update('<img src="/images/__img_loader.gif" width="16" height="16" alt="lädt..." />');
			}
		});
	},
	save: function(id,params,remove)
	{
		new Ajax.Updater(id,'/Profile/'+this.id,
		{
			method: 'post',
			parameters: params,
			evalScripts: true,
			onCreate: function()
			{
				$(id).update('<img src="/images/__img_loader.gif" width="16" height="16" alt="lädt..." />');
				if($('container-'+id))
					var element = 'container-'+id;
					/*$('container-'+id).setStyle({'background':'#FFF'});*/
				else
					var element = id;
					
				new Effect.Highlight(element,
				{
					startcolor: '#ffffcc',
					endcolor: '#ffffff',
					restorecolor: '#ffffff',
					keepBackgroundImage: false
				});
			},
			onSuccess: function()
			{
				$$('.edit').invoke('setStyle',{'visibility':'visible'});
				$$('.add').invoke('setStyle',{'display':'block'});
				if(remove != '')
					$(remove).remove();
			}
		});
	}
});

function chkUsername(form,id)
{
	new Ajax.Request('/Setup', {
		method: 'post',
		parameters: form+'&op=chk-username',
		onSuccess: function(request)
		{
			var json = request.responseText;
			var result = eval ("(" + json + ")");	
			if(result.resUsername > 0)
			{
				Validation.add('validate-username', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Dieser Benutzername wird bereits verwendet.', 			
				{
					isNot : $('username').value
				});
			}
			else
			{
				Validation.add('validate-username', '<img src="/images/__icn_error.gif" width="16" height="16" alt="Fehler" class="middle" />Bitte geben Sie mind. 4 Zeichen und maximal 20 Zeichen ein. Es sind ausschließlich alphanumerische Zeichen erlaubt.', 			
				{
					pattern : new RegExp(/^[\d\w]+$/), minLength : 4, maxLength : 20
				});
			}
			
			if(new Validation('edit-setup').validate() == true)
			{
				profile.save(id,form);
				window.location.reload();
			}
		}
	});
}

var startDate;

// Countdown
function countdown()
{	
	var countdown = '';
	
	new Ajax.Request('/Events',
	{
		method: 'post',
		parameters: 'op=counter',
		onSuccess: function(request)
		{
			var json = request.responseText;
			// alert(json);
			var result = eval ("(" + json + ")");
			startDate = new Date(result.y,result.m,result.d,result.h,result.i,result.s);
			
			// Countdown berechnen und anzeigen, bis Ziel-Datum erreicht ist
			if(startDate < endDate)
			{
				var year = 0, month = 0, day = 0, hour = 0, minute = 0, sec = 0;
				
				while(startDate < endDate)
				{
					year++;
					startDate.setFullYear(startDate.getFullYear()+1);
				}
				
				startDate.setFullYear(startDate.getFullYear()-1);
				year--;
				
				while(startDate < endDate)
				{
					month++;
					startDate.setMonth(startDate.getMonth()+1);
				}
				
				startDate.setMonth(startDate.getMonth()-1);
				month--;
				
				while(startDate.getTime()+(24*60*60*1000) < endDate)
				{
					day++;
					startDate.setTime(startDate.getTime()+(24*60*60*1000));
				}
				
				hour = Math.floor((endDate-startDate)/(60*60*1000));
				startDate.setTime(startDate.getTime() + hour*60*60*1000);
				
				minute = Math.floor((endDate-startDate)/(60*1000));
				startDate.setTime(startDate.getTime() + minute*60*1000);
				
				sec = Math.floor((endDate-startDate)/1000);
				
				if(year > 0)
					countdown = year != 1 ? year +" J&nbsp; " : year + " J&nbsp; ";
				if(month > 0 || year > 0)
					countdown += month != 1 ? month + " M&nbsp; " : month +" M&nbsp; ";
				if(day > 0 || month > 0 || year > 0)
					countdown += day != 1 ? day + " T&nbsp; " : day + " T&nbsp; ";
				if(hour > 0 || day > 0 || month > 0 || year > 0)
					countdown += hour != 1 ? hour + " Std&nbsp; " : hour + " Std&nbsp; ";
				if(minute > 0)
					countdown += minute != 1 ? minute + " Min&nbsp; " : minute + " Min&nbsp; ";
				
				if(sec < 10)
					countdown += "0";
				countdown += sec != 1 ? sec + " Sek" : sec + " Sek";
				
				$('countdown').update(countdown);
				setTimeout('countdown()',200);
			}
			else
			{
				// window.location.reload();
			}
		}
	});
}

var Tooltip = Class.create({
	initialize: function(tooltip,options)
	{
		this.id = tooltip;
		
		this.options = Object.extend({
			link: '',
			tooltip_inner: '',
			tooltip_inner_link: '',
			tooltip_inner_params: ''
		}, options || {});

		
		Event.observe(this.options.link,'mouseover',this._show.bind(this));
		Event.observe(this.options.link,'mouseout',this._hide.bind(this));
	},
	_show: function()
	{
		this._update.bind(this);
		Event.observe(document,'mousemove',this._update.bind(this));
		$(this.id).show();
		if(this.options.tooltip_inner != '')
		{
			this.insert();
		}
	},
	_hide: function()
	{
		Event.stopObserving(document);
		$(this.id).hide();
	},
	_update: function(e)
	{
		if($(this.id) != null)
		{
			if(!e)
				var e = window.event || window.Event;
			
			if('undefined' != typeof e.pageX)
			{
				x = e.pageX;
				y = e.pageY;
			}
			else
			{
				x = e.clientX + document.body.scrollLeft;
				y = e.clientY + document.body.scrollTop;
			}
			var size = this.getWinSize();
			var scroll = this.getScrollXY();

			$(this.id).style.left = (x + 20) + 'px';
			
			if(((y-scroll[1])+$(this.id).offsetHeight) >= size.h)
				$(this.id).style.top = ((y + 10)-$(this.id).offsetHeight) + 'px';
			else
				$(this.id).style.top = (y + 20) + 'px';
		}
	},
	insert: function()
	{
		new Ajax.Updater(this.options.tooltip_inner,this.options.tooltip_inner_link,
		{
			method: 'post',
			parameters: this.options.tooltip_inner_params,
			onCreate: function()
			{
				$(this.options.tooltip_inner).update('<img src="/images/__img_loader_4.gif" width="16" height="16" alt="lädt..." />');
			}.bind(this)
		});
	},
	getWinSize: function(win)
	{
		if(!win) win = window;
		var pos = {x:0,y:0};
		if(typeof win.innerWidth != 'undefined')
		{
			pos.w = win.innerWidth;
			pos.h = win.innerHeight;
		}
		else if(win.document.body)
		{
			pos.w = parseInt(win.document.body.clientWidth);
			pos.h = parseInt(win.document.body.clientHeight);
		}
		/*pos.w = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
		pos.h = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);*/

		return pos;
	},
	getScrollXY: function()
	{
		var scrOfX = 0, scrOfY = 0;
		
		if(typeof( window.pageYOffset ) == 'number')
		{
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		}
		else if(document.body && (document.body.scrollLeft || document.body.scrollTop))
		{
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		}
		else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
		{
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		return [scrOfX,scrOfY];
	}
});