function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function printVersion(url){
	var content = document.getElementById('page_text').innerHTML;
	var headerContent = document.getElementById('page_header').innerHTML;
	
	var win_width = screen.availWidth;
	var win_height = screen.availHeight;
	
	var width = 560;
	var height = 490;
	
	if (navigator.appName == "Microsoft Internet Explorer"){
		var pop_width = width+36;
		var pop_height = height+20;
	}else{
		var pop_width = width+20;
		var pop_height = height+20;
	}
	
	var top = parseInt(win_height/2-height/2);
	var left = parseInt(win_width/2-width/2);
	
	var body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	body += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
	body += '<head>';
	body += '<title>LNB</title>';
	body += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
	body += '<link rel="stylesheet" type="text/css" href="css/style.css" />';
	body += '</head>';
	body += '<body class="bodyprint">';
	body += '<div class="printLogo"><img src="'+url+'images/logo.gif" width="137" height="45" alt="" /></div>';
	body += '<div class="printheader">';
	body += '<div>';
	body += '<ul>';
	body += '<li class="printlink"><a href="javascript:window.print()" class="link_1" style="background: none;padding: 0">Drukuj</a></li>';
	body += '<li class="printclose"><a href="javascript:window.close()" class="link_1" style="background: none;padding: 0">Zamknij</a></li>';
	body += '</ul>';
	body += '</div>';
	body += '</div>';
	body += '<div class="printcontent">';
	body += '<div class="printTitle"><h1>'+headerContent+'</h1></div>';
	body += '<div id="simpleCenter"><div id="simpleContentInner"><div id="simpleText" style="text-align: left;float: left;width: 516px">';
	body += content;
	body += '</div>';
	body += '</div></div></div>';
	body += '<div class="printfooter">';
	body += '<span class="text_grey">&copy; TEZET 2007</span>';
	body += '<div class="text_grey"><a class="link_honki" href="http://www.honki.pl" target="_blank">Created by HONKI Multimedia</a></div>';
	body += '</div></body>';
	body += '</html>';
	
	pop = window.open('','','width='+pop_width+', height='+pop_height+',left='+left+',top='+top+',scrollbars=yes')
	pop.document.open();
	pop.document.write(body);
	pop.document.close();	
}


function openPopup(src, title, params)
{
	// flash
	if  ( src.indexOf(".swf") != -1 ){
		openPopFlash(src, title, params);
	}
	// image
	else if  ( src.indexOf(".") != -1 ){	

		if ( typeof imgCheck == 'undefined' ){
			imgCheck = setInterval(function () {
				checkImgCache(src, title, params);
			}, 200);
		}
		
	// page
	}else{
		openPopPage(src, title, params);
	}
}//openPopup

function openPopFlash(url, title, params){
	
	var pop_title = (title == undefined || title.length == 0) ? "Popup" : title;
	
	if ( params != undefined && params.length > 0 ){
		temp = params.split(",");
		params = new Array();
		
		for ( i=0;i<temp.length;i++ ){
			if ( temp[i] != undefined )
			{
				var k = temp[i].split("=");
				params[k[0]] = new Array();
				params[k[0]] = k[1];
			}
		}
	}
	
	var win_width = screen.availWidth;
	var win_height = screen.availHeight;
	
	var pop_width = 800;
	var pop_height = 700;
	
	var	pop_top = parseInt(win_height/2-pop_height/2);
	var	pop_left = parseInt(win_width/2-pop_width/2);
	
	var pop_params = '';
	
	if ( params != undefined ){
		if ( params['scrollbars'] != undefined ) pop_params += ',scrollbars = yes';
		if ( params['menubar'] != undefined ) pop_params += ',menubar = yes';
		if ( params['resizable'] != undefined ) pop_params += ',resizable = yes';
		if ( params['toolbar'] != undefined ) pop_params += ',toolbar = yes';
		if ( params['location'] != undefined ) pop_params += ',location = yes';
		if ( params['status'] != undefined ) pop_params += ',status = yes';
		
		if ( params['top'] != undefined )  pop_top = params['top'];
		if ( params['left'] != undefined )  pop_left = params['left'];
		if ( params['width'] != undefined )  pop_width = params['width'];
		if ( params['height'] != undefined )  pop_height = params['height'];
		
		if ( params['top'] == undefined && params['left'] == undefined && params['width'] != undefined && params['height'] != undefined){
			pop_top = parseInt(win_height/2-params['height']/2);
			pop_left = parseInt(win_width/2-params['width']/2);
		}
		
	}else{
		pop_params += ',scrollbars=yes,resizable=yes';
		pop_width = 700;
		pop_height = 560;
		pop_top = parseInt(win_height/2-pop_height/2);
		pop_left = parseInt(win_width/2-pop_width/2);
	}
	
	pop_params += ',left='+pop_left+',top='+pop_top+',width='+pop_width+', height='+pop_height;
	
	pop = window.open(url, pop_title, ''+pop_params+'');
	
}//openPopFlash

function openPopPage(url, title, params){
	
	pop_title = (title == undefined || title.length == 0) ? "Popup" : title;
	
	if ( params != undefined && params.length > 0 ){
		temp = params.split(",");
		params = new Array();
		
		for ( i=0;i<temp.length;i++ ){
			if ( temp[i] != undefined )
			{
				var k = temp[i].split("=");
				params[k[0]] = new Array();
				params[k[0]] = k[1];
			}
		}
	}
	
	var win_width = screen.availWidth;
	var win_height = screen.availHeight;
	
	var pop_width = 800;
	var pop_height = 700;
	
	var	pop_top = parseInt(win_height/2-pop_height/2);
	var	pop_left = parseInt(win_width/2-pop_width/2);
	
	var pop_params = '';
	
	if ( params != undefined ){
		if ( params['scrollbars'] != undefined ) pop_params += ',scrollbars = yes';
		if ( params['menubar'] != undefined ) pop_params += ',menubar = yes';
		if ( params['resizable'] != undefined ) pop_params += ',resizable = yes';
		if ( params['toolbar'] != undefined ) pop_params += ',toolbar = yes';
		if ( params['location'] != undefined ) pop_params += ',location = yes';
		if ( params['status'] != undefined ) pop_params += ',status = yes';
		
		if ( params['top'] != undefined )  pop_top = params['top'];
		if ( params['left'] != undefined )  pop_left = params['left'];
		if ( params['width'] != undefined )  pop_width = params['width'];
		if ( params['height'] != undefined )  pop_height = params['height'];
		
		if ( params['top'] == undefined && params['left'] == undefined && params['width'] != undefined && params['height'] != undefined){
			pop_top = parseInt(win_height/2-params['height']/2);
			pop_left = parseInt(win_width/2-params['width']/2);
		}
		
	}else{
		pop_params += ',scrollbars=yes,resizable=yes';
		pop_width = 700;
		pop_height = 560;
		pop_top = parseInt(win_height/2-pop_height/2);
		pop_left = parseInt(win_width/2-pop_width/2);
	}
	
	pop_params += ',left='+pop_left+',top='+pop_top+',width='+pop_width+', height='+pop_height;
	pop_params = pop_params.substr(1);
	
	pop = window.open(url, pop_title, pop_params);
	
}//openPopPage

function checkImgCache(image, title, params){
	
	var img = new Image();
	var img_src = (image.substring(0,7)!= '_images') ? '_images'+image : image;
	
	img.src = img_src;
	var width = img.width;
	var height = img.height;
	
	if ( width > 0 ){
		clearInterval(imgCheck);
		delete imgCheck;
		
		var pop_title = (title == undefined || title.length == 0) ? "Popup" : title;
		var img = new Image();
		img.src = img_src;
		var img_width = img.width;
		var img_height = img.height;
		
		if ( params != undefined && params.length > 0 ){
			temp = params.split(",");
			params = new Array();
			
			for ( i=0;i<temp.length;i++ ){
				if ( temp[i] != undefined )
				{
					var k = temp[i].split("=");
					params[k[0]] = new Array();
					params[k[0]] = k[1];
				}
			}
		}
		
		var win_width = screen.availWidth;
		var win_height = screen.availHeight;
		
		var pop_top = parseInt(win_height/2-img_height/2);
		var pop_left = parseInt(win_width/2-img_width/2);
		
		if (navigator.appName == "Microsoft Internet Explorer"){
			var pop_width = img_width+36;
			var pop_height = img_height+20;
		}else{
			var pop_width = img_width+20;
			var pop_height = img_height+20;
		}
		
		
		if ( pop_height > win_height ){
			pop_height = win_height-60;
			pop_top = 0;
		}
		
		if ( pop_width > win_width ){
			pop_width = win_width-60;
			pop_left = 0;
		}
		
		var pop_params = '';
		
		if ( params != undefined ){
			if ( params['scrollbars'] != undefined ) pop_params += ',scrollbars = yes';
			if ( params['menubar'] != undefined ) pop_params += ',menubar = yes';
			if ( params['resizable'] != undefined ) pop_params += ',resizable = yes';
			if ( params['toolbar'] != undefined ) pop_params += ',toolbar = yes';
			if ( params['location'] != undefined ) pop_params += ',location = yes';
			if ( params['status'] != undefined ) pop_params += ',status = yes';
			
			if ( params['top'] != undefined )  pop_top = params['top'];
			if ( params['left'] != undefined )  pop_left = params['left'];
			if ( params['width'] != undefined )  pop_width = params['width'];
			if ( params['height'] != undefined )  pop_height = params['height'];
			
			if ( params['top'] == undefined && params['left'] == undefined && params['width'] != undefined && params['height'] != undefined){
				pop_top = parseInt(win_height/2-params['height']/2);
				pop_left = parseInt(win_width/2-params['width']/2);
			}
			
		}else{
			pop_params += ',scrollbars=yes,resizable=yes';
		}
		
		pop_params += ',left='+pop_left+',top='+pop_top+',width='+pop_width+', height='+pop_height;
		
		showPop(pop_title, img_width, img_height, img_src, pop_params);
		
	}
	
}//checkCache

function showPop(pop_title, img_width, img_height, img_src, params){
	
	body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	body += '<html><head><title>'+pop_title+'</title>';
	body += '<script language="JavaScript"></script>';
	body += '</head><body style="background:#EEEEEE;padding:6px;margin:0px">';
	body += '<div style="position:absolute; left: 50%; top: 50%; width: '+img_width+'px; height: '+img_height+'px; margin-top: -'+(img_height/2)+'px; margin-left: -'+(img_width/2)+'px;"><a id="image" href="#" onClick="window.close()" onfocus="blur()"><img src="'+img_src+'" alt="" style="border:1px solid #CCCCCC" /></a></div>';
	body += '</body></html>';
	pop = window.open('','',''+params+'')
	pop.document.open();
	pop.document.write(body);
	pop.document.close();
	
}//showPop


function showlayer(id) {
	layer = document.getElementById(id);
	if(layer.style.display == 'none') layer.style.display = 'inline';
	else layer.style.display = 'none';
}

function ustaw_layer(layer)
{
	if(document.all || navigator.userAgent.indexOf("Gecko")!=-1		)
	{
		var w = document.body.clientWidth;
		var h = document.body.clientHeight;
		if(w < 770)	w = 770;

		MM_findObj(layer).style.left = (w/2) - parseInt(MM_findObj(layer).style.width)/2 ;
		MM_findObj(layer).style.top = (h/2) - parseInt(MM_findObj(layer).style.height)/2 ;
	}
	else
	{
		var w =  window.innerWidth;
		var h =  window.innerHeight;
		if(w < 770) w = 770;

		MM_findObj(layer).left = (w/2) - parseInt(MM_findObj(layer).width)/2;
		MM_findObj(layer).top = (h/2) - parseInt(MM_findObj(layer).height)/2;
	}
	MM_findObj(layer).style.visibility = "visible";
}

function drukuj_strone(plik)
{
	window.open("druk.php?file="+plik, "drukuj_strone", "width=437,height=490,scrollbars=yes").focus();
}

function pop_image(img, w, h)
{
	window.open('pop_image.php?i='+img+'&w='+w+'&h='+h,'image','width='+w+', height='+h, 'scrollbars=no').focus()
}

function pop_image2(img, w, h, k)
{
	window.open('pop_image.php?i='+img+'&w='+w+'&h='+h+'&k='+k,'image','width='+w+', height='+h, 'scrollbars=no').focus()
}

function pop_af(img, w, h)
{
	window.open('pop_af.php?i='+img+'&w='+w+'&h='+h,'image','width='+w+', height='+h, 'scrollbars=no').focus()
}

function onSzukaj(form)
{
	if(!form)
		form = document.forms['f_search'];

	form.submit();
}
 
function printFlash(w, h, swf, lng, noflashimg, ssl) {
	ssl = (!ssl)?"http":"https";
	if ((document.implementation && document.implementation.createDocument)||(window.ActiveXObject)){
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'" codebase="'+ssl+'://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0"><param name="MOVIE" value="'+swf+'" /><param name="PLAY" value="true" /><param name="LOOP" value="true" /><param name="flashvars" value="param_page='+lng+'" /><param name="WMODE" value="transparent" /><param name="QUALITY" value="high" /><embed src="'+swf+'" width="'+w+'" height="'+h+'" play="true" loop="true" wmode="transparent" quality="high" pluginspage="'+ssl+'://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>');		
	}else {
		document.write('<div style="background:url('+noflashimg+') 0 0 no-repeat;width:'+w+'px;height:'+h+'px"></div>');
	}
}

function setFlash(id, w, h, swf, lng, noflashimg, ssl) {
	ssl = (!ssl)?"http":"https";
	if ((document.implementation && document.implementation.createDocument)||(window.ActiveXObject)){
		//document.getElementById(id).innerHTML = '<div id="'+id+'_mask" style="position: absolute;width:'+w+'px;height:'+h+'px;background:url(images/pix.gif)"></div><div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'" codebase="'+ssl+'://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0"><param name="MOVIE" value="'+swf+'" /><param name="PLAY" value="true" /><param name="LOOP" value="true" /><param name="flashvars" value="param_page='+lng+'" /><param name="WMODE" value="transparent" /><param name="QUALITY" value="high" /><embed src="'+swf+'" width="'+w+'" height="'+h+'" play="true" loop="true" wmode="transparent" quality="high" pluginspage="'+ssl+'://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object></div>'
		document.getElementById(id).innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'" codebase="'+ssl+'://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0"><param name="MOVIE" value="'+swf+'" /><param name="PLAY" value="true" /><param name="LOOP" value="true" /><param name="flashvars" value="param_page='+lng+'" /><param name="WMODE" value="transparent" /><param name="QUALITY" value="high" /><embed src="'+swf+'" width="'+w+'" height="'+h+'" play="true" loop="true" wmode="transparent" quality="high" pluginspage="'+ssl+'://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>'		
	}else {
		document.getElementById(id).style.background = 'url('+noflashimg+') 0 0 no-repeat';
		document.getElementById(id).style.height = h+'px';
	}
}

function popupAcatar(url, xml, bck) {
	var w = 630;
	var h = 435;
	var winOpen = 'swf/autotest.htm?url='+url+'&xml='+xml+'&bck='+bck;
	
	var win_width = screen.availWidth;
	var win_height = screen.availHeight;
	
	var	pop_top = parseInt(win_height/2-h/2);
	var	pop_left = parseInt(win_width/2-w/2);
	
	
	window.open(winOpen,'','width='+w+', height='+h+', left='+pop_left+', top='+pop_top,  'scrollbars=no,menubar=0,resizable=0').focus()
}


function akademiaShowMonth(selectedMonth){
	monthsList = new Array('listopad_2006','grudzien_2006','styczen_2007');
	for(var i in monthsList){
			var m = monthsList[i];
			var btn = document.getElementById('btn_'+m);
			if (btn) {
				btn.src = (selectedMonth==m)?'images/btn_'+m+'_on.gif':'images/btn_'+m+'.gif'
			}
			var tableDiv = document.getElementById(m);
			if (tableDiv) {
				tableDiv.style.display = (selectedMonth==m)?'':'none'
			}
			
	}
}

function checkEmail(e) {
	if(e.indexOf('@') >=0)
		return true;
	else
		return false;
}

function checkProf() {
	if(	(document.forms.zyciorys.wa_marketing.checked) ||
		(document.forms.zyciorys.wa_public_relations.checked) ||
		(document.forms.zyciorys.wa_dzial_sprzedazy.checked) ||
		(document.forms.zyciorys.wa_dzial_eksportu.checked) ||
		(document.forms.zyciorys.wa_biuro_projektow.checked) ||
		(document.forms.zyciorys.wa_dzial_informacji_medycznej.checked) ||
		(document.forms.zyciorys.wa_dzial_outsourcingu.checked) ||
		(document.forms.zyciorys.wa_dzial_finansowy.checked) ||
		(document.forms.zyciorys.wa_personalno_administracyjny.checked) ||
		(document.forms.zyciorys.wa_prawny.checked) ||
		(document.forms.zyciorys.wa_it.checked) ||

		(document.forms.zyciorys.wr_dzial_pakowania.checked) ||
		(document.forms.zyciorys.wr_dzial_form_suchych.checked) ||
		(document.forms.zyciorys.wr_dzial_kontroli_jakosci.checked) ||
		(document.forms.zyciorys.wr_dzial_zapewnienia_jakosci.checked) ||
		(document.forms.zyciorys.wr_dzial_logistyki.checked) ||
		(document.forms.zyciorys.wr_dzial_utrzymania_ruchu.checked) ||
		(document.forms.zyciorys.wr_sekcja_ksiegowosci.checked) ||
		(document.forms.zyciorys.wr_sekcja_kontrolingu.checked) ||
		(document.forms.zyciorys.wr_personalno_administracyjny.checked) ||
		(document.forms.zyciorys.wr_it.checked)
		)
		return true;
	else
		return false;
}

function sendApp() {
    if (document.forms.zyciorys.email.value == '') 				alert('Proszę podać swój adres e-mail.');
    else if (!checkEmail(document.forms.zyciorys.email.value)) 	alert('Błędny adres e-mail.');
    else if (document.forms.zyciorys.cv.value == '') 			alert('Proszę załączyć plik z CV.');
    else if (!checkProf()) 										alert('Proszę wybrać dział.');
    else if (!document.forms.zyciorys.choice.checked) 			alert('Proszę zaznaczyć pole "Wyrażam zgodę na przetwarzanie moich danych osobowych..."');
    else document.forms.zyciorys.submit()
}

function sendInvite() {
	if (document.forms.polec_znajomym.email2.value == '') 				alert('Proszę podać adres e-mail znajomego.');
    else if (document.forms.polec_znajomym.email.value == '') 			alert('Proszę podać swój adres e-mail.');
    else if (!checkEmail(document.forms.polec_znajomym.email.value)) 	alert('Błędny adres e-mail.');
    else if (!checkEmail(document.forms.polec_znajomym.email2.value)) 	alert('Błędny adres e-mail.');
    else document.forms.polec_znajomym.submit()
}

function prepAppJob() {
    if (!document.forms.req.choice.checked) {
        alert('Proszę zaznaczyć pole "Wyrażam zgodę na przetwarzanie moich danych osobowych..."');
        return;
    }
    document.forms.req.submit();
}

function sendAppJob() {
    if (document.forms.zyciorys.email.value == '') 				alert('Proszę podać swój adres e-mail.');
    else if (!checkEmail(document.forms.zyciorys.email.value)) 	alert('Błędny adres e-mail.');
    else if (document.forms.zyciorys.cv.value == '') 			alert('Proszę załączyć plik z CV.');
    else document.forms.zyciorys.submit()
}

function akademiaShowMonth(selectedMonth){
	monthsList = new Array('month1','month2','month3');
	for(var i in monthsList) {
		var m = monthsList[i];
		var btn = document.getElementById('af_mnu_'+m);
		//alert('af_mnu_tab_'+m);
		if (btn) {
			btn.className = (selectedMonth==m)?'af_tab_current':'';
		}
		var tableDiv = document.getElementById(m);
		if (tableDiv) {
			tableDiv.style.display = (selectedMonth==m)?'block':'none';
		}			
	}
}

function printRandomTip() {
	porady = new Array('﻿Jesteś gospodarzem w aptece. Zawsze pierwszy witaj pacjenta.','Rozmawiając z pacjentem, zadawaj pytania otwarte. Np.: "Jakie ma Pan objawy? Dla kogo ma być ten lek? Co stosowała Pani do tej pory? Kiedy nasilają się objawy?"','Rekomendując produkt, mów do pacjenta językiem korzyści. Np.: "Mówił Pan, że bóle nasilają się wieczorem. Zatem polecam Apap Noc, który ułatwi zasypianie."','Szukaj dla każdego pacjenta indywidualnych korzyści. Np.: "Gripex zadziała kompleksowo na objawy przeziębienia."','Polecaj produkty dodatkowe. Np.: "Skoro mówi Pani, że często się przeziębia, proponuję w okresie wiosennym brać profilaktycznie witaminy."');
	do {
		pIndex = Math.round(Math.random()*10);
	}
	while (pIndex>=porady.length);
	text = "<b>Porada " + (pIndex+1) + "</b><br/> " + porady[pIndex];
	document.write(text);
}

function isIE(){
	return ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
}
