var incs = 'inc/';

   

   
$(document).ready(function(){
   
   $("div#content").load(incs + 'esileht.html', {} , function(){

         timeout = setTimeout(function() {
            $('a.lightBox').lightBox()
          }, 100);
       })       
   
   $("div.pais p a, p.menu a.ajax").click(function(){    

       return aload(this)   

   });
   
   $("p.bands span a.media").click(function(){    

       var html = '<img src="images/loading.gif" alt="Laadimas...">'

       $("div.mediabox").html(html);
        
       _link = incs + 'pleier.php?dir=' + URLEncode($(this).attr("href"))     

       $("div.mediabox").load(_link);
   
       return false   

   });

   
    var resizeTimer = null;
    $(window).bind('resize', function() {
        if (resizeTimer) clearTimeout(resizeTimer);
        resizeTimer = setTimeout(resizecontent, 100);
    });
    
    resizecontent()

    $("p.bands span").mouseover(function(){
        $(this).addClass('showadds');
    
    })
    $("p.bands span").mouseout(function(){
        $(this).removeClass('showadds');
    
    })
    $("p.bands span a.desc").click(function(){
        $("div#content").html($(this).parent().find('input').val());
        return false
    
    })
    
     
    jQuery.each(jQuery.browser, function(i, val) {
      if(i=="msie" && val != false) {        
        $('a.snow').css("font-size","xx-small");
        $('div.mediabox').css("top","235px");                
        
        browserIE = true
      }                             
                
    });
    
     $("a.print").corner();
/*
  
   $("a.print").click(function() {    
      $("link[rel=stylesheet]").attr({href : "style/print.css"});       
         setTimeout(function(){window.print()}, 100);
         $("#print_dialog").show();                  

         $("div#print_dialog a.back").click(function() {
           $("#print_dialog").hide();         
           $("link[rel=stylesheet]").attr({href : "style/index.css"});
            return false;
         })

         $("div#print_dialog a.cancel").click(function() {
           $("#print_dialog").hide();
           return false;
         })         
      
      return false;
      
    });      
   */
});


  function resizecontent() {
     h = $(window).height()
     $('div.center div#content').height(h -300)
  }

  function allmeida() {
     var html = '<img src="images/loading.gif" alt="Laadimas...">'
     $("div.mediabox").html(html);  
     $("div.mediabox").load(incs + 'pleier.php', {}, function(){               
         $('.mediabox').jqDrag('span.drag').jqResize('span.resize');                   
     });         
  }
  
  function setEmbedobj(width, height) {
  //called from jqDnR.js line 20
     $('.embedobject').attr('width',  width);
     $('.embedobject').attr('height',height);        
  }
   

  function aload(obj) {

    var html = '<img src="images/loading.gif" alt="Laadimas...">'

//    html += '<br><a href="javascript:snowStorm.stop()" class="snowoff">Kui laadimine v&#245;tab liialt kaua aega oleks m&#245;tekas lumi v&#228;lja l&#252;litada</a> '   

    $("div#content").html(html);

    var incs = 'inc/';  
    _href = $(obj).attr("href").replace(new RegExp('http://veebruari.lellealternatiiv.ee/', "i"), '')
    $("div#content").load(incs + _href)

    return false;
  }


 function URLEncode(unencodedValue )
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = unencodedValue;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};


 


