var active = Array();

goSite = function(url) {
location.href = url;
}

Switch = function(o)
{
var o;
var obj;
	if(!o.id) o = document.getElementById(o);
  obj = document.getElementById(o.id);
  /*
  *	wartstwa z menu ma nazwe '_d'+o.id, nadrzęďna dla niej jest: o.id
  */
  if (obj.style.display == 'inline')
  {
  obj.style.display = 'none';
  }
  else
  {
  /*
  *	jesli jakie menu jest aktywne, to wyłącza je
  */
    if (active != 0)
    {
	active.style.display = 'none';
    }
  obj.style.display = 'inline';
  active = obj;
  }
}

NewsLetterSubmit = function() {
   var req;
   var url = 'modules/mod_exec.php?mode=newsLetter';
   var _data = '&mail='+$('mail_').value;
	if (!checkemail($('mail_').value)) return;

	req = new Ajax.Request(url, {method: 'post',asynchronous:false, parameters:_data} );
	$('NSForm').innerHTML = req.transport.responseText;
	
}
menuUpperOver = function(item) {
item.style.color = "red";
}
menuUpperOut = function(item) {
item.style.color = "#286BA6";
}
menuOver = function(item) {
item.style.background = "#4881B4";
}
menuOut = function(item) {
item.style.background = "#286BA6";
}
submenuOver = function(item) {
$(item).style.background = "#98B4D1";
}
submenuOut = function(item) {
$(item).style.background = "#286BA6";
}

function ShowLogin()
{
	document.getElementById('LoginForm').style.display = '';
}
function showInfo(mid,uid,box)
{
info = document.getElementById('e');
info.style.display = 'block';

frame = document.getElementById('inframe');
frame.innerHTML = "Czekaj...";
if (box.checked) 
	LoadData('inframe','modules/set_module.php?mid='+mid+'&oper=set&uid='+uid, true);
else
	LoadData('inframe','modules/set_module.php?mid='+mid+'&oper=unset&uid='+uid, true);
setTimeout("info.style.display = 'none;'",1250);
}
function goEdit(mode, id)
{
location.href='?mode='+mode+'&exec=Edit&item='+id;
}
function goDel(mode, id)
{
if (confirm('Czy napewno usunąć?'))
location.href='?mode='+mode+'&exec=Delete&item='+id;
}
function goPermDel(mode, id)
{
if (confirm('Czy napewno usunąć?'))
location.href='?mode='+mode+'&exec=PernamentDelete&item='+id;
}
function goOrder(mode, id)
{
location.href='?mode='+mode+'&exec=Order&item='+id;
}
function goCat(CatID, DepID)
{
if (!DepID) DepID = '';
if (!CatID) CatID = '';
location.href = '?mode=shop&data=Product&CategoryID='+CatID+'&DepID='+DepID;
}
function goProduct(id, CatID, DepID)
{
if (DepID) DepID = '&DepID='+DepID; else DepID = '';
if (CatID) CatID = '&CategoryID='+CatID; else CatID = '';
//LoadData('mainData','?mode=shop&amp;data=Product&amp;item='+id+'&amp;CategoryID='+CatID+'&amp;DepID='+DepID);
location.href = '?mode=shop&data=Product&item='+id+CatID+DepID;
}
function LoadData(o, _url, mod) {
   var req;
   var url;
  if (!mod) url = 'modules/mod_exec.php'+_url;
  	else url = _url;	
	if(!o.id) o = document.getElementById(o);
  	obj = document.getElementById(o.id);

//	$('DebugLayer').innerHTML += req.getAllResponseHeaders();

	req = new Ajax.Request(url, {asynchronous:false} );
 	o.innerHTML = req.transport.responseText;
	document.getElementById('LoadLayer').style.display = 'none';
	return req.transport.responseText;
}
function checkemail(str){
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Wpisz poprawny adres e-mail!")
testresults=false
}
return (testresults)
}

function checkRegForm()
{
var stop = false;
email = document.getElementById('email');
cname = document.getElementById('name');
address2 = document.getElementById('address2');
phone = document.getElementById('phone');
pass1 = document.getElementById('password');
pass2 = document.getElementById('password2');

if (email.value.length < 5) 
		{
		alert('Wpisz poprawny adres e-mail!');
	return;
	}
else
	{
	if (!checkemail(email.value)) return;
 }

if (pass1.value != pass2.value || pass1.value < 5) 
	{
	alert('Podane hasła są różne lub za krótkie!');
	return;
	}
if (phone.value == '') 
	{
	alert('Proszę podać telefon kontaktowy!');
	return;
	};
if (cname.value == '') 
	{
	alert('Proszę podać nazwisko!');
	return;
	};
document.registerForm.submit();
}

