jQuery.fn.delay = function(time,func){
    return this.each(function(){
        setTimeout(func,time);
    });
};

$(document).ready(function() {
	$('#BrowserInfo').delay(10000, function(){
		$('#BrowserInfo').fadeOut('fast');
    });
	$('div.ServicesContainer').hide();
	$("div.LangVersion a img").add("a.RandBanner img").hover(function(){
		var url = $(this).attr('rel');
		$(this).attr('src', url);
	},
	function(){
		var url = $(this).attr('rel').split('.');
		$(this).attr('src', url[0] + 'gs.' + 'png');
	});

	$('form.SearchForm select').selectbox();
	$("#AjaxNav").parent().children('div').hide().eq(0).show();
	$("#AjaxNav").children('li').eq(0).addClass("active");
	$("#AjaxNav li a").click(function()	{
		$("#AjaxNav .active").removeClass("active");
		$(this).parent().addClass("active");

		var element_index = $("#AjaxNav a").index(this);

		$(this).parent().parent().parent().children('div:visible').hide();
		$(this).parent().parent().parent().children('div').eq(element_index).show();

		return false;
	});
	$('input[title]').each(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title'));	
			}
			
			$(this).focus(function() {
				if($(this).val() == $(this).attr('title')) {
					$(this).val('');	
				}
			});
			$(this).blur(function() {
				if($(this).val() === '') {
					$(this).val($(this).attr('title'));	
				}
			});
	});
	$('form.LoginForm').children('input').eq(1).hide();
	$('form.LoginForm').children('input').eq(2).focus(function() {
		$(this).hide();
		$(this).prev().show().focus();	
	});
	$('form.LoginForm').children('input').eq(1).blur(function() {
		if($(this).val() == '') {
			$(this).hide();	
			$(this).next().show();	
		}
	});
	$('textarea[title]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('title'));	
		}
		
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title'));	
			}
		});
	});
});

