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();
  }

} );

var App = new MainApplication();

var Util = {};

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;
}

function heightHacking( cntID ){

  var height       = 0;
  var elements     = $(cntID).find(".item");

  for ( i=0; i<elements.length; i++ ){

    if ( $(elements[i]).height()>=height ) {
      height = $(elements[i]).height()
    }

  }

  for ( i=0; i<elements.length; i++ ){

    $(elements[i]).height(height);
  }

}

function getCountry( ezip, ecity ){

  var val = $(ezip).val();
  ecity = document.getElementById( ecity );

  if (val.length == 4 ) {

    $.ajax({
      type:    "POST",
      url:     "auth/getcountry",
      data:    "zipcode=" + val,
      success: function( ret ){
        $(ecity).val( ret );
      }
    });

  }

}
