//var bh = 0;

$(document).ready(function() {
	var s = 'com';
	var d = 'ua';
	var u = 'elsie';
	$('.ldr').each(function(){
		var m = this.id + '@' + u +
			'.' + s + '.' + d;
		$(this).replaceWith('<a style="color:#000;" class="email" href="mailto:' +
			m + '">' +
			m + '</a>'
		);
	});

	$('.menu_td_block').mouseover(function() {
		$(this).width($(this).parent('td').width());	// width div <= width td
		$(this).css('position', 'absolute');
		$(this).css('top', '0');
		$(this).children('ul').width($(this).width());	//width ul <= width div
		w_ul = $(this).children('ul').width();
		$(this).children('ul').children('li').children('a').width(w_ul);	// width ul li a <= width ul - 15px
		$(this).children('ul').children('li').children('a').children('span.text').width(w_ul - 15);
		$(this).children('ul').css('display', 'block');	
		$(this).children('ul').children('li').last().addClass('last_li'); //last-1
		$(this).children('ul').children('li').eq(0).addClass('first'); //for last
	});

	$('.menu_td_block').mouseout(function() {
		$(this).children('.sub').css('display', 'none');
		$(this).css('position', 'static');
		$(this).width('100%');							//unbiliveble
	});
/*
	bh = $("#content").height();
	set_height();
*/
}); 

/*
$(window).resize(function() {
	set_height();
});

function set_height(){
	// 315 + 81
	var wh = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight)) - 396;
	if(bh != 0 && bh < wh && !$('#result').length) {
		$("#content").height(wh);
	}
}
*/

function InputPlaceholder(input, value, cssFilled, cssEmpty) {
	var thisCopy = this;
	this.Input = input;
	this.Value = value;
	this.SaveOriginal = (input.value == value);
	this.CssFilled = cssFilled;
	this.CssEmpty = cssEmpty;

	this.setupEvent(this.Input, 'focus', function() {
		return thisCopy.onFocus();
	})
	this.setupEvent(this.Input, 'blur', function() {
		return thisCopy.onBlur();
	})
	this.setupEvent(this.Input, 'keydown', function() {
		return thisCopy.onKeyDown();
	})

	if (input.value == '') {
		this.onBlur();
	}
	
	return this;
}

InputPlaceholder.prototype.setupEvent = function(elem, eventType, handler) {
	if (elem.attachEvent) {
		elem.attachEvent('on' + eventType, handler);
	}

	if (elem.addEventListener) {
		elem.addEventListener(eventType, handler, false);
	}
}

InputPlaceholder.prototype.onFocus = function() {
	if (!this.SaveOriginal && this.Input.value == this.Value) {
		this.Input.value = '';
	} else {
		this.Input.className = '';
	}
}

InputPlaceholder.prototype.onKeyDown = function() {
	this.Input.className = '';
}

InputPlaceholder.prototype.onBlur = function() {
	if (this.Input.value == '' || this.Input.value == this.Value) {
		this.Input.value = this.Value;
		this.Input.className = this.CssEmpty;
	} else {
		this.Input.className = this.CssFilled;
	}
}

