/* drop-down */
//startList = function() {
//    if (document.all&&document.getElementById) {
//	    navRoot = document.getElementById("subdocsSelector");
//            if (typeof navRoot != 'undefined') { 
//                for (i=0; i<navRoot.childNodes.length; i++) {
//		    node = navRoot.childNodes[i];
//		    if (node.nodeName=="LI") {
//			    node.onmouseover=function() {				    
//				    this.className+=" hover";
//			    }
//			    node.onmouseout=function() {				    
//				    this.className=this.className.replace(" hover", "");
//			    }
//		    }
//	    }
//            }
//	    
//    }
//}
//
//window.onload = startList;

/* drop-down koniec */

var globalCurrent = '1';

function showBlock(id)
	{
	if(document.getElementById(id).style.display == 'block')
		{document.getElementById(id).style.display = 'none';}
	else
		{document.getElementById(id).style.display = 'block';}
	}

function showBlockArchive(id)
	{
	//alert('do zamnkięcia: ' +current);
	if(current != '')
		{
		document.getElementById(current).style.display = 'none';
		document.getElementById('archCell'+current).style.backgroundImage = 'url("images/archiveCell.gif")';
		}
	current = id;
	setCurrent(current);
	//pierwszy warunek mozna pominac, ale moze sie kiedys przyda
	if(document.getElementById(id).style.display == 'block')
		{
		document.getElementById(id).style.display = 'none';
		document.getElementById('archCell'+id).style.backgroundImage = 'url("images/archiveCell.gif")';
		}
	else
		{
		document.getElementById(id).style.display = 'block';
		document.getElementById('archCell'+id).style.backgroundImage = 'url("images/archiveCellActive.gif")';
		}
	//return current;
	}

function setCurrent(current)
	{
	globalCurrent = current;
	}

function getCurrent(href)
	{
	return window.location.href = href+'?back='+globalCurrent;
	}


function getEmail()
	{
	var email = document.getElementById('userEmail').value;
	return email;
	}
	
function addSubscriber()
	{

	validMail=/^[a-zA-Z0-9._-]+\@([a-zA-Z0-9_-]+\.){1,}[\w]{1,5}$/;
	if((getEmail() == '') || (getEmail() == 'wpisz e-mail') || getEmail().search(validMail) == -1)
		{ alert('podaj adres e-mail');		
		}
    
	else
		{parent.location.href="newsletter_login.xml?email="+getEmail()+"&subscribe";}

	}
	
function removeSubscriber()
	{
	validMail=/^[a-zA-Z0-9._-]+\@([a-zA-Z0-9_-]+\.){1,}[\w]{1,5}$/;

	if((getEmail() == '') || (getEmail() == 'wpisz e-mail') || getEmail().search(validMail) == -1)
		{ alert('podaj adres e-mail');}



	else
		{parent.location.href="newsletter_login.xml?email="+getEmail();}
	}

function openWindow(location,width,height)
	{
	window.open(location,'popup','width='+width+',height='+height+',left=20,top=20,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	}

function openWindowPrint(location,width,height)
	{
	window.open(location,'popup','width='+width+',height='+height+',left=20,top=20,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}


function getUrl()
	{
	return document.location.href; 
	}

function getLocation()
	{
	return document.location; 
	}
temp = getUrl();

function setLang(lang)
	{document.cookie = 'LANG=' + lang + '; path=/';}

function wywolajTopLayera()
	{
	//Script wywołuj±cy to layera
		//alert(document.body.clientWidth);
		//szer = (document.body.clientWidth) - 250;
		obj = document.getElementById('toplayer').style;
		//obj.left=szer;
		obj.display="block";
	}
function adzamknij()
	{
	//Script zamykający to layera
	document.getElementById('toplayer').style.display="none";	
	}
	

function setCookie(name, value, days) {

	// ustawia Cookies (potrzebne dla flashy - dopisał mpr
   var now=new Date();
   var expTime=now.getTime()+days*24*60*60*1000;
   var expDate=new Date(expTime);
   document.cookie=name+"="+value+"; EXPIRES="+expDate.toGMTString();

}

function setMainCookie(name, value, days) {

	// ustawia Cookies (potrzebne dla flashy - dopisał mpr
   var now=new Date();
   var expTime=now.getTime()+days*24*60*60*1000;
   var expDate=new Date(expTime);
   var cookieStr = name+"="+value+"; path=/; EXPIRES="+expDate.toGMTString();    
	 document.cookie=cookieStr;
	 
}


function getCookie(name) {

	// pobiera Cookies (potrzebne dla flashy - dopisał mpr
   var start=document.cookie.indexOf(name+"=");
   if(start==-1) return null;
   var len=start+name.length+1;
   var end=document.cookie.indexOf(";", len);
   if(end==-1) {
		 end=document.cookie.length;
	 } 
	var cookieTxt = document.cookie.substring(len, end) 
   return cookieTxt;

}

function createFlash(id,width,height,url)
	{
	//IE=(document.all)? true:false
	//if (IE) {codebase = 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'; alert('zzz');}
	//else {codebase = "";}

	
	//alert(url);
	document.write('<object id="'+id+'" style="width:'+width+'px; height:'+height+'px; margin:0px;" data='+url+' type="application/x-shockwave-flash">');
	document.write('	<param name="movie" value='+url+' />');
	document.write('	<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />');
	document.write('	<param name="wmode" value="transparent" />');
	document.write('	<param name="quality" value="high" />');
	document.write('	<param name="bgcolor" value="#ffffff" />');
	document.write('	<param name="scale" value="noscale" />');
	document.write('	<param name="menu" value="false" />');
	document.write('	<param name="salign" value="t" />');
	document.write('	<p style="width:'+width+'px; height:'+height+'px; border:1px solid #dedede;"><a href="http://www.macromedia.com/go/getflashplayer" target="_blank">Zainstaluj plugin flash</a></p>');
	document.write('</object>');
	}

	function closeTL()
	{
		//Script zamykający to layera
		var layer = document.getElementById('banerTopLayer');
		layer.style.display="none";
		layer.innerHTML = '';
	}

function checkEmail(str) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) {
        return true;
    }else {
        return false;
    }
}

function validateForm() {
    var isError = false;
    var errorString = '';
    //var numericExpression = /^[0-9]+$/;
    if($("#contactForm #imie").val() == "" ){
        isError = true;
        errorString = errorString + "-> Imię\r\n";
    }
    if($("#contactForm #nazwisko").val() == "" ){
        isError = true;
        errorString = errorString + "-> Nazwisko\r\n";
    }
    //alert('e='+$("#email").val());
    //alert(checkEmail($("#email").val()));
    if(!checkEmail($("#email").val())){
        isError = true;
        errorString = errorString + "-> Email\r\n";
    }
    if (!$("#agree").attr('checked')) {
          errorString = errorString + "-> Proszę wyrazić zgode na przetwarzanie danych osobowych\r\n";
    }
    if(isError){
        alert("Wpisz poprawnie:\r\n"+errorString);
        return false;
    }
    else{
        return true;
    }
}
