/* Made by Mathias Bynens <http://mathiasbynens.be/> */
function number_format(a, b, c, d) {
 if (b == null) b = 2;
 if (c == null) c = ',';
 if (d == null) d = ' ';
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}
function cq (kod,zm) {



		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if ((zm > 0) && (tmpIl < 999999) ) {

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm - reszta;");

		}

		else if ((zm < 0) && (tmpIl > 0)){

			if ( reszta > 0 ) { eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;"); }

			else {	eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm;"); }

		}

	if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}

}



function rq (kod,zm) {

		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if (!(tmpIl >= 0)) {

			alert ("Wprowadzono nie poprawna wartosc!");

			eval( "document.grupa[\"il["+kod+"]\"].value = 0;");

		}

		else if (reszta > 0) {

			alert ("Ilosc musi być wielokrotnoscia liczby "+zm);

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;");

		}

		if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}



}

  
  // convert all characters to lowercase to simplify testing

    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
    var is_opera = (window.opera)?true:false;
    var is_opera7 = (window.opera)?true:false;
    var is_gecko = (agt.indexOf('gecko') != -1);


if(document.all && !document.getElementById)
    document.getElementById = function(id) { return document.all[id]; }

if(document.all && !document.getElementsByTagName)
    document.getElementsByTagName = function(tag) { return document.all.tags(tag); }


var lo = 1;
function sof (a) {
	if (document.getElementById('foto' + lo)) document.getElementById('foto' + lo).style.display = 'none';
	document.getElementById('oferta' + lo).style.display = 'none';
	document.getElementById('lin' + lo).className = '';
	lo = a;
	if (document.getElementById('foto' + lo)) document.getElementById('foto' + lo).style.display = '';
	document.getElementById('oferta' + lo).style.display = '';
	document.getElementById('lin' + lo).className = 'selected';

}

function footReset() {
	f = document.getElementById('footer').style.position="relative";
	f = document.getElementById('footer').style.position="absolute";
	//alert('test');
	if (txtalert != '') {
		alert(txtalert);
		txtalert = '';
	}
}


function flash(name,src,x,y,ver,opcja) {
	

	if (opcja == 'w3c') {
		document.write ('<object id="'+name+'" type="application/x-shockwave-flash" data="'+src+'" width="'+x+'" height="'+y+'" >');
		document.write ('<param name="movie" value="'+src+'" >');
		document.write ('<param name="swliveconnect" value="true">');
		document.write ('</object>');
	}
	else {

		document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+',0,0,0"');
		document.write ('width='+x+' height='+y+' id="'+name+'">');
		document.write ('<param name=movie value="'+src+'">');
		document.write ('<param name=quality value=high>');

		if (opcja == 'transparent') document.write ('<param name="wmode" value="transparent">');

		document.write ('<param name="swliveconnect" value="true">');
		document.write ('<embed src="'+src+'" quality="high" width="'+x+'" height="'+y+'"');
		document.write (' type="application/x-shockwave-flash"');
		document.write (' pluginspage="http://www.macromedia.com/downloads/"');
		document.write (' name="'+name+'" swliveconnect="true">');
		document.write ('</embed>');
		document.write ('</object>');
	}
}



var lastWin;
function setImg (imgSrc,reSize) {
	if (lastWin.jestem) {
		
		if (reSize == 1) {
			lastWin.document.body.innerHTML = '<img src="'+imgSrc+'" id="obrazek" onload="window.resizeTo(this.width + 10,this.height + 30);window.moveTo(20,20);" >'; 
			lastWin.focus();
		}
		else {
			lastWin.document.body.innerHTML = '<img src="'+imgSrc+'" id="obrazek" >'; 
		}
			
	}	
	else {
		setTimeout("setImg('"+imgSrc+"', '"+reSize+"')",100);
	}
}


function setSizeImg () {
	if (lastWin.document.getElementById('obrazek')) {

	//	lastWin.resizeTo(lastWin.document.getElementById('obrazek').width + 10,lastWin.document.getElementById('obrazek').height + 30);
	//	lastWin.moveTo(20,20); 
		alert(lastWin.document.getElementById('obrazek').src);
		lastWin.close(); 
		zoomImg(lastWin.document.getElementById('obrazek').src,lastWin.document.getElementById('obrazek').width,lastWin.document.getElementById('obrazek').height);
	}	
	else {
		setTimeout("setSizeImg()",100);
	}
}

// onload="window.resizeTo(this.width + 10,this.height + 30);window.moveTo(20,20);

function zoomImg(imgSrc,xSize,ySize) {
	reSize = 1;
	if (xSize && ySize) reSize = 0;
	if (!xSize) xSize=300;
	if (!ySize) ySize=300;
	scrollBary='no';
	xPos=20;
	lastWin = window.open('','Zoom', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollBary+',resizable=yes,fullscreen=no,channelmode=no,width='+xSize+',height='+ySize+',top=0,left='+xPos);
	
	setImg (imgSrc,reSize);
	void(0);
}
function zoom2(imgSrc) {
	lastWin = window.open('sdgsdgsd','zoomOkno','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,fullscreen=no,channelmode=no,width=300,height=300,top=0,left=150');

	void(0);
}

function oW (path,Xsiz,Ysiz,Xp,Yp,resi,scrollb) {
	if (path.indexOf('zoom.php') != -1) path = '/heuristic2/'+path;
	var przed = '';
	if (!(Xsiz > 0)) { Xsiz = 300; }
	if (!(Ysiz > 0)) { Ysiz = 300; }
	if (Xp == 'right') Xp = screen.width - 20 - Xsiz;
	if (!(Xp > 0)) { Xp = 30; }
	if (!(Yp > 0)) { Yp = 30; }
	if (resi == null) resi = 'yes';
	if (scrollb == null) scrollb = 'yes';
	var w = window.open(przed+path, 'fotozoom', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollb+',resizable='+resi+',fullscreen=no,channelmode=no,width='+Xsiz+',height='+Ysiz+',top='+Yp+',left='+Xp);
	w.focus();
	void(0);
}

function el (id) {
        return document.getElementById(id);
}

function tf (txt,id) {
		if (el(id).value == '') {
	        alert(txt);
			el(id).focus();
			return false;
		}
		else return true;
}

function ts (txt,id) {
		if (el(id).selectedIndex == 0) {
	        alert(txt);
			el(id).focus();
			return false;
		}
		else return true;
}

function te (txt,id) {
		if (el(id).value != '' && el(id).match(/^.*\@.*\..*$/)==null) {
	        alert(txt);
			el(id).focus();
			return false;
		}
		else return true;
}

function tc (txt,id) {
		if (!(el(id).checked)) {
		
	        if (txt != '') { alert(txt); el(id).focus(); }
			return false;
		}
		else return true;
}



function pobierz(nazwa) {
    if (document.cookie.length > 0) {
        startc = document.cookie.indexOf(nazwa + "=");
        if (startc != -1) {
            startc += nazwa.length + 1;
            endc = document.cookie.indexOf(";", startc);
            if (endc == -1) {
                endc = document.cookie.length;
            }
            return unescape(document.cookie.substring(startc,endc));
        }
	return false;
    }
    return false;
}

function rejestruj(nazwa, wartosc,dni) {
    var dzisiaj=new Date();
    var wygasnie=new Date();
    !dni ?dni=7 :"";
    // dni - data po ktorej ciastko traci waznosc (domyslnie tydzien)
    // jesli dni==0 to wazne w ciagu danej "sesji"
    wygasnie.setTime(dzisiaj.getTime()+1000*60*60*24*dni);
	document.cookie=nazwa+"="+escape(wartosc)+";expires="+wygasnie.toGMTString();
}

function sClear(obj,itxt) {
	if (obj.value == itxt) obj.value = '';
}
function sReturn(obj,itxt) {
	if (obj.value == '') obj.value = itxt;
}


// **************** MENU *******************

var activeSubMenu = false;
var timeOut = 1000;

$(document).ready(function(){
	$('#menu ul li a.menu').mouseover(function(){subMenu($(this).get(0), 1);});
	$('#menu ul li a.menu').mouseout(function(){subMenu($(this).get(0), 0);});
	$('#menu ul li ul.submenu').mouseover(function(){overMenu($(this).get(0));
							 if($(this).parent().attr('class') != 'selected')
							 {
							 	$(this).parent().addClass('selected2');
							 }});
	$('#menu ul li ul.submenu').mouseout(function(){outMenu($(this).get(0));
							if($(this).parent().attr('class') != 'selected')
							{
								$(this).parent().removeClass('selected2');
							}});
});

function subMenu(obj,show)
{
  if(obj.nextSibling)
  {
    if(obj.nextSibling.innerHTML)
    {
      activeSubMenu = t = obj.nextSibling;	

      if (show)
      {
	allul = document.getElementsByTagName('ul');
	for (a = 0; a < allul.length; ++a) if (allul[a].className == 'submenu') allul[a].style.visibility = 'hidden';
	t.style.visibility = 'visible';
      }
      else
      {
        activeSubMenu = false;
	setTimeout ("hideSubmenu(document.getElementById('"+t.id+"'))",timeOut);
      }
    }
  }
}

function hideSubmenu(t) {
	if (!activeSubMenu || activeSubMenu != t) t.style.visibility = 'hidden';
}

function overMenu(t) {
	activeSubMenu = t;
}

function outMenu(t) {
	activeSubMenu = false;
 	setTimeout ("hideSubmenu(document.getElementById('"+t.id+"'))",timeOut);
}

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

function emailValid(t,im,em) {
	
	var imie = document.getElementById('newsImieF');
	var mail = document.getElementById('newsEmailF');
	var er = document.getElementById('newsEmailI');
	
	try{
	if (!imie.value) {
		er.innerHTML = im;
		mail.focus(); 
		mail.parentNode.parentNode.className = 'alertRow';
		return false;
	}
	else {
		if (mail.value.indexOf('@',0) == -1 || mail.value.indexOf('.',0) == -1){
			er.innerHTML = em;
			mail.focus(); 
			mail.parentNode.parentNode.className = 'alertRow';
			return false;
		}
	}
	}
	catch(e){}
}

function emailPassValid(t,g) {
	
	var email = document.getElementById('emailF');
	var eror = document.getElementById('emailI');
	
	try{
	if (email.value.indexOf('@',0) == -1 || email.value.indexOf('.',0) == -1){
		eror.innerHTML = g;
		email.focus(); 
		email.parentNode.parentNode.className = 'alertRow';
		return false;
	}
	}catch(e){}
}


function prints(a) {


	var links = document.location.href;
	if(links.indexOf('#') != -1) {
		links=document.location.href.substring(0,links.indexOf('#'));

	}

	if(links[links.length-1] != '/') {
		links = links+'&print=1';
	}
	else {
		links = links+'page.php?print=1';
	}

	oW(links,740,740);

}


// **************** JQUERY *******************

$(document).ready( function(){

	// mp3 player
        $('img.actItemMp3').each(function(){

               if (this.alt != '') {
                       $(this).after('<object type="application/x-shockwave-flash" style="width: ' + this.width + 'px; height:' + this.height + 'px;" data="/mp3player.swf?mp3file=' + this.alt + '&txt=' + this.title + '"><param name="movie" value="/mp3player.swf?mp3file=' + this.alt + '&txt=' + this.title + '"/><param name="wmode" value="transparent" /></object>');
               }
        });
        $('img.actItemMp3').remove();


	// youtube player
        $('img.actItemYoutube').each(function(){

		if (this.alt != '') {
			$(this).after('<object type="application/x-shockwave-flash" style="width: ' + this.width + 'px; height:' + this.height + 'px;" data="' + this.alt + '"><param name="movie" value="' + this.alt + '" /><param name="wmode" value="transparent" /></object>');
		}		
	});
	$('img.actItemYoutube').remove();


	// last gallery
	$('.last_gallery').cycle({fx: 'fade',
		                       speed: 300,
	        	               timeout: 5000});


	// Prochniaki box
	$('#boxProchniakiCycle').cycle({
		fx:	'scrollHorz', 
		speed:       500,
		timeout:     0,
		prev:   '#prev3', 
		next:   '#next3'
	});

	// WeddTV box
	$('#boxWeddTVCycle').cycle({
		fx:	'scrollHorz', 
		speed:       450,
		timeout:     0,
		prev:   '#prev8', 
		next:   '#next8'
	});

	// Nowosci box
	$('#slideshow2').cycle({
		fx:	'scrollHorz', 
		speed:       550,
		timeout:     0,
		prev:   '#prev2', 
		next:   '#next2'
	});

	$('#slideshow3').cycle({
		fx:	'scrollHorz', 
		speed:       550,
		timeout:     0,
		prev:   '#prev4', 
		next:   '#next4'
	});

	$('#newUsers').cycle({
		fx:	'scrollHorz', 
		speed:       700,
		timeout:     0,
		prev:   '#prev5', 
		next:   '#next5'
	});

	$('#mainBoxHolder').cycle({
		fx:	'fade', 
		speed:       300,
		timeout:     8000,
		pager:      '#mainBoxNavi',
		pagerEvent: 'mouseover'
	});

	// Przelaczanie zakladek na glownej stronie
	$('.tab').click(function(){
		var par=($(this).parent().parent().attr('id'));
		$('#'+par).children('.main_tabs_top').children('.tab').removeClass('active');
		$('#'+par).children('.main_tabs_top').children('.tab').removeClass('inactive');
		$('#'+par).children('.main_tabs_top').children('.tab').addClass('inactive');
		$(this).removeClass('inactive');
		$(this).addClass('active');

		$('#'+par).children('.main_tab_content').css('display', 'none');
		$('#wnd_'+$(this).attr('id')).css('display', 'block');
	});

   $('.caltooltip').tooltip({ 
    	track: true, 
    	delay: 0, 
  	showURL: false, 
  	showBody: "-----", 
    	extraClass: "caltooltip", 
    	fixPNG: true, 
    	opacity: 1, 
    	left: -110
   });

});


// **************** ONE ROW MENU *******************

var submenu_show = 0;
var submenu_hidden = 0;
var timeout = 0;

function show_submenu(id) {
	$('.mainmenu .level_0 a').removeClass('selected');
	$('.mainmenu .level_0 #'+id).addClass('selected');

	$('.mainmenu .level_1').removeClass('selected');
	$('.mainmenu .level_1#s'+id).addClass('selected');
}

function hide_submenu() {

	if(submenu_show == 0 && submenu_hidden == 0) {
		$('.mainmenu .level_0 a.active').addClass('selected');
		$('.mainmenu .level_0 a').not('.active').removeClass('selected');

		$('.mainmenu .level_1.active').addClass('selected');
		$('.mainmenu .level_1').not('.active').removeClass('selected');

		submenu_hidden = 1;
	}
}

$(document).ready(function(){
	$('.mainmenu .level_0 a').not('.item_forum').mouseover(function(){
		if(!$(this).hasClass('selected')) {
			submenu_show = 1;
			submenu_hidden = 0;
			show_submenu($(this).attr('id'));
		}
	});

	$('.mainmenu .level_0 a').not('.item_forum').mouseout(function(){
		submenu_show = 0;
		if(timeout) clearTimeout(timeout);
		timeout = setTimeout("hide_submenu()", 2000);
	});

	$('.mainmenu .level_1').mouseover(function(){
		submenu_show = 1;
		submenu_hidden = 0;
	});

	$('.mainmenu .level_1').mouseout(function(){
		submenu_show = 0;
		if(timeout) clearTimeout(timeout);
		timeout = setTimeout("hide_submenu()", 2000);
	});

	


});

// ************* END OF ONE ROW MENU ****************




// ************* Panel Logowania *******************

var locked=0;
var state=0;

$(document).ready(function(){
	
	
	$('#switchLogin').click(function(){
		if(locked==0)
		{
			if(state==0)
			{
				locked=1;
				$('#loginPanel').css('display', 'block');
				$('#loginPanel').animate({
					opacity: 1,
					right: "180px"
				}, 200, function(){
					locked=0;
					state=1;
				});
			}
			else
			{
				locked=1;
				$('#loginPanel').css('display', 'block');
				$('#loginPanel').animate({
					opacity: 0,
					right: "160px"
				}, 200, function(){
					locked=0;
					state=0;
				});	
			}
		}
	});

});


// ************* galeria ****************

$(function(){
  //Get our elements for faster access and set overlay width
  var div = $('div.sc_menu'),
               ul = $('ul.sc_menu'),
               // unordered list's left margin
               ulPadding = 15;

  //Get menu width
  var divWidth = div.width();

  //Remove scrollbars
  div.css({overflow: 'hidden'});

  //Find last image container
  var lastLi = ul.find('li:last-child');

  //When user move mouse over menu
  div.mousemove(function(e){

    //As images are loaded ul width increases,
    //so we recalculate it each time
    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
    div.scrollLeft(left);
  });
});


// ************* FAKTURA VAT ****************

$(document).ready(function(){
	$(".fakturaVATbtn").click().toggle(function(){
		$("#fakturaVAT").animate({
			height: '200px',
			opacity: 1

		},500);


	},function(){
		$("#fakturaVAT").animate({
			height: '0px',
			opacity: 0
		},500);
	}

	);
});


// ************* Obsługa mapki ***********************
var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;

/* ****************************** map 1 ***************************************/
if (document.getElementById || document.all)
	document.write('<div id="opiss" class="box_right_sk_desc" style="position:absolute;visibility:hidden; z-index:200"></div>')

function getopissobject(){
	if (document.getElementById)
		return document.getElementById("opiss")
	else if (document.all)
		return document.all.opiss
}

function getopissobj(){
	if (document.getElementById)
		return document.getElementById("opiss").style
	else if (document.all)
		return document.all.opiss.style
}

function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function opisOff(){
	document.onmousemove='';
	getopissobj().visibility="hidden";
}

function opisOn(opis,thh){
	if(ua.indexOf('safari') == -1){
		getopissobj().left="-500px";
		//divthw = parseInt(thw) + 2;
		divthh = parseInt(thh) + 2;
		getopissobject().innerHTML = '<span class="accsearchmapindic">'+opis+'</span>';
		getopissobj().visibility="visible";
		//alert(gettrailobject().height);
		//divw = parseInt(thw)+25;
		divh = parseInt(thh)+30;
		document.onmousemove=followmouse;
	}
}

function followmouse(e){
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
	if(typeof e != "undefined"){
		xcoord = 15+e.pageX;
		ycoord = -5+e.pageY;
	}
	else if (typeof window.event != "undefined"){
		xcoord = truebody().scrollLeft+15+event.clientX;
		ycoord = truebody().scrollTop-5+event.clientY;
	}
	getopissobj().left=xcoord+"px"
	getopissobj().top=ycoord+"px"
}


/************wybieranie wojewodztwa z mapki*************************/

function wojewodztwo(w,t) {
	
	var woj = document.getElementById('woj_search');
	for (i=0; i<woj.options.length; i++) {
		if (w == woj.options[i].value) {
			woj.options[i].selected	= true;
//			alert(woj.options[i].value);
		}
	}
	if (t) {
//		$('.search_btn').click();
	}
}




/************ odliczanie do slubu *************************/

  function StartCountDown(myDiv,myTargetDate)
  {
    var dthen	= new Date(myTargetDate);
    var dnow	= new Date();
    ddiff	= new Date(dthen-dnow);
    gsecs	= Math.floor(ddiff.valueOf()/1000);
    CountBack(myDiv,gsecs);
  }
  
  function Calcage(secs, num1, num2)
  {
    s = ((Math.floor(secs/num1))%num2).toString();
    if (s.length < 2) 
    {	
      s = "0" + s;
    }
    return (s);
  }
  
  function CountBack(myDiv, secs)
  {
    var DisplayStr;
    var DisplayFormat = "%%D%% &nbsp;&nbsp;&nbsp; %%H%% &nbsp;&nbsp;:&nbsp;&nbsp; %%M%%<br/><i>dni &nbsp;&nbsp; godzin &nbsp; minut</i>";
    DisplayStr = DisplayFormat.replace(/%%D%%/g,	Calcage(secs,86400,100000));
    DisplayStr = DisplayStr.replace(/%%H%%/g,		Calcage(secs,3600,24));
    DisplayStr = DisplayStr.replace(/%%M%%/g,		Calcage(secs,60,60));
    DisplayStr = DisplayStr.replace(/%%S%%/g,		Calcage(secs,1,60));
    if(secs > 0)
    {	
      document.getElementById(myDiv).innerHTML = DisplayStr;
      setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
    }
    else
    {
      document.getElementById(myDiv).innerHTML = "";
    }
  }


/************ show / hide - by id *************************/

function img_show(el)
{
myEl = document.getElementById(el);
myEl.style.display = 'block';
}

function img_hide(el)
{
myEl = document.getElementById(el);
myEl.style.display = 'none';
}





/************ !!! AJAX !!! *************************/

$(document).ready(function(){


/*** profil uzytkownika (prawa strona) ***/
	$("#profileWedInfoEditBtn").click(function(){
		img_hide("profileTopRight");
		img_show("profileTopRightEdit");
		return false;
	});

	$("#profileWedInfoEditBtnCancel").click(function(){
		img_hide("profileTopRightEdit");
		img_show("profileTopRight");
		return false;
	});

	$("#profileWedInfoEditBtnSave").click(function(){  
		$.post("/addfun.php",{  
			pan_imie: $("#AjaxPanImie").val(),  
			pan_nazwisko: $("#AjaxPanNazwisko").val(),  
			pan_miejsceur: $("#AjaxPanMiejsceUr").val(),  
			pan_dataur: $("#AjaxPanDataUr").val(),  
			panna_imie: $("#AjaxPannaImie").val(),  
			panna_nazwisko: $("#AjaxPannaNazwisko").val(),  
			panna_miejsceur: $("#AjaxPannaMiejsceUr").val(),  
			panna_dataur: $("#AjaxPannaDataUr").val(),  
			slub_data: $("#AjaxSlubData").val(),  
			slub_godzina: $("#AjaxSlubGodzina").val(),  
			slub_miejsce: $("#AjaxSlubMiejsce").val(),  
			user_id: $("#AjaxUserId1").val(),  
			action: "profileWedInfoAjax"
		});  
		document.getElementById("profileWedInfoAjax1").innerHTML = $("#AjaxPanImie").val();
		document.getElementById("profileWedInfoAjax21").innerHTML = $("#AjaxPanNazwisko").val();
		document.getElementById("profileWedInfoAjax22").innerHTML = $("#AjaxPanMiejsceUr").val();
		document.getElementById("profileWedInfoAjax23").innerHTML = $("#AjaxPanDataUr").val();
		document.getElementById("profileWedInfoAjax2").innerHTML = $("#AjaxPannaImie").val();
		document.getElementById("profileWedInfoAjax24").innerHTML = $("#AjaxPannaNazwisko").val();
		document.getElementById("profileWedInfoAjax25").innerHTML = $("#AjaxPannaMiejsceUr").val();
		document.getElementById("profileWedInfoAjax26").innerHTML = $("#AjaxPannaDataUr").val();
		document.getElementById("profileWedInfoAjax3").innerHTML = $("#AjaxSlubData").val();
		document.getElementById("profileWedInfoAjax4").innerHTML = $("#AjaxSlubGodzina").val();
		document.getElementById("profileWedInfoAjax5").innerHTML = $("#AjaxSlubMiejsce").val();

		img_hide("profileTopRightEdit");
		img_show("profileTopRight");
		return false;
	});  



/*** profil uzytkownika (lewa strona) ***/
	$("#profileInfoBtn").click(function(){
		img_hide("profileInfoBox");
		img_show("profileInfoBoxEdit");
		return false;
	});

	$("#profileInfoBtnCancel").click(function(){
		img_hide("profileInfoBoxEdit");
		img_show("profileInfoBox");
		return false;
	});

	$("#profileInfoBtnSave").click(function(){  
		$.post("/addfun.php",{  
			para_gdzie: $("#AjaxParaGdzie").val(),  
			para_jakdlugo: $("#AjaxParaJakDlugo").val(),  
			para_datazar: $("#AjaxParaDataZar").val(),  
			para_miejscezar: $("#AjaxParaMiejsceZar").val(),  
			user_id: $("#AjaxUserId2").val(),  
			action: "profileInfoAjax"
		});  
		document.getElementById("profileInfoAjax1").innerHTML = $("#AjaxParaGdzie").val();
		document.getElementById("profileInfoAjax2").innerHTML = $("#AjaxParaJakDlugo").val();
		document.getElementById("profileInfoAjax3").innerHTML = $("#AjaxParaDataZar").val();
		document.getElementById("profileInfoAjax4").innerHTML = $("#AjaxParaMiejsceZar").val();

		img_hide("profileInfoBoxEdit");
		img_show("profileInfoBox");
		return false;
	}); 



/*** lista zdjec (zmiana tytulu galerii) ***/
	$("#AjaxGalInfoEdit1Btn").click(function(){
		img_hide("AjaxGalInfo1");
		img_show("AjaxGalInfoEdit1");
		return false;
	});

	$("#AjaxGalInfoEdit1Cancel").click(function(){
		img_hide("AjaxGalInfoEdit1");
		img_show("AjaxGalInfo1");
		return false;
	});

	$("#AjaxGalInfoEdit1Save").click(function(){
		$.post("/addfun.php",{  
			gal_title: $("#AjaxGalInput11").val(),  
			gal_id: $("#AjaxGalInput12").val(),  
			action: "AjaxGalTitle"
		});  

		document.getElementById("AjaxGalInfoValue1").innerHTML = $("#AjaxGalInput11").val();
		document.getElementById("h1title2").innerHTML = $("#AjaxGalInput11").val();

		img_hide("AjaxGalInfoEdit1");
		img_show("AjaxGalInfo1");
		return false;
	});


/*** lista zdjec (zmiana statusu galerii) ***/
	$("#AjaxGalInfoEdit2Btn").click(function(){
		img_hide("AjaxGalInfo2");
		img_show("AjaxGalInfoEdit2");
		return false;
	});

	$("#AjaxGalInfoEdit2Cancel").click(function(){
		img_hide("AjaxGalInfoEdit2");
		img_show("AjaxGalInfo2");
		return false;
	});

	$("#AjaxGalInfoEdit2Save").click(function(){
		$.post("/addfun.php",{  
			gal_type: $("#AjaxGalInput21").val(),  
			gal_id: $("#AjaxGalInput22").val(),  
			action: "AjaxGalType"
		});  

		document.getElementById("AjaxGalInfoValue2").innerHTML = $("#AjaxGalInput21 option:selected").text();

		img_hide("AjaxGalInfoEdit2");
		img_show("AjaxGalInfo2");
		return false;
	});



/*** gratulacje (przycisk) ***/
	$("#AjaxGratulacjeBtn").click(function(){
		$.post("/addfun.php",{  
			komu: $("#AjaxGratulacjeKomu").val(),  
			gal_id: $("#AjaxGalInput22").val(),  
			action: "AjaxGalType"
		});  

		document.getElementById("AjaxGratulacjeBox").innerHTML = "&nbsp;";
		return false;
	});



/*** dodawanie nowej galerii (widok glowny profilu) ***/
	$("#AjaxNewGalleryBtn").click(function(){
		$.get('/addfun.php', {addnewgallery: 1}, function(data){
			tmp = document.getElementById("AjaxNewGalleryBtn").href;
			location.replace(tmp + data);
		});
		return false;
	});


});




/*** lista zdjec (usuwanie zdjecia) ***/
	function AjaxDelFoto(img_id,user_id){
		$.post("/addfun.php",{  
			img_id: img_id,  
			user_id: user_id,  
			action: "AjaxDelFoto"
		});
		AjaxID = "AjaxFoto"+img_id;
		img_hide(AjaxID);
	}
 


	/*** lista zdjec (ustawianie ikony galerii) ***/
	function AjaxSetIcon(img_id,gal_id,user_id){
		$.post("/addfun.php",{  
			img_id: img_id,  
			gal_id: gal_id,  
			user_id: user_id,  
			action: "AjaxSetIcon"
		});

		$('.ActiveIcon').removeClass('ActiveIcon');
		$('#AjaxFoto'+img_id).addClass('ActiveIcon');
	}



/*** lista zdjec (zmiana nazwy zdjecia) ***/
	function AjaxFotoNameEdit(img_id,user_id){
		AjaxID1 = "#AjaxFotoNameEditInput"+img_id;
		$.post("/addfun.php",{
			img_id: img_id,
			user_id: user_id,
			img_title: $(AjaxID1).val(),
			action: "AjaxFotoNameEdit"
		});
		AjaxID2 = "AjaxFotoNameChange"+img_id;
		document.getElementById(AjaxID2).innerHTML = $(AjaxID1).val();

		AjaxID3 = "AjaxFotoNameEdit"+img_id;
		img_hide(AjaxID3);
		AjaxID4 = "AjaxFotoName"+img_id;
		img_show(AjaxID4);
	}


/*** lista galerii (zmiana nazwy galerii) ***/
	function AjaxGalNameEdit(gal_id,user_id){
		AjaxID5 = "#AjaxGalNameEditInput"+gal_id;
		$.post("/addfun.php",{
			gal_id: gal_id,
			user_id: user_id,
			gal_title: $(AjaxID5).val(),
			action: "AjaxGalNameEdit"
		});
		AjaxID6 = "AjaxGalNameChange"+gal_id;
		document.getElementById(AjaxID6).innerHTML = $(AjaxID5).val();

		AjaxID7 = "AjaxGalNameEdit"+gal_id;
		img_hide(AjaxID7);
		AjaxID8 = "AjaxGalName"+gal_id;
		img_show(AjaxID8);
	}

/*** lista galerii (usuniecie galerii) ***/
	function AjaxGalDel(gal_id,user_id){
		$.post("/addfun.php",{
			gal_id: gal_id,
			action: "AjaxGalDel"
		});
		AjaxID9 = "AjaxGal"+gal_id;
		img_hide(AjaxID9);
	}


/*** lista komentarzy (usuniecie komentarza) ***/
	function AjaxPostDel(post_id){
		$.post("/addfun.php",{ 
			post_id: post_id, 
			action: "AjaxPostDel"
		});
		AjaxID10 = "post"+post_id;
		img_hide(AjaxID10);
	}





/*** konkursy (ocena zgloszenia w skali 1-5) ***/
	function AjaxCompRate(rate,rid){
		$.post("/addfun.php",{
			rid: rid, 
			rate: rate, 
			action: "AjaxCompRate"
		}, function(data){
			AjaxID13 = "#AjaxRateStars"+rid;
			$(AjaxID13).html(data);	
		});
		AjaxID14 = "#AjaxCompRateStars"+rid;
		$(AjaxID14).html('[zgłoszenie zostało ocenione]');	
	}


/*** konkursy (usuwanie zgloszenia w panelu uzytkownika) ***/
	function AjaxCompDel(rid){
		$.post("/addfun.php",{
			rid: rid,
			action: "AjaxCompDel"
		});
		AjaxID11 = "AjaxCompUser"+rid;
		img_hide(AjaxID11);
		AjaxID12 = "AjaxCompUser2"+rid;
		img_hide(AjaxID12);
	}




// ************* Dodawanie zgloszenia do konkursu *******************

var state=0;

$(document).ready(function(){
	$('#AjaxCompAddBtn').click(function(){
		if(state==0)
		{
			$('.konkursBox').animate({
				height: "215px"
			}, 200, function(){
				$('.konkursForm').toggle();
				$('.konkursForm').animate({
					opacity: "1"
				}, 200, function(){
				});	
			});

			state=1;
		}
		else
		{
			$('.konkursForm').animate({
				opacity: "0"
			}, 200, function(){
				$('.konkursForm').toggle();
				$('.konkursBox').animate({
					height: "29px"
				}, 200, function(){});	
			});	


			state=0;
		}
		return false;
	});

	$('.konkursForm').submit(function(){
		var ext = $('.konkursFormFile').val().split('.').pop().toLowerCase();
		var allow = new Array('jpg','jpeg','mp3','wmv');
		if(jQuery.inArray(ext, allow) == -1) {
			alert('niepoprawne rozszerzenie pliku ...');
			return false;
		}
	});
});



