﻿/*
	Процедура для второй вкладки, для radio buttons
*/		
function checkRadio(parent)
{
	if(parent)
	{
		var len = parent.childNodes.length;
		for(var i = 0; i < len; i++)
		{
			var elem = parent.childNodes[i];
			if(elem && elem.tagName == "INPUT" && elem.type == "radio")
			{
				elem.checked = true;
				elem.onclick();
			}
		}
	}
}

/*
	Отображение помощи, контактов, etc.
*/
function showInWindow(src, width, height)
{
	if (width == undefined)
		width = 447;
	if (height == undefined)
		height = 500;
	var x = (screen.width - width) / 2;
	var y = (screen.height - height) / 2;
	
	window.open("http://"+window.location.hostname+"/"+src, "", "toolbar = 0, location = 0, status = 0, menubar = 0, scrollbars = 1, resizable = 0, width = " + width + ", height = " + height + ", left = " + x + ", top = " + y);
}

/*
	Переход к табу tab
*/
function goStep(tab)
{
	xajax_goStep(tab);
}

/*
	Выбор цвета
*/
function preview(id)
{
	document.getElementById("preview").style.backgroundColor="#"+id;
}

function previewtxt(id){
	document.getElementById("previewtxt").value="#"+id;
}

function set(id)
{
	document.getElementById("set").style.backgroundColor="#"+id;
}

function settxt(id){
	document.getElementById("settxt").value="#"+id;
}

function setColor(idColor)
{
	i = document.getElementById('_tmp').value;
	document.getElementById(i).value = '#'+idColor;
	document.getElementById(i).focus();
	document.getElementById(i).select();
}

function setMenu(hdMenu, bdMenu)
{
	if (document.getElementById(bdMenu).style.display == "none")
	{
		hdMenu.className = "caption";
		document.getElementById(bdMenu).style.display = "block";
	}
	else
	{
		hdMenu.className = "caption-hidden";
		document.getElementById(bdMenu).style.display = "none";
	}
}

/*
	Удаление флеш со страницы
*/
function deleteFlesh()
{
	var doc = document.getElementById("MAINFRAME").contentWindow.document;
	deleteFleshFromDoc(doc);
}

function deleteFleshFromDoc(doc)
{
	var div;

	flesh = doc.getElementsByTagName("object");
	while (flesh.length > 0)
	{
		div = creatDiv(doc)
		flesh[0].parentNode.replaceChild(div, flesh[0]);
		flesh = doc.getElementsByTagName("object");
	}
	flesh = doc.getElementsByTagName("embed");
	while (flesh.length > 0)
	{
		div = creatDiv(doc)
		flesh[0].parentNode.replaceChild(div, flesh[0]);
		flesh = doc.getElementsByTagName("embed");
	}

	var e, frames = doc.getElementsByTagName("frame");
	for (var key in frames)
		try
		{
			deleteFleshFromDoc(frames[key].contentWindow.document);
		}
		catch (e) {;}
	frames = doc.getElementsByTagName("iframe");
	for (var key in frames)
		try
		{
			deleteFleshFromDoc(frames[key].contentWindow.document);
		}
		catch (e) {;}
}

function creatDiv(doc)
{
	var div = doc.createElement("DIV");
	div.innerHTML = "Hier ist ein Flash-Element";
	div.style.width = flesh[0].width;
	div.style.height = flesh[0].height;
	div.style.textAlign = "center";
	div.style.color = "#E92C0A";
	div.style.fontSize = "12px";
	return div;
}

/*
	Проверка e-mail при регистрации
*/
function checkEmail(field)
{
	var email_string = field.value;
	var reMail = /^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$/;
	if (!email_string.match(reMail))
	{
		field.focus();
		field.select();
		return false;
	}
	return true;
}