var flash_name = 'img/princ_4.swf';

var zvyraznit = "";
var flashvars = {};


$(document).ready(function() 
{ 
  //mainmenu();//dropdown menu - nutne pro IE
  $(".dropshadow").wrap("<div class='wrap0'><div class='wrap1'><div class='wrap2'><div class='wrap3'></div></div></div></div>");
  
  //return;
  $('.galerie a').lightBox();
   
  //$("#hlavnipanelvnitrek").backgroundCanvas();
  $("#input_search").bind("keypress",stisk_enter);//objednani zasilani menu
  $("#img_search").bind("click",hledej);//objednani zasilani menu


//   $(".a_gal_velky").bind("click", function(e){
//     obrazek_detail(this);
//     return false;//zaraz otevreni odkazu 
//   });

   //alert(1);
  $("#flash_start").flash(
        { src: flash_name,
          width: 905,
          name: flash_name,
          wmode:'transparent',
          flashvars:flashvars,
          height: 340},
          {update: false}
    );

  if(zvyraznit != '')$('#div_plocha_obsah').highlight(zvyraznit);//pokud se vyhledavalo oznac hledany text

  //flash_start
  //if(parseInt($("#div_plocha_obsah_start").css("height")) < 395)$("#div_plocha_obsah_start").css("height",395);
  //if(parseInt($("#div_plocha_normal").css("height")) < 395)$("#div_plocha_normal").css("height",395);
  //alert('zvyraznit = ' + zvyraznit);
  
});


//$(window).load(function () { DrawBackground(); }); 
//$(window).resize(function() { DrawBackground(); });



function mys_over_nastav(nazev)
{
  //zmena ikony pri prejeti mysi
  var id = "#a_" + nazev;
  var src =  "img/" + nazev + ".png"
  var src_akt =  "img/" + nazev + "_akt.png"
  $(id).bind("mouseover", function(e){$(id).attr("src",src_akt);});
  $(id).bind("mouseout", function(e){$(id).attr("src",src);});
}

function obrazek_detail(el)
{
 //zobrazeni detailu obrazku
 //nejprve nastavim fci, ktera po naloadovani obrazek ukaze
  $('#img_close').fadeOut(1);
  var url = $(el).attr('href');
  var offset_klik = $(el).offset();
  //alert(url);
 $("#img_detail").one("load",function(){
   
   
   var w = this.width + "px";
   var h = this.height + "px";
   var div = $('#div_obr_detail');
   var screen_w = $(window).width();
   div.css('left',(screen_w - this.width)/2);//vycentruj
   var offset = $(this).offset();
   div.css('top',offset.top+10);
   div.css('width',w);
   div.css('height',h);
   div.fadeIn(500);
   $('#img_detail').fadeIn("slow");
   $('#img_detail').one("click",function(e){
   $('#div_obr_detail').fadeOut("slow")});//na kliknuti ho schovej
 });
 $('#img_detail').attr('title','Kliknutím obrázek zavřete');
 $('#img_detail').attr('src',url);//nacti obrazek  
}



var mail = '';

function stisk_enter(e){
  if(e.keyCode == 13)hledej();
}

function hledej(){
  //hledání na webu  
  
  var hledat = $("#input_search").attr('value');
  if(hledat == "")return;
  $.get("jquery.php", {akce:'hledej', hledat: hledat}, vysledky_hledani , "json");
}

function vysledky_hledani(data){
  //
  if(data.stav == "OK")
  {
    //alert(data.vysledky);
    $("#div_plocha_obsah").html(data.vysledky);
  }else{
    alert("Chyba při vyhledávání, omlouváme se.");
  }
}

function DrawBackground() 
{	
	//$("#mnu_zalozky").backgroundCanvasPaint(menu_zalozky);
	//if(!$.browser.msie)
  $("#hlavnipanelvnitrek").backgroundCanvasPaint(stiny);
	
}


function stiny(context, width, height, canvas, $canvas, $canvasDiv, $content, $element ) 
{
  //return;
//   $this = $(this);
//   var offsetParent = $content.offset();
//   var offset = $this.offset({relativeTo:$content[0]});
//   var width = $this.outerWidth();
//   var height = $this.outerHeight();
//   var options = {x: offset.left - offsetParent.left , height: height, 
//   width: width , offsetLeft: 0, offsetRight: 0, radiusLeft: 7, radiusRight: 7,
//   border:0};
//   
//   
  var h = 420; 
  var s = 5;
  var max_alpha = 0.05;
  var min_alpha = 0;
  var c_start = 'rgba(0,0,0,0)';
  var c_stop = 'rgba(0,0,0,'+ max_alpha +')';
  

//   var c_stop = 'rgba(0,0,0,0)';
//   var c_start = 'rgba(0,0,0,'+ max_alpha +')';

  //var c_start2 = 'rgba(0,0,0,'+ min_alpha +')';

  var top_h = 150;
  var roh_stop = 0.44;
  var tlc = 5;
  context.fillStyle = "rgba(212,212,212,1)";
  //context.fillRect(s,s,width-2*s,top_h);
  
  context.fillStyle = "rgba(255,255,255,1)";
  //context.fillRect(s+tlc,top_h+ s ,width-2*s-2*tlc,height-top_h-2*s-tlc);
  
//horni stin
  var grad = context.createLinearGradient(0,0,0,s);
  grad.addColorStop(0, c_start);
  grad.addColorStop(1, c_stop);
  context.fillStyle = grad;
  context.fillRect( s, 0, width-2*s, s);
  //context.fillRect(width,0,width + 20,100  );
  
  //return;
  //dolni stin
//   var grad = context.createLinearGradient(0,h-s,0,h);
//   grad.addColorStop(0,c_stop );
//   grad.addColorStop(1, c_start);
//   context.fillStyle = grad;
//   context.fillRect( s, h-s,width-2*s, h);
  //context.fillRect( s, height-s,width-2*s, height);



  //levy stin
  
  //var vyska = parseInt(h) - 2*s;
  //alert(vyska)
  var grad = context.createLinearGradient(0,0,s,0);
  grad.addColorStop(0, c_start);
  grad.addColorStop(1, c_stop);
  context.fillStyle = grad;
  context.fillRect( 0, s,  s,h - 2*s);


  var grad = context.createLinearGradient(0,0,s,s);
  grad.addColorStop(0, c_start);
  grad.addColorStop(roh_stop, c_start);
  grad.addColorStop(1, c_stop);
  context.fillStyle = grad;
  context.fillRect( 0, 0,  s,s);
  
  //levy dolni roh
  var grad = context.createLinearGradient(0,h,s,h-s);
  grad.addColorStop(0, c_start);
  grad.addColorStop(roh_stop, c_start);
  grad.addColorStop(1, c_stop);
  context.fillStyle = grad;
  //context.fillRect( s, height,0,height-s);
  context.fillRect( 0, h-s,s,h);


  //s = 5;  
  //pravy stin
  var grad = context.createLinearGradient(width-s,0,width,0);
  grad.addColorStop(0, c_stop);
  grad.addColorStop(1, c_start);
  context.fillStyle = grad;
  context.fillRect( width-s, s,  width+10,h-s);


  //levy horni roh

  //pravy horni roh
  var grad = context.createLinearGradient(width,0,width-s,s);//(width,0,width-s,s);
  grad.addColorStop(0, c_start);
  grad.addColorStop(roh_stop, c_start);
  grad.addColorStop(1, c_stop);
  context.fillStyle = grad;
  //context.fillRect( width-s, 0,  width-s,s);
  context.fillRect( width-s, 0,  width,s);
 
  //pravy dolni roh
  var grad = context.createLinearGradient(width,h,width-s,h-s);//(width,0,width-s,s);
  grad.addColorStop(0, c_start);
  grad.addColorStop(0.45, c_start);
  grad.addColorStop(1, c_stop);
  context.fillStyle = grad;
  context.fillRect(width-s,h-s,width,h);

      
}
