var isMsie=(navigator.appVersion.indexOf("MSIE") == -1) ? false : true;

var from_em = document.location.search;
var from_name = ((from_em == '?em')||(parent.from_em == '?em')) ? 'e-Marketing' : 'Ogłoszenia Uczelniane';
var commonaddr = 'e-marketing.pl';

function testemail(_email) {
if(_email == "") { alert("Prosze podac adres e-mail"); return false; };
var posat = _email.indexOf('@');
var posdot = _email.indexOf('.');
var possp = _email.indexOf(' ');
var lastch = _email.length-1;
if((posat <= 0) || (posat == lastch) || (posdot < 0) || (posdot == lastch) || (possp >= 0)) { alert("Prosze poprawic adres e-mail"); return false; };
return true;
}

function startsearch(f) {
	if(f.fid.selectedIndex == 0) { 
		alert('Należy wskazać dział do przeszukiwania');
		f.fid.focus();
		return false;
	};
	f.action = f.fid.options[f.fid.selectedIndex].value + '.php';
};

function viewtoplist() {
	var obj = document.getElementById('toplist');
	var tempX;
	obj.style.display = 'block';
	if (isMsie) {
		tempX = event.clientX + document.body.scrollLeft;
	} else {
		tempX = e.pageX;
	}  
	obj.style.left = tempX - 320;
	return false;
};

function hidetoplist() {
	var obj = document.getElementById('toplist');
	obj.style.display = 'none';
	return false;
};

function findword() {
	searchform.submit();
	return false;
};

function wpop(link) {
	var wnd = window.open(link.href,'','toolbar=0, scrollbars=1, resizable=1, width=500, height=420');
	wnd.from = 'e-marketing';
	return false;
};

function addfav() {
	if(isMsie) {
		window.external.AddFavorite(this.location.href, this.document.title);
	} else {
		alert("Aby dodać \""+this.document.title+"\" do ulubonych\nwciśnij klawisze \"Ctrl-D\"");		
	};
	return false;
};

function asstart(page) {
	if(isMsie) {
		page.style.behavior='url(#default#homepage)';
		page.setHomePage(location.href);
	} else {
		alert("Aby strona \""+page.document.title+"\" była startow±\nwybierz w menu \"Edit > Preferences > Navigator\"\nopcję \"Use Current Page\"");
	};
	return false;
};

function isexcept(addr) { return true; };

function send_form(_form) {
  if(!testemail(_form.fromaddr.value)) return;
  var wnd = window.open('send_wait.html','','toolbar=0, scrollbars=0, resizable=0, status=0, width=300, height=180');
  wnd.name = '_redirect';
  _form.submit();
}

function send_eso(addr) {
  if(!testemail(addr.value)) return;
  if(isexcept(addr.value)) return;
  document.eso.fromaddr.value = addr.value;
  var wnd = window.open('','','toolbar=0, scrollbars=0, resizable=0, status=0, width=320, height=160');
  wnd.name = '_redirect';
  wnd.document.writeln('<h3>Proszę czekać<br>rejestracja w toku...</h3>');
  document.eso.submit();
}

function onm(txt) {
	if(!txt || (txt=='')) self.status=from_name;
	else self.status=txt;
	return true;
}

function go_to(link) { parent.location.href = link + from_em; }

function go_select(s) {
  var gourl = s.options[s.selectedIndex].value;
  window.top.location.href = gourl;
}

function draw_stdtool() {
	document.writeln('<A HREF="index.php" onMouseOver="return onm(\'Strona główna\');" onMouseOut="return onm();"><img align=right src="img/home2.gif" width=43 height=22 vspace=1 alt="Powrót" border=0></A>');
	document.writeln('<A HREF="javascript:history.back()" onMouseOver="return onm(\'Powrót\');"><img align=right src="img/back.gif" width=23 height=22 vspace=1 alt="Powrót" border=0></A>');
}

function draw_stdbottom() {
	draw_stdtool();
	document.writeln('<br clear=all><TABLE border=0 cellspacing=0 cellpadding=0 width=100%><TR><TD align=left><HR color=#104080 size=1>');
	document.writeln('<I><A HREF="http://www.e-marketing.pl" target=_top>ELECTRONIC-MARKETING</A></I></TD>');
	document.writeln('<TD align=right><HR color=#804010 size=1><I><A HREF="http://www.ou.pl" target=_top>www.ou.pl</A></I></TD></TR></TABLE>');
}

function kasuj(f) {
	if(confirm('Rzeczywi¶cie usun±ć?')) { f.usun.value='TAK'; return true; }
	else return false;
};

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function seladdr(addr) {
	addrok = '';
	for(i=addr.length-1; i>=0; i--) addrok += addr.charAt(i);
	location.href = 'mailto:'+addrok+'@'+commonaddr;
	return false;
};

