// Hover move listing
$(document).ready(function() {
	
	
	$('#accordion').accordion({
			autoheight: false,
			active: false,
			clearStyle: true,
			header: 'h1'
		});
		
	
	/* Such Eingabe Default Text */
	$(".defaultText").each(function(){
		$(this).addClass("defaultTextActive");
		$(this).val(jQuery(this)[0].title);
	}); 
	
    $(".defaultText").focus(function(srcc)
    {
        if (jQuery(this).val() == $(this)[0].title)
        {
            jQuery(this).removeClass("defaultTextActive");
            jQuery(this).val("");
        }
    });
    
    $(".defaultText").blur(function()
    {
        if (jQuery(this).val() == "")
        {
            jQuery(this).addClass("defaultTextActive");
            jQuery(this).val($(this)[0].title);
        }
    });
    
    $(".defaultText").blur();

});

var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#popupBackground").css({
			"opacity": "0.7"
		});
		$("#popupBackground").fadeIn("slow");
		$("#popupContent").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#popupBackground").fadeOut("slow");
		$("#popupContent").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContent").height();
	var popupWidth = $("#popupContent").width();
	//centering
	$("#popupContent").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#popupBackground").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	// $("#button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	// });
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContent_Close").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#popupBackground").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});



google.load("swfobject", "2.1");



/* FB LIKE BTN */
 window.fbAsyncInit = function() {
    FB.init({appId: '277663398928911', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
  
  c = document.getElementById('fb_like');
if (c !== null) {
    e = document.createElement('fb:like');
	e.setAttribute('action', 'like');
    e.setAttribute('width', '110');
    e.setAttribute('show_faces', 'false');
    e.setAttribute('colorscheme', 'dark');
    e.setAttribute('layout', 'button_count');
    c.appendChild(e);
}



/* ANALYTICS */
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27184731-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

