var lang;
function flash(w, h, path)
{ 
	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" width="'+w+'" height="'+h+'" align="middle">'
	+'<param name="allowScriptAccess" value="always" />'
	+'<param name="movie" value="'+path+'" />'
	+'<param name="menu" value="false" />'
	+'<param name="quality" value="best" />'
	+'<param name="scale" value="noscale" />'
	+'<embed src="'+path+'" menu="false" scale="noscale" quality="best" width="'+w+'" height="'+h+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	+'</object>');
}

function flash2(w, h, path)
{ 
	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" width="'+w+'" height="'+h+'" align="middle">'
	+'<param name="allowScriptAccess" value="always" />'
	+'<param name="movie" value="'+path+'" />'
	+'<param name="menu" value="false" />'
	+'<param name="quality" value="best" />'
	+'<param name="scale" value="noscale" />'
    +'<param name="wmode" value="transparent" />'  
	+'<embed src="'+path+'" menu="false" scale="noscale" quality="best" wmode="transparent" width="'+w+'" height="'+h+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	+'</object>');
}
    
    
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function init(lng)
{
	lang = lng;
}

function showTab(nr)
{
	var Tabs = 3;
	
	for(a=1; a<=Tabs; a++)
	{
		if(document.getElementById('nbox_'+a))
		{
			if(a == nr)
			{
				document.getElementById('nbox_'+a).style.display = 'block';
				document.getElementById('tab_'+a).src = 'templates/image/'+lang+'_n'+a+'-.jpg';
			}
			else
			{	
				document.getElementById('nbox_'+a).style.display = 'none';
				document.getElementById('tab_'+a).src = 'templates/image/'+lang+'_n'+a+'.jpg';
			}
		}
	}
}

function showOne(nr)
{
	$("#snews_"+nr).toggle("slow");
	$(".linker_"+nr).toggle();
}

function goSearch(lang)
{
	document.location.href = '/'+lang+'/search/'+document.getElementById('searchField').value;
}

function keybEnter(a, b, lang)
{
	var c=b.keyCode?b.keyCode:b.which?b.which:b.charCode;
	if(c==13)
		{
		var i;
		for(i=0;
		i<a.form.elements.length;
		i++)if(a==a.form.elements[i])break;
		i=(i+1)%a.form.elements.length;
		a.form.elements[i].focus();
		goSearch();
		return false
	}
	else
		{
		return true
	}
}


function checkField()
{
	oldValue = document.getElementById('searchField').value;
	
	if(document.getElementById('searchField').value == "wpisz szukaną frazę" || document.getElementById('searchField').value == "enter search word")
	{
		document.getElementById('searchField').value = "";
	}
	else
	{
		if(document.getElementById('searchField').value == "")
		{
			document.getElementById('searchField').value = oldValue;
		}
	}
}


$(document).ready(function(){
	
	var setSelector = "#mainMenu";
	var setCookieName = "poldrogmenu";
	var setCookieExpiry = 365;

	
	$("#mainMenu").sortable({
		placeholder: 'ui-state-highlight-drag',
		update : function () { 
	      $.cookie(setCookieName, $(setSelector).sortable("toArray"), { expires: setCookieExpiry, path: "/" });
	    } 
	});
	
	$("#mainMenu").disableSelection();
	
	$('.up').click(function(){
		$(document).scrollTo($(this).attr('href'),500);
		return false;
	});
	$(".print").click(function(){
		$("div#modulesContent").printArea();
	});
	$('#big').click(function() {$('#nbox_1, #nbox_2, #nbox_3, #nbox_1 a, #nbox_1 span, #nbox_2 a, #nbox_2 span, #nbox_3 a, #nbox_3 span, #modulesContent').addClass('setBig');});
	$('#small').click(function() {$('#nbox_1, #nbox_2, #nbox_3, #nbox_1 a, #nbox_1 span, #nbox_2 a, #nbox_2 span, #nbox_3 a, #nbox_3 span, #modulesContent').removeClass('setBig');});
});
