/* WOOD-WIN.RU Common JS functions									*/
/* Author: Alexey Ryumin (ryumin_av@panteon1.ru)					*/
/* Copyright: Panteon &amp; M &copy; 2008 (http://www.panteon1.ru/)	*/

if (self.location != top.location) { top.location = self.location; }
var bOK = document.getElementsByTagName;

function init() {
	var arrAnchors = document.getElementsByTagName("a");
	for (var i = 0; i < arrAnchors.length; i++) {
		if (arrAnchors[i].getAttribute("rel") == "nofollow" || arrAnchors[i].getAttribute("rel") == "external") {
			arrAnchors[i].setAttribute("target", "_blank");
		}
	}
	if (typeof(initFlakes) == "function") {
		initFlakes();
	}
}

document.createHTMLElement = function(elemName, attribs) {
	var i, elem, isNamespaced;
	if (document.createElementNS && elemName != "a") {
		elem = document.createElementNS("http://www.w3.org/1999/xhtml", elemName);
		isNamespaced = true;
	} else {
		elem = document.createElement(elemName);
		isNamespaced = false;
	}
	if (typeof attribs != 'undefined') {
		for (i in attribs) {
			switch (true) {
			case (i == "text")  : elem.appendChild(document.createTextNode(attribs[i])); break;
			case (i == "class") : elem.className = attribs[i]; break;
			case (i == "id") : elem.id = attribs[i]; break;
			default :
				if (isNamespaced) {
					elem.setAttributeNS("http://www.w3.org/1999/xhtml", i, attribs[i]);
				} else {
					elem.setAttribute(i, attribs[i]);
				}
			}
		}
	}
	return elem;
}

if (bOK) {
	window.onload = init;
}
