if(top.location.href != self.location.href) top.location.href = self.location.href;

function preloadImages(){
  if(document.images){
    pic1 = new Image(16, 16);
    pic1.src = 'images/4-0.gif';
    pic2 = new Image(16, 16);
    pic2.src = 'images/accept.png';
    pic3 = new Image(16, 16);
    pic3.src = 'images/exclamation.gif';
    pic4 = new Image(48, 48);
    pic4.src = 'images/growl.jpg';
    pic5 = new Image(211, 206);
    pic5.src = 'images/bezel.png';
    pic6 = new Image(16, 16);
    pic6.src = 'images/78.gif';
  }
}

function refresh(name, value){
  $('num').focus();
  document.forms[0].reset();
  $('captcha').setProperty('name', name);
  $('captcha').setProperty('value', value);
}

window.addEvent('domready', function(){
  var help = new Fx.Style($('help'), 'opacity', {duration: 500}).start(0);
  $('help').makeDraggable();
  preloadImages();

  $('help').setStyles({
    display: 'none',
    left: getWidth() - $('help').getStyle('width').toInt() - 18,
    top: 5
  });

  $('content').addEvent('submit', function(e){
    e = new Event(e);

    new Ajax('smsSender.php', {
      method: 'post',
      evalScripts: true,
      data: $('content'),
      update: $('status'),
      onStart: $('status').setHTML('<' + 'img src="images/4-0.gif" alt="Sending&#8230;" title="Sending&#8230;" style="float: right; margin: 5px 5px 0 0;" />')
    }).request();

    e.stop();
  });

  $$('.switch').each(function(el, i){
		el.addEvent('click', function(e){
      e = new Event(e).stop();
			if($('help').getStyle('display') == 'none') $('help').setStyle('display', '');
      if($('help').getStyle('opacity') == 1) help.start(0);
      else{
        help.start(1);

        new Ajax('noteHandler.php?req=' + el.id, {
          method: 'post',
          evalScripts: true,
          update: $('middle'),
          onStart: $('middle').setHTML('<' + 'br /><img src="images/78.gif" alt="loading&#8230;" title="Sending&#8230;" style="display:block; right; margin: 0 auto;" /><br />')
        }).request();
      }
    });
	});

  $('msg').addEvent('keypress', function(){
    $('ctr').setText(160 - ($('msg').value.length + 1));
  });

  $('msg').addEvent('keyup', function(){
    $('ctr').setText(160 - ($('msg').value.length));
  });

  $('about').addEvent('click', function(){
    Growl.Bezel({
      title: 'KuripoTxt<br />by Vincent Bambico<br />and Avenson Navalta',
      text: 'Brought To You By<br />Adobolabs',
      image: 'images/growl.jpg',
      duration: 3
    });
  });
});