// JavaScript Document
$(document).ready(function()
{
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
		$("#close").show();
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
		$("#close").hide();
	});			
	
	$('div.pageTabs a').each(function(_i)
	{
      $(this).click(function()
      {
         $('div.pageTabs a').each(function(_i2)
         {
           $(this).toggleClass('on',_i2==_i);
         });
         var _margin = (690 * _i) * -1;
         $('div.pagePane').stop().animate({marginLeft:_margin+'px'}, 500);
   		return false;
      });
	});
	
	$('#navigationDropdown').hover(function(){$(this).addClass('hov');},function(){$(this).removeClass('hov');});
	$('#nav_link_2').parent().hoverIntent(function(){$('#navigationDropdown').addClass('nav');},function(){$('#navigationDropdown').removeClass('nav');});
	
	if ($.fn.prettyPopin)
	{
		$("a[rel^='contact']").prettyPopin({
			modal: false, /* true/false */
			width: 500, /* true/false */
			height: false, /* true/false */
			opacity: 0.1, /* value from 0 to 1 */
			animationSpeed: 'fast', /* slow/medium/fast */
			followScroll: true, /* true/false */
			loader_path: '/images/preloader-white.gif', /* path to your loading image */
			callback: function(){} /* callback called when closing the popin */
		});
	}
	
	$("#add_comment .genericForm,div.pageContent .genericForm").submit(function()
	{
		var _parameters = $(this).serialize();
		var _this = this;
		
		_parameters += '&ajax=1';
		
		$.ajax({type: 'POST', url: _this.action, data: _parameters, dataType: 'json', success: function(_data) 
		{
			if (_data.ok == 1)
			{
				$(_this).hide();
				$('.error_content',$(_this).closest('div')).fadeOut(0).html('<div class="info-success">'+_data.response+'</div>').fadeIn('slow');
			}
			else
			{
				$('.error_content',$(_this).closest('div')).fadeOut(0).html('<div class="info-error">'+_data.response+'</div>').fadeIn('slow');
				
				var _key = $('#tbxKey');
				
				if (_key.length == 1)
				{
					$('#tbxKeyCode').val('');
					var _src = _key.attr('src')+'?'+(new Date()).getTime();
					_key.attr('src',_src);
				}
			}
		}
		});
		return false;
	});
	
	$('#tbxComment').focus(function()
	{
		var _this = $(this);
		if (_this.val() == 'Type your comment here...') _this.val('');
	}).blur(function()
	{
		var _this = $(this);
		if (_this.val() == '') _this.val('Type your comment here...');
	});
});
