jobArray = new Array (
	"Персональный блог начинающего iconmaker’а",
	"Персональный блог какого-никакого дизайнера",
	"Персональный блог какого-то flasher’а",
	"Персональный блог дивного верстальщика",
	"Персональный блог какого-то странного человека",
	"Персональный блог в каком-то смысле программиста"
);
randomJob = Math.round (Math.random()*jobArray.length);
keyisdown = false;

$(function () {

	
	window.startTime = new Date ();
	window.allHTML = $("#body").html ();
	mailChecker = /([0-9a-z][a-z0-9_.\-]*)[\(\[\^]{1}(тяф-тяф|©|.*?)[\)\]\^]{1}([0-9a-z][0-9a-z_.\-]*[.]([a-z]{2,4}))/g
	
	emailSecure = window.allHTML.replace(mailChecker, function (str, one, two, three) {
		if (two=="тяф-тяф")
			return '<a href="mailto:'+one+'@'+three+'">'+one+'@'+three+'</a>';
		else if (two=="©")
			return one+'@'+three;
		else
			return '<a href="mailto:'+one+'@'+three+'">'+two+'</a>';
	});
	
	$("#body").html (emailSecure);
	window.stopTime = new Date ();
	window.res = stopTime-startTime;

	$(".banner span").hover (function (){
		$(this).addClass ("hover");
	}, function (){
		$(this).removeClass ("hover");
	});
	
	$(".comments").hover (function (event) {
		clearTimeout (this.timeout);
		that = this;
		this.timeout = setTimeout (function () {
			if (!$(that).find(".comments-summ b").css("display")) {
				$(that).find (".view-comments").hide();
			}
			if (!$(that).parent().find(".more-link").css("display")) {
				$(that).find (".read-more").hide();
			}
			$(that).find (".subsumm").slideDown ("fast");
		}, 700);
	}, function (event) {
		clearTimeout (this.timeout);
		this.timeout = setTimeout (function () {
			$(that).find (".subsumm").slideUp ("fast");
		}, 500);
	}).click (function () {
		clearTimeout (this.timeout);
	});
	$(window).scroll (function (event) {
		scroll = parseInt (self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop));
		
		if (scroll>125) {
			$("#head .note").text (jobArray[randomJob]);
		}else {
			randomJob = Math.round (Math.random()*jobArray.length);
		}
	});
	$(window).resize (function () {
		if ($(window).width()>1210) {
			$("#genicon").fadeIn (400);
		}else {
			$("#genicon").fadeOut (400);
		}
	});
	$(window).resize();
	
	$("#genicon").dblclick (function() {
		$("#head .fn").attr ("href", "/wp-admin");
	});
	
	
	targetBlank = function (title, myurl) {
		var regExp = new RegExp ();
		if (!myurl)
			myurl = window.location.host;
		regExp.compile (myurl+"|^/|^mailto:", "i");
		var aArray = document.getElementsByTagName ("a");
		var aLen = aArray.length;
		for (var i=0; i<aLen; i++) {
			if (!regExp.test (aArray[i].getAttribute("href"))) {
				if (!aArray[i].getAttribute("target")) {
					if (!aArray[i].getAttribute("title"))
						aArray[i].setAttribute("title", title);
					aArray[i].setAttribute("target", "_blank");
					aArray[i].className += " targetblank";
				}
			}
		}
	}
	targetBlank("Открыть в новом окне");
	
});
