
$(document).bind('css_ready', function(){

	//var ignoreMe = document.body.offsetWidth;
	//alert(ignoreMe);

	window.scrollBy(0,1);

	function descramble(a){f=a.split('%');var out='';for(i=1;i<f.length;i++)out+=String.fromCharCode(parseInt(f[i],16)-5);return out;}
	var mailaddress = descramble('%6e%73%6b%74%45%71%6e%67%6a%77%7a%73%6e%79%78%33%73%71');

	if ($.browser.msie)
	{
		$('body').addClass('ie');
		$('body').addClass('ie'+$.browser.version.match(/[0-9]+/));
		
		$('input[type=radio], input[type=checkbox]').css({border: 'none'});

		$("input[type=text], textarea")
			.focus(function(){  $(this).addClass('focus'); } )
			.blur(function(){   $(this).removeClass('focus'); } );
	
		$("button").hover(function(){  $(this).addClass('hover'); }, function(){  $(this).removeClass('hover'); } );
	}
	else
	{
		$('body').addClass('std');
	}

	$('a.popup').tmodal();

	$('a.edit').click(function()
			{
				PopUp(this.href);
				return false;
			});

	AutoItemHeight();

	$('.textblock').shadow();
	

	$('div.items div.item')
		.hover(function() {  $(this).addClass('my_hover'); }, function() {  $(this).removeClass('my_hover'); })
		.click(function(){ location.href = $(this).find('> a[href]').attr('href'); });


	$('.email_href').attr('href', 'mailto:' + mailaddress);
	$('.email_content').text(mailaddress);


});

function wait_for_css()
{
	$(document.body).append('<div id="css_tester" style="display: none;"></div>');
	if ( parseInt($('#css_tester').css('margin-left')) )
	{
		$(document).triggerHandler('css_ready');
	}
	else
	{
		setTimeout(wait_for_css, 10);
	} 
}

$(document).ready(function(){
		if ($.browser.safari) wait_for_css();
		else $(document).triggerHandler('css_ready');
});
/*
$(function(){


});
*/

function PopUp(url)
{
	window.open(url, '','width=850,height=600,resizable=no,scrollbars=yes,top='+((screen.availHeight/2)-(600/2))+',left='+((screen.availWidth/2)-(850/2)-10)+'');
}


function AutoItemHeight()
{

	$('div.items').each(function(){

			var div = $(this).find('div:eq(0)');
			var top = 0;
			var max_height = 0;

			while (div.length)
			{
				var cur_top = div.offset().top;
				var cur_height = div.height();

				if (cur_top > top)
				{
					top = cur_top;
					max_height = cur_height;
				}
				else
				{
					if (cur_height < max_height)
					{
						div.height(max_height);

					}
					else
					{
						max_height = cur_height;

						for (c_div = div; c_div.length && (c_div.offset().top==cur_top) ; c_div = c_div.prev())
						{
							c_div.height(max_height);

						}
					}
				}
				div = div.next();
			}
		});

}








