//Инициализация формы поиска
function setUpSearchTextField () {
	var searchText = $("#search-text");
	if (searchText) {
		var placeHolder = searchText.attr('placeholder');
		if (placeHolder) {
			searchText.val(placeHolder);
			searchText.focus( function() { if ($(this).val() == $(this).attr('placeholder')) $(this).val(""); } );
			searchText.blur( function() { if ($(this).val() == "") $(this).val($(this).attr('placeholder')) } );
		}
	}
}

//Инициализация элементов в IE6
function initIE6 () {
	$(".pseudo-link").hover(function () { if ($(this).hasClass("pseudo-link")) $(this).addClass("pseudo-link-hover"); }, function () { $(this).removeClass("pseudo-link-hover"); });
}

//Инициализация элементов
function init () {
	if ($(".description").length > 1) {
		$(".description").css({display:"none"});
		$(".pseudo-link").each( function () { $(this).click( function() {
			var obj = $("#d" + $(this).attr("oid"));
			if (obj.css("display") == "none") {
				obj.css({display:"block"});
				$(this).removeClass("pseudo-link");
				$(this).removeClass("pseudo-link-hover");
			}
			else {
				obj.css({display:"none"});
				$(this).addClass("pseudo-link");
			}
		} ); } );
	}
	else {
		$(".pseudo-link").removeClass("pseudo-link");
	}
}

//Открытие изображения в отдельном окне
function picOpen (pic, width, height) {
	var x = (screen.availWidth - width ) / 2;
	var y = (screen.availHeight - height ) / 2;
	var pWidth = parseInt(width) + 10;
	var pHeight = parseInt(height) + 8;
	var sFeatures = "width=" + pWidth + ", height=" + pHeight + ", toolbar=no, status=no, scrollbars=0, resizable=no, left=" + x + ", top=" + y;
	var page = window.open('', '', sFeatures);
	page.document.write('<html><head><title>Просмотр изображения</title>');
	page.document.write('<style type="text/css">');
	page.document.write('* { margin: 0; padding: 0; }');
	page.document.write('BODY { color: #000; padding: 4px 0; background: #FFF4DC; text-align: center; }');
	page.document.write('IMG { border: none; }');
	page.document.write('</style>');
	page.document.write('</head><body>');
	page.document.write('<a href="javascript:self.close()" title="закрыть окно"><img width="'+width+'" height="'+height+'" src="'+pic+'" /></a></p>');
	page.document.write('</body></html>');
	page.document.close();
	if (window.focus) page.focus();
}

//Открытие страницы в отдельном окне
function winOpen(href, target, width, height, resizable) {
	if (resizable != "yes" && resizable != "no") resizable = "yes";
	(resizable == "no") ? scrollbars = "no" : scrollbars = "yes";
	window.open(href, target, 'width=' + width + ', height=' + height + ', location=no, toolbar=no, menubar=no, status=no, scrollbars=' + scrollbars + ', resizable=' + resizable + ', ');
}

//Действия после загрузки страницы
$(document).ready( function() {
	setUpSearchTextField();
	init();
} );
