//Reload CAPTCHA
function reloadCaptcha(imgIdToReload) {
	document.getElementById(imgIdToReload).setAttribute('src', document.getElementById(imgIdToReload).getAttribute('src')+'?1');
}


jQuery.fn.newsletterTabs = function ()
{
	jQuery(this).show();
	jQuery('div#newsletterSlider div.sliderContentContainer').hide().eq(sliderInitialActiveTab).addClass('active').show();
    jQuery('ul#newsletterSliderMenu li').removeClass('active');
    jQuery('ul#newsletterSliderMenu').find('li:nth-child(' + ((sliderInitialActiveTab * 2) + 1 ) + ')').addClass('active').show();
	
	jQuery(this).find('li:nth-child(odd)').click(function()
	{
		var index = jQuery('#newsletterSliderMenu li:nth-child(odd)').index(this);

		jQuery('#newsletterSliderMenu li').removeClass('active');
		jQuery(this).addClass('active');

		jQuery('div#newsletterSlider div.sliderContentContainer.active').removeClass('active').fadeOut(300, function()
		{
			jQuery('div#newsletterSlider div.sliderContentContainer').eq(index).addClass('active').fadeIn(200);
		});
	});

	return jQuery(this);
}

jQuery.fn.productdetailTabs = function ()
{
	jQuery(this).show();
	jQuery('div#productdetailSlider div.sliderContentContainer').hide().eq(sliderInitialActiveTab).addClass('active').show();
        jQuery('ul#productdetailSliderMenu li').removeClass('active');
        jQuery('ul#productdetailSliderMenu').find('li:nth-child(' + ((sliderInitialActiveTab * 2) + 1 ) + ')').addClass('active').show();
	jQuery(this).find('li:nth-child(odd)').click(
	function()
	{
		var index = jQuery('#productdetailSliderMenu li:nth-child(odd)').index(this);

		jQuery('#productdetailSliderMenu li').removeClass('active');
		jQuery(this).addClass('active');

		jQuery('div#productdetailSlider div.sliderContentContainer.active').removeClass('active').hide();
		jQuery('div#productdetailSlider div.sliderContentContainer').eq(index).addClass('active').show();

		//@ToDo, dont work with float style
		/*jQuery('div#productdetailSlider div.sliderContentContainer.active').removeClass('active').fadeOut(300,
		function()
		{
			jQuery('div#productdetailSlider div.sliderContentContainer').eq(index).addClass('active').fadeIn(200);
		});*/
	});

	return jQuery(this);
}


jQuery.fn.superSimpleTabs = function () {

	return this.each(function () {

		// reference to ul (list) element
		var ul = jQuery(this);

		// go through all tab images in ul with attribute rel
		ul.find('img[rel^=#]').each(function (i) {

			var image = jQuery(this);

			// Hide all containers cept the first
			if (i!=sliderInitialActiveTab) {
				jQuery(image.attr('rel')).hide();
			} else {
				image.addClass('selected');
				jQuery(image.addClass('selected').attr('rel')).show();
				image.attr('src', image.attr('src').replace('_no', '_act'));
			}

			// When clicking link
			image.click(function () {

				// hide selected image
				changeImage     = ul.find('img.selected');
				changeImage.attr('src', changeImage.attr('src').replace('_act', '_no'));
				jQuery(changeImage.removeClass('selected').attr('rel')).fadeOut('slow');

				// show clicked image
				jQuery(image.addClass('selected').attr('rel')).fadeIn('slow');
				image.attr('src', image.attr('src').replace('_no', '_act'));

				return false;
			});
		});
	});
};


/**
 * check if the form submitted. avoid sumitting form more times
 *
 * @access public
 * @return bool
 */
var isFormSubmitted = false;
function checkSubmit() {
	if (! isFormSubmitted) {
		isFormSubmitted = true;
		return true;
	} else {
		return false;
	}
}


/**
 *  products paging fucntion for cross-selling products and alternative products
 */
jQuery.fn.products_paging = function () {

	// binding forwarding button
	jQuery('#crossproducts_paging_front').bind('click', crossproducts_paging_front_click);
	jQuery('#altproducts_paging_front').bind('click', altproducts_paging_front_click);

	// binding backwarding button
	jQuery('#crossproducts_paging_back').bind('click', crossproducts_paging_back_click);
	jQuery('#altproducts_paging_back').bind('click', altproducts_paging_back_click);

	// call the initial production paging function
	init_products_paging();
}


// current paging index
var curr_paging_index = 0;

// next paging index
var next_paging_index = 0;

// previous paging index
var previous_paging_index = 0;

// the paging index
var paging_index = 0;

// the size of pages
var products_paging_size = 0;

/**
 *  the initial products paging function for cross-selling products and alternative products,
 *  will be called after the page load
 */
function init_products_paging() {
	// reset the paging index and the button display mode
	crossproducts_paging_reset();

	// get the page size
	jQuery('div.crossproducts_paging').each(function (){
		paging_index++;

		if ( jQuery(this).css('display') == 'block'){
			if (curr_paging_index == 0){
				curr_paging_index = paging_index;
				next_paging_index = curr_paging_index + 1;
				previous_paging_index = curr_paging_index -1;
			}
		}
	});

	products_paging_size = paging_index;

	// check if the paging header should be displayed
	if (products_paging_size < 2){
		jQuery('#crossproducts_paging_header').css('display','none');
	}else{
		jQuery('#crossproducts_paging_header').css('display','block');

		if (next_paging_index > products_paging_size){
			// last
			jQuery('#crossproducts_paging_front').css('display','none');
		}

		if (previous_paging_index < 1){
			// first
			jQuery('#crossproducts_paging_back').css('display','none');
		}

		paging_index = 0;
		// walking through the crossproducts
		jQuery('div.crossproducts_paging').each(function (){
			paging_index++;

			if (paging_index == curr_paging_index){
				jQuery(this).css('display', 'block');
			}else{
				jQuery(this).css('display', 'none');
			}

		});
	}

	// reset the paging index and the button display mode
	altproducts_paging_reset();

	// get the page size
	jQuery('div.altproducts_paging').each(function (){
		paging_index++;

		if ( jQuery(this).css('display') == 'block'){
			if (curr_paging_index == 0){
				curr_paging_index = paging_index;
				next_paging_index = curr_paging_index + 1;
				previous_paging_index = curr_paging_index -1;
			}
		}
	});

	products_paging_size = paging_index;


	// check if the paging header should be displayed
	if (products_paging_size < 2){
		jQuery('#altproducts_paging_header').css('display','none');
	}else{
		jQuery('#altproducts_paging_header').css('display','block');

		if (next_paging_index > products_paging_size){
			// last
			jQuery('#altproducts_paging_front').css('display','none');
		}

		if (previous_paging_index < 1){
			// first
			jQuery('#altproducts_paging_back').css('display','none');
		}

		paging_index = 0;
		// walking through the altproducts
		jQuery('div.altproducts_paging').each(function (){
			paging_index++;

			if (paging_index == curr_paging_index){
				jQuery(this).css('display', 'block');
			}else{
				jQuery(this).css('display', 'none');
			}

		});
	}

}

/**
 *  forwarding button function
 */
function crossproducts_paging_front_click(ev)
{
	// reset the paging index and the button display mode
	crossproducts_paging_reset();

	// search the next display page
	jQuery('div.crossproducts_paging').each(function (){
		paging_index++;

		if ( jQuery(this).css('display') == 'block'){
			curr_paging_index = paging_index;
			next_paging_index = curr_paging_index + 1;
		}
	});

	// set the size of pages
	products_paging_size = paging_index;

	// try to paging
	if (next_paging_index <= products_paging_size)
	{
		paging_index = 0;

		jQuery('div.crossproducts_paging').each(function (){
			paging_index++;

			if (paging_index != next_paging_index){
				jQuery(this).css('display','none');
			}else{
				jQuery(this).css('display','block');
			}
		});
	}

	// check if the next page is the last page?
	if (next_paging_index == products_paging_size){
		jQuery('#crossproducts_paging_front').css('display','none');
	}
}

/**
 *  forwarding button function
 */

function altproducts_paging_front_click(ev)
{

	// reset the paging index and the button display mode
	altproducts_paging_reset();

	// search the next display page
	jQuery('div.altproducts_paging').each(function (){
		paging_index++;

		if ( jQuery(this).css('display') == 'block'){
			curr_paging_index = paging_index;
			next_paging_index = curr_paging_index + 1;
		}
	});

	// set the size of pages
	products_paging_size = paging_index;

	// try to paging
	if (next_paging_index <= products_paging_size)
	{
		paging_index = 0;

		jQuery('div.altproducts_paging').each(function (){
			paging_index++;

			if (paging_index != next_paging_index){
				jQuery(this).css('display','none');
			}else{
				jQuery(this).css('display','block');
			}
		});
	}

	// check if the next page is the last page?
	if (next_paging_index == products_paging_size){
		jQuery('#altproducts_paging_front').css('display','none');
	}
}

/**
*  backwarding button function
*/
function crossproducts_paging_back_click(ev)
{

	// reset the paging index
	crossproducts_paging_reset();

	// search the previous display page
	jQuery('div.crossproducts_paging').each(function (){
		paging_index++;

		if ( jQuery(this).css('display') == 'block'){
			curr_paging_index = paging_index;
			previous_paging_index = curr_paging_index - 1;
		}
	});

	// set the size of pages
	products_paging_size = paging_index;

	// try to paging
	if (previous_paging_index > 0 && previous_paging_index <= products_paging_size)
	{
		paging_index = 0;

		jQuery('div.crossproducts_paging').each(function (){
			paging_index++;

			if (paging_index != previous_paging_index){
				jQuery(this).css('display','none');
			}else{
				jQuery(this).css('display','block');
			}
		});
	}

	// check if the previous page is the first page?
	if (previous_paging_index == 1){
		jQuery('#crossproducts_paging_back').css('display','none');
	}
}

/**
*  backwarding button function
*/

function altproducts_paging_back_click(ev)
{
	// reset the paging index
	altproducts_paging_reset();

	// search the previous display page
	jQuery('div.altproducts_paging').each(function (){
		paging_index++;

		if ( jQuery(this).css('display') == 'block'){
			curr_paging_index = paging_index;
			previous_paging_index = curr_paging_index - 1;
		}
	});

	// set the size of pages
	products_paging_size = paging_index;

	// try to paging
	if (previous_paging_index > 0 && previous_paging_index <= products_paging_size)
	{
		paging_index = 0;

		jQuery('div.altproducts_paging').each(function (){
			paging_index++;

			if (paging_index != previous_paging_index){
				jQuery(this).css('display','none');
			}else{
				jQuery(this).css('display','block');
			}
		});
	}

	// check if the previous page is the first page?
	if (previous_paging_index == 1){
		jQuery('#altproducts_paging_back').css('display','none');
	}
}

/*
* reset the paging index and button display style
*/

function crossproducts_paging_reset()
{
	// reset
	paging_index = 0;
	curr_paging_index = 0;
	next_paging_index = 0;
	previous_paging_index = 0;
	products_paging_size = 0;

	jQuery('#crossproducts_paging_front').css('display','block');
	jQuery('#crossproducts_paging_back').css('display','block');
}

/*
* reset the paging index and button display style
*/

function altproducts_paging_reset()
{
	// reset
	paging_index = 0;
	curr_paging_index = 0;
	next_paging_index = 0;
	previous_paging_index = 0;
	products_paging_size = 0;

	jQuery('#altproducts_paging_front').css('display','block');
	jQuery('#altproducts_paging_back').css('display','block');
}

/*
* function for loading the popup window
*/

function load_popup_window(link, width, height)
{

	window.open(link,'popup','toolbar=no,width=' + width + ',height=' + height + ',resizable=yes,top=40,left=100,scrollbars=yes')

}

/**
 *
 * function for the automatical focus from one element to next lement
 *
 * @param firstElem the current element
 * @param nextElem the next element to focus
 * @return
 */
function bindFocusElement(firstElem, nextElem){
	if (jQuery('#' + firstElem) && jQuery('#' + nextElem)){
		jQuery('#' + firstElem).bind('keyup', function(event){
			var elem = event.target;
			if ( (! jQuery(elem).valid()) || (event.keyCode == 9) || (event.keyCode == 16)) {
				return false;
			} else {
				// focus the next element
				jQuery('#' + nextElem).focus();
			}
		});
	}
}

/**
  *
  * function for the automatical focus from one element to next lement
  *
  * @param firstElem the current element
  * @param nextElem the next element to focus
  * @return
  */
function bindFocusElement2(firstElem, firstElemLength, nextElem){
	if (jQuery('#' + firstElem) && jQuery('#' + nextElem)){
		jQuery('#' + firstElem).bind('keyup', function(event){
			var elem = event.target;
			if ( (! jQuery(elem).valid()) || (event.keyCode == 9) || (event.keyCode == 16)) {
				return false;
			} else {
				if ( jQuery(elem).val().length >= firstElemLength ){
					// focus the next element
					jQuery('#' + nextElem).focus();
				}
			}
		});
	}
}

/*
  * function for popup window for the print version of order confirmation
  */
function create_popup_window(link, width, height)
{
	var html = jQuery('#wk_content').html();

	// store the stylesheets
	var array = new Array(document.styleSheets.length);
	for(var i=0; i< document.styleSheets.length; i++){
		css = document.styleSheets[i].href;
		array[i] = css;
	}

	// open the popup window
	var this_win = window.open('','popup','toolbar=no,width=' + width + ',height=' + height + ',resizable=yes,top=40,left=100,scrollbars=yes')


	// write the new content
	with (this_win)
	{
		document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"');
		document.writeln('<html><head>');
		document.writeln('<title></title>');

		for(var i=0; i< array.length; i++){
			document.writeln( '<link rel="stylesheet" type="text/css" href="' + array[i] + '">');
		}
		document.writeln('</head>');
		document.writeln('<body>');
		document.writeln('<div style="width:99% !important;">');
		document.writeln(html);

		document.writeln('<br /><br />');
		document.writeln('<div class="footer" style="text-align:center"><a href="javascript:print()"><strong>Drucken</strong></a> <span style="width:8px">&nbsp;</span> <a href="javascript:self.close()"><strong>Fenster schließen</strong></a></div><br/>')
		document.writeln('</div>');
		document.writeln('</body>');


		if (document.getElementById('wk_button')){
			document.getElementById('wk_button').style.display = 'none';
		}
	}
	this_win.document.close();
}

/**
  *
  * @access public
  * @return void
  **/
function addIgnoreClass(elementId){
	$("#" + elementId) . addClass("ignore");
	$("#" + elementId) . removeClass("error");
}

/**
  *
  * @access public
  * @return void
  **/
function removeIgnoreClass(elementId){
	$("#" + elementId) . removeClass("ignore");
}

/**
  *
  * adds ignore class to all form-elements
  * inside the container elementId
  *
  * needed for clientside-validation
  *
  * @access public
  * @return void
  **/
function setOverallIgnoreClass(elementId) {

	if(is_array(elementId)) {
		for(var i = 0; i < elementId.length; i++) {
			$("#" + elementId[i]) . find("input") . addClass("ignore");
			$("#" + elementId[i]) . find("input") . removeClass("error");
		}
	} else {
		$("#" + elementId) . find("input") . addClass("ignore");
		$("#" + elementId) . find("input") . removeClass("error");
	}
}



/**
  *
  * removes ignore classes from all form-elements
  * which is needed for clientside-validation
  *
  * @access public
  * @return void
  **/
function removeIgnoreClasses(elementId) {
	if(is_array(elementId)) {
		for(var i = 0; i < elementId.length; i++) {
			$("#" + elementId[i]) . find("input") . removeClass("ignore");
		}
	} else {
		$("#" + elementId) . find("input") . removeClass("ignore");
	}
}

/**
  * unchecks an input checkbox
  *
  * @access public
  * @return void
  **/
function unCheck(inputId){
	if (document.getElementById(inputId)) {
		document.getElementById(inputId).checked = false;
	}
}

function is_array(variable) {
	return typeof(variable) == "object" && (variable instanceof Array);
}



/**
  * trim any String
  *
  * @access public
  * @param	String	myString			Any String to trim
  * @return String
  **/
function trim (myString) {
	return myString.replace (/^\s+/, '').replace (/\s+$/, '');
	}

/**
  * build a date together in the US Format MM.DD.YYYY to use it for matching against a regular expression
  *
  * @access public
  * @param	String	day			The day part of a date, two digits
  * @param	String	month		The month part of a day, two digits
  * @param	String	year		The year part of a day, 4 digits
  * @return String
  **/
function formatDateForValidation(day, month, year){
	var fulldate = '';

	fulldate = trim(month) + '.' + trim(day) + '.' + trim(year);

	if( fulldate != '..'){
		return fulldate;
	}
	return '';
}

/*
* input focus color
*/
$(document).ready(function() {
	$("form input:text, form input:password, form textarea").bind("focus", function(e){
		//$("form input:text, form input:password, form textarea").css({backgroundColor:'#fefefe',color:'#585757'});
		//$(this).css({backgroundColor:'#fefefe', color:'#20599c', border:'1px solid #890889'});
	});

	$("form input:text, form input:password, form textarea").bind("blur", function(e){
		//$(this).css({backgroundColor:'#fefefe',color:'#585858', border:'1px solid #EDEDED'});
	});

	/* for colored button */
	$(".btn").bind("mouseover", function(e){
			$(this).css('background-position','center bottom'); //red
	});

	$(".btn").bind("mouseout", function(e){
		$(this).css('background-position','center top');	//black
	});

	/* patch the radio button error stylesheet caused by validation */
	$('.dmc_div_radiogroup').bind('click', function(){
		$(this).find('input[type="radio"]').each(function(){
			$(this).removeClass('error');
		});

	});


	/* for resultnavi-paging */
	if ($('#res_middle').length > 0) {
		resWidth = $('#res_container').width();
		resLeft = (resWidth/2)-(($('#res_middle').width())/2);
		$('#res_middle').css({left: resLeft,visibility:'visible'});
	} //if
});

/**
 * validate the fulldate date and display the error message in the error element
 * @param errorElementId
 * @param fulldate
 * @param message
 * @return
 */
function validateFulldateAndShowError(errorElementId, fulldate, message)
{

	if($('#' + errorElementId).length){
		// remove message
		$('#' + errorElementId).empty();
	}

	// check date
	var retval = false;
	var dateArray = fulldate.split(".");
	if (typeof(dateArray) == "object" && (dateArray instanceof Array)){
		if ( dateArray[0].length != 0 && dateArray[0] != 'undefined' &&
				dateArray[1].length != 0 && dateArray[1] != 'undefined' &&
				dateArray[2].length != 0 && dateArray[2] != 'undefined'){

				var day = parseInt(dateArray[1],10);
				var month = parseInt(dateArray[0],10) -1;
				var year = parseInt(dateArray[2],10);

				var myDate = new Date(year, month, day);

				retval = (myDate.getMonth() == month);
		}
	}

	if (!retval){
		if($('#' + errorElementId).length){
		var message = "<label class=\"error\" style=\"display: block;\">" + message + "</label>";
		// add message to the error element
		$('#' + errorElementId).html(message);
		}
	}
}

/**
* validate the fulldate date within a valid duration display the error message in the error element
* @param errorElementId
* @param fulldate
* @param message
* @return
*/
function validateFulldateAndShowError2(errorElementId, fulldate, message, duration, durationMessage)
{

	if($('#' + errorElementId).length){
		// remove message
		$('#' + errorElementId).empty();
	}

	// check date
	var retval = false;
	var dateArray = fulldate.split(".");
	if (typeof(dateArray) == "object" && (dateArray instanceof Array)){
		if ( dateArray[0].length != 0 && dateArray[0] != 'undefined' &&
				dateArray[1].length != 0 && dateArray[1] != 'undefined' &&
				dateArray[2].length != 0 && dateArray[2] != 'undefined'){

				var day = parseInt(dateArray[1],10);
				var month = parseInt(dateArray[0],10) -1;
				var year = parseInt(dateArray[2],10);

				var myDate = new Date(year, month, day);

				retval = (myDate.getMonth() == month);

				if (duration > 0 && retval){
					retval = false;



					// check if the date within the duration
					var now = new Date();
					var maxDate = new Date();
					maxDate.setDate(maxDate.getDate() + duration);

					retval = ( myDate.getTime() <= maxDate.getTime() && myDate.getTime() >= now.getTime() );

					if (!retval){
						//set error message
						message = durationMessage;
					}
				}

		}
	}

	if (!retval){

		if($('#' + errorElementId).length){
		var message = "<label class=\"error\" style=\"display: block;\">" + message + "</label>";
		// add message to the error element
		$('#' + errorElementId).html(message);
		}
	}
}

jQuery.validator.addMethod("fulldate", function(value, element) {
	var retval = this.optional(element) || /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/.test(value);

	return retval;

}, "Please specify the correct domain for your documents");

//extends the default handling on input enter
$(document).ready(function () {
	$("form input").live('keypress', function (e) {

		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {

			var matches = [];
			// extend handling for shopping basket inputs
			if (matches = $(this).attr('name').match(/(dmc_mb3_shoppingbasket_pi1)\[([0-9]+)\]/)) {

				var ctype = matches[1];
				var uid = matches[2];

				var redirectStep = [];
				redirectStep[10] = 20;
				redirectStep[20] = 30;
				redirectStep[21] = 30;
				redirectStep[30] = 40;
				redirectStep[40] = 50;

				var currentStep = $('#'+ctype+'\\['+uid+'\\]\\[step\\]').attr('value');

				$('#'+ctype+'\\['+uid+'\\]\\[nextstep\\]').attr('value', redirectStep[currentStep]);

				$('#'+ctype+'_'+uid+'_form').submit();

			} else {
				return true;
			}

		} else {
			return true;
		}
	});
});

/**
 * trim any String
 *
 * @access public
 * @param	String	myString			Any String to trim
 * @return String
 **/
function trim (myString) {
	return myString.replace (/^\s+/, '').replace (/\s+$/, '');
}


/**
 * function for display the current thema
 * @return
 */
function current_thema_display(){

	if ($('div.current_thema').length){
		var i=0;
		var size= 0;
		// get the element of themenlist
		$('div.current_thema').each(function(){
			if ($(this).text().length){
				var text = $(this).text().replace(/^\s+|\s+$/g,"");
				if (text.length == 0){
					// hide
					$(this).css('display', 'none');
				}else{
					i++;
				}
			}
		});
		size = i;
		i=0;
		$('div.current_thema').each(function(){
			i++;
			if (i == size){
				$(this).find('div.list_akt_line').css('display','none');
			}
		});
	}
}


var calServiceFormDoubleSubmit = false; // PREVENT DOUBLE SUBMIT

/**
  *  form submit for new calender service
  * @param ctype
  * @param uid
  * @param nextstepValue
  * @return
  */
function calServiceAddEntry(ctype){
		var form	= document.getElementById(ctype + '_' + 'form');

		if ($('#' + ctype + '_' + 'form').valid()){
		if (calServiceFormDoubleSubmit == false) {
				if (form) {
				// form.action: add entry
				var el = document.createElement('input');
				el.type = 'hidden';
				el.name = ctype + '[submit_as_new]';
				el.value = "1";
				form.appendChild(el);

				calServiceFormDoubleSubmit = true;
				form.submit();
				}
			}
		}
}

/**
 *  form submit for edit calendar service
 * @param ctype
 * @param uid
 * @param nextstepValue
 * @return
 */
function calServiceEditEntry(ctype){
		var form	= document.getElementById(ctype + '_' + 'form');

		if ($('#' + ctype + '_' + 'form').valid()){
			if (calServiceFormDoubleSubmit == false) {
				if (form) {
					// form.action: edit entry
				var el = document.createElement('input');
				el.type = 'hidden';
				el.name = ctype + '[submit_edit]';
				el.value = "1";
				form.appendChild(el);

				calServiceFormDoubleSubmit = true;
				form.submit();
				}
			}
		}
	}

/**
 * build a date together in the US Format MM.DD.YYYY to use it for matching against a regular expression
 *
 * @access public
 * @param	String	day			The day part of a date, two digits
 * @param	String	month		The month part of a day, two digits
 * @param	String	year		The year part of a day, 4 digits
 * @return String
 **/
function formatDateForValidation(day, month, year){
	var fulldate = '';

	fulldate = trim(month) + '.' + trim(day) + '.' + trim(year);

	if( fulldate != '..'){
		return fulldate;
	}
	return '';
}

/*
 * IE6 Hack for pull down of Hovermenu
 *
 */

sfHover = function() {
	if($("#navstart").length > 0) {
		var sfEls = document.getElementById("navstart").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" over";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" over\\b"), "");
			}
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);


/* typo3 popup windown, do not edit it */
function openPic(url,winName,winParams) {
var theWindow = window.open(url,winName,winParams);
if (theWindow) {theWindow.focus();}
}

/* fixxes 8bit transperencys for IE6 */
var arVersion = navigator.appVersion.split("MSIE");
var ieVersion = parseFloat(arVersion[1]);
function fixPNG(myImage, imgWidth, imgHeight) {
	if ((ieVersion >= 5.5) && (ieVersion < 7) && (document.body.filters)) {
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
		var imgTitle = (myImage.title) ?
					"title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";
		var imgStyle = "display:inline-block;" + myImage.style.cssText;
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + imgWidth
					+ "px; height:" + imgHeight
					+ "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
		myImage.outerHTML = strNewHTML;
	}
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
{
    if (navigator.appVersion.match(/MSIE 5?6/)==null) return;
    for(var i=0; i<document.images.length; i++)
    {
        var img = document.images[i];
        var imgName = img.src.toUpperCase();
        if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
        {
            img.style.display = 'block';
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = img.style.cssText;
            var imgAttribs = img.attributes;
            for (var j=0; j<imgAttribs.length; j++)
            {
                var imgAttrib = imgAttribs[j];
                if (imgAttrib.nodeName == "align")
                {
                    if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle;
                    if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle;
                    break;
                }
            }

            var strNewHTML = "<span " + imgID + imgClass + imgTitle; 
            strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";";
            strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
            strNewHTML += "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
            img.outerHTML = strNewHTML;
            i = i-1;
        }
    }
}



/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
