$(document).ready(function () {
	//if ($(window).height() < $(document).height()) { $('div.top').css('height', '900px'); }
//else { $('div.top').css('height','100%'); } 

	Cufon.replace('.left-col h2', { fontFamily: 'Myriad' });
	Cufon.replace('.rblock h2', { fontFamily: 'Myriad' });
	Cufon.replace('.right-col h2', { fontFamily: 'Myriad' });
	Cufon.replace('.over-form h3', { fontFamily: 'Myriad' });
	Cufon.replace('.slogan', { fontFamily: 'Myriad' });
	Cufon('.nav a.flevel', { fontFamily: 'Myriad', hover: { color: '#9B002A' }});
	//$('div.scroll-pane').jScrollPane({showArrows: true});
	/*
	$('#slider').before('<div><div id="pager">').cycle({ 
		fx:     'scrollHorz', 
		timeout: 4000, 
		next:   '#next', 
		prev:   '#prev',
		cleartypeNoBg: true,
		pager:  '#pager'
	}).after('</div>');
	$('#scroll').cycle({ 
		fx:     'scrollHorz', 
		slideExpr: 'div',
		speed:  400, 
		timeout: 0, 
		cleartypeNoBg: true,
		next:   '#tnext', 
		prev:   '#tprev' 
	});
	*/
	$('a.tlevel').live("click", function(){
		var lnk = $(this);
		var lnk2 = $(this).parent().parent().parent().parent().parent().children('div').children('ul').children('li').children('ul').children('li').children('a');
		$.each( lnk2.parent().parent(), function(){
		   $(this).parent().parent().children('li').children('ul').slideUp();
		 });

		$(this).parent().parent().children('ul').slideToggle('slow', function(){ 
			colHeight();			
			if (lnk.parent().parent().hasClass('selected')) { 
				lnk.parent().parent().removeClass('selected'); 
			}
			else { 
				lnk.parent().parent().parent().children('li').removeClass('selected'); 
				lnk.parent().parent().addClass('selected'); 
			}
		});
	});
	$('div.archive a.tlevel').live("click", function(){
		$(this).parent().children('ul').slideToggle('show');
		if ($(this).parent().hasClass('selected')) { 
			$(this).parent().removeClass('selected'); 
		}
		else { 
			$(this).parent().parent().children('li').removeClass('selected'); 
			$(this).parent().addClass('selected'); 
		}
		colHeight();
	});
	$('#tosubscribe').live("click", function(){ $('#osubscribe').toggle(); });
	colHeight();
	//$('#osend').live("click", function(){ $('#osubscribe').hide(); });
	
	//$.each($('a'), function(index, value) {
	//	if($(this).attr('href')!='' && $(this).attr('href')!='#' && $(this).attr('href')!='javascript:;' && $(this).attr('href')[1]!='#'){
	//		$(this).attr('href','/#'+$(this).attr('href'));
	//	}
	//});
});
function colHeight() {
	if ($('#wrap').height() < $(window).height()) { $('#wrap').height($(window).height()); }
	$('div.left-col').css('height', '900px'); 
	$('div.right-col').css('height', 'auto'); 
	if ($('div.left-col').height() < $('#wrap').height()) { 
		$('div.left-col').css('height', $('#wrap').height()); 
		var version = jQuery.browser.version || "0";
		var splitVersion = version.split('.');
		if ((navigator.userAgent.toLowerCase().indexOf('chrome') > -1) || (navigator.userAgent.toLowerCase().indexOf('safari') > -1)) { 
			$('div.left-col').css('height', $('#wrap').height() + 107);  
		}
		if ((jQuery.browser.opera && splitVersion[0] >= 9) || !!( (/msie 8./i).test(navigator.appVersion) && !(/opera/i).test(navigator.userAgent) && window.ActiveXObject && XDomainRequest && !window.msPerformance )) { 
			$('div.left-col').css('height', $('#wrap').height() + 107);  
			$('div.about').css('padding-bottom', 116);  
		}
	}
	if ($('div.right-col').height() < $('#wrap').height()) { 
		$('div.right-col').css('height', $('#wrap').height()); 
	}
	$('div.top').css('height',  $('#wrap').height());
	if ($('div.top img').height() < $('#wrap').height()) { $('div.top img').css('height', '100%'); $('div.top img').css('width', 'auto'); }
	if ($('div.top img').width() < $('#wrap').width()) { $('div.top img').css('width', '100%'); $('div.top img').css('height', 'auto'); }
}
function SearchForm(){
	$.ajax({
				type: "POST",
				url: "/ajax.php",
				data: $('#search_form').serialize(),
				success: function(data){
					$('#container_main').html(data);
					Cufon('.nav a.flevel', { fontFamily: 'Myriad', hover: { color: '#570623' }});
					Cufon.replace('.rblock h2', { fontFamily: 'Myriad' });
					Cufon.replace('.right-col h2', { fontFamily: 'Myriad' });
					Cufon.replace('.over-form h3', { fontFamily: 'Myriad' });
					Cufon.replace('.slogan', { fontFamily: 'Myriad' });
					Cufon('.nav a.flevel', { fontFamily: 'Myriad', hover: { color: '#570623' }});
					
					if(firstlevel==1){
						$('a.slevel').eq(0).parent().parent().addClass('selected');
					}
					
					$.each($('a'), function(index, value) {
						if($(this).attr('rel')!=''){
							$(this).attr('href','/#'+$(this).attr('rel'));						
														
						}
					});
				}
			});
	
	return false;
}
