/*!
 * Modified: 2009-12-09 10:47:50
 * CHECKSUM[e6b106bf017fb0fe7175e23011ec0e2f]
 */
 

 

// Super Class

window.$Transbaltic = new function() {

	var $this = this;
	
	// Constructor
	
	$(function(){ 
	
		$this.init();	
		 
	});
	
	
	$this.init = function() { 
	
		$this.formHints('#mainWrapper');
		$this.modal('.StripedTable a');
		$this.toggleNext('.ShowFormLink');
		
		$this.initSpecialForm1();
		
		$this.initGallery();
		
		/*
		$('.alignright').each(function() {
		
			var p = $(this).parent();
		
			p.css('float', 'right');
			p.css('display', 'inline');
			p.css('width', $(this).width());
		
		});
		*/
		
	};
	
	/**
	*
	*/
	$this.initGallery = function() {
	
		// 
		$('#Content .ngg-gallery-thumbnail a').fancybox({titlePosition: 'inside'});
	
	}
	
	
	$this.initSpecialForm1 = function() {
	
		$('#vegetarianDetails').hide();
		
		$('#allergyNo').click(function() {
		
			if($(this).attr('checked')) {
		
				$('#vegetarianDetails').slideUp();
				
			}
		});
		
		$('#allergyYes').click(function() {
		
			if($(this).attr('checked')) {
		
				$('#vegetarianDetails').slideDown();
				
			}
		});		
	
	}
	
	$this.toggleNext = function(selector) {
	
		$(selector).nextAll('div.SignUpFormWrapper:not(.showForm)').hide().end().click(function(e){
		
			e.preventDefault();
			$(this).toggleClass('Active').nextAll('div.SignUpFormWrapper').toggle();
			return false;
		
		});
	
	}
	
	$this.formHints = function(selector) {
	
		$(selector).find('input.hint, textarea.hint').each(function() {
		
			var obj = $(this);	
			var hintvalue = obj.val();
			var textTransformVal = obj.css('text-transform');
			obj.attr('hintvalue', hintvalue);
			
			if (!obj.attr('title')) obj.attr('title',hintvalue);

			$(this).focus(function(){
			
				$(this).css('text-transform', 'none');
				if ($(this).val() == hintvalue) $(this).val("");
				
	    	}).blur(function(){	
	    	
	    		if ($(this).val() == "") {
		    		$(this).css('text-transform', textTransformVal);
	    			$(this).val(hintvalue);
	    		}
	    		
			});
		});
	};
	
	
	$this.modal = function(selector) {
	
	
	
	$(selector).each(function(){
	
	$(this).click(function(e){
	
		e.preventDefault();
	
	})
	
	
$(this).qtip(
   {
      content: {
         title: {
            text: $(this).text(),
            button: '&nbsp;'
         },
         text: 'loading...',
         url: $(this).attr('href') + '?ajax=1'
      },
      position: {
         target: $(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
      },
      show: {
         when: 'click', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: { 
      	when: { event: 'unfocus' } },
      style: {
      		width: 500,
      		color: "#999999",
      		title: {"background-color": "#ffffff"}
      	
      },
      api: {
         beforeShow: function()
         {
            // Fade in the modal "blanket" using the defined show speed
            $('#qtip-blanket').fadeIn(this.options.show.effect.length);
         },
         beforeHide: function()
         {
            // Fade out the modal "blanket" using the defined hide speed
            $('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   });

	
	
	});
	

   // Create the modal backdrop on document load so all modal tooltips can use it
   $('<div id="qtip-blanket">')
      .css({
         position: 'absolute',
         top: 0, // Use document scrollTop so it's on-screen even if the window is scrolled
         left: 0,
         height: $(document).height(), // Span the full document height...
         width: '100%', // ...and full width

         opacity: 0.7, // Make it slightly transparent
         backgroundColor: 'black',
         zIndex: 5000  // Make sure the zIndex is below 6000 to keep it below tooltips!
      })
      .appendTo(document.body) // Append to the document body
      .hide(); // Hide it initially
};

	
};

window.$Calendar = new function() {

	var $this = this;
	
	$(function(){ 
	
		$this.init();
		 
	});
	
	$this.init = function() {
	
		$this.applyFilterFunctionality();
	
	}
	
	$this.applyFilterFunctionality = function() {
	
		$('#filterCalButton').click(function() {
		
			//alert(1);
		
		});
	
	}
	
	
	$this.navigate = function(month, year, calendarModuleFile, targetElmId, loadingPostId) {
	       
		var extraData = '';
	       
		$('#calendarLoading').css('display', 'block');
	       
		if(($('#calFilterInternal').is(':checked'))) {
		
			extraData += '&internal';
		
		}
		
		if(($('#calFilterExternal').is(':checked'))) {
		
			extraData += '&external';
		
		}		
		
		$.ajax({
			method: 'get',
			dataType: 'html',
			url: calendarModuleFile,
			data: 'month='+month+'&year='+year+'&loadingPostId=' + loadingPostId + '&isAjax=1' + extraData,
			success: function(result) { 
			
				var targetElm = $('#' + targetElmId);				
				targetElm.html(result);
				
			},
			complete: function() {
			
				$('#calendarLoading').css('display', 'none');
			
			}
		});
		
		return false;

	}

}

window.$partnerMap = new function() {

	var $this = this;
	
	$this.openList = function(wpHome, listId) {
	
		var targetElm = $('#listWrapper2');
		var loaderElm = $('#listWrapper1 .loader');
		var listWrapper = $('#listWrapper1');
	
		listWrapper.show();
		loaderElm.show();
		targetElm.html('');
	
		$.ajax({
			method: 'get',
			dataType: 'html',
			url: wpHome + '/wp-content/themes/transbaltic/modules/partnerMapList.php',
			data: 'listId=' + listId,
			success: function(result) { 

				loaderElm.hide();			
				targetElm.html(result);
				
				$('div#partnerMapWrapper2 div#listWrapper1 div.bg').css('height', ($('div#partnerMapWrapper2 div#listWrapper2').height() + 20) + 'px');
				
			},
			complete: function() {

				$('#listWrapper1 a.close').click(function(event) {
				
					event.preventDefault();
					listWrapper.hide();
				
				});

			}
		});	
	
	}
	
	
	
}

