﻿$(document).ready(function(){
		var x = 0;
		var y = 0;
		var x2 = 0;
		var y2 = 0;
		$().mousemove(function(e){
			x = e.pageX;
			y = e.pageY;
		}); 

		$("a.faq").click(function(e){
			var id = this.id.substring(this.id.indexOf('_'));
			var w = ($("#block"+id).css("max-width")!='none')? $("#block"+id).css("max-width") : '300px';
			var h = ($("#block"+id).css("max-height")!='none')? $("#block"+id).css("max-height") : '150px';
			//$("#block"id).show("slow"); //"slow", "normal", "fast" or milliseconds
			if ($("#block"+id).css("display") == 'none')
			{
				$("#block"+id).css("left", x);
				$("#block"+id).css("top", y);
			}
			$("#block"+id).css("display", '');
			$("#block"+id).animate({
				left: (window.innerWidth-w.substring(0, w.indexOf('px')))/2, //x+50, 
				top: (window.innerHeight-h.substring(0, h.indexOf('px')))/2, //y-30,
				opacity: 1,
				width: w,
				height: h
      }, "slow" );
      x2 = x;
      y2 = y;
		});

		$("a.floatingBoxClose").click(function(){
			var id = this.id.substring(this.id.indexOf('_'));
			//$("#block"+id).hide("slow"); //"slow", "normal", "fast" or milliseconds
			$("#block"+id).animate({
				left: x2, 
				top: y2,
				opacity: 0,
				width: 1,
				height: 1
      }, "normal" );
			$("#block"+id).css("display", 'none');
		});

	});