// -8: border compensation
//document.body.scrollHeight 
var height_total = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight - 60) - 8;
var height_header = 59;
var height_footer;
var height_promobase;

var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if ( !(browser=="Microsoft Internet Explorer" && version<=6) ) {
	// padding compensation
	height_total = height_total - 60;
}

height_footer = 75;
height_promobase = height_total - height_footer - height_header;

document.write('<style type="text/css">');
document.write('	div#wrapper {');
document.write('		height: ' + height_total + 'px;');
document.write('	}');

document.write('	div#promobase {');
document.write('		height: ' + height_promobase + 'px;');
document.write('	}');

document.write('	div#footer {');
document.write('		height: ' + height_footer + 'px;');
document.write('	}');
document.write('</style>');

// jquery
$(document).ready(function(){
   $("#itemsPerPage").change(function() {
	 $("#resultsPerPage").val($(this).val());
	 $("#formSearch").submit();
   });
   
   $("a.sortName, a.sortPrice, a.sortBrand").click(function(event){
	 if( $("#sortBy").val() == $(this).attr('class') ) { // Same sort type clicked twice then inverse sort order
		if( $("#sortOrder").val() == 'ASC' ) {
			$("#sortOrder").val( 'DESC' );
		} else {
			$("#sortOrder").val( 'ASC' );
		}
	} else { // Sort on clicked type ascending
		$("#sortBy").val( $(this).attr('class') );
		$("#sortOrder").val( 'ASC' );
	}
	$("#formSearch").submit();	
   });
      
   $("a.listView").click(function(event){
	 $("div.gridView").removeClass("gridView").addClass("listView");
	 $("#view").val( 'list' );	 
   });
   
   $("a.gridView").click(function(event){
     $("div.listView").removeClass("listView").addClass("gridView"); 
	 $("#view").val( 'grid' );
   });   
});

