//------------------7----77-----------------------------------------
// funkcja otwiera okno /// NIE WYRZUCAC POD ZADNYM POZOREM
//---------------------------------------------------------------

function setCookie(name, value, days) {
   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 getCookie(name) {
   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;
   return document.cookie.substring(len, end)
}


function AF_WindowOpen(url, win_name, width, height, resizable, alt)
{
	if(alt == undefined)
		alt = '';

	if (alt!='')
		{	height_n=parseInt(height)+30;}
	else
		{	height_n=height;}

	if(height_n > 800)
		{	resizable = 1; }
	else
		{	resizable = 0; }
		
	hWin = window.open(url, win_name, "width="+width+",height="+height_n+",toolbar=0,scrollbars="+resizable+",resizable="+resizable);

	hWin.document.write('<html>\n'+
						'<head>\n'+

						'<script>'+

						'function FitPic(width,height) {'+

						'if (document.images[0].width < 100)'+
								'{window.setTimeout("FitPic('+width+','+height+')",1000);} '+
						'else'+
								'{'+
									'iWidth = document.images[0].width-width;'+
									'iHeight = document.images[0].height-height;'+ 
			
									'window.resizeBy(iWidth, iHeight);'+
									'self.focus();'+
								'}'+
						'}'+
						'</script>'+

						'<title>'+alt+'</title>\n'+
						'<meta http-equiv="content-type" content="text/html; charset=iso-8859-2">\n'+
						'</head>\n'+
						'<body style="margin:0px 0px 0px 0px; padding:0px 0px 0px 0px;">'+
						'<table style="border: 0px solid green; border-collapse: collapse; width:'+width+'px; height:'+height+'px; border-collpase:collpase;">'+
						'<tr><td style="border-collapse: collapse; margin: 0px; padding: 0px; text-align: left; vertical-align: top;"><img id="image" src="'+url+'" style="border: 0px solid #FFFFFF; margin: 0px; padding: 0px;"></td></tr>');
	if (alt!='')
		{
			hWin.document.write(
									'<tr><td style="height: 30px; font-size:10px; font-family: tahoma;">'+alt+'</td></tr>'
								);
		}
	hWin.document.write(
						'</table>'+
						'<script>FitPic('+width+','+height+');</script>'+
						'</body>'
						);

	hWin.focus();
}

function zaznacz(field)
	{
		field.focus();
		field.select();
	}

function popOpen(url, width, height)
{
     var hwnd = window.open(url, 'popwnd', 'width='+width+',height='+height+', menubar=0,scrollbars=1,resizable=0');
     hwnd.focus();
}



function ajax_polec()
	{
		var login_alert = '';
		var comunicat = '';
		action	= 'polec';

		text = document.forms['polecform'].text.value;	
		sender = document.forms['polecform'].sender.value;	
		email = document.forms['polecform'].email.value;	
		refurl = document.forms['polecform'].refurl.value;	

		comunicat = 'Proszę czekać,<br> trwa komunikacja z serwerem';

		document.getElementById('POLEC_ALERT').innerHTML = '<div style="margin-top: 5px;"><CENTER><img src="webimg/preloader.gif"><div style="padding: 3px 0px 0px 5px;">'+ comunicat +'</div></CENTER></div>';

		var obj = new Ajax.Request('ajax_polec.php', {method: 'post', parameters: 'action=' + action +'&text=' + text + '&refurl='+ refurl + '&email=' + email + '&sender=' + sender, onComplete: ajax_polec_response});
	}


function ajax_polec_response(originalRequest)
	{
		obj = originalRequest.responseText;

		var result = obj.split('<explode>');
		var comunicat ='';

		action = result[0];
		response = result[1];

		if (response=='true')
			{
				document.forms['polecform'].email.value = '';
				document.forms['polecform'].sender.value = '';
				document.forms['polecform'].text.value = '';

				comunicat = '<span class="TXT_DY">Email polecający aktywną stronę został wysłany.<br><br></span.';

				document.getElementById('POLEC_ALERT').innerHTML = '<div style="margin-top: 5px;"><CENTER><div style="padding: 3px 0px 0px 5px;">' + comunicat + '</div></CENTER></div>';
			}
		else
			{
				comunicat = '<span class="TXT_R">Niepoprawnie wypełniony formularz.<br><br></span>';

				document.getElementById('POLEC_ALERT').innerHTML = '<div style="margin-top: 5px;"><CENTER><div style="padding: 3px 0px 0px 5px;">' + comunicat + '</div></CENTER></div>';
			}
	}	

function ajax_polec_nav()
	{
		var login_alert = '';
		var comunicat = '';
		action	= 'polec';

		text = document.forms['polecformnav'].text.value;	
		sender = document.forms['polecformnav'].sender.value;	
		email = document.forms['polecformnav'].email.value;	
		refurl = document.forms['polecformnav'].refurl.value;	

		comunicat = 'Proszę czekać,<br> trwa komunikacja z serwerem';

		document.getElementById('POLEC_ALERT_NAV').innerHTML = '<div style="margin-top: 5px;"><CENTER><img src="webimg/preloader.gif"><div style="padding: 3px 0px 0px 5px;">'+ comunicat +'</div></CENTER></div>';

		var obj = new Ajax.Request('ajax_polec.php', {method: 'post', parameters: 'action=' + action +'&text=' + text + '&refurl='+ refurl + '&email=' + email + '&sender=' + sender, onComplete: ajax_polec_response_nav});
	}


function ajax_polec_response_nav(originalRequest)
	{
		obj = originalRequest.responseText;

		var result = obj.split('<explode>');
		var comunicat ='';

		action = result[0];
		response = result[1];

		if (response=='true')
			{
				document.forms['polecformnav'].email.value = '';
				document.forms['polecformnav'].sender.value = '';
				document.forms['polecformnav'].text.value = '';

				comunicat = '<span class="TXT_DY">Email polecający aktywną stronę został wysłany.<br><br></span.';

				document.getElementById('POLEC_ALERT_NAV').innerHTML = '<div style="margin-top: 5px;"><CENTER><div style="padding: 3px 0px 0px 5px;">' + comunicat + '</div></CENTER></div>';
			}
		else
			{
				comunicat = '<span class="TXT_R">Niepoprawnie wypełniony formularz.<br><br></span>';

				document.getElementById('POLEC_ALERT_NAV').innerHTML = '<div style="margin-top: 5px;"><CENTER><div style="padding: 3px 0px 0px 5px;">' + comunicat + '</div></CENTER></div>';
			}
	}	


function ajax_zglosblad()
	{
		var login_alert = '';
		var comunicat = '';
		action	= 'zglos';

		text = document.forms['zglosform'].text.value;	
		sender = document.forms['zglosform'].sender.value;	
		email = document.forms['zglosform'].email.value;	
		refurl = document.forms['zglosform'].refurl.value;	

		comunicat = 'Proszę czekać,<br> trwa komunikacja z serwerem';

		document.getElementById('ZGLOSBLAD_ALERT').innerHTML = '<div style="margin-top: 5px;"><CENTER><img src="webimg/preloader.gif"><div style="padding: 3px 0px 0px 5px;">'+ comunicat +'</div></CENTER></div>';

		var obj = new Ajax.Request('ajax_zglosblad.php', {method: 'post', parameters: 'action=' + action +'&text=' + text + '&refurl='+ refurl + '&email=' + email + '&sender=' + sender, onComplete: ajax_zglosblad_response});
	}


function ajax_zglosblad_response(originalRequest)
	{
		obj = originalRequest.responseText;

		var result = obj.split('<explode>');
		var comunicat ='';

		action = result[0];
		response = result[1];

		if (response=='true')
			{
				document.forms['zglosform'].email.value = '';
				document.forms['zglosform'].sender.value = '';
				document.forms['zglosform'].text.value = '';

				comunicat = '<span class="TXT_DY">Email zgłaszajacy błąd na aktywnej stronie został wysłany.<br><br></span>';

				document.getElementById('ZGLOSBLAD_ALERT').innerHTML = '<div style="margin-top: 5px;"><CENTER><div style="padding: 3px 0px 0px 5px;">' + comunicat + '</div></CENTER></div>';
			}
		else
			{
				comunicat = '<span class="TXT_R">Niepoprawnie wypełniony formularz.<br><br></span>';

				document.getElementById('ZGLOSBLAD_ALERT').innerHTML = '<div style="margin-top: 5px;"><CENTER><div style="padding: 3px 0px 0px 5px;">' + comunicat + '</div></CENTER></div>';
			}
	}	

function zamknijToplayer()
	{
		document.getElementById('ADS_TOPLAYER').style.display = 'none';
	}
