var Chesterton = {
	homepage: {}
}
Chesterton.initFormPlaceholders = function(search, cls) {
	$(search).addClass(cls).focus(function() {
		if ($(this).val() == this.defaultValue) {
			$(this).val('').removeClass(cls);
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).addClass(cls).val(this.defaultValue);
		}
	});
}
Chesterton.homepage.initShowcaseDialogs = function(search) {
	$(search).click(function() {
		var width = (screen.width > 1024)? 800: 750;
		var height = (screen.height > 768)? 670: 570;

		$(document.createElement('div')).html($(this).parent().next().html()).dialog({
			dialogClass: 'dialog',
			modal: true,
			resizable: false,
			width: width,
			height: height,
			title: $(this).text()
		});
		return false;
	});
}
	Chesterton.rot13 = function(a) {
	    var rot13map = Chesterton.rot13init();
	  s = "";
	  for (i=0; i<a.length; i++)
	    {
	      var b = a.charAt(i);

	      s	+= (b>='A' && b<='Z' || b>='a' && b<='z' ? rot13map[b] : b);
	    }
	  return s;
	}
	Chesterton.rot13init = function() {
	  var map = new Array();
	  var s = "abcdefghijklmnopqrstuvwxyz";

	  for (i=0; i<s.length; i++) {
	    map[s.charAt(i)]			= s.charAt((i+13)%26);
	  }
	  for (i=0; i<s.length; i++) {
	    map[s.charAt(i).toUpperCase()]	= s.charAt((i+13)%26).toUpperCase();
	  }
	  return map;
	}
$(document).ready(function() {
	Chesterton.initFormPlaceholders('input.placeholder', 'placeholder_js');
	$('.ad').each(function(i) {
		$(this).text(Chesterton.rot13('Ntragf Qryvirerq'));
	});
	$('.pc').each(function(i) {
		$(this).text(Chesterton.rot13('Cebira Perqvoyr'));
	});
});