/* Needed scripts */
document.write('<s'+'cript type="text/javascript" src="/scripts/prototype.js"></s'+'cript>');
document.write('<s'+'cript type="text/javascript" src="/scripts/moo.ajax.js"></s'+'cript>');
document.write('<s'+'cript type="text/javascript" src="/scripts/moo.dom.js"></s'+'cript>');
document.write('<s'+'cript type="text/javascript" src="/scripts/moo.fx.js"></s'+'cript>');
document.write('<s'+'cript type="text/javascript" src="/scripts/moo.fx.pack.js"></s'+'cript>');
document.write('<s'+'cript type="text/javascript" src="/scripts/scriptaculous.js"></s'+'cript>');

/* Commonly used functions */


/* For this project */
window.onload = function(){
	setTimeout("hide_flash_notice()", 3000);
	
	$S('a.reveal').action({
		onclick: function(){
			thediv = this.className.replace('reveal ', '');
			if($(thediv).style.display == 'block')
			{
				$(thediv).style.display = 'none';
			} else {
				$(thediv).style.display = 'block';
			}
		}
	});
	
	
	$S('a.destroy').action({
		onclick: function(){
			if(confirm('Vill du verkligen ta bort?')){
				new ajax (this.href, { });
				parentdiv = this.className.replace('destroy ', '');
				Element.remove(parentdiv);
				return false;
			} else {
				return false;
			}
		}
	});
	
	/* Change of Colorschemes */
	$S('#colorscheme').action({
		onchange: function()
		{
			user_input = this.options[this.selectedIndex].value;
			new ajax ('/admin:ajax/looks/colorschemeview/' + user_input, { 
				update: $('colorschemeview')
			});			
		}
	});
	
	$S('#uploadform').action({
		onsubmit: function()
		{
			$('progressbar').style.display = 'block';			
			this.submit();
		}
	});
	
}


function hide_flash_notice()
{
	if($('flash_notice'))
	{
		$('flash_notice').style.display = 'none';
		
	} 
}

function hideit(elm, ajaxurl)
{
	if(ajaxurl != 'no')
	{
		new ajax('/' + ajaxurl, {});
	}
	$(elm).style.display = 'none';
}


var Color= new Array();
Color[1] = "ff";
Color[2] = "ee";
Color[3] = "dd";
Color[4] = "cc";
Color[5] = "bb";
Color[6] = "aa";
Color[7] = "99";

function waittofade() {
  if ($('fade')) {
    setTimeout("fadeIn(7)", 200);
  }
}

function fadeIn(where) {
  if (where >= 1) {
      document.getElementById('fade').style.backgroundColor = "#ffff" + Color[where];
    if (where > 1) {
      where -= 1;
      setTimeout("fadeIn("+where+")", 200);
    } else {
      where -= 1;
      setTimeout("fadeIn("+where+")", 200);
      document.getElementById('fade').style.backgroundColor = "transparent";
      document.getElementById('fade').id = '';
    }
  }
}

