jQuery.noConflict();
jQuery(document).ready(function() {
	loginForm();
	lostPasswordForm();
	//makeScrollbar();
	salutationDivToggle();
	subMenu();
	
	function loginForm () {
		var loginFormUserName = jQuery("div[id=loginformpanel] input[id*=user_login]");
		var loginFormPassword = jQuery("div[id=loginformpanel] input[id*=user_pass]");

		if (loginFormUserName != null || loginFormUserName.val() == "") {
			loginFormUserName.val('');
		}
	
		if (loginFormPassword != null || loginFormPassword.val() == "") {
			loginFormPassword.val('');
		}

//		if (loginFormUserName != null || loginFormUserName.val() == "") {
//			loginFormUserName.val('Benutzername');
//		}
//		
//		if (loginFormPassword != null || loginFormPassword.val() == "") {
//			loginFormPassword.val('Password');
//		}
//		
//		loginFormUserName.click(function(){
//			loginFormUserName.val('');
//		});
//		
//		loginFormPassword.click(function(){
//			loginFormPassword.val('');
//		});
//		
//		loginFormUserName.blur(function(){
//			if (loginFormUserName.val() == ''){
//				loginFormUserName.val('Benutzername');
//			}
//		});
//		
//		loginFormPassword.blur(function(){
//			if (loginFormPassword.val() == ''){
//				loginFormPassword.val('Password');
//			}
//		});
	}
	
	function lostPasswordForm () {
		var emailInputField = jQuery("div[id=lost-password-panel] input[type=text]");

		if (emailInputField != null || emailInputField.val() == "") {
			emailInputField.val('E-Mail-Adresse');
		}
		
		emailInputField.click(function(){
			emailInputField.val('');
		});
		
		emailInputField.blur(function(){
			if (emailInputField.val() == ''){
				emailInputField.val('E-Mail-Adresse');
			}
		});
	}
	
	function makeScrollbar() {
		var imgBackgroundElement = jQuery("img[id=login-form-panel-background]");
		var imgBackgroundPositionBottom = imgBackgroundElement.offset().top + imgBackgroundElement.height();
		alert(imgBackgroundPositionBottom);
		
		var footerElement = jQuery("div[id=footer]");
		alert(footerElement.offset().top);
		
		if (imgBackgroundPositionBottom > footerElement.offset().top)
		{
			alert ("yes");
			jQuery(window).scroll();
		}
	}
	
	function subMenu() {
		jQuery("#startnavigator ul li#two").hover(
			function(){ jQuery("ul", this).fadeIn("fast"); }, 
			function(){ jQuery("ul", this).fadeOut("fast"); } 
		);
//		jQuery("#startnavigator ul li#two").hover(
//				function(){ jQuery("ul", this).addClass("showIt"); }, 
//				function(){ jQuery("ul", this).removeClass("showIt"); } 
//		);
	}
	
	/**
	 * in registerierung-panel toggle Anrede div and set the value to Anrede input
	 */
	function salutationDivToggle() {
		var hide=false;
		var divSalutation = jQuery("#div-customer-salutation");
		var inputSalutation = jQuery("#customer_salutation");
		
		if (inputSalutation != null && divSalutation != null) {
			inputSalutation.click(function() {
				jQuery("#div-customer-salutation").toggle();
			});
			jQuery("#div-customer-salutation > ul > li").click(function() {
				inputSalutation.val(jQuery(this).text());
				divSalutation.hide();
			});
		}
	}
	  
});
