//POPUP
function popup_sms_file(url) {
	new_size_w = 505;
	new_size_h = 500+25;
	popup_left = Math.round((screen.availWidth-new_size_w)/2);
	popup_top = Math.round((screen.availHeight-new_size_h)/2);
	msg=open(url,"PIT","scrollbars=auto,toolbar=no,directories=no,width="+new_size_w+",height="+new_size_h+",menubar=no, top="+popup_top+", left="+popup_left+"");
	msg.document.close();
	msg.focus();
};

function popup_url(url, size_w, size_h, scroll) {
	new_size_w = size_w;
	new_size_h = size_h+25;
	popup_left = Math.round((screen.availWidth-new_size_w)/2);
	popup_top = Math.round((screen.availHeight-new_size_h)/2);
	msg=open(url,"PIT","scrollbars="+scroll+",toolbar=no,directories=no,width="+new_size_w+",height="+new_size_h+",menubar=no, top="+popup_top+", left="+popup_left+"");
	msg.document.close();
	msg.resizeTo(new_size_w,new_size_h);
	msg.focus();
};

function popup_page(page, size_w, size_h, scroll)	{
	new_size_w = size_w;
	new_size_h = size_h+25;
	popup_left = Math.round((screen.availWidth-new_size_w)/2);
	popup_top = Math.round((screen.availHeight-new_size_h)/2);
	msg=open(page,"PIT","scrollbars="+scroll+",toolbar=no,directories=no,width="+new_size_w+",height="+new_size_h+",menubar=no, top="+popup_top+", left="+popup_left+"");
	msg.document.close();
	msg.resizeTo(new_size_w,new_size_h);
	msg.focus();
};

function popup_img(url, size_w, size_h, scroll) {
	new_size_w = size_w;
	new_size_h = size_h+25;
	popup_left = Math.round((screen.availWidth-new_size_w)/2);
	popup_top = Math.round((screen.availHeight-new_size_h)/2);
	msg=open("","PITObrazek","scrollbars="+scroll+",toolbar=no,directories=no,width="+new_size_w+",height="+new_size_h+",menubar=no, top="+popup_top+", left="+popup_left+"");
	msg.document.close();
	msg.document.write("<HTML><HEAD><TITLE>PIT</TITLE></HEAD>");
	msg.document.write("<BODY BGCOLOR=White TEXT=#8F82AE TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0>");
	msg.document.write("<CENTER><IMG SRC='"+url+"' ALT='Zamknij Okno' BORDER='0' onclick='window.close()' style='cursor: hand;'><BR><BR>");
	msg.document.write("</BODY></HTML>");
	msg.resizeTo(new_size_w,new_size_h);
	msg.focus();
};

function popup_flash(flashsrc, size_w, size_h, scroll)	{
	msg=open("","PIT","scrollbars="+scroll+",toolbar=no,directories=no,width="+size_w+",height="+size_h+",menubar=no");
	msg.document.close();
	msg.document.write("<HTML><HEAD><TITLE>PIT</TITLE></HEAD>");
	msg.document.write("<BODY BGCOLOR=White TEXT=#8F82AE TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0>");	
	msg.document.write("<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width="+size_w+" height="+size_h+" classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>");
	msg.document.write("<PARAM NAME='Movie' VALUE='"+flashsrc+"'>");
	msg.document.write("<PARAM NAME=\"Src\" VALUE='"+flashsrc+"'>");
	msg.document.write("<EMBED src='"+flashsrc+"' quality=high bgcolor=#000000 width="+size_w+" height="+size_h+" TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>");
	msg.document.write("</EMBED>");
	msg.document.write("</OBJECT>");
	msg.document.write("</BODY></HTML>");	
	msg.focus();
};

function popup_print(url, size_w, size_h, scroll) {
	new_size_w = size_w;
	new_size_h = size_h+25;
	scroll='yes';
	msg=open(url,"PIT","scrollbars="+scroll+",toolbar=no,directories=no,width="+new_size_w+",height="+new_size_h+",menubar=no");
	msg.document.close();
	msg.resizeTo(new_size_w,new_size_h);
	msg.focus();
};

//SHOWHIDE
	ns4 = (document.layers)? true:false;
	ie4 = (document.all)? true:false;
	
	function showhide(lift) {
		if (lift.length) {
			styleObject = getStyleObject(lift);
			if ((styleObject.display == 'none') || (styleObject.display == ''))	{
				o_show(lift);
			}	
			else {
				o_hide(lift);
			}	
		}
	};
	
	function o_show(id)
	{
	    if(changeObjectVisibility(id, 'visible','inline'))
			return true;
	    else 
			return false;
	} //show

	function o_hide(id)
	{
		if(changeObjectVisibility(id, 'hidden','none'))
			return true;
	    else
			return false;
	} //hide
	
	function show(id,e)
	{
		e.cancelBubble=true;
	    if(changeObjectVisibility(id, 'visible','inline'))
		{
			hideShowCovered(id);
			return true;
		}
	    else 
			return false;
	    
		return;
	}

	function hide(id,e)
	{
		if (ie4)
		{
			el=document.all[id];
			var p = getAbsolutePos(el);
			var EX1 = p.x;
			var EX2 = el.offsetWidth + EX1;
			var EY1 = p.y;
			var EY2 = el.offsetHeight + EY1;
			mX=event.clientX;
			mY=event.clientY;
			if ((mX>EX1+1 && mX<EX2) && (mY>EY1 && mY<EY2))	return false;
			hideShowCovered('winda_out');
		}

		e.cancelBubble=true;
	    if(changeObjectVisibility(id, 'hidden','none'))
		{
			return true;
		}
	    else
			return false;
	}

	function getStyleObject(objectId) {
		if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
		} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
		} else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
		} else {
		return false;
		}
	} 

	function getObject(objectId) {
		if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId);
		} else if (document.all && document.all(objectId)) {
		return document.all(objectId);
		} else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
		} else {
		return false;
		}
	} 


	function changeObjectVisibility(objectId, newVisibility,newDisplay) {
		var styleObject = getStyleObject(objectId);
		if(styleObject)
		{
			styleObject.visibility = newVisibility;
			styleObject.display = newDisplay;
			return true;
		} 
		else
		{
			return false;
		}
	} // changeObjectVisibility

	function hideShowCovered(id) {
		if (ie4)
			el=document.all[id];
		else
			el=document.layers[id];

		var tags = new Array("applet", "iframe", "select");
		var res;

		var p = getAbsolutePos(el);
		var EX1 = p.x;
		var EX2 = el.offsetWidth + EX1;
		var EY1 = p.y;
		var EY2 = el.offsetHeight + EY1;
		for (var k = tags.length; k > 0; ) {
			var ar = document.getElementsByTagName(tags[--k]);
			var cc = null;

			for (var i = ar.length; i > 0;) {
				cc = ar[--i];

				p = getAbsolutePos(cc);
				var CX1 = p.x;
				var CX2 = cc.offsetWidth + CX1;
				var CY1 = p.y;
				var CY2 = cc.offsetHeight + CY1;

				if ((CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
					cc.style.visibility = "visible";
					res=1;

				} else {
					cc.style.visibility = "hidden";
					res=0;
				}
			}
		}
		return res;
	};

	function getAbsolutePos(el) {
		var r = { x: el.offsetLeft, y: el.offsetTop };
		if (el.offsetParent) {
			var tmp = getAbsolutePos(el.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	};

	function getAttrib(oElem,name)
	{
		var val='';
		var oAttribs = oElem.attributes;
		for (var i = 0; i < oAttribs.length; i++)
		{
			var oAttrib = oAttribs[i];
			if (name==oAttrib.nodeName)
			{
				val=oAttrib.nodeValue;
				break;
			}
		}
		return  val;
	}
	function setAttrib(oElem,name,val)
	{
		var oAttribs = oElem.attributes;
		for (var i = 0; i < oAttribs.length; i++)
		{
			var oAttrib = oAttribs[i];
			if (name==oAttrib.nodeName)
			{
				oAttrib.nodeValue=val;
				break;
			}
		}
	}

//VALIDATE
function checkEmail(obj)
	{
		re = new RegExp("[a-z|A-Z|0-9|\.|\-|\_]+@[a-z|A-Z|0-9|\.|\-|\_]+");

		if (!re.test(obj.value))
		{
			obj.focus();
			return true;
		}
		return false;
	}


function val_polecam(obj)
	{
		if (checkEmail(obj.mailto))
		{
			alert('Proszę podać prawidłowy email odbiorcy!');
			obj.mailto.focus();
			return false;
		}
		
		if (checkEmail(obj.mailfrom))
		{
			alert('Proszę podać swój prawidłowy email nadawcy!');
			obj.mailfrom.focus();
			return false;
		}

		if (obj.name.value.length == 0)
		{
			alert('Proszę wpisać imie i nazwisko!');
			obj.name.focus();
			return;
		}

		obj.submit();
	}
	
function val_uwagi(obj)
	{
		if (checkEmail(obj.mailfrom))
		{
			alert('Proszę podać swój prawidłowy email nadawcy!');
			obj.mailfrom.focus();
			return false;
		}

		if (obj.name.value.length == 0)
		{
			alert('Proszę wpisać imie i nazwisko!');
			obj.name.focus();
			return;
		}

		obj.submit();
	}	

function val_nl(obj)
	{
		if (checkEmail(obj.email))
		{
			alert('Proszę podać swój prawidłowy email!');
			obj.email.focus();
			return false;
		}

		if (obj.imie.value.length == 0)
		{
			alert('Proszę wpisać imie!');
			obj.imie.focus();
			return;
		}
		
		if (obj.nazwisko.value.length == 0)
		{
			alert('Proszę wpisać nazwisko!');
			obj.nazwisko.focus();
			return;
		}
		
		if (obj.rok_urodzenia.value.length <4)
		{
			alert('Proszę podać rok urodzenia!');
			obj.rok_urodzenia.focus();
			return;
		}
		
		if (!obj.verify.checked)
		{
			alert('Proszę zaakceptować regulamin!');
			obj.verify.focus();
			return;
		}

		obj.submit();
	}	
	
	
	function val_nl_mail(obj)
	{
		if (checkEmail(obj.email))
		{
			alert('Proszę podać swój prawidłowy email!');
			obj.email.focus();
			return false;
		}
		obj.submit();
	}	
	
	
