


/* GOOGLE MAPS */
var gm_icon;
var gm_marker_opt;
var gm_map;
var gm_geocoder;
var gm_ad1;
var gm_ad2;
     
function fgm_load()
{
 if( GBrowserIsCompatible()) {
     gm_map = new GMap2( document.getElementById( "d_gm_map"));
     gm_geocoder = new GClientGeocoder();

     gm_map.addControl( new GSmallZoomControl());
     gm_map.addControl( new GMapTypeControl());
     
     gm_icon = new GIcon();
     gm_icon.image = "img/gm_icon.png";
     gm_icon.shadow = "img/gm_icon_sh.png";
     gm_icon.iconSize = new GSize( 100, 60);
     gm_icon.shadowSize = new GSize( 187, 55);
     gm_icon.iconAnchor = new GPoint( 1, 60);
     gm_icon.infoWindowAnchor = new GPoint( 50, 1);
     
     gm_marker_opt = { icon: gm_icon };

     fgm_new_ad( 1);
     fgm_new_ad( 2);
     fgm_goto_ad( 1);
 }
}


function fgm_new_ad( ad) {
  gm_geocoder.getLatLng(
    (( ad == 1) ? "Poland, Katowice, ul. Grabskiego 25d" :
                  "Poland, Częstochowa, ul. Warszawska 398/400"),
    function( point) {
      if( point) {
        if( ad == 1)
            gm_map.setCenter( point, 13);
        var marker = new GMarker( point, gm_marker_opt);
        gm_map.addOverlay( marker);
     //   marker.openInfoWindowHtml( "<a align='left'>" + (( ad == 1) ? "40-862 Katowice<br />ul. Grabskiego 25d" :
    //              "42-200 Częstochowa<br />ul. Warszawska 398/400") + "</a>");
        if( ad == 1) gm_ad1 = point;
        else gm_ad2 = point;
      }
    }
  );
}

function fgm_goto_ad( ad)
{
 if( ad == 1)
     gm_map.setCenter( gm_ad1, 13);
 else
     gm_map.setCenter( gm_ad2, 14);
     

}

/* ------------ */

function fhref( loc)
{
 document.location.href = loc;
}

var icur_prod_tab = 0;

function fprod_tabs( itab)
{
         hide = "";
         show = "";
         switch( icur_prod_tab) {
                 case 1: hide = "opis"; break;
                 case 2: hide = "params"; break;
                 case 3: hide = "access"; break;
         }

         switch( itab) {
                 case 1: show = "opis"; break;
                 case 2: show = "params"; break;
                 case 3: show = "access"; break;
         }
         
         icur_prod_tab = itab;

         if( hide != "")
             document.getElementById( "d_prod_tab_"+hide).style.display = 'none';
         document.getElementById( "d_prod_tab_"+show).style.display = 'block';
         
         
         
         if( hide != "") {
             document.getElementById( "td_prod_tab_"+hide).className = 'prod_tabs';
             document.getElementById( "a_prod_tab_"+hide).className = 'prod_tabs';
         }
         document.getElementById( "td_prod_tab_"+show).className = 'prod_tabs_sel';
         document.getElementById( "a_prod_tab_"+show).className = 'prod_tabs_sel';
}

	
var ccur_zam_desc = "";

function fzam_desc( show)
{
         if( ccur_zam_desc != '')
             document.getElementById( ccur_zam_desc).style.display = 'none';
         document.getElementById( show).style.display = 'block';

         ccur_zam_desc = show;
}


var timeout_id = 0;
function fdiv_block( div, i)
{
         document.getElementById( div).style.display = (( i == 0) ? "none" : "block");
         timeout_id = 0;
}

/*
var sh_timeout = new Array( 0, 0);
function fsh_div_block( div, i)
{
         document.getElementById( div).style.display = (( i == 0) ? "none" : "block");
         sh_timeout[i] = 0;
}


function frolldown( div, h, h_max)
{
         // if starting, show div and set height to 0
         if( h == 0) {
      //       document.getElementById( div).style.display = "block";
             h_max = document.getElementById( div).scrollHeight;
             document.getElementById( div).style.clip.top = h_max+'px';
             h = 1;
         }
         else {
              h += 10;
              document.getElementById( div).style.clip = "rect( "+(h_max-h)+"px 0px "+h_max+"px 220px)";
         }

         if( h < h_max) {
           //  alert( "hello");
             window.setTimeout( "frolldown( \""+div+"\", "+h+", "+h_max+")", 200);
         }
}
*/
// getElementsByName that works also in IE =)
function fgetElementsByName( tag, name) {

     var elem = document.getElementsByTagName( tag);
     var arr = new Array();
     for( i = 0, iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if( att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}
/*
function fmenu_prod( id, fixed, t)
{
         if( t == 0) {
             if( timeout_id != 0) {
                 window.clearTimeout( timeout_id);
                 timeout_id = 0;
             }

             fmenu_prod_show( id, fixed, t);
         }

         else {
              timeout_id = window.setTimeout( "fmenu_prod_show( \""+id+"\", \""+fixed+"\", \""+t+"\")", 200);
         }
}
*/

img_arrow_open_w = new Image();
img_arrow_open_w.src = 'img//arrow_open_w.gif';
img_arrow_close_w = new Image();
img_arrow_close_w.src = 'img//arrow_close_w.gif';

img_arrow_open_b = new Image();
img_arrow_open_b.src = 'img//arrow_open_b.gif';
img_arrow_close_b = new Image();
img_arrow_close_b.src = 'img//arrow_close_b.gif';

function fmenu_prod( id, fixed, t)
{
         if( t == 2 && document.getElementById( "d_menu_prod_gr_"+id)) {
             if( document.getElementById( "d_menu_prod_gr_"+id).style.display == 'block')
                 t = 1;
             else
                 t = 0;
         }

         // hide all
         d = fgetElementsByName( "div", "d_menu_prod_gr");
         im = fgetElementsByName( "img", "img_arrow_mp_dzial");
         i = 0;
         while( i < d.length) {
                if( d[i].id != ( "d_menu_prod_gr_"+fixed)) {
                    d[i].style.display = "none";
                }

                ++i;
         }
         i = 0;
         while( i < im.length) {
                if( im[i].id != ( "img_arrow_mp_dzial_"+fixed)) {
                    im[i].src = img_arrow_close_w.src;
                }
                ++i;
         }

         if( t == 1) {
             // show
             document.getElementById( "d_menu_prod_gr_"+id).style.display = "block";
             document.getElementById( "img_arrow_mp_dzial_"+id).src = img_arrow_open_w.src;
         }
}


function fmenu_koszyk( i)
{
 /*        if( i == 0) {
             if( timeout_id != 0) {
                 window.clearTimeout( timeout_id);
                 timeout_id = 0;
             }
   */
             fdiv_block( "d_menu_koszyk_ext", i);
             if( i == 1) {
                 document.getElementById( "img_arrow_koszyk").src = img_arrow_open_w.src;
             }
             else {
                 document.getElementById( "img_arrow_koszyk").src = img_arrow_close_w.src;
             }
   /*      }
         else {
              timeout_id = window.setTimeout( "fdiv_block( \"d_menu_koszyk_ext\", "+i+")", 200);
   //      }   */
}

function fmenu_schowek( i)
{
     /*    if( i == 0) {
             if( timeout_id != 0) {
                 window.clearTimeout( timeout_id);
                 timeout_id = 0;
             }
     */
             fdiv_block( "d_menu_schowek_ext", i);
             if( i == 1) {
                 document.getElementById( "img_arrow_schowek").src = img_arrow_open_w.src;
             }
             else {
                 document.getElementById( "img_arrow_schowek").src = img_arrow_close_w.src;
             }
    /*     }
         else {
              timeout_id = window.setTimeout( "fdiv_block( \"d_menu_schowek_ext\", "+i+")", 100);
         }    */
}

function fprod_tb_params( i, t)
{
         show = "d_tb_" + (( t == 0) ? "opis" : "params") + i;
         hide = "d_tb_" + (( t == 0) ? "params" : "opis") + i;

         if( t == 0) {
         
             if( timeout_id != 0) {
                 window.clearTimeout( timeout_id);
                 timeout_id = 0;
             }

             fprod_tb_params_show( show, hide);
         }

         else {
              timeout_id = window.setTimeout( "fprod_tb_params_show( \""+show+"\", \""+hide+"\")", 200);
         }
}

function fprod_tb_params_show( show, hide)
{
         document.getElementById( hide).style.display = "none";
         document.getElementById( show).style.display = "block";
         timeout_id = 0;
}


/* prod filter */
var ifltr_show = 0;
function fprod_fltr_show()
{
         if( ifltr_show == 1) {
             fdiv_block( "d_prod_fltr_ext", 0);
             ifltr_show = 0;
             document.getElementById( "img_arrow_fltr").src = img_arrow_close_b.src;
         }
         else {
              fdiv_block( "d_prod_fltr_ext", 1);
              ifltr_show = 1;
              document.getElementById( "img_arrow_fltr").src = img_arrow_open_b.src;
         }
}

var ccur_fltr_ptab = "";
function fprod_fltr_ptab( id)
{
         // hide last one
         if( ccur_fltr_ptab != "") {
             fdiv_block( "d_prod_fltr_"+ccur_fltr_ptab, 0);
             
             document.getElementById( "td_prod_fltr_"+ccur_fltr_ptab).className = 'prod_fltr_params';
             document.getElementById( "a_prod_fltr_"+ccur_fltr_ptab).className = 'prod_fltr_params';
         }

         // show new one
         fdiv_block( "d_prod_fltr_"+id, 1);
         ccur_fltr_ptab = id;
         
         document.getElementById( "td_prod_fltr_"+id).className = 'prod_fltr_params_sel';
         document.getElementById( "a_prod_fltr_"+id).className = 'prod_fltr_params_sel';
         
         
         
 /*       div = document.getElementById( "d_prod_fltr_"+id);
        ifrm = document.getElementById( "if_menu_mask");
        
        if( t == 1) {
            div.style.display = "block";
            ifrm.style.width = div.offsetWidth;
            ifrm.style.height = div.offsetHeight;
            ifrm.style.top = div.style.top;
            ifrm.style.left = div.style.left;
            ifrm.style.zIndex = div.style.zIndex - 1;
            ifrm.style.display = "block";
        }
        else {
            div.style.display = "none";
            ifrm.style.display = "none";
        }         */
}

function fprod_fltr_produc_selectall( t)
{
         // produc tab
         el_produc = document.f_prod_fltr_produc;

         f_produc = "";
         n = 0;
         while( n < el_produc._many.value) {

                el_produc.elements["_"+n].checked = (( t == 1) ? true : false);
                ++n;
         }
}

function fprod_fltr_params_selectall( t)
{
         // params div
         el_params = document.f_prod_fltr_params;

         f_params = "";
         i = 0;
         while( i < el_params._many.value) {

                if( document.getElementById( "d_prod_fltr_params_"+i).style.display == "block") {

                    el_params_i = document.getElementById( "f_prod_fltr_param_"+i);
                    n = 0;
                    while( n < el_params_i._many.value) {

                       el_params_i.elements["_"+n].checked = (( t == 1) ? true : false);
                       ++n;
                    }
                    
                    break;
                }

                ++i;
         }
}

function fprod_fltr_selectall()
{
         // produc tab
         el_produc = document.f_prod_fltr_produc;

         f_produc = "";
         n = 0;
         while( n < el_produc._many.value) {

                el_produc.elements["_"+n].checked = true;
                ++n;
         }


         // params div
         el_params = document.f_prod_fltr_params;

         f_params = "";
         i = 0;
         while( i < el_params._many.value) {

                el_params_i = document.getElementById( "f_prod_fltr_param_"+i);

                n = 0;
                while( n < el_params_i._many.value) {

                       el_params_i.elements["_"+n].checked = true;
                       ++n;
                }

                ++i;
         }
}

function fprod_fltr_set( self_nofltr, query_nofltr)
{
         s = self_nofltr;
         
         // produc tab
         el_produc = document.f_prod_fltr_produc;

         f_produc = "";
         n = 0;
         while( n < el_produc._many.value) {

                if( el_produc.elements["_"+n].checked == false) {

                    f_produc += (( f_produc == "") ? "" : " AND ");
                    f_produc += "produc_id!='" + el_produc.elements["_"+n].value;
                    f_produc += "'";
                }
                
                ++n;
         }
         

         // params div
         el_params = document.f_prod_fltr_params;
         
         f_params = "";
         i = 0;
         while( i < el_params._many.value) {

                el_params_i = document.getElementById( "f_prod_fltr_param_"+i);

                n = 0;
                while( n < el_params_i._many.value) {

                       if( el_params_i.elements["_"+n].checked == false) {
                       
                           f_params += (( f_params == "") ? "" : " AND ");
                           f_params += ( el_params_i._i.value + "!=" + n);
                       }
                       
                       ++n;
                }

                ++i;
         }
                       

         
         if( f_produc != "") {
             s += (( query_nofltr != "") ? "&" : "?");
             s += "fltr=";
             s += escape( f_produc);
             
             s += "&p_fltr=";
             s += escape( f_params);
         }
         
         else if( f_params != "") {
             s += (( query_nofltr != "") ? "&" : "?");
             s += "p_fltr=";
             s += escape( f_params);
         }

         window.location.href = s;
}


function flost_pass( f)
{
        f.action = "lost_pass.php";
        f.method = 'post';
        f.submit();
}


function fcheck( f)
{
         f.checked = (( f.checked == true) ? false : true);
}
