/*
 *	functions.js
 *	-------------------------------------------
 *	JavaScript functions.
 */

function o(id)
{
	return document.getElementById(id);
}

function w(id,content)
{
	o(id).innerHTML = content;
}

function h(id)
{
	o(id).style.display = 'none';
}

function validateEmail(src) 
{
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(src);
}

function confirmWindow(text)
{
	var content = "<div id='windowWrapper'>"
		+ "<div class='icon'><img src='/img/confirm.png' /></div>"
		+ "<div id='windowContent'>"+text+"<p /><input type='button' class='button' value='OK' onclick='cWindow.close();' /></div>"
		+ "</div>";
		
	cWindow = dhtmlwindow.open("cWindow","inline",content,"Potwierdzenie","width=400px,height=auto,center=1,resize=0,scrolling=0");
	cWindow.show();
}

function delWindow(title)
{
	var content = "<div id='windowWrapper'>"
		+ "<div class='icon'><img src='/img/question.png' /></div>"
		+ "<div id='windowContent'></div>"
		+ "</div>";
		
	dWindow = dhtmlwindow.open("dW","inline",content,title,"width=400px,height=auto,center=1,resize=0,scrolling=0");
	dWindow.show();
}

function warningWindow(text)
{
	var content = "<div id='windowWrapper'>"
		+ "<div class='icon'><img src='/img/warning.png' /></div>"
		+ "<div id='warningContent'>";
		
	if (text) content += text;	
		
	content += "</div>"
		+ "<p class='acenter' /><input class='button' type='button' value='OK' onclick='wWindow.close();' />"
		+ "</div>";
		
	wWindow = dhtmlwindow.open("wWindow","inline",content,"Ostrzeżenie!","width=400px,height=auto,center=1,resize=0,scrolling=0");
	wWindow.show();
}

function createWindow(title,width,height)
{
	var cnt = "<div id='windowWrapper'></div>";
	newWindow = dhtmlwindow.open("newWindow","inline",cnt,title,"width="+width+"px,height="+height+"px,center=1,resize=0,scrolling=0");
	newWindow.show;
}


function toggle(divId)
{
	var divName = "#" + divId;
	$(divName).toggle("fast");
}

function delPost(id)
{
	if (confirm("Potwierdzasz usunięcie posta?"))
	{
		location.href = "/forum/refuse/" + id;
	}
}

