$(document).ready(function(){

    justify_screen();

    if ( $("#inhalt_innen").height( ) > $("#inhalt").height( ) ) {
        $("#inhalt_innen").css('marginRight', '5px')
    }

    $('#sortierung').val('0');
    weinSort();

    $('#page_selector').css('opacity', 0.4);

});


function justify_screen()
{
 var x,y;
 if (self.innerHeight) // all except Explorer
 {
 x = self.innerWidth;
 y = self.innerHeight;
 }
 else if (document.documentElement && document.documentElement.clientHeight)
 // Explorer 6 Strict Mode
 {
 x = document.documentElement.clientWidth;
 y = document.documentElement.clientHeight;
 }
 else if (document.body) // other Explorers
 {
 x = document.body.clientWidth;
 y = document.body.clientHeight;
 }


 if (y<650) {
 document.body.scroll = "yes";
 document.body.style.overflow = "auto";
 document.getElementById("rahmen").style.marginTop = "auto";
 document.getElementById("rahmen").style.top = "0px";
 }
}

function weinSort()
{

  var val=$('select#sortierung').val();

  switch (val) {
    case "0":
      $('div.content-view-children>div.wein_rahmen').tsort({order:'asc',attr:'preis'});
      break;
    case "1":
      $('div.content-view-children>div.wein_rahmen').tsort({order:'desc',attr:'preis'});
      break;
    case "2":
      $('div.content-view-children>div.wein_rahmen').tsort({order:'asc',attr:'jahrgang'});
      break;
    case "3":
      $('div.content-view-children>div.wein_rahmen').tsort({order:'desc',attr:'jahrgang'});
      break;
    case "4":
      $('div.content-view-children>div.wein_rahmen').tsort({order:'asc',attr:'weingut'});
      break;
  }

}
