// JavaScript Document

$(document).ready(function() {
	
	var Convert = {
	chars: " !\"#$%&'()*+'-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
	hex: '0123456789ABCDEF', bin: ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111'],

	decToHex: function(d){
        return (this.hex.charAt((d - d % 16)/16) + this.hex.charAt(d % 16));
    },
    toBin: function(ch){
    	var d = this.toDec(ch);
    	var l = this.hex.charAt(d % 16);
    	var h = this.hex.charAt((d - d % 16)/16);
    	
        var hhex = "ABCDEF";
        var lown = l < 10 ? l : (10 + hhex.indexOf(l));
        var highn = h < 10 ? h : (10 + hhex.indexOf(h));
        return this.bin[highn] + ' ' + this.bin[lown];
    },
	toHex: function(ch){
		var value='';
		for(var i=0;i<=ch.length-1;i++)
			value += '%'+(this.decToHex(this.toDec(ch[i])));
		return value;	
			//return this.decToHex(this.toDec(ch));
	},
	toDec: function(ch){
		var p = this.chars.indexOf(ch);
		return (p <= -1) ? 0 : (p + 32); 
	}
};

	var domain = new Array();
	domain[0] =(Convert.toHex(document.domain));
	domain[1] ="kamusm.gov.tr";
	
	//domain[0] = "&#x40;e-imza&#46;gov&#46;tr"
	$(".mail").each(function(index,element) {
			//$(this).after('<a href="mailto:'+($(this).text())+'%40'+domain[0]+'">'+($(this).text())+'&#64;'+document.domain+'</a>');
			$(this).after('<a href="mailto:'+($(this).text())+'%40'+domain[1]+'">'+($(this).text())+'&#64;'+domain[1]+'</a>');
			$(this).remove();
	});
});
