$('.hidden').hide();

/*
function setPos() {
	if ($(window).height()>=$(document).height()) {
		$('#footer').css({
			'position': 'absolute',
			'bottom': '0'
		});
		alert('x');
	}
	else {
		$('#footer').css({
			'position': 'relative'
		});
		alert('stop');
	}
}

$(document).ready(setPos());

$(window).resize(setPos());
*/

$('.mail').each(function(i) {
	/* <![CDATA[ */
	var mail = ($(this).text());
	mail = mail.replace(' [dot] ', '.');
	mail = mail.replace(' [at] ', '@');
	
	var result = '<a href="mailto:'+mail+'">'+mail+'</a>';
	// x = result.replace(' [dot] ', '.');
	
	$(this).html(result);
	/* ]]> */
});

$('a').each(function() {
	var a = new RegExp('/' + window.location.host + '/');
	if(!a.test(this.href)) {
		$(this).click(function(event) {
			event.preventDefault();
			event.stopPropagation();
			window.open(this.href, '_blank');
		});
	}
});

$('a#clients').click(function() {
	var loginBox = $('#clientLoginDiv');
	
	if ($(loginBox).is(':hidden')) {
		$(loginBox).show();
	}
	
});


var mouse_is_inside = false;

$(document).ready(function() {
    $('#clientLoginDiv').hover(function(){ 
        mouse_is_inside=true; 
    }, function(){ 
        mouse_is_inside=false; 
    });

    $(body).mouseup(function(){ 
        if(! mouse_is_inside) $('#clientLoginDiv').hide();
    });
    
    
    
        // initialize scrollable 
    $("div.scrollable").scrollable({
    	size: 1,
    }).navigator();
    
    $('a.browse').click(function() {
		return false;
	});
    

	$("input.file").filestyle({ 
		image: "/images/filebrowse.png",
		imageheight : 26,
		imagewidth : 66,
		width : 130
	});
					
    
    
});

			$('#contactForm').submit(function() {
				variables = $(this).serialize();
				$('#form').fadeOut('slow');

				$.post($(this).attr('action'), variables, function(response) {
					$('#form').html(response);
					$('#form').fadeIn('slow');
				});
			
				return false;
			});

