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

document.observe("dom:loaded", function() {
  // the element in which we will observe all clicks and capture
  // ones originating from pagination links
  var container = $(document.body)

  if (container) {
    var img = new Image
    img.src = '/images/spinner.gif'

    function createSpinner() {
      new Element('img', { src: img.src, 'class': 'spinner' })
    }

    container.observe('click', function(e) {
      var el = e.element()
      if (el.match('.pagination a')) {
        el.up('.pagination').insert(createSpinner())
        new Ajax.Request(el.href, { method: 'get' })
        e.stop()
      }
    })
  }
})

function Transpose_Email(userid,domain,subject)
{
	var email = domain +'@' + userid;
	var TempBefore = '';
	var TempAfter = '';
	var NewString = '';
	var Start = 0;
	
	var WhereHash = email.indexOf ('@');
	for (Count = 1; Count <= WhereHash; Count ++)
	{
		TempBefore += email.substring (Start, Count);
		Start++
	}
	Start = WhereHash;
	Start ++
	WhereHash +=2;
	for (Count = WhereHash; Count <=email.length; Count++)
	{
		TempAfter +=email.substring (Start, Count)
		Start++
	}
	NewString = TempAfter +'@' + TempBefore;
	parent.location = 'mailto:'+NewString+'?subject='+subject;
}

// Script by hscripts.com 
//Edit the counter/limiter value as your wish
/*var count = "250";
function limiter() 
{
	var tex = document.new_prayer.prayer[content].value;
	var len = tex.length;
	if(len > count){
        tex = tex.substring(0,count);
        document.new_prayer.prayer[content].value =tex;
        return false;
			}
document.new_prayer.limit.value = count-len;
}
*/

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Steve | http://jsmadeeasy.com/ */
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("-CHAR-",length);
}


