//jQuery.noConflict();

$(document).ready(function()
{
	// top link header drawer
	$('#drawer').click(function() {
		slideLoginDrawer();
	});
	
	// erase initial keywords
	$('#search_keywords').focus(function() {
		if (this.value == 'cauta subiecte sau articole')
			this.value = '';
	});
	
	// extend link (make page 100% wide)
	$('#extend_link').click(function() {
		var current = $('#footer').parent().attr('class');
		current = current.split("_");
		current = current[2];
		
		if (current == 'extended') {
			$('.main_header_extended').switchClass('main_header_extended', 'main_header', 1000);
			$('.main_search_extended').switchClass('main_search_extended', 'main_search', 1000);
			$('.main_content_extended').switchClass('main_content_extended', 'main_content', 1000);
			$('.main_footer_extended').switchClass('main_footer_extended', 'main_footer', 1000);
			$('#extend_link').html("&laquo; Intinde-te cat ti-e plapuma &raquo;");
		}
		else {
			$('.main_header').switchClass('main_header', 'main_header_extended', 1000);
			$('.main_search').switchClass('main_search', 'main_search_extended', 1000);
			$('.main_content').switchClass('main_content', 'main_content_extended', 1000);
			$('.main_footer').switchClass('main_footer', 'main_footer_extended', 1000);
			$('#extend_link').html("&laquo; Strange-ti randurile! &raquo;");
		}
	});
	
	// sections accordion
	if ($("#sectionacc").length != 0)
		$('#sectionacc').accordion({ active: false, autoHeight: false, collapsible: true })
	
	// jQuery UI buttons
	if ($(".ui_button").length != 0)
		$('.ui_button').button();
	
	// profile edit details
	$('#profile_details_edit_link').click(function() {
		$('#profile_details').hide();
		$('#profile_details_edit').show(200);
	});
	$('#profile_details_cancel_link').click(function() {
		$('#profile_details_edit').hide();
		$('#profile_details').show(200);
	});
	
	if ($("a.lightbox").length != 0)
		$('a.lightbox').lightBox();
	
	// carousel scroller
	if ($('#scroller').length != 0) {
		$('#scroller').jcarousel({
			scroll: 1
	    });
	}
	
	// jQuery rating system
	//bindRatingSystem();

});

function slideLoginDrawer() {
	if ($('#headeruser').attr('drawer_status') == 1) {
		$('#headeruser').slideUp();
		$('#headeruser').attr('drawer_status', '0');
	}
	else {
		$('#headeruser').slideDown();
		$('#headeruser').attr('drawer_status', '1');
	}
}
