// JQuery form-default-value-remover-on-focus by KOTE 
(function($) {
	$.fn.inputDefualts = function(options) {
		// Values by default
		var defaults = {
 			text: this.val()   // take the value of the input
  		}, 	opts = $.extend(defaults, options);	
  		
  		this.val(opts['text']);			// set the deffault value
  		
  		// handlling focus event on the field
  		this.focus(function() {
  			if($(this).val() == opts['text']) $(this).val(''); // remove default text on focus
  		});
  		
  		// handling blur (unfocus) event
  		this.blur(function() {
  			if($(this).val() == '') {
  				$(this).val(opts['text']); 			// set the default value back
  			}
  		});
	};
	
})(jQuery);


$(function(){
	
	// form-default-value-remover-on-focus
	$('#fdb-block input[name=name]').inputDefualts({ text: 'name' }); 
	
	$('#fdb-block input[name=mail]').inputDefualts({ text: 'mail' });
	
	$('#fdb-block textarea[name=text]').inputDefualts({ text: 'comment' });
	
}); 

/*******************/


// JavaScript Document
function getAnswer(faq_id,status,text)
{
	if(status == 1) {
		$('#answer_'+faq_id).slideDown('fast');
		$('#a_'+faq_id).attr('onClick',"getAnswer('"+faq_id+"','2','"+$('#a_'+faq_id).html()+"')");
		$('#a_'+faq_id).html(text);
		$('#div_'+faq_id+" span").each(function() {
			$(this).css("font-weight","bold");
		});
	} else {
		$('#answer_'+faq_id).slideUp('fast');
		$('#a_'+faq_id).attr('onClick',"getAnswer('"+faq_id+"','1','"+$('#a_'+faq_id).html()+"')");
		$('#a_'+faq_id).html(text);
		$('#div_'+faq_id+" span").each(function() {
			$(this).css("font-weight","normal");
		});
	}
}

function showDepartments()
{
	$("#deps li").each( function () {
		$(this).show();
	});
	$("#showDeps").hide();
}
function hideDepartments()
{
	var i=0;
	$("#deps li").each( function () {
		i = i+1;
		if(i>4) {
			$(this).hide();
		}
	});
}

function menuLine()
{
	var menu = $('#horiz_nav');
	
	var items = $('#horiz_nav>li');
	var subItem = $('#horiz_nav>li>ul');
	var current = $('#horiz_nav>li[class="selected"]');
	var cur = $(current)[0] || $('#horiz_nav>[class="par_selected"]')[0];
	
	var setLeft = typeof(cur) !== 'undefined' ? cur.offsetLeft : 0;
	var setWidth = typeof(cur) !== 'undefined' ? cur.offsetWidth : 0;

	var line = $('#topMenuLine').css({
		left: setLeft,
		width: setWidth
	});
	if(typeof(cur) == 'undefined') {
		line.hide();
	}

	current.addClass('current');
	items.dequeue().each(function(){
		var me = $(this);
		me.mouseenter(function(){
			current.removeClass('current');
			line.stop().animate({
				left: me[0].offsetLeft,
				width: me[0].offsetWidth
			}, 'normal');
		});
	});
	menu.mouseleave(function(){
		line.stop().animate({
			left: setLeft,
			width: setWidth
		}, 'normal', function(){
			if(typeof(cur) == 'undefined') {
				line.hide();
			}
			current.addClass('current');
		});
	});
}

function centerSubMenu()
{
	var items = $('#horiz_nav>li');
	items.each(function(){
		var li = $(this);
		var ul = $(this).find('ul');
		//ul.css('left', '-' + ((ul.width()-li.width())/2) + 'px');
		ul.css('width', ul.width() + 'px');
	});
}
function showSubMenuHover() 
{
	var items = $('#horiz_nav>li');
	items.hover(function(){
		var ul = $(this).find('ul');
		ul.fadeIn('fast');
		//ul.stop().animate({ bottom: '-' + (ul.height()+5) + 'px' }, 'normal');
	}, function(){
		var ul = $(this).find('ul');
		ul.hide();
		//ul.stop().animate({ bottom: '13px' }, 'normal');
	});
}








