var Application = new JS.Class( {
  
  initialize : function() {
    $( document ).ready( function() {
      App.init();
    } );
  },
  
  init : function() {
    $.each( Fonts, function( font ) {
      Cufon.replace( font[ 0 ], font[ 1 ] );
    } );
  },
  
  run : function() {
    //$( '.layout' ).show();
  }
  
} );

var MainApplication = new JS.Class( Application, {
  
  init : function() {
    //this.callSuper();
    this.run();
  },


  initArticleGallery: function(){

	  $( document ).ready(
	  );
  },

  initProgramFader: function(){

	  $( document ).ready(

		function(){

			$.getScript(
				URI_STATIC + 'scripts/jquery.cycle.js',
				function(){


					$.getScript( URI_STATIC + 'scripts/blocks/programFader.js' );
				}
			);
		}
	  );
  },
 
  initVote : function(){
  	
  	$( document ).ready( 
  		function() {
		  	$.ajaxSetup( {
				async : false,
				cache : false,
				global : false
			} );
			
			$.getScript( 
				URI_STATIC + 'scripts/blocks/vote.js', 
				function() {
					// Ez akkor fut, ha betöltötte
				} 
			);
  		}
  	);
  }
  
} );

var App = new MainApplication();

/**
 * Search box functions
 */
var Search = { } ;
Search.changeBlogCategory = function()
{
	if(  $("#blogCategories option:selected").hasClass( 'allCategories' ) ) {
		selectedCategory = 'allCategories';
		$('#blogBloggers .option').show();	
	} else {
		if(  $("#blogCategories option:selected").hasClass( 'purple' )  )
			selectedCategory = 'purple';
		if(  $("#blogCategories option:selected").hasClass( 'green' )  )
			selectedCategory = 'green';
		if(  $("#blogCategories option:selected").hasClass( 'black' )  )
			selectedCategory = 'black';
		$('#blogBloggers .option').hide();
		$('#blogBloggers .allBloggers').show();
		$('#blogBloggers').val( 0 );
		$('#blogBloggers .'+selectedCategory+'').show();
	}
}
 
var Util = { fontSize : 14 };

Util.urlMedia = function( parameters ) {
	
	parameters.id     = parameters.id     || 0;
	parameters.width  = parameters.width  || 320;
	parameters.height = parameters.height || 240;
	parameters.mode   = parameters.mode   || 'O';
	parameters.ext    = parameters.ext    || 'jpg';
	
	var path = '';
	var length = ( parameters.id + '' ).length;
	for( chr = 0; chr < length; chr++ )
		path += ( parameters.id + '' ).charAt( chr ) + '/';
	
	return URI_STATIC + 
		'media/' + path + 
		parameters.id + '_' + 
		parameters.mode.toUpperCase() + '_' + 
		parameters.width + 'x' + 
		parameters.height + '.' +
		parameters.ext;
}

Util.changeTopListTab = function ( from, to ) {
	
	$("#toplist-content-"+from).hide();
	$("#toplist-content-"+to).show();
	$("#toplist-nav-"+from).removeClass('active');
	$("#toplist-nav-"+to).addClass('active');
}



Util.changeSearchTab = function ( to ) {
	
	$(".searchContent").hide();
	$("#search-content-"+to).show();
	$(".searchNav a").removeClass('active');
	$("#search-nav-"+to+" a").addClass('active');
}

Util.incSize = function () {
	if( Util.fontSize <20 ) {
		Util.fontSize++;
		Util.fontSize++;
		$(".article-title").css( { 'font-size': Util.fontSize + 7 + 'px' } );
		$(".article-lead").css( { 'font-size': Util.fontSize + 1 + 'px' } );
		$(".article-body").css( { 'font-size': Util.fontSize + 'px' } );
		$(".article-title").css( { 'line-height': Util.fontSize + 10 + 'px' } );
		$(".article-lead").css( { 'line-height': Util.fontSize + 2 + 'px' } );
		$(".article-body").css( { 'line-height': Util.fontSize + 2 + 'px' } );
	}
}

Util.decSize = function () {
	if( Util.fontSize > 10 ) {
		Util.fontSize--;
		Util.fontSize--;
		$(".article-title").css( { 'font-size': Util.fontSize + 7 + 'px' } );
		$(".article-lead").css( { 'font-size': Util.fontSize + 1 + 'px' } );
		$(".article-body").css( { 'font-size': Util.fontSize + 'px' } );	 
		$(".article-title").css( { 'line-height': Util.fontSize + 10 + 'px' } );
		$(".article-lead").css( { 'line-height': Util.fontSize + 2 + 'px' } );
		$(".article-body").css( { 'line-height': Util.fontSize + 2 + 'px' } );
	}
}

