function gotonewpage(what) {

  value = what.options[what.selectedIndex].value;
  if (value == "") return;
  window.location.href = value;
}


function odkryj(co) {
  
  el=document.getElementById(co).style;
  el.visibility='hidden';

}

function skryj(ideecko) {

  ell=document.getElementById(ideecko).style;
  ell.visibility='hidden';

}

// smajlici

var smajl,i_smile,nosmajl,cislo_smajlu;
var vklad,smile;
  
function smajl(cislo)
{
  for (i_smile=1; i_smile<28; i_smile++)
    {
    var b = "s"+i_smile
    document.images[b].style.borderColor ='RGB(255,255,255)';
    }
  var c = "s"+cislo;
  document.images[c].style.borderColor ='RGB(153,61,61)'; 
  //cislo_smajlu = cislo; 
  document.forms['vklad'].smile.value = cislo;  
}  

function nosmajl(cislo)
{
  var d = "s"+cislo;
  document.images[d].style.borderColor ='RGB(255,255,255)';
  document.forms['vklad'].smile.value = 'none';    
}  

function zobrazeni_zalozka(zalozka) {
  var cislo = 1;
  //var id_zalozky = "zalozka"+cislo;
  
  while(cislo < 4) {
    var id_zalozky = "zalozka"+cislo;
    var id_odkazu = "odkaz-zalozka"+cislo;
    ell=document.getElementById(id_zalozky).style;
    if(id_zalozky==zalozka)  {
      ell.display='block';
      document.getElementById(id_odkazu).style.background='#f0f0f0';
      document.getElementById(id_odkazu).style.color='#336633';
    }
    else {
      ell.display='none';
      document.getElementById(id_odkazu).style.background='#b0b0b0';
      document.getElementById(id_odkazu).style.color='#fff';      
    }
    cislo++;
  }
}

function star()   {
    this.postovneZdarmaZakaznici=function(email) {
       jQuery.ajax({
          url: 'moduly/isOldCustomer.php',
          data: {'email':email},
          type: "POST",
          success: function(responseText) {
            if(responseText=="TRUE") {
                jQuery('#order_IDplatby').val('6');
                jQuery('#order_textPlatby').html('<strong style="color: red;">ZPŮSOB PLATBY - Akce - poštovné zdarma</strong>');
                //var puvodniPriplatek = jQuery('#order_hodnotaPriplatek').html();
                var celkovaCenaBezDopravy = jQuery('#order_totalPriceItems').html();
                var FormOdpocet = STAR_OBJ.numberFormatFn(celkovaCenaBezDopravy,0,',',' ')+',-';
                //console.log(odpocet);
                jQuery('#order_totalPriceFormatted').html(FormOdpocet);
                jQuery('#order_hodnotaPriplatekText').html('<strong style="color: red;">+ Kč <span id="order_hodnotaPriplateka">0</span>,-</strong>');
            }
          }
        });
    }
    // a = cislo, b = desetinna mista, c = oddelovac desetin, d = oddelovac tisicu
    this.numberFormatFn=function(a,b,c,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];                    
    }
    
    this.loadFB=function() {
      var htmlText = '<iframe src="http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/pages/UStar-Converse-shop/267779071273&amp;width=190&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=false&amp;header=true&amp;height=400" scrolling="no" frameborder="0" style="border:none; background: #fff; overflow:hidden; width:190px; height:400px;" allowTransparency="true"></iframe>';
      jQuery('#facebookWrapper').html(htmlText);
      return true;
    }    
}

$(document).ready(function()    {
   STAR_OBJ = new star();
   /*
   jQuery('#order_email').blur(function()   {
    var email = jQuery(this).val();
    STAR_OBJ.postovneZdarmaZakaznici(email);
   });
   */
   //STAR_OBJ.loadFB();
  /*
  $("a[rel^='prettyPhoto']").prettyPhoto({
      theme: 'light_rounded',
      show_title: false,
      animationSpeed: 'fast'
  });*/
/*
  $('a.thickbox').prettyPhoto();*/
   
});
