// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function toggleSpinner(specific_id) {
	var id = 'spinner';
	if (specific_id) id = specific_id;	 
	var spinner = document.getElementById(id);	
	if (spinner.style.visibility != 'visible')
		showSpinner();
	else
		hideSpinner();
		
	return true
}

function hideSpinner(specific_id) {
	var id = 'spinner';
	if (specific_id) id = specific_id;
	var spinner = document.getElementById(id);	
	spinner.style.visibility = 'hidden';
	return true
}

function showSpinner(specific_id) {
	var id = 'spinner';
	if (specific_id) id = specific_id;
	var spinner = document.getElementById(id);	
	spinner.style.visibility = 'visible';
	return true
}

  function textileReference() {
      window.open( 
          "/admin/textile.html",
          "textile",
          "height=600,width=550,channelmode=0,dependent=0," +
          "directories=0,fullscreen=0,location=0,menubar=0," +
          "resizable=0,scrollbars=1,status=1,toolbar=0"
      );
  }


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();


function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}
