is = new function() {
	this.agent  = navigator.userAgent.toLowerCase();
    this.appVer = navigator.appVersion.toLowerCase();
	this.minor  = parseFloat(this.appVer);
    this.major  = parseInt(this.minor);
	this.opera  = (this.agent.indexOf("opera") != -1);
	this.konq   = (this.agent.indexOf('konqueror') != -1)
	this.safari = ((this.agent.indexOf('safari')!=-1)&&(this.agent.indexOf('mac')!=-1));
	this.khtml  = (this.safari || this.konq);
	var msiePos = this.appVer.indexOf('msie');
	this.ie     = ((msiePos!=-1)&&(!this.opera)&&(!this.khtml));
	if (msiePos !=-1) {
       this.minor = parseFloat(this.appVer.substring(msiePos + 5, this.appVer.indexOf(';', msiePos)));
       this.major = parseInt(this.minor);
    }
	this.ie6    = (this.ie && this.major == 6);
	this.menuRep = (this.ie && this.minor <= 6);
}

var lang = '';
function SprLang() {
	return;
    try {
//        var reg = new RegExp(".*/([a-z]{2})/")
        var jezyk = document.location.pathname;
        var arr = reg.exec(jezyk);
        lang = arr[1];
    }
    catch (ex) { }
}
SprLang(); // sprawdz jaki jest jezyk :]

function Alert(text)
 {
 alert(text);
 return false;
 }

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function show_hide(obj)
{
  try {
      var element = document.getElementById(obj);
      var ret = element.style.display;
      element.style.display = (ret?'':'none');
      return ret;
  }
  catch (err) { }
}

/*
function PokazObrazek(src, w, h, print) // nie usuwac, bo przy newsach to lepiej wyglada
{
  var s_w = w>810?true:false;
  var s_h = h>640?true:false;
  var is_scroll = (s_w)||(s_h);
  var w_ = s_w?810:w;
  var h_ = s_h?640:h;
  var zamknij;// = "Zamknij";
  var print_txt;
  var print2 = '';
  switch (lang)
  {
        case "pl": zamknij = "Zamknij"; print_txt = "Drukuj"; break;
        case "en": zamknij = "Close"; print_txt = "Print"; break;
        case "de": zamknij = "Abschliessen"; break;
  }

  if (print) {
      h_+= 20;
      print2 = '<tr><td style="width:100%; height:20; text-align:right; border-bottom:1px solid #C9C9C9; background-color:#F3F3F3;"><a href="javascript:window.print()" style="color:#808080; font-size:11px; font-family:Verdana; text-decoration:none;"><img src="../gfx/ico_printer.gif" width="16" height="16" border="0" align="top" /> '+print_txt+' &nbsp; &nbsp;</a></td></tr>';
//      print2 = '<div style="position:absolute; top:10px; left:'+(w_-35)+'px; border:1 solid #C9C9C9; background-color:#F3F3F3;"></div>';
  }

  var win = window.open('', 'Obrazek_duzy', 'width='+w_+',height='+h_+',scrollbars='+(is_scroll?1:0));
  win.document.open();
  win.document.writeln('<html><head><title>'+(lang=='pl'?'Podgl&#261;d':(lang=='en'?'View':''))+'</title><meta http-equiv="Content-type" content="text/html; charset=ISO-8859-2"></head>');
  win.document.writeln('<body leftmargin="0" topmargin="0" title="'+zamknij+'">');
  win.document.writeln('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">'+print2+'<tr>');
  win.document.writeln('<td><img src="'+src+'" alt="'+zamknij+'" border="0" onclick="window.close()"></td>');//width="'+w+'" height="'+h+'"
  win.document.writeln('</tr></table>');
  win.document.writeln('</body></html>');
  win.document.close();
  win.focus();
}
function OtworzDrukuj() {
    var form = document.getElementById('form_do_druku');
    if ((form)&&(form.tagName=='FORM')) {
        form.submit();
        return false;
    }
}


function setCookie(cookieName, data, expiration)
 {
 document.cookie=cookieName+"="+data+";expires="+expiration;
 }

function get_cookie(Name)
 {
 search = Name + '=';
 returnvalue = '';
  if (document.cookie.length > 0)
   {
   offset = document.cookie.indexOf(search);
    if (offset != -1)
     {
     offset += search.length;
     end = document.cookie.indexOf(';', offset);
      if (end == -1) end = document.cookie.length;
     returnvalue = unescape(document.cookie.substring(offset, end));
     }
   }
 return returnvalue;
 }


function printf(fstring)
  { var pad = function(str,ch,len)
      { var ps='';
        for(var i=0; i<Math.abs(len); i++) ps+=ch;
        return len>0?str+ps:ps+str;
      }
    var processFlags = function(flags,width,rs,arg)
      { var pn = function(flags,arg,rs)
          { if(arg>=0)
              { if(flags.indexOf(' ')>=0) rs = ' ' + rs;
                else if(flags.indexOf('+')>=0) rs = '+' + rs;
              }
            else
                rs = '-' + rs;
            return rs;
          }
        var iWidth = parseInt(width,10);
        if(width.charAt(0) == '0')
          { var ec=0;
            if(flags.indexOf(' ')>=0 || flags.indexOf('+')>=0) ec++;
            if(rs.length<(iWidth-ec)) rs = pad(rs,'0',rs.length-(iWidth-ec));
            return pn(flags,arg,rs);
          }
        rs = pn(flags,arg,rs);
        if(rs.length<iWidth)
          { if(flags.indexOf('-')<0) rs = pad(rs,' ',rs.length-iWidth);
            else rs = pad(rs,' ',iWidth - rs.length);
          }
        return rs;
      }
    var converters = new Array();
    converters['c'] = function(flags,width,precision,arg)
      { if(typeof(arg) == 'number') return String.fromCharCode(arg);
        if(typeof(arg) == 'string') return arg.charAt(0);
        return '';
      }
    converters['d'] = function(flags,width,precision,arg)
      { return converters['i'](flags,width,precision,arg);
      }
    converters['u'] = function(flags,width,precision,arg)
      { return converters['i'](flags,width,precision,Math.abs(arg));
      }
    converters['i'] =  function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        var rs = ((Math.abs(arg)).toString().split('.'))[0];
        if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
        return processFlags(flags,width,rs,arg);
      }
    converters['E'] = function(flags,width,precision,arg)
      { return (converters['e'](flags,width,precision,arg)).toUpperCase();
      }
    converters['e'] =  function(flags,width,precision,arg)
      { iPrecision = parseInt(precision);
        if(isNaN(iPrecision)) iPrecision = 6;
        rs = (Math.abs(arg)).toExponential(iPrecision);
        if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs.replace(/^(.*)(e.*)$/,'$1.$2');
        return processFlags(flags,width,rs,arg);
      }
    converters['f'] = function(flags,width,precision,arg)
      { iPrecision = parseInt(precision);
        if(isNaN(iPrecision)) iPrecision = 6;
        rs = (Math.abs(arg)).toFixed(iPrecision);
        if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs + '.';
        return processFlags(flags,width,rs,arg);
      }
    converters['G'] = function(flags,width,precision,arg)
      { return (converters['g'](flags,width,precision,arg)).toUpperCase();
      }
    converters['g'] = function(flags,width,precision,arg)
      { iPrecision = parseInt(precision);
        absArg = Math.abs(arg);
        rse = absArg.toExponential();
        rsf = absArg.toFixed(6);
        if(!isNaN(iPrecision))
          { rsep = absArg.toExponential(iPrecision);
            rse = rsep.length < rse.length ? rsep : rse;
            rsfp = absArg.toFixed(iPrecision);
            rsf = rsfp.length < rsf.length ? rsfp : rsf;
          }
        if(rse.indexOf('.')<0 && flags.indexOf('#')>=0) rse = rse.replace(/^(.*)(e.*)$/,'$1.$2');
        if(rsf.indexOf('.')<0 && flags.indexOf('#')>=0) rsf = rsf + '.';
        rs = rse.length<rsf.length ? rse : rsf;
        return processFlags(flags,width,rs,arg);
      }
    converters['o'] = function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        var rs = Math.round(Math.abs(arg)).toString(8);
        if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
        if(flags.indexOf('#')>=0) rs='0'+rs;
        return processFlags(flags,width,rs,arg);
      }
    converters['X'] = function(flags,width,precision,arg)
      { return (converters['x'](flags,width,precision,arg)).toUpperCase();
      }
    converters['x'] = function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        arg = Math.abs(arg);
        var rs = Math.round(arg).toString(16);
        if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
        if(flags.indexOf('#')>=0) rs='0x'+rs;
        return processFlags(flags,width,rs,arg);
      }
    converters['s'] = function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        var rs = arg;
        if(rs.length > iPrecision) rs = rs.substring(0,iPrecision);
        return processFlags(flags,width,rs,0);
      }
    farr = fstring.split('%');
    retstr = farr[0];
    fpRE = /^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/;
    for(var i=1; i<farr.length; i++)
      { fps=fpRE.exec(farr[i]);
        if(!fps) continue;
        if(arguments[i]!=null) retstr+=converters[fps[4]](fps[1],fps[2],fps[3],arguments[i]);
        retstr += fps[5];
      }
    return retstr;
  }

*/
var menuTimeoutHwnd;
var menuLastItem;
var menuTimeDelay = 0;
function menuOnMouseOver() {
	try {
		var tmp = event.srcElement;
		while (tmp = tmp.parentNode)
			if (tmp.tagName == "LI")
				break;
		var ulTmp = tmp;
		while (ulTmp = ulTmp.parentNode)
			if (ulTmp.tagName == "UL")
				break;
		if (tmp) {
			clearTimeout(menuTimeoutHwnd);
			if (menuLastItem != ulTmp) {
				menuOnMouseOut();
				var ul = tmp.getElementsByTagName("UL")[0];
				ul.style.visibility = 'visible';
				tmp.onmouseout = function() {
					menuLastItem = ul;
					menuTimeoutHwnd = setTimeout("menuOnMouseOut()",
							menuTimeDelay);
				};
				ul.onmouseout = function() {
					if (menuLastItem != ul) {
						menuLastItem = ul;
						menuTimeoutHwnd = setTimeout("menuOnMouseOut()",
								menuTimeDelay);
					}
				};
			}
		}
	} catch (err) {
	}
}
function menuOnMouseOut() {
	if (menuLastItem) {
		menuLastItem.style.visibility = 'hidden';
		menuLastItem = null;
		menuTimeoutHwnd = 0;
	}
}
function menuSpr() {
	if (is.menuRep)
		for ( var mi = (mt = document.getElementsByTagName("LI")).length; mi; mi--) {
			var tmp = mt[mi - 1];
			while (tmp = tmp.parentNode)
				if (tmp.className == "menu")
					break;
			if (tmp)
				mt[mi - 1].onmouseover = menuOnMouseOver;
		}
}

function var_dump(obj)
{
	w = window.open();
	for(a in obj)
	{
		w.document.write(a+'='+obj[a]+'<br />');
	}
}


function addEvent(obj, event, func)
{
    if (obj.addEventListener){
        obj.addEventListener(event, func, false);
    } else if (obj.attachEvent){
        obj.attachEvent('on'+event, func);
    }
}

$(document).ready(function ()
	{
		$('UL.menuleft LI A').each(function() 
				{
					$(this).removeClass('njs');
					if($(this).hasClass('menuleft_ajaxlink'))
					{
						var name = $(this).attr('href').split('/')[4].split(',')[0];
//						if(typeof $(this).attr('href').split('#')[1] == 'undefined')
						if(name == '')
							$(this).attr('href', '#');
						else
							$(this).attr('href', '#'+name);
						$(this).data('content_name', name);
						$(this).click(function()
								{
									SwitchContent($(this).data('content_name'), $('#content')); 
								});
					}
				});
		$('UL.menuleft LI').elementExtend('rollUp', function() // zwin
				{
//					$(this).parent('UL').parent('LI').execute('rollDown');
					$(this).animate({'borderLeftColor': '#3C7CB0'}, 700);
					$(this).children('UL').slideUp('fast');
					$(this).data('rolled', 0);
				});
		$('UL.menuleft LI').elementExtend('rollDown', function() // rozwin
				{
					$(this).parents('LI').execute('rollDown');
					if($(this).find('UL'))
					{
						if($(this).parent('UL').hasClass('menuleft'))
							$(this).animate({'borderLeftColor': '#6FA9D8'}, 700);
						$(this).children('UL').slideDown(500);
						$(this).data('rolled', 1);
					}
				});
		$('UL.menuleft LI').elementExtend('roll', function()
				{
					$(this).stop();
					if($(this).data('rolled')) // jezeli rozwiniety
					{
						$(this).execute('rollUp');
					}
					else
					{
						$(this).execute('rollDown');
					}
//					$(this).parent().stop().animate({'borderLeftColor': '#6FA9D8'}, 700);
//					$(this).parent().children('UL').slideDown('fast');
				});
		$('UL.menuleft LI A').click(function() 
				{
/*					if($(this).data('rollup'))
					{
						$(this).parent().stop().animate({'borderLeftColor': '#3C7CB0'}, 700);
						$(this).data('rollup', 0);
					}
					else
					{
						$(this).parent().stop().animate({'borderLeftColor': '#6FA9D8'}, 700);
						$(this).data('rollup', 1);
					}
					$(this).parent().children('UL').slideToggle('fast');
					*/
					$(this).parent().execute('roll');
//					return false;
				})
			.each(function()
				{
					$(this).data('origBackgroundColor', $(this).css('backgroundColor') == 'transparent' ? '#fff' : $(this).css('backgroundColor'));
					
				})
			.hover(function()
				{
					$(this).stop().animate({'backgroundColor': '#E8EDF0'}, 150);
				},
				function()
				{
					$(this).stop().animate({'backgroundColor': $(this).data('origBackgroundColor')}, 750, function() { $(this).css('backgroundColor', null); });
				});
		//$('IMG').fullsize({shadow: false, zoomInSpeed: 0, zoomOutSpeed :0, fadeInSpeed :500,fadeOutSpeed:500 });
	});
function SwitchContent(name, block)
{
	if(typeof name == 'undefined' || name == '' || name == 'undefined')
		return;
	if($(block).length > 1)
		return;
	if($(block).data('loadingName') == name || $(block).data('loadedName') == name)
		return;
	$(block).data('loadingName', name);
	if(typeof loading_block == 'undefined' || loading_block == null)
	{
		loading_block = 
			$('<div class="loading"></div>')
			.html('<img src="/gfx/ajax_loader_big.gif" alt="ładowanie... " /><br /> ładowanie treści')
			.css({position: 'absolute',
				  top: $(block).offset().top+'px',
				  left: $(block).offset().left+'px',
				  textAlign: 'center',
				  width: $(block).width(),
				  marginTop: '40px',
				  opacity: 0});
		$(block).parent().append(loading_block);
		$(loading_block).animate({'opacity': 1}, 'medium');
	}
	else
	{
		$(loading_block)
		.stop()
		.fadeIn('medium');
		//.css('opacity', 1);
	}
	$(block)
		.stop()
//		.fadeOut('slow')
		.animate({'opacity': 0}, 400)
//		.fadeTo(400, 0)
	;
	if($(block).data('ajaxRequest')) 
			$(block).data('ajaxRequest').abort();
	$(block).data('ajaxRequest', $.ajax(
			{
				url: '/pl/rozwiazania_dla_biznesu/oprogramowanie/'+name+'.ajax',
				complete: function(v)
				{
					$(block).data('nextContent', v.responseText);
					$(block).queue('fx2', 
						function()
						{
							$(loading_block)
							.fadeOut('medium', 
								function() 
								{ 
									$(this).remove();
									loading_block = null;
									$(block).data('loadingContent', 0);
								}
							); //.queue('fx', function() { $(this).remove(); });
							$(this)
								.queue(function() { $(this).html($(this).data('nextContent')); $(this).dequeue(); })
//								.stop()
//								.fadeTo(400, 1, function() { $(this).data('loadedName', $(this).data('loadingName')); $(this).data('loadingName', null); $(this).ieffembedfix(); })
								.animate({'opacity': 1}, 400, null, 
										function()
										{ 
											$(this).data('loadedName', $(this).data('loadingName'));
											$(this).data('loadingName', null);
											$(this).ieffembedfix();
											//$(this).find('IMG').fullsize({shadow: false, zoomInSpeed: 0, zoomOutSpeed :0, fadeInSpeed :500,fadeOutSpeed:500 });

										}
								)
//								.animate({'opacity': 1}, 700)
//								.stop()
//								.queue('fx', function() { $(this).css({'opacity': 1, 'display': 'block'}); })
//								.fadeIn('slow', function() { alert('loaded'); })
							;
						}
					).dequeue('fx2')
					;
				}
			}));
}

$(document).ready(function()
	{
//	return;
		var content_name = location.hash.substring(1);
		if(content_name == '')
			return;
		$('#content').html('&nbsp;');
		SwitchContent(content_name, $('#content'));
		$('A[href$=#'+content_name+']').parent('LI').execute('rollDown');
	});
function debug(text)
{
	$('#test').html($('#test').html()+text+'<br />');
}



