/**
 * @copyright	eyeworkers interactive GmbH
 * @author		$Author: milan $
 */
$(document).ready(function() {
	$(function(){
	 	//change dynamically input type password to show description inside field
	    $('#password-clear').show();
	    $('#passwd').hide();

	    $('#password-clear').focus(function() {
	        $('#password-clear').hide();
	        $('#passwd').show();
	        $('#passwd').focus();
	    });
	    $('#passwd').blur(function() {
	        if($('#passwd').val() == '') {
	            $('#password-clear').show();
	            $('#passwd').hide();
	        }
	    });

	    $('#login-clear').each(function() {
	        var default_value = this.value;
	        $(this).focus(function() {
	            if(this.value == default_value) {
	                this.value = '';
	            }
	        });
	        $(this).blur(function() {
	            if(this.value == '') {
	                this.value = default_value;
	            }
	        });
	    });
	  
		// jquery superfish menu
		$('.sf-menu').superfish({ 
		    delay:       200,               // delay on mouseout 
		    animation:   {opacity:'show'},  // fade-in animation 
		    speed:       'fast',             // faster animation speed  
		    autoArrows:  false
		});
		  

		//Toggle by Soh Tanaka
		//Hide (Collapse) the toggle containers on load
		$(".toggle_container").hide(); 

		//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
		$("h2.trigger").click(function(){
			$(this).toggleClass("active").next().slideToggle("slow");
			return false; //Prevent the browser jump to the link anchor
		});
		
		// hide all emtpy areas in content accordeon
		if (jQuery('#inserterLite').length == 0) {	// do it online outside eyekit
			jQuery.each(jQuery('div.toggle-wrapper').children('.toggle_container').children(), function() {
				var toggler = jQuery(this);
				if ( toggler.children().length == 0 ) {				
					toggler.parent().prev().hide();
				}
			});
		}
		
		// jQuery image-slider by malsup
		$('.slider').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
		

		// login panel 
	    $('.triggerLogin').toggle(function() {
			$('.panelLogin').animate({width: 225});
			  }, function() {
				  $('.panelLogin').animate({width: 0});
		});
	    $('.triggerLogin').click(function(){
			$(this).toggleClass("open");
		});
	    
	    // portlet panel 
	    $(this).find(".closePanel").click(function(){
	    	$(this).parent().animate({height: 0, opacity:0});
	    	return false;
		});
	    $(this).find(".moreInfo").click(function(){
	    	$(this).parent().siblings('.listPanel').animate({height: 130, opacity:1});
	    	return false;
		});
	    
	    // Clears default text of text input fields on click
		var resetFields = {
			    init: function() {
			        for (var i=0; i < document.forms.length; i++) {
			            var thisform = document.forms[i];
			            resetFields.reset(thisform);
			        }
			    },
			    reset: function(whichform) {
			        for (var i=0; i < whichform.elements.length; i++) {
			            var element = whichform.elements[i];
			            if (element.type == "submit" || element.type == "radio" || element.type == "checkbox") { continue; }
			            if (!element.defaultValue) { continue; }
			            element.onfocus = function() {
			                if (this.value == this.defaultValue) {
			                    this.value = "";
			                }
			            }
			            element.onblur = function() {
			                if (this.value == "") {
			                    this.value = this.defaultValue;
			                }
			            }
			        }
			    }
			};
		
		 // Textinputfeldwerte zuruecksetzen
	 	var resetFields = {
	 		init: function() {
	 			for (var i=0; i < document.forms.length; i++) {
	 				var thisform = document.forms[i];
	 				resetFields.reset(thisform);
	 			}
	 		},
	 		reset: function(whichform) {
	 			for (var i=0; i < whichform.elements.length; i++) {
	 				var element = whichform.elements[i];
	 				if (element.type == "submit" || element.type == "radio" || element.type == "checkbox") { continue; }
	 				if (!element.defaultValue) { continue; }
	 				element.onfocus = function() {
	 					switch( this.value ) {
	 						case "username":
	 						case "password":
	 						case "Loginname":
	 						case "Passwort":
	 							this.value = "";
	 							break;
	 					}
	 				}
	 			}
	 		}
	 	};
		
	 	resetFields.init();
	 	
	 	// Fancybox
	    if (typeof $.fn.fancybox != 'undefined') {
	        $(".fancybox a").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'	:       600,
			'speedOut'	:       200,
			'centerOnScroll':	true,	
	        'titlePosition' :       'over' //ggf auch 'inside'
	        });
	    }
	    
	    
	    $('.panelLogin').css('display','block');
	    
	    // Fade-In site (avoiding lazy collapsing & hiding)
	    $('body').fadeIn(300);
	    

	}); 
});

// Print Page Popup Window
//<![CDATA[
	function printView (url) {
		fenster = window.open(url, "fenster1", "width=820,height=830,status=yes,scrollbars=yes,resizable=yes");
		fenster.focus();
	}
// ]]>
	
	

