

$(document).ready(function(){
	//$("input.inputButtonFloatRight").wrap('<div class=""wrapButton></div>');
});

$(document).ready(function(){


	$.dpText = {
		TEXT_PREV_YEAR	 : 'Vorheriges Jahr',
		TEXT_PREV_MONTH	 : 'Vorheriger Monat',
		TEXT_NEXT_YEAR	 : 'Nächstes Jahr',
		TEXT_NEXT_MONTH	 : 'Nächster Monat',
		TEXT_CLOSE		 : 'Schließen (Esc)',
		TEXT_CHOOSE_DATE : 'Datum auswählen',
		HEADER_FORMAT	 : 'mmmm yyyy'
	}


	$('.j_datePicker').datePicker({
		startDate: '01/01/1900',
		year: 1962, // initially display 1962
		month: 4,
		day: 17,
		endDate: (new Date()).asString(),

		clickInput:true, // Bei Click IN Feld!

		verticalPosition: 0,	// Nach unten klappen.
		horizontalPosition: 0,	// Linksbündig.
		verticalOffset: 21,

		displayClose: true
	});
});


$(document).ready(function() {
    $('input[type="text"]').addClass("idleField inputText");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
        /**
		if (this.value == this.defaultValue){
        	this.value = '';
    	}
        if(this.value != this.defaultValue){
	    	this.select();
        }
        */
    });
    $('input[type="text"]').blur(function() {
    	$(this).removeClass("focusField").addClass("idleField");
        /**
        if ($.trim(this.value == '')){
        	this.value = (this.defaultValue ? this.defaultValue : '');
    	}
    	*/
    });

    $('textarea').addClass("idleField inputTextarea");
    $('textarea').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
    });
     $('textarea').blur(function() {
    	$(this).removeClass("focusField").addClass("idleField");
    });

    $('input[type="password"]').addClass("idleField inputPassword");
    $('input[type="password"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
    });
    $('input[type="password"]').blur(function() {
    	$(this).removeClass("focusField").addClass("idleField");
    });
});


// Popup-Windows:
$(document).ready( function() {
	$('A[rel="external"]').click( function() {
		oWin = window.open(
			$(this).attr('href'),
			"hsdc_popup_print",
			"height=700,width=800,menubar=yes,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes"
		);
		oWin.focus();
		return false;
	});
});
$(document).ready( function() {
	$('A[rel="externalEmail"]').click( function() {
		oWin = window.open(
			$(this).attr('href'),
			"hsdc_popup_print",
			"height=600,width=500,menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=no"
		);
		oWin.focus();
		return false;
	});
});


function setup(){

	myDialogWidth = 250;
	myDialogHeight = 100;

	$('a.nyroPopup').click(function(e){
		e.preventDefault();

		myUrl = $(this).attr("href");
		myTitle = "Hundeschulen.com: " + $(this).attr("title");

		// Ausblenden der Serviceseite: Kein Effekt.
		$.nyroModalSettings({
			hideContent: function(elts, settings, callback) {
				elts.contentWrapper.hide();
				callback();
			}
		});

		$.nyroModalManual({
			type: "ajax",
			url: myUrl,
			title: myTitle,

			wrap: { // Wrapper div used to style the modal regarding the content type
				ajax: '<div class="wrapper ajaxPage"></div>'
	  		},
		  	css: {
			    wrapper: {
			    	borderColor: '#ffa500'
			    }
			}

			//debug: true

		});

		return false;
	});


	$("dfn").click(function(e) {
		//e.preventDefault(e);

		var helpContent = $(this).attr("title");
		  helpContent = helpContent + '<button class="nyroModalClose">&nbsp;OK&nbsp;</button>';

		  $.nyroModalSettings({
			  showLoading: function(elts, settings, callback) {
					callback();
				},
				showContent: function(elts, settings, callback) {
					elts.contentWrapper
						.css({
							width: settings.width+'px',
							height: settings.height+'px',
							marginTop: settings.marginTop+'px',
							marginLeft: settings.marginLeft+'px'
						})
						.show();
						elts.loading.fadeOut(200, callback);
				},
				hideContent: function(elts, settings, callback) {
					elts.contentWrapper.hide();
					callback();
				}
			});

		  $.nyroModalManual({
			content: helpContent,
			modal: true,
		    bgColor: 'transparent',
		    width: myDialogWidth,
		    height: myDialogHeight,
		    minWidth: myDialogWidth, // Minimum width
			minHeight: myDialogHeight, // Minimum height
			wrap: { // Wrapper div used to style the modal regarding the content type
			    manual: '<div class="wrapper helpDialog"></div>'
		  	},
		  	css: {
			    wrapper: {
			    	border: 'none'
			    }
			  }
		  });
	  return true;
	});

	// $("acronym").click(function() {
	$("acronym").click(function() {
		  var helpContent = $(this).attr("title");
		  helpContent = helpContent + '<button class="nyroModalClose">&nbsp;OK&nbsp;</button>';

		  $.nyroModalSettings({
			  showLoading: function(elts, settings, callback) {
					callback();
				},
				showContent: function(elts, settings, callback) {
					elts.contentWrapper
						.css({
							width: settings.width+'px',
							height: settings.height+'px',
							marginTop: settings.marginTop+'px',
							marginLeft: settings.marginLeft+'px'
						})
						.show();
						elts.loading.fadeOut(200, callback);
				},
				hideContent: function(elts, settings, callback) {
					elts.contentWrapper.hide();
					callback();
				}
			});

		  $.nyroModalManual({
			content: helpContent,
			modal: true,
		    bgColor: 'transparent',
		    width: myDialogWidth,
		    height: myDialogHeight,
		    minWidth: myDialogWidth, // Minimum width
			minHeight: myDialogHeight, // Minimum height
			wrap: { // Wrapper div used to style the modal regarding the content type
			    manual: '<div class="wrapper helpDialog"></div>'
		  	},
		  	css: {
			    wrapper: {
			    	border: 'none'
			    }
			  }
		  });
	  return true;
	});


}

/*
$.fn.nyroModal.settings = {
		  debug: false, // Show the debug in the background
		  blocker: false, // Element which will be blocked by the modal
		  modal: false, // Esc key or click backgrdound enabling or not
		  type: '', // nyroModal type (form, formData, iframe, image, etc...)
		  forceType: null, // Used to force the type
		  from: '', // Dom object where the call come from
		  hash: '', // Eventual hash in the url
		  processHandler: null, // Handler just before the real process
		  selIndicator: 'nyroModalSel', // Value added when a form or Ajax is sent with a filter content
		  formIndicator: 'nyroModal', // Value added when a form is sent
		  content: null, // Raw content if type content is used
		  bgColor: '#00331a', // Background color
		  ajax: {}, // Ajax option (url, data, type, success will be overwritten for a form, url and success only for an ajax call)
		  swf: { // Swf player options if swf type is used.
		    wmode: 'transparent'
		  },
		  width: null, // default Width If null, will be calculate automatically
		  height: null, // default Height If null, will be calculate automatically
		  minWidth: 400, // Minimum width
		  minHeight: 300, // Minimum height
		  resizable: true, // Indicate if the content is resizable. Will be set to false for swf
		  autoSizable: true, // Indicate if the content is auto sizable. If not, the min size will be used
		  padding: 20, // padding for the max modal size
		  regexImg: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', // Regex to find images
		  addImageDivTitle: false, // Indicate if the div title should be inserted
		  defaultImgAlt: 'Image', // Default alt attribute for the images
		  setWidthImgTitle: true, // Set the width to the image title
		  ltr: true, // Right to left by default. Put to false for Hebrew or Left to Right language
		  gallery: null, // Gallery name if provided
		  galleryLinks: '<a href="#" class="nyroModalPrev">Prev</a><a href="#"  class="nyroModalNext">Next</a>', // Use .nyroModalPrev and .nyroModalNext to set the navigation link
		  galleryCounts: galleryCounts, // Callback to show the gallery count
		  zIndexStart: 100,
		  css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
		    bg: {
		      position: 'absolute',
		      overflow: 'hidden',
		      top: 0,
		      left: 0,
		      height: '100%',
		      width: '100%'
		    },
		    wrapper: {
		      position: 'absolute',
		      top: '50%',
		      left: '50%'
		    },
		    wrapper2: {
		    },
		    content: {
		      overflow: 'auto'
		    },
		    loading: {
		      position: 'absolute',
		      top: '50%',
		      left: '50%',
		      marginTop: '-50px',
		      marginLeft: '-50px'
		    }
		  },
		  wrap: { // Wrapper div used to style the modal regarding the content type
		    div: '<div class="wrapper"></div>',
		    ajax: '<div class="wrapper"></div>',
		    form: '<div class="wrapper"></div>',
		    formData: '<div class="wrapper"></div>',
		    image: '<div class="wrapperImg"></div>',
		    swf: '<div class="wrapperSwf"></div>',
		    iframe: '<div class="wrapperIframe"></div>',
			iframeForm: '<div class="wrapperIframe"></div>',
		    manual: '<div class="wrapper"></div>'
		  },
		  closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close">Close</a>', // Adding automaticly as the first child of #nyroModalWrapper
		  title: null, // Modal title
		  titleFromIframe: true, // When using iframe in the same domain, try to get the title from it
		  openSelector: '.nyroModal', // selector for open a new modal. will be used to parse automaticly at page loading
		  closeSelector: '.nyroModalClose', // selector to close the modal
		  contentLoading: '<a href="#" class="nyroModalClose">Cancel</a>', // Loading div content
		  errorClass: 'error', // CSS Error class added to the loading div in case of error
		  contentError: 'The requested content cannot be loaded.<br />Please try again later.<br /><a href="#" class="nyroModalClose">Close</a>', // Content placed in the loading div in case of error
		  handleError: null, // Callback in case of error
		  showBackground: showBackground, // Show background animation function
		  hideBackground: hideBackground, // Hide background animation function
		  endFillContent: null, // Will be called after filling and wraping the content, before parsing closeSelector and openSelector and showing the content
		  showContent: showContent, // Show content animation function
		  endShowContent: null, // Will be called once the content is shown
		  beforeHideContent: null, // Will be called just before the modal closing
		  hideContent: hideContent, // Hide content animation function
		  showTransition: showTransition, // Show the transition animation (a modal is already shown and a new one is requested)
		  hideTransition: hideTransition, // Hide the transition animation to show the content
		  showLoading: showLoading, // show loading animation function
		  hideLoading: hideLoading, // hide loading animation function
		  resize: resize, // Resize animation function
		  endResize: null, // Will be called one the content is resized
		  updateBgColor: updateBgColor, // Change background color animation function
		  endRemove: null // Will be called once the modal is totally gone
		};
*/



/**
 * getWindowsInnerHeight
 *
 * Hilfsfunktion um innere Fensterhöhe zu ermitteln.
 * @height      int Vorgegebene Höhe falls Ermittlung versagt.
 * @placeholder int Abzüglich vorkalkuliertem Platzbedarf.
 */
function getWindowsInnerHeight( height, placeholder ){
	// Alle Browser außer IE.
	if (self.innerHeight) {
		height = self.innerHeight;
	}
	// IE 6 strict Mode
	else if (document.documentElement && document.documentElement.clientHeight) {
		height = document.documentElement.clientHeight;
	}
	// Alle anderen IE's.
	else if (document.body) {
		height = document.body.clientHeight;
	}

	return height-placeholder;
} // -getWindowsInnerHeight



/**
  * Tip a Friend
  * Function verschiebt den am Ende der Seite erstellten Link der Ext. tipafriend nach
  * oben in die Liste des Service.Menues.
  * Dazu wird der Link mit einem LI umgeben und dann an die best. Position in der
  * Liste eingefügt.
  **/
function placeLinkInServiceMenu(linkId){
	if( document.getElementById(linkId) ){						// Zugriff auf den Tip-Link.
		var newLink = document.getElementById(linkId);			// Link durch Ext. am Ende der Seite bereits erstellt.
		var newListitem = document.createElement("li");			// Einen neuen Listeneintrag erzeugen:
		newListitem.appendChild(newLink);						// A in LI einfügen.
		var naviListe = document.getElementById("naviService");	// LI in die UL-Liste vor Position [n] einfügen:
		naviListe.insertBefore(newListitem, naviListe.getElementsByTagName("li")[1]);
	}
}
 