// JavaScript Document

function changeText(s) {
	if (s=='b' && $('url').value=='' || $('url').value=='http://') {
		$('url').value='enter a long url here to make it short';
		$('url').style.textAlign='center';
		$('url').style.border='1px solid #c1c1c1';
	}		
	if (s=='f' && ($('url').value=='http://' || $('url').value=='enter a long url here to make it short')) {
		$('url').value='http://';
		$('url').style.textAlign='left';
		$('url').style.border='1px solid #000000';
	}	
}

function changePw(s) {
	if (s=='b' && $('pw').value=='') {
		$('pw').type='text';
		$('pw').value='optional password here';
		$('pw').style.textAlign='center';
		$('pw').style.border='1px solid #c1c1c1';
	}		
	if (s=='f' && $('pw').value=='optional password here') {
		$('pw').type='password';
		$('pw').value='';
		$('pw').style.textAlign='left';
		$('pw').style.border='1px solid #000000';
	}	
}

function createUrl() {
	formS=Form.serialize($('form'));

	if (formS==null) { var formS='url='; }
		$('newurl').innerHTML='<img src="/images/load.gif">';
		$('dwarfit').disabled=true;

/*	urlTwo=urlOne.replace("?", "[!q]");
	urlThree=urlTwo.replace("&", "[!a]");
	url=urlThree.replace("=", "[!e]");
*/
	//alert(url);
	password=$('pw').value;
	
 	var ajax = new Ajax.Updater('newurl', '/newurl.php', {method: 'post', parameters: formS,
	onComplete: function() { Effect.BlindDown('newurl'), { duration: .10 }; setTimeout("$('dwarfit').disabled=false;",3000); }}
	);
	
}

function install (aEvent)
{
  var params = {
    "dwarfURL Extension": { URL: aEvent.target.href,
             IconURL: aEvent.target.getAttribute("iconURL"),
             
             toString: function () { return this.URL; }
    }
  };
  InstallTrigger.install(params);
  new Ajax.Request('/ffdownload.php', {method:'post', postBody:'dl=1'});
  

  return false;
}

function installUpdate (aEvent)
{
  var params = {
    "dwarfURL Extension": { URL: aEvent.target.href,
             IconURL: aEvent.target.getAttribute("iconURL"),
             
             toString: function () { return this.URL; }
    }
  };
  InstallTrigger.install(params);
  new Ajax.Request('/ffupdate.php', {method:'post', postBody:'dl=1'});
  

  return false;
}

function feedback(answer) {

	$('yes').disabled=true;
	$('no').disabled=true;

/*	urlTwo=urlOne.replace("?", "[!q]");
	urlThree=urlTwo.replace("&", "[!a]");
	url=urlThree.replace("=", "[!e]");
*/
	//alert(url);
	
 	var ajax = new Ajax.Updater('feedbackanswer', '/feedback.php', {method: 'post', parameters: 'answer=' + answer,
	onComplete: function() { Effect.Puff('feedback'), { duration: .10 };  }}
	);
	
}

function clearHistory() {

var ajax = new Ajax.Updater('clearhistory', '/clearhistory.php', {method: 'post', parameters: '',
	onComplete: function() { Effect.Appear('clearhistory'), { duration: 1.2 };  }}
	);
	
}