/* INIT JQUERY AND STUFF */
$(document).ready(function(){

  try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) { }

//$("img").lazyload();

/*
$("#content dl dd.info p").hover( function()
{ 
      $(this).css("overflow","auto");
       
  
},function()
{
  $(this).css("overflow","hidden");

});
*/

$("#platba").click( function() { 

if ($(this).attr('value')=='Na dobierku') { $("#table_sposob_prepravy").hide(); $("#preprava").val('');  }
if ($(this).attr('value')!=='Na dobierku') { $("#table_sposob_prepravy").show();
$("#preprava").val("prepravna_spolocnost");

 }

});

$("body").change( function(e) {

var EV=$(e.target);    

    if (EV.attr("class")=="kat_select") {
    
    idecko='#'+EV.attr("rel");    
    $(idecko).val(EV.val());
    
    };
});

var updateID=''; 

$("body").click( function(e)
{
    
    var EV=$(e.target);    
          
    if (EV.attr("class")=="zrusit-editbox") {   

      EV.parent().remove();   
      return false;    

    }
    
    
    if (jQuery.browser.msie) {
    
      if (EV.attr("class")=="kat_select") {
    
      idecko='#'+EV.attr("rel");    
      $(idecko).val(EV.val());
    
      };
    
    } 
    
    
        
    if (EV.attr("class")=="edit-submit") {
          
        EV.parent().submit();           
          
        EV.parent().parent().parent().fadeOut("slow",function(){      
          EV.parent().parent().parent().remove();
          
          //alert(updateID);
          
          myurl='http://knihkupectvo.aspektnd.sk/?get-kniha-data/'+updateID;
          
          updateID='#t'+updateID; //toto sa upravi az po vytvoreni url                                  
          
          //if (confirm (updateID)) {
          
           
          
            $.getJSON(myurl,
            {  },
            function(json){

                $(updateID+" dt a").text(json['nazov']);                      
                $(updateID+" dt a").attr("href",'http://knihkupectvo.aspektnd.sk/?kniha/'+json['nazov-href']);
                $(updateID+" dd.info a.autori").text(json['autori']);
                $(updateID+" dd.info a.autori").attr("href",json['autori-href']);            
                $(updateID+" dd.info a.vydavatelstvo").text(json['vydavatelstvo']);
                $(updateID+" dd.info a.vydavatelstvo").attr("href",json['vydavatelstvo-href']);
                $(updateID+" dd.info p.o-knihe").text(json['kratky-text']);
                
                $(updateID).css("background-color","#e8e1ea");

               });
              
            //}     
          
          
          //$(updateID).remove();
        });
       
    }           

		if (EV.attr("rel")=="editacia") { 
                
      if (EV.next().attr("class") !== "editbox") {
      
          linktext=EV.text();     
           
          
          myurl=EV.attr("href");
                                
            if (linktext=='EDITUJ') {                                
              myurl=myurl+'/ajax_load_edit_form';
              EV.text('NAČÍTAVAM');
            }          
            
            if (linktext=='OBRÁZOK') {                                                                                                               
              myurl=myurl+'/ajax_load_obr_form';
              EV.text('NAČÍTAVAM');
            }
            
            if (linktext=='X') {                        
              if (confirm('Zmazať?')==false) { return false; }                                                                                       
              myurl=myurl+'/ajax_remove_book';
              //EV.text('NAČÍTAVAM');
            }
            
           
                                                                      
          $.post( myurl ,
          { balast: "1" },
            function(data){
                             
              if (data=='DELETED!') { EV.parent().parent().remove(); } else {                                                                 
                  updateID=EV.attr("target");
                  
                  
                  EV.text(linktext);
                  EV.after(data); 
                  }
                                  
            }
          );
     
      }
      
      return false;
    }
		
});

  
  //$("#treemenu2 li.submenu").addClass("suback");

/*  
  $("div#podmenu-strom dl dd img.growme").hover(function()
    { $(this).animate(
            {
            left: -50, 
            top: -50, 
            height: 200, 
            width: 200, 
            borderColor: '#d0d0d0'
            }, 175 ) 
    },function()
    { $(this).animate(
            {
            height: 100, 
            width: 100, 
            left: 0, 
            top: 0,
            borderColor: 'white'
            }, 100 ); 
    });
*/  


  

$("#zoradovaci_form select").change( function()
{
//if (this.id=='podla_ceny') { document.getElementById('podla_nazvu').selectedIndex=0;  } 
//if (this.id=='podla_nazvu') { document.getElementById('podla_ceny').selectedIndex=0;  }
$("#zoradovaci_form").submit();

});



$("#kosik-zbalit-rozbalit").click( function() {
    
  
if ($.cookie('kosik_rozbaleny')==1) {



  
  $("#kosik-zbalit-rozbalit").attr("class","obr-zbaleny-kosik");
  
  $("#nakupny-kosik").hide("fast",function(){
    
  $.cookie('kosik_rozbaleny', '0');
  
  //kosik_rozbaleny=0;
  
  });
  

} else {
  
  $("#kosik-zbalit-rozbalit").attr("class","obr-rozbaleny-kosik");
    
  $("#nakupny-kosik").show("fast",function(){
  
  //$(".panel-inner-content").fadeTo("fast", 0.95);
  
  $.cookie('kosik_rozbaleny', '1');
     
  //kosik_rozbaleny=1;
  
  });
  
}


//alert ($("#nakupny-kosik").attr("style");

//alert($.cookie('kosik_rozbaleny'));
 
return false; 
 
});


  
  $("dd.konf-checkbox").click( function()
  {
  
  var blok = $(this);
  var tovar_myid = blok.attr('title');
  
    if (blok.parent().attr('rel')=='vybrate') {    
    
    	myurl='http://www.lacnepc.com/?konfigurator-mode/'+tovar_myid;
	
	    $.post( myurl ,
          { konf_uncheckbox: "1" },
          function(data){
            if (data !== '') { 
        		 //alert(data);
        		 
        		  blok.parent().removeClass('kvybrate');
              blok.parent().removeAttr('rel');        		          	              
        		  
              } 
          }
       );
    
      
      } else {
      
          
      
           myurl='http://www.lacnepc.com/?konfigurator-mode/'+tovar_myid;
	
    	    $.post( myurl ,
              { konf_checkbox: "1" },
              function(data){
                if (data !== '') { 
            		 //alert(data);
            		 
            		  blok.parent().attr('rel','vybrate');
                  blok.parent().addClass('kvybrate');        		          	
            		  
                  } 
              }
           );
      
           
        }
  
  });
  
$(document).pngFix();




 

    
   
});








time=new Date() - time;
//alert (time);







function popwin(cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=no,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open(cesta,'info',WinFeatures);
	}

function showpic(language,cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=no,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open('showpic.php?language='+language+'&path='+cesta,'info',WinFeatures);
	}

function showpic_scrollbar(language,cesta, width, height) 
	{
	WinFeatures = 'toolbar=no,scrollbars=yes,status=no,resizable=yes,width='+width+',height='+height;
	ShowWindow = window.open('showpic.php?language='+language+'&path='+cesta,'info',WinFeatures);
	}


function targetBlank(href) {
	var newWindow = window.open(href, "print_page", "toolbar=yes,titlebar=yes,directories=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes");

	if(!newWindow) return false;
	return true;
}


function stripHTML(oldString) {

var re= /<\S[^>]*>/g; 
oldString = oldString.replace(re,""); 
return oldString;
  
}

function isEmailAddress (string) {
  var addressPattern = 
    /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return addressPattern.test(string);
}
function checkEmail (field) {
  if (!isEmailAddress(field.value)) {
    alert('Prosím vložte správnu e-mailovú adresu!');
    field.focus();
    field.select();
  }
}


/*
 * Cross browser Layer visibility / Placement & Detection
 * Done by Chris Heilmann (mail@onlinetools.org) www.onlinetools.org
 * Modified by Roman Chlebec (rchlebec@studiostyle.sk) www.studiostyle.sk / added getx & gety functions
 */


function la(status,id) {

// Layer visible
if (status=="1"){
	if (document.layers) document.layers[''+id+''].visibility = "show"
	else if (document.all) document.all[''+id+''].style.visibility = "visible"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"				
	}
// Layer hidden
else if (status=="0"){ 	

//	which=setxy.arguments[2];
//	clearTimeout(l[which]);

	if (document.layers) document.layers[''+id+''].visibility = "hide"
	else if (document.all) document.all[''+id+''].style.visibility = "hidden"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"	
	}
		
}

// Place layer
function setxy(id,lax0,lay0) {
if (lax0){
	if (document.layers){document.layers[''+id+''].left = lax0}
	else if (document.all){document.all[''+id+''].style.left=lax0}
	else if (document.getElementById){document.getElementById(''+id+'').style.left=lax0+"px"}
	}
if (lay0){
	if (document.layers){document.layers[''+id+''].top = lay0}
	else if (document.all){document.all[''+id+''].style.top=lay0}
	else if (document.getElementById){document.getElementById(''+id+'').style.top=lay0+"px"}
	}
}




// script by 1999 Idocs, Inc. http://www.idocs.com
function pismenacisla(e)
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
// control keys
if ((key==null) || (key==0) || (key==8) || 
(key==9) || (key==13) || (key==27) )
return true;
// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}	

