// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function toggleSearch() {
	if ($('FooterButtonSearch').style.width == '200px') {
		new Effect.Morph('FooterButtonSearch', {
		  style: 'width: 450px;', // CSS Properties
		  duration: 0.25 // Core Effect properties
		});
		
		// Collapse the other one.
		new Effect.Morph('FooterButtonJoin', {
		  style: 'width: 260px;', // CSS Properties
		  duration: 0.25 // Core Effect properties
		});
	} else {
		new Effect.Morph('FooterButtonSearch', {
		  style: 'width: 200px;', // CSS Properties
		  duration: 0.25 // Core Effect properties
		});
	}
}

function toggleJoin() {
	if ($('FooterButtonJoin').style.width == '260px') {
		new Effect.Morph('FooterButtonJoin', {
		  style: 'width: 450px;', // CSS Properties
		  duration: 0.25 // Core Effect properties
		});

		// Collapse the other one.
		new Effect.Morph('FooterButtonSearch', {
		  style: 'width: 200px;', // CSS Properties
		  duration: 0.25 // Core Effect properties
		});
	} else {
		new Effect.Morph('FooterButtonJoin', {
		  style: 'width: 260px;', // CSS Properties
		  duration: 0.25 // Core Effect properties
		});
	}
}

var remove_home_dropdown_timeout;

function showHomeDropDown() {
	$('HomeDropDown').style.display = 'block';
	
	if (remove_home_dropdown_timeout) {
		clearTimeout(remove_home_dropdown_timeout);
	}
}

function hideHomeDropDown() {
	remove_home_dropdown_timeout = setTimeout("$('HomeDropDown').style.display = 'none';",1000);
}

function dropdown_item_over(img) {
	img.src = img.src.replace('default.png', 'hover.png');
}

function dropdown_item_out(img) {
	img.src = img.src.replace('hover.png', 'default.png');
}


function showTab(idx, anchor, content_image, background_image) {
	tabs = $$('#side_nav .tab');
	
	tabs.each(function(tab, index) {
		if (index == idx) {
			activateTab(tabs, index);
		} else {
			deactivateTab(tabs, index);
		}
	});
	
	if (content_image != null) {
		$('ContentMainImage').src = content_image;
	}
	
	if (background_image != null) {
		$('ContentBox').style.backgroundImage = "url('" + background_image + "')";
	}

	anchor.blur();
}

function activateTab(tabs, idx) {
	tabs[idx].removeClassName('tab_inactive');
	tabs[idx].addClassName('tab_active');
	$('tab_content[' + idx + ']').show();
}

function deactivateTab(tabs, idx) {
	tabs[idx].removeClassName('tab_active');
	tabs[idx].addClassName('tab_inactive');
	$('tab_content[' + idx + ']').hide();
}

