function initSite() {

	  $('#mycarousel').jcarousel();
		
		$('.accordeonHeader').click(function() {
			var lastActive = $('.accordeonHeader p.active');
			$('.accordeonHeader p').removeClass('active');
			$(this).children().not(lastActive).addClass('active');

			var next = $(this).next();
			$('.accordeonContent').not(next).slideUp();
			this.blur();
			next.slideToggle();
			return false;
		});


	$("#top-tab").each(function() {
		$(this).append($("<div id=\"links\""+($("#login-tab").hasClass("active") ?  " class=\"active\"" : "")+"></div>"));
		$(this).append($("<div id=\"rechts\"></div>"));
	});
	
	$(".prodSPbutton").each(function() {
		$(this).append($("<div class=\"prodSPbutton_dreieck\"></div>"));
	});


	$('input[name="zselect"]').click(function() {
		$("button.weiter").removeAttr("disabled");
	});

	//$("pre.lazy").lazyLoad();

		
		
		$('input.username').focus(function() {
			if ($(this).val() == $(this).attr("alt")) $(this).val("");
		}).blur(function() {
			if ($(this).val() == "") $(this).val($(this).attr("alt"));
		});


		$('input.pw_clear').focus(function() {
			if ($(this).val() == $(this).attr("alt")) {
				//$(this).val("").attr("type", "password");
				$(this).hide().siblings(".pw_bullet").show().focus();
			}
		});
		$('input.pw_bullet').blur(function() {
			if ($(this).val() == "") {
				$(this).hide().siblings(".pw_clear").show();
			}
		});



		$('input.emptyOnFocus').focus(function() {
			if ($(this).val() == $(this).attr("alt")) $(this).val("");
		}).blur(function(){
			if($(this).attr("value") == "") $(this).attr("value", $(this).attr("alt"));
		});
		

	$('.tooltip').cluetip({
		splitTitle: '|',
		showTitle: false,
		cursor: "pointer",
		clickThrough: true
	});

	$("#schnellsuche input").click(function() {
					if($(this).attr("value") == "Suche") $(this).attr("value", "");
	});

	$("#schnellsuche input").blur(function() {
					if($(this).attr("value") == "") $(this).attr("value", "Suche");
	});	

	$(".schritt1").find("option:selected").parent().trigger("change");

	$(".merkzettel-trenner:last").css("border-bottom", "none");

}



function valueChanged(theSource, theTarget) {
	// setzen der Hidden-Variable f?r theSource
	myId = theSource.id;
	hiddenFieldName = 'h'+myId;
	hiddenField = document.forms.produkt[hiddenFieldName];
	hiddenField.value = theSource.value;

	// index f?r das Select-Element finden
	zielIndex = 0;
	elementArrayLength = document.forms.produkt.elements.length;
	for (i= 0; i < elementArrayLength; i++)
	{
		if (document.forms.produkt.elements[i] == theSource)
		{
			zielIndex = i;
			break;
		}
	}


	theForm = document.forms.produkt;

	// Werte f?r alle nachfolgenden Select-Element l?schen
	// inklusive hidden-fields

	if (document.forms.produkt.prefilled.value != 1) {
		resetCounter = 0;
		for (i=zielIndex+1; i < elementArrayLength; ++i)
		{
			theElement = document.forms.produkt.elements[i];
			if (theElement.tagName == 'SELECT')
			{

				for (j=theElement.length-1; j > 0; --j)
				{
					theElement.remove(j);
				}

				selectId = theElement.id;
				hfieldName = 'h'+selectId;
				hfield = document.forms.produkt[hfieldName];
				hfield.value='';
				resetCounter++;
			}
		}
	}

/*
	if (resetCounter > 0)
		document.forms.produkt.auflage.disabled = true;
*/

	// kein Target; dann letztes Dropdown und Auflage-Input freischalten
	if (!theTarget) {
		$("#auflage_ajax").load('/auflage.xajax.php',
			{
				format: document.forms.produkt.hformat.value,
				material: document.forms.produkt.hmaterial.value,
				weiterverarbeitung: document.forms.produkt.hweiterverarbeitung.value,
				umfang: document.forms.produkt.humfang.value,
				produktuntertyp: document.forms.produkt.hproduktuntertyp.value,
				cat: document.forms.produkt.catid.value,
				auflage: document.forms.produkt.auflage.value
			},
			function() {
				document.forms.produkt.prefilled.value = 0; // Jetzt sind wir nicht mehr vorgef?llt
			}
		);
		return;
	} else {
		$("#auflage_ajax").html('<div class="auflage_placeholder"></div>');
	}

	// Ergebnis der Berechnungen und Vergleichsauflagen l?schen
	$('#comparison_div').html('');
	$("#prodimage2").hide();
	$("#pgimage").show();
	//$("#prod_desc").html("").show();


	$(theTarget).load("/produkt_material.ajax.php",
									{
										format: document.forms.produkt.hformat.value,
										material: document.forms.produkt.hmaterial.value,
										weiterverarbeitung: document.forms.produkt.hweiterverarbeitung.value,
										umfang: document.forms.produkt.humfang.value,
										produktuntertyp: document.forms.produkt.hproduktuntertyp.value,
										next: theTarget.name,
										cat: document.forms.produkt.catid.value
									},
									function() {
										if (document.forms.produkt.prefilled.value == 1) {
												$(theTarget).find("option:selected").parent().trigger("change"); // Den Umweg darum, um nur zu triggern wenn was ausgew?hlt ist
											}
									}
								);  // Achtung als Callback m?sste hier jetzt die history gespeichert werden!

}

function checkAGB() {
        var agb = document.forms.agbform.agb;
        
        if (!agb.checked) {
                var message = i18n_agb_not_accepted;
                alert(message);
                return false;   
        }
        return true;
}

function checkUploadForm() {
	var emptycount = 0;
	var nonemptycount = 0;
	var value;
	var elements = $(':file');
	for (i=0; i < elements.size(); ++i) {
		value = elements[i].value;
		value = value.replace(' ', ''); 
		if (value == '')
			emptycount++;
		else
			nonemptycount++;
	}
	
	if (nonemptycount == 0) {
		var message = i18n_no_file_selected;
		alert(message);
		return false;
	}
	
	return true;
}


	var UP = function() {

    /* private variables */

    var ifr = null;

    var startTime = null;
    var upload_max_filesize = 100 * 1024*1024*1024;

    var infoUpdated = 0;

    var writeStatus = function(text,color) {
        var statDiv = document.getElementById("status");
        if (color == 1 ) {
            statDiv.style.backgroundColor = "green";
        } else if (color == 2 ) {
            statDiv.style.backgroundColor = "orange";
        } else if (color == 3 ) {
            statDiv.style.backgroundColor = "red";
        } else {
            statDiv.style.backgroundColor = "white";
        }
        statDiv.innerHTML = text;
    }


    return {
        start: function() {
        	 $('#status').css('visibility','visible');
        	 $('#progresswrapper').css('visibility','visible');
           ifr = document.getElementById("ifr");
           startTime = new Date();
           infoUpdated = 0;
           this.requestInfo();
        },
        stop: function(files) {
           if (typeof files == 'undefined' || files) {
                var secs = (new Date() - startTime)/1000;
                var statusText = i18n_upload_succeeded+ " " + secs + " " + i18n_seconds + " <br/> ";

                /*
                if (infoUpdated > 0) {
                    writeStatus(statusText + "You had " + infoUpdated + " updates from the progress meter, looks like it's working fine",1);
                } else {
                    statusText += "BUT there were no progress meter updates<br/> ";
                    if (secs < 3) {
                      writeStatus(statusText + "Your upload was maybe too short, try with a bigger file or a slower connection",2);
                    } else {
                      writeStatus(statusText + "Your upload should have taken long enough to have an progress update. Maybe it really does not work...",3);
                    }
                }*/

                writeStatus(statusText, 1);
                $('#realprogressbar').css('width', '100%');

           } else {
               writeStatus(i18n_fail_msg, 3);
           }
           startTime = null;
        },
        requestInfo: function() {
                ifr.src="/uptest/info.php?ID="+ uploadIdentifier + "&"+new Date();
        },

        updateInfo: function(uploaded, total, estimatedSeconds) {
            if (startTime) {
                if (uploaded) {
                    infoUpdated++;
                    if (total > upload_max_filesize) {
                        writeStatus(i18n_too_large_msg + " " + total + " "+ i18n_bytes_allowed + " " + upload_max_filesize + " " + i18n_bytes + " " + i18n_started_since + " " + (new Date() - startTime)/1000 + " <?=dbtr('seconds',$_SESSION['lang'],'js')?>. " + Math.floor(uploaded / total * 100) + "% " + i18n_done + ", " + estimatedSeconds + " " + i18n_seconds_to_go,2);
                    } else {
                        writeStatus(i18n_started_since + " " + (new Date() - startTime)/1000 + " "+ i18n_seconds + ". " + Math.floor(uploaded / total * 100) + "% " + i18n_done + ", " + estimatedSeconds + " " + i18n_seconds_to_go);
                        var pc = Math.floor(uploaded / total * 100) + "%";
                        $('#realprogressbar').css('width', pc);
                    }
                } else {
                    writeStatus( i18n_started_since + " " + (new Date() - startTime)/1000 + " " + i18n_no_info_yet);
                }
                window.setTimeout("UP.requestInfo()",1000);
            }
        }
    }

}();


