function a()
{

//
// 0 href
// 1 title
// 2 class
// 3 target
// 4 other
//

	if(arguments.length > 0)
	{
		str = "<a href=\"" + arguments[0] + "\"";

		if(arguments.length > 1)
		{
			if(arguments[1] != "")
				str += " title=\"" + arguments[1] + "\"";

			if(arguments.length > 2)
			{
				if(arguments[2] != "")
					str += " class=\"" + arguments[2] + "\"";

				if(arguments.length > 3)
				{
					if(arguments[3] != "")
						str += " target=\"" + arguments[3] + "\"";

					if( (arguments.length > 4) && (arguments[4] != "") )
						str += arguments[4];
				}
			}
		}

		str += " >";
	}
	else
		str = "</a>";

	document.write(str)
}

//////////////////////////////////////////////////

function show_hide_obj(id)
{
	with(document.getElementById(id).style)
	{
		if(display == "none")
			display = "";
		else
			display = "none";
	}
}

//////////////////////////////////////////////////

function setCookie(name, value, expires, path, domain, secure)
{
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") + // Wed, 01-Jan-20 00:00:00 GMT
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

//////////////////////////////////////////////////

function reload_page()
{
//
// reload page
// window.location.reload не подходит,
// т.к. оставляет неправильно выбранными select-ы
//

	with(document)
		for(i = 0; i < forms.length; i++)
			if(forms[i].name == "reload")
				forms[i].submit();
}

//////////////////////////////////////////////////

function getCookie(name)
{
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = "";
	var offset = 0;
	var end = 0;

	if(cookie.length > 0)
	{
		offset = cookie.indexOf(search);

		if(offset != -1)
		{
			offset += search.length;
			end = cookie.indexOf(";", offset)

			if(end == -1)
				end = cookie.length;

			setStr = unescape(cookie.substring(offset, end));
		}
	}

	return(setStr);
}

//////////////////////////////////////////////////

function checkVote()
{
	with(document.forms["vote"])
		for(i = 0; i < vote.length; i++)
			if(vote[i].checked)
				return true;

	alert("Необходимо выбрать один из вариантов");

	return false;
}

//////////////////////////////////////////////////

function wishlist(dataId, obj)
{
	newCookie = "";
	counter = 0;
	str = "";

	icon = obj.firstChild;

	dataIdArray = getCookie("wishlist").split(".");

//
// удаление dataId из текущего набора
// чтобы не было повторений
//

	for(i=0;i<(dataIdArray.length-1);i++)
	{
		if(dataIdArray[i] != dataId)
		{
			newCookie += dataIdArray[i]+".";
			counter++;
		}
	}

//
// добавление dataId в текущий набор
//

	if(icon)
	{
		if(icon.className == "wishlist add")
		{
			newCookie += dataId+".";
			counter++;

			className = "wishlist delete";
			alt = "Удалить из блокнота";
			display = "";
		}
		else
		{
			className = "wishlist add";
			alt = "Добавить в блокнот";
			display = "none";
		}

		icon.className = className;
		icon.alt = alt;
		obj.title = alt;

		if(obj.nextSibling)
			obj.nextSibling.style.display = display;
	}

	setCookie("wishlist", newCookie, "Wed, 01-Jan-20 00:00:00 GMT", "/", ".infoyar.ru");

	switch(counter % 10)
	{
		case 1 : { if(counter == 11) counter += " записей"; else counter += " запись"; break; }
		case 2 : { if(counter == 12) counter += " записей"; else counter += " записи"; break; }
		case 3 : { if(counter == 13) counter += " записей"; else counter += " записи"; break; }
		case 4 : { if(counter == 14) counter += " записей"; else counter += " записи"; break; }

		default : counter += " записей";
	}

	if(document.getElementById("wishlist"))
		document.getElementById("wishlist").innerHTML = counter;
}

function popup_photo(URL, width, height)
{
	var popup_photo_win = window.open('about:blank', '_blank', 'width='+width+',height='+height+',status=no,toolbar=no,menubar=no,location=no,resizable=no');
	popup_photo_win.document.writeln("<html><body topmargin=0 leftmargin=0 bgcolor=#ffffff><table border=0 width=100% height=100% cellpadding=0 cellspacing=0><tr><td align=center valign=center><a href=javascript:window.close();><img src=" + URL + " border=0></a></td></tr></table></body></html>");
	popup_photo_win.focus();
}
