  $.localise( lang_file, { timeout: 700 } );
  var hint_idx = new Array();

  if(!Array.indexOf){
	    Array.prototype.indexOf = function(obj){
	        for(var i=0; i<this.length; i++){
	            if(this[i]==obj){
	                return i;
	            }
	        }
	        return -1;
	    }
	}

  $(function(){
			//tabs
			$('#tabs > ul').tabs({
        remote: true,
        fx: { opacity: 'toggle' }
      });

      function get_hint( idx ){
        return hint_data[ hint_idx.indexOf( idx ) ];
      }

      //l10n
      function translate(){
        len = lang.length;
        for( i=0; i < len; i++ ){
            temp = lang[i].split('=>');

            switch( temp[2] ){
              case 'value': $( temp[0] ).val( temp[1] );break;
              default: $( temp[0] ).html( temp[1] );
            }
        }

        len = hint_data.length;
        for( i=0; i < len; i++ ){
            temp = hint_data[i].split('=>');
            hint_idx[i] = temp[0];
            hint_data[i] = temp[1];
        }

        $("#help").html( get_hint('default') );
      }

      $('#ru,#en').click( function(){
        new_lang = $(this).attr('id');
        $.localise( lang_file, { language: new_lang, timeout: 700 } );
        translate();
      } );

      //Show Hints
      $("div.row").mouseover(function(){
        $("#help").html( get_hint( $(this).attr('hint') ) );
      });

      $("div.row").mouseout(function(){
        $("#help").html( get_hint('default') );
      });


      translate();
      //$('#ln_cur').html($.defaultLanguage);
      
      //example data
      $("#expl-btn").click(function(){
        $("#url").val( 'http://www.discogs.com/release/579528' );
        $("#quality").val( 'FLAC' );
        qualityChange( $("#quality").val() );
        $("#lossless-type").val('image + .cue');
        $("#files").val('http://rapidshare.com/files/62325564/Lustmord_Heresy_flac5.part1.rar, 103000 KB, part1.rar\nhttp://rapidshare.com/files/62329444/Lustmord_Heresy_flac5.part2.rar, 103000 KB, part2.rar\nhttp://rapidshare.com/files/62320710/Lustmord_Heresy_flac5.part3.rar, 93530 KB, part3.rar\nhttp://rapidshare.com/files/62329920/Lustmord_Heresy_SCANS5.rar, 18301 KB, Scans.rar');
      });
      
      //release images select
      $("#nimages > img").click( function(){
        $("#nimages > img").removeClass('selected');
        $(this).addClass('selected');
        $("#news-image").text( $(this).attr('rel') );
      } );
  });
