// JavaScript Document

$(function (){
	base_url=$('base').attr('href');
	Cufon.replace('h1', {fontFamily: 'Bodoni SvtyTwo OS ITC TT', hover:'true'});
	//$('.menu li.active').removeClass('active');
	$('.menu>ul li').hover(function(){$('ul',this).fadeIn('slow')},function(){$('ul',this).hide()});

	$('.menu li a').each(function(){
		if(location.href.indexOf($(this).attr('href'))!=-1){
			$(this).closest('ul').find('li').removeClass('active');
			$(this).parent().addClass('active');
		}
	});

	var n=$('.top_image img').size();
	if(n>1){
		//preparing the inner fade thing
		$('.top_image img').wrap('<li class="slide"></li>');
		$('.top_image').wrapInner('<ul class="slides"></ul>');

		$('.top_image .slides').height($('.top_image .slides li').height());

		$('.top_image').append('<ul class="navigation"></ul>');

		//now preparing the navigation
		for(var i=1;i<=n;i++){
			$('.top_image .navigation').append('<li><a href="javascript:;" class="page">'+i+'</a></li>');
		}
		$('.top_image').slideShow({
			interval: 3
		});

	}
	
	$('.close').click(function(){
		var href='http://'+decodeURIComponent(top.document.location.href.split("url=")[1]);
		top.location.href=href;
		return false;
	});
	
	$('.item.frame a').each(function(){
		var href=$(this).attr('href');
		href=href.replace('http://','');
		href=href.replace('https://','');
		href=encodeURIComponent(href);
		href='frame?url='+href;
		$(this).attr('href',href);
		$(this).removeAttr('target');
	})

})


