// JavaScript Document

/*------------------------------------------------------------------------------------ obsluga alertMessage*/
var time;
function alert_message( text, typ, link, java )
{
   time = setTimeout( "alert_message_hide()", 5000 );

   var okienko = document.getElementById( "alert_message" );
   okienko.style.visibility="visible";

   /*
    btn: am_zatwierdz, am_anuluj, am_ok
   */

   if ( java ) var button_C = '<button class="am_zatwierdz" onclick="clearTimeout(time); alert_message_hide(); '+link+'"></button><button class="am_anuluj" onclick="clearTimeout(time);alert_message_hide();"></button>';
   else var button_C = '<button class="am_zatwierdz" onclick="clearTimeout(time);parent.location.href=\''+link+'\';"></button><button class="am_anuluj" onclick="clearTimeout(time);alert_message_hide();"></button>';

   var button_A = '<button class="am_ok" onclick="clearTimeout(time); alert_message_hide();"></button>';

   if ( typ == "A" ) // alert
   {
      var text_new = '<div class="alert_message_x"><a href="javascript:alert_message_hide();">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></div><div class="alert_message_t">'+text+'</div><div class="alert_message_b">'+button_A+'</div>';
      okienko.innerHTML = text_new;
   }
   else if ( typ == "C" ) // nonfirm
   {
      var text_new = '<div class="alert_message_x"><a href="javascript:alert_message_hide();">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></div><div class="alert_message_t">'+text+'</div><div class="alert_message_b">'+button_C+'</div>';
      okienko.innerHTML = text_new;
   }
}

function alert_message_hide()
{
   var okienko = document.getElementById( "alert_message" );
   okienko.style.visibility="hidden";

   /* if ( isset(time) ) clearTimeout(time); */
}
function getScrollXY()
{
  var scrOfX = 0, scrOfY = 0;

  if( typeof( window.pageYOffset ) == 'number' )
  {
    //Netscape
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  }
  else if ( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
  {
    //DOM
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  }
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
  {
    //IE6
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return {x: scrOfX, y: scrOfY };
}

setInterval( function() {
	var xy=getScrollXY();
	document.getElementById('alert_message').style.top=(300+xy.y)+'px';
	document.getElementById('alert_message').style.left= ((screen.width/2)-170)+'px';
         },10);
/*------------------------------------------------------------------------------------ obsluga alertMessage*/


/*------------------------------------------------------------------------------------ obsluga info box*/
function show_help( text,myEvent )
{
     var x = 0;
     var y = 0;

     if ( myEvent.pageX || myEvent.pageY )
     {
        x = myEvent.pageX;
        y = myEvent.pageY;
     }
     else if ( myEvent.clientX || myEvent.clientY )
     {
        x = myEvent.clientX + document.body.scrollLeft;
        y = myEvent.clientY + document.body.scrollTop;
     }


      var warstwa = document.getElementById( "div_help" );
      warstwa.style.visibility = "visible";

      var topp = (y+20);
      var leftt = (x-180);
      
      warstwa.style.top = "" + topp+"px";
      warstwa.style.left = "" + leftt+"px";

      //alert( y + " / " + x );

      warstwa.innerHTML = "<table width=100% CELLPADDING=0 CELLSPACING=0><tr><td><img src='graph/helpbg_top.gif'></td></tr><tr><td class='div_help_tekst'>"+text+"</td></tr></table>";
}

function hide_help()
{
      var warstwa = document.getElementById( "div_help" );
      warstwa.style.visibility="hidden";
}
/*------------------------------------------------------------------------------------ obsluga info box*/




/*------------------------------------------------------------------------------------ obsluga resetu pol*/
function resetuj_formularz( the_form )
{
   var wszystkie = document.forms[the_form];
   var wszystkie_zaznaczone  = ( typeof( wszystkie.length ) != 'undefined' ) ? wszystkie.length : 0;

   //alert( wszystkie_zaznaczone );

   for ( var i = 0 ; i < wszystkie_zaznaczone ; i++  )
   {
       //alert( wszystkie[i].type )//="";
       if ( wszystkie[i].type == "text" )
          wszystkie[i].value = "";
       else if ( wszystkie[i].type == "select-one" )
          wszystkie[i].selectedIndex = 0;
       else if ( wszystkie[i].type == "textarea" )
          wszystkie[i].value = "";
       else if ( wszystkie[i].type == "checkbox" )
          wszystkie[i].checked = false;
       else
          alert( wszystkie[i].type );
   }
}
/*------------------------------------------------------------------------------------ obsluga resetu pol*/







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_jumpMenu(targ,selObj,restore){ //v3.0

  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

  if (restore) selObj.selectedIndex=0;

}



function show_over(id) {
	document.getElementById(id).style.display='block';
}


function show_out(id){
	document.getElementById(id).style.display='none';
}



function OpacityOver(This){
	This.style.filter='alpha(opacity=80)';
	This.style.opacity='0.8';
}

function OpacityOut(This){
	This.style.filter='alpha(opacity=100)';
	This.style.opacity='1';
}

function marquee(x,typ,p){
    typ={
        'up':[-1,'top','offsetHeight'],
        'down':[1,'top','offsetHeight'],
        'left':[-1,'left','offsetWidth'],
        'right':[1,'left','offsetWidth']
    }[typ];

    var m=this,mOut,mIn,turlaj,T,i=typ[0],j=0,p=p||30;
    (mOut=document.getElementById(x)).onmouseover=function(){T=clearInterval(T)};

     mOut.appendChild((mIn=mOut.childNodes)[0].cloneNode(1));

     mOut.onmouseout=function(e){
        e=e||event;e=e.toElement||e.relatedTarget;
        if(e)do{if(e==this)return!1}while(e=e.parentNode)
        T=setInterval(turlaj,p)
     };

     mOut=mIn[0][typ[2]];
     turlaj=function(){
        mIn[0].style[typ[1]]=(-2*i*(j+=i)<(i-1)*mOut?(j=(-i-1)/2*mOut+i):j)+'px';
        mIn[1].style[typ[1]]=j+mOut+'px';
     }
    T=setInterval(turlaj,p);
}



/* ================================================================================== */

/* =============================== foto.php [START] ================================= */

/* ================================================================================== */



var foto_paths;

var foto_actual;



function foto_set(paths){ 

	foto_paths=paths; 

	foto_actual=0;

	document.getElementById('boxc_foto_nav_2_p').innerHTML=1+'/'+foto_paths.length;

	return;	

}





function foto_change(img_path){

	var found=false;

	for (var i=0;i<foto_paths.length;i++)

	{

		if( foto_paths[i]==img_path){ found=true; break; }

		

	}

	if(found==false){ return 0;}

	

	MM_preloadImages(img_path);

	document.getElementById('boxc_foto_img').style.background = "url("+img_path+") no-repeat";

	

	//var total=foto_paths.length0;

	document.getElementById('boxc_foto_nav_2_p').innerHTML=(i+1)+'/'+foto_paths.length;

	foto_actual=i;

	

}



function foto_prev(){

	

	if(foto_actual>0 && foto_actual<foto_paths.length){

		foto_actual=foto_actual-1;

		foto_change(foto_paths[foto_actual]);

	}

}



function foto_next(){

	

	if(foto_actual>=0 && foto_actual<foto_paths.length-1){

		foto_actual=foto_actual+1;

		foto_change(foto_paths[foto_actual]);

	}

}



/* ================================================================================== */

/* =============================== foto.php [END] =================================== */

/* ================================================================================== */

/* ================================================================================== */

/* =============================== business.php [START] ============================= */

/* ================================================================================== */

	var menua_active; 

	var menua_time;

	

	function show_submenu(id){

		var time=menua_time;

		

		if (time!='lato' && time!='zima' && time!='cms_lato' && time!='cms_zima'){ alert('Zla pora roku'); return 0; }

		if (time=='lato'){ var img_path='graph/business_lato/shared/menua/'; var color='#ffffff'; }

		if (time=='zima'){ var img_path='graph/business_zima/shared/menua/'; var color='#ffffff'; }

		if (time=='cms_lato'){ var img_path='graph/cms_lato/shared/menua/'; var color='#ffffff'; }

		if (time=='cms_zima'){ var img_path='graph/business_zima/shared/menua/'; var color='#ffffff'; }

		var id1=id+'1';

		var id2=id+'2';

		var id3=id+'3';

		var id4=id+'4';

				

		document.getElementById(id1).style.background = "url("+img_path+"menua_div_bkg.gif) repeat-x";

		document.getElementById(id2).style.background = "url("+img_path+"menua_div_lt.gif) no-repeat";

		document.getElementById(id3).style.background = "url("+img_path+"menua_div_rt.gif) no-repeat";

		document.getElementById(id4).style.color = color;

		

		/* errors possible */

		document.getElementById(id).style.display = "block";

		

		if(id!=menua_active){ document.getElementById(menua_active).style.display = "none"; }

		

	}

	

	function hide_submenu(id){

		var time=menua_time;

		

		if (time!='lato' && time!='zima' && time!='cms_lato' && time!='cms_zima'){ alert('Zla pora roku'); return 0; }

		if (time=='lato'){ var color='#1e1e1e'; }

		if (time=='zima'){ var color='#003e49'; }

		if (time=='cms_lato'){ var color='#1e1e1e'; }

		if (time=='cms_zima'){ var color='#003e49'; }

		

		var id1=id+'1';

		var id2=id+'2';

		var id3=id+'3';

		var id4=id+'4';

		

		

		

		if(id!=menua_active){

			document.getElementById(id1).style.background = "none";

			document.getElementById(id2).style.background = "none";

			document.getElementById(id3).style.background = "none";

			document.getElementById(id4).style.color = color;

			

			/* errors possible */

			document.getElementById(id).style.display = "none";

		}

		

		document.getElementById(menua_active).style.display = "block";

	}

	

	

	function set_submenu(id, time){

		if (time!='lato' && time!='zima' && time!='cms_lato' && time!='cms_zima'){ alert('Zla pora roku'); return 0; }

		menua_active=id;

		menua_time=time;

		

		show_submenu(menua_active);

		document.getElementById(menua_active).style.display = "block";

	}

/* ================================================================================== */

/* =============================== business.php [END] =============================== */

/* ================================================================================== */
