function getElementsStd(n) {
	 if (!document.all) return document.getElementsByName(n);
	 return document.all.item(n);
}
function getOneElementStd(n) {
	 if (!document.all) { r = document.getElementsByName(n); return r.item ? r.item(0) : r; }
	 return document.all.item(n, 0);
}

function openUrl(src) {
	if(document.all) {
		a = getOneElementStd("advA");
		if(a) {
			a.href = src;
			a.click();
			return;
		}
	}
	window.open(src);
	//if(document.all) window.open(u);
	//else document.location.href=u; 
}

function setImg(ctrl, img) {
	var i = getElementsStd(ctrl);
	if(!i) return;
	if(i.length) i.item(0).src = img;
	else i.src = img;
}

function popup(url, name, options) { 
	if(url != "") window.open(url, name, options); 
}

function GoToSelectedUrl(c, t) {
	url = c.options[c.selectedIndex].value;
	if(url == "") return;
  	if(t == 1) popup(url, '', ''); 
	else window.location = url;
}

function isI(v) {
	var re = /^\d+$/;
	return(re.test(v) ? 0 : 2);
}
function isL(v) {
	var re = /^(\,*\d+\,*)*$/;
	return(re.test(v) ? 0 : 2);
}
function isD(v) {
	var re;
	if(culture == 1045) {
		re = /^\d{4}-\d{2}-\d{2}$/;
		return(re.test(v) ? 0 : 2);
	}
	if(culture == 1033) {
		re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
		return(re.test(v) ? 0 : 2);
	}
	if(culture == 1049) {
		re = /^\d{2}\.\d{2}\.\d{4}$/;
		return(re.test(v) ? 0 : 2);
	}
}
function isE(v) {
	return 0;
 	var re = /^\s*[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+(\.[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+)*@[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+(\.[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+)+((\s*;\s*)+[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+(\.[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+)*@[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+(\.[\w!#\$%&'\*\+\-\/=\?\^`\{\|\}~]+)+)*\s*$/;
	return(re.test(v) ? 0 : 2);
}
function isW(v) {
	return 0;
 	var re = /^\s*(https?:\/\/)?\w([\-\w]*\w)*(\.\w([\-\w]*\w)*)+(\/[\w:@\&=\+\$\,\-\.!~\*'\(\)%]*)*(\?[^\/\?;]*)?((\s*;\s*)+(https?:\/\/)?\w([\-\w]*\w)*(\.\w([\-\w]*\w)*)+(\/[\w:@\&=\+\$\,\-\.!~\*'\(\)%]*)*(\?[^\/\?;]*)?)*\s*$/i 
	return(re.test(v) ? 0 : 2);
	return 0;
}
function isY(v) {
	var re = /\d{4}/;
	return(re.test(v) ? 0 : 2);
}

function getInt(v, d) {
	r = parseInt(v, 10);
	if(isNaN(r) || v != r) return d;
	return r;
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function startup(service, pgn) {
    return;
    if(service != "automatyka" && service != "energetyka" && service != "wodkaneko") return;
	c = readCookie("userpolling.xtech.pl");
	if(c == null || c == '' || c == 'null') {
		document.write("<div id='usrpp' name='usrpp' style='position: absolute; top: 170px; left: 50px; z-index: 1000;'>");
		document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'");		    
		document.write("width='500' height='500' id='badanie_uzytkownikow2008_2' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='/DataForms/badanie_uzytkownikow2008_2.swf' />");		    
		document.write("<param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />");		    
		document.write("<embed src='/DataForms/badanie_uzytkownikow2008_2.swf' quality='high' bgcolor='#ffffff' width='500' height='500' name='badanie_uzytkownikow2008_2' align='middle' allowscriptaccess='sameDomain'");		    
		document.write("type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");		    
		document.write("</object></div>");		    
	}
}

function go() {
	getOneElementStd("usrpp").style.visibility = 'hidden';
	window.open("/dataForms/BadanieUzytkownikow.htm", "", "");
}

function zamykaj() {
	getOneElementStd("usrpp").style.visibility = 'hidden';
	var date = new Date();
	createCookie("userpolling.xtech.pl", date.valueOf(), 1)
}
