var DomLoaded =
{
	onload: [],
	loaded: function()
	{
		if (arguments.callee.done) return;
		arguments.callee.done = true;
		for (i = 0;i < DomLoaded.onload.length;i++) DomLoaded.onload[i]();
	},
	load: function(fireThis)
	{
		this.onload.push(fireThis);
		if (document.addEventListener) 
			document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
		if (/KHTML|WebKit/i.test(navigator.userAgent))
		{ 
			var _timer = setInterval(function()
			{
				if (/loaded|complete/.test(document.readyState))
				{
					clearInterval(_timer);
					delete _timer;
					DomLoaded.loaded();
				}
			}, 10);
		}
		/*@cc_on @*/
		/*@if (@_win32)
		var proto = "src='javascript:void(0)'";
		if (location.protocol == "https:") proto = "src=//0";
		document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DomLoaded.loaded();
		    }
		};
		/*@end @*/
	   window.onload = DomLoaded.loaded;
	}
};

var iGewinne = 0;
var iGewinner = 0;
var bGewinne = true;
var bGewinner = true;
var bGewinneMovement = true;
var bGewinnerMovement = true;
var speed = 10;

function initSlides() {
	if (document.getElementById('Gewinne')) {
		gewinne();
	}
	if (document.getElementById('Gewinner')) {
		gewinner();
	}
}

function setGewinneMovement(direction) {
	if (direction == 'left') {
		bGewinneMovement = true;
	} else {
		bGewinneMovement = false;
	}
}

function setGewinnerMovement(direction) {
	if (direction == 'left') {
		bGewinnerMovement = true;
	} else {
		bGewinnerMovement = false;
	}
}

function startStopGewinne() {
	if (bGewinne) {
		bGewinne = !bGewinne;
	} else {
		bGewinne = !bGewinne;
	}
}

function startStopGewinner() {
	if (bGewinner) {
		bGewinner = !bGewinner;
	} else {
		bGewinner = !bGewinner;
	}
}

function gewinne() {
	if (iGewinne >= 965) {
		iGewinne = 0;
	}
	if (iGewinne < 0) {
		iGewinne = 965;
	}
	if (bGewinne) {
		if (bGewinneMovement) {
			iGewinne = iGewinne + 1;
		} else {
			iGewinne = iGewinne - 1;
		}
	}
	document.getElementById('Gewinne').style.right = iGewinne + 'px';
	window.setTimeout("gewinne()", speed);
}

function gewinner() {
	if(iGewinner >= 826) {
		iGewinner = 0;
	}
	if (iGewinner < 0) {
		iGewinner = 826;
	}
	if (bGewinner) {
		if (bGewinnerMovement) {
			iGewinner = iGewinner + 1;
		} else {
			iGewinner = iGewinner - 1;
		}
	}
	document.getElementById('Gewinner').style.right = iGewinner + 'px';
	window.setTimeout("gewinner()", speed);
}

function addBookmark(title, url) {
	if (window.sidebar) { // firefox
		alert("Bitte druecken sie Strg + D um das Lesezeichen zu erstellen");
	} else if( document.all ) { //MSIE
		window.external.AddFavorite( url, title);
	} else {
		alert("Leider unterstuetzt ihr Browser diese Funktion nicht. Legen Sie bitte ein Lesezeichen per Hand an.");
	}
}

function openBlank(href) {
    // aufruf: onclick="return openBlank(this);"
    return !open(href, "_blank");
}

/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* JsPopUp 1.0
* Opening Browser-Windows the unobtrusive way
* Dirk Ginader
* www.ginader.de
* dirk@ginader.de
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* degrades nicely, unbobtrusive
* succesfully testet in:
* Windows
* * Firefox 2.0
* * Firefox 1.5
* * IE 7
* * IE 6
* * IE 5.5
* * IE 5.01
* * Opera 8.02
* MAC OS X
* * Firefox 1.5
* * Safari 2.03
* * IE 5.02 MAC 
* Linux (Ubuntu)
* * Firefox 1.07
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* USAGE in the Head of an HTML-Page: 
<script language="JavaScript" type="text/javascript" src="JsPopUpClass/popup.js"></script>
<script type="text/javascript">
window.onload = function(){ // Better use use a modern onDomReady-Event instead
	if(document.getElementById && document.getElementsByTagName){ // Check DOM
		popup = new PopUp(); // create new PopUp-Instance
		popup.addType({ // add a additional type with custom Properties
			name: "pdf",
			width: 1024,
			height: 706,
			location:true
		});
		popup.apply(); // Apply Popup-Behavior to all Links using the Class "popup"		
		//popup.open("http://www.webkrauts.de"); // call open Method onload to open popup directly
		//popup.open("http://www.webkrauts.de","pdf"); // 2nd Param optional to define a special type
	}
}
</script>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* USAGE in the Body of an HTML-Page:
<p><a class="popup" href="http://www.ginader.de">Ich</a> bin nur ein Link mit der Klasse "popup"</p>
<p>Ich <a class="popup pdf" href="http://www.webkrauts.de">bin</a> nur ein Link mit der Klasse"popup" und der Klasse "pdf" </p>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* License:
* This file is entirely BSD licensed.

* More information:
* http://blog.ginader.de/dev/popup.html
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* CHANGELOG:
1.0 Initial Version
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
*/
PopUp = function(autoapply){
	this.types = [];
	this.defaults = {
		width:800,
		height:600,
		top:0,
		left:0,
		location:false,
		resizable:false,
		scrollbars:false,
		status:false,
		toolbar:false,
		menubar:false,
		center:true,
		title:""
	}
	this.addType({
		name:"standard",
		location:true,
		resizable:true,
		scrollbars:true,
		status:true,
		toolbar:true,
		menubar:true
    });
	if(autoapply) this.apply();
}
o = PopUp.prototype;
o.apply = function(){
	var links = document.getElementsByTagName("a");
	if(!links) return;
	for(var i=0;i<links.length;i++){
		var l = links[i];
		if(l.className.indexOf("popup") > -1){
			this.attachBehavior(l,this.getType(l));
		}
	}
}
o.addType = function(type){
	for(var prop in this.defaults){
		if(type[prop] == undefined) type[prop] = this.defaults[prop];
	}
	this.types[type.name] = type;
}
o.getType = function(l){
	for(var type in this.types){
		if(l.className.indexOf(type) > -1) return type;
	}
	return "standard";
}
o.attachBehavior = function(l,type){
	var t = this.types[type];
	l.title = t.title;
	l.popupProperties = {
		type: type,
		ref: this
	};
	l.onclick = function(){
		this.popupProperties.ref.open(this.href,this.popupProperties.type);
		return false;
	}
}
o.booleanToWord = function(bool){
	if(bool) return "yes";
	return "no";
}
o.getTopLeftCentered = function(typeObj){
	var t = typeObj;
	var r = {left:t.left, top:t.top};
	var sh = screen.availHeight-20;
	var sw = screen.availWidth-10;
	if(!sh || !sw) return r;
	r.left = (sw/2)-(t.width/2);
	r.top = (sh/2)-(t.height/2);
	return r;
}
o.getParamsOfType = function(typeObj){
	var t = typeObj;
	var c = this.booleanToWord;
	if(t.center){
		var tc = this.getTopLeftCentered(typeObj);
		t.left = tc.left;
		t.top = tc.top;
	}
	var p = "width="+t.width;
	p+=",height="+t.height;
	p+=",left="+t.left;
	p+=",top="+t.top;
	p+=",location="+c(t.location);
	p+=",resizable="+c(t.resizable);
	p+=",scrollbars="+c(t.scrollbars);
	p+=",status="+c(t.status);
	p+=",toolbar="+c(t.toolbar);
	p+=",menubar="+c(t.menubar);
	return p;
}
o.open = function(url,type){
	if(!type) type = "standard";
	var t = this.types[type];
	var p = this.getParamsOfType(t);
	var w = window.open(url,t.name,p);
	if(w) w.focus();
	return false;
}
/*** usage ***/
DomLoaded.load(function(){
  if(window.location.search != '?noscript'){
    if(document.getElementById && document.getElementsByTagName){ // DOM available?
      popup = new PopUp();
      popup.addType({
        name: "pdf",
        width: 800,
        height: 900,
        location: true,
        title:""
      });
      popup.addType({
        name: "druck",
        width: 600,
        height: 400,
        status: false,
        toolbar: false,
        menubar: false,
        location: false,
        title:""
      });
      popup.addType({
        name: "nachweis",
        width: 800,
        height: 600,
        status: false,
        toolbar: false,
        menubar: false,
        location: false,
        scrollbars: true,
        title:""
      });
      popup.addType({
        name: "static",
        width: 600,
        height: 400,
        status: false,
        toolbar: false,
        menubar: false,
        location: false,
        scrollbars: true,
        title:""
      });
      popup.addType({
        name: "dooyoo",
        width: 477,
        height: 600,
        status: false,
        toolbar: false,
        menubar: false,
        location: false,
        scrollbars: true,
        title:""
      });
      popup.addType({
        name: "garantie",
        width: 350,
        height: 250,
        status: false,
        toolbar: false,
        menubar: false,
        location: false,
        scrollbars:false,
        title:""
      });
      popup.addType({
        name: "topCampaign",
        width: 600,
        height: 400,
        status: false,
        scrollbars: true,
        toolbar: false,
        menubar: false,
        location: false,
        title:""
      });
      popup.addType({
        name: "teilnahmenw",
        width: 485,
        height: 437,
        status: false,
        scrollbars: false,
        toolbar: false,
        menubar: false,
        location: false,
        title:""
      });
      popup.apply();
    }
  }
});

/*** cookiecheck 
// remember, these are the possible parameters for Set_Cookie:
// name, value, expires, path, domain, secure
Set_Cookie( 'test', 'none', '', '/', '', '' );
// if Get_Cookie succeeds, cookies are enabled, since
//the cookie was successfully created.
if ( Get_Cookie( 'test' ) )
{
    document.write( 'cookies are currently enabled.' );
    //
    this is an example of a set cookie variable, if
    you want to use this on the page or on another script
    instead of writing to the page you would just check that value
    for true or false and then do what you need to do.
    //
    cookie_set = true;
    // and these are the parameters for Delete_Cookie:
    // name, path, domain
    // make sure you use the same parameters in Set and Delete Cookie.
    Delete_Cookie('test', '/', '');
}
//if the Get_Cookie test fails, cookies
//are not enabled for this session.
else
{
    document.write( 'cookies are not currently enabled.' );
    cookie_set = false;
}
*/


function toogleCCForm() {
    var form = document.getElementById('ccForm1').style.display == 'none' ? 'block' : 'none';
    var frage = document.getElementById('ccLink').style.display == 'none' ? 'block' : 'none';
    document.getElementById('ccForm1').style.display=form;
    document.getElementById('ccForm2').style.display=form;
    document.getElementById('ccText').style.display=form;
    document.getElementById('ccLink').style.display=frage;
}

/**
 * Laedt die uebergebenen Bilder in den Cache
 *
 * @param array pathArray Array mit Pfaden der zu ladenen Bilder
 */
function ImagePreloader (pathArray) {

	//Array mit Pfaden der zu ladenen Bilder
	this.pathArray = pathArray;

	//Array mit vorgeladenen Bildobjekten
	this.images = new Array();

	//startet den preload
	this.preload = function () {

	   var count = this.pathArray.length;
	   for (var i = 0; i < count; i++) {

		   var img = new Image();
		   img.src = this.pathArray[i];
		   this.images.push(img);
	   }
	}
}