<!--
// to be included in particular pages
var no_right_menu=false;

var hide_end_products = new Array();

/*
document.body.clientWidth;
document.body.clientHeight;

WIDTHS:
body margin: 2×18 = 36
menu width: 164
TOTAL: 210
AFFECTED: main, top_menu, content, sub

HEIGHTS:
body margin: 0
logo margin: 3
logo height: 94
top menu height: 30
TOTAL: 127
AFFECTED: menu, content
*/
var margin = 36;
var menu_width = 164;
var right_menu_width = 153;
var top_menu_left_width = 161;

var menu_height;//582
var actual_menu_height;
var top_menu_height = 30;
var menu_margin = 18;
var sub_height = 9;
var original_content_height;
var actual_content_height;

var screen_width;
//var screen_height;
var width_1;
var width_2;

var number_pb;
var min_width_pb = 286;
var actual_width_pb;
var pb_gap = 10;//edit later 10

if ( no_right_menu )
{
	right_menu_width = 0;
}

function docRef(element)
{
	if (element) {
		if (document.getElementById) {
			if (document.getElementById(element)) {
				var ref = document.getElementById(element).style;
			}
		} else if (document.all) {
			if (document.all[element]) {
				var ref = document.all[element].style;
			}
		} else if (document.layers) {
			if (document.layers[element]) {
				var ref = document.layers[element];
			}
		} else {  }
		return ref;
	}
	else {return null;}
}

function docRef_withoutstyle(element)
{
	if (element) {
		if (document.getElementById) {
			if (document.getElementById(element)) {
				var ref = document.getElementById(element);
			}
		} else if (document.all) {
			if (document.all[element]) {
				var ref = document.all[element];
			}
		} else if (document.layers) {
			if (document.layers[element]) {
				var ref = document.layers[element];
			}
		} else {  }
		return ref;
	}
	else {return null;}
}

// to go inside other functions
function measure_content_div()
{
	// curtop = height that content_measure_1 div (at to of content div) is down page, measuring from the top
	var obj_1 = docRef_withoutstyle('content_measure_1');
	var curleft_1 = curtop_1 = 0;
	if (obj_1.offsetParent) {
		curleft_1 = obj_1.offsetLeft;
		curtop_1 = obj_1.offsetTop;
		while (obj_1 = obj_1.offsetParent) {
			curleft_1 += obj_1.offsetLeft;
			curtop_1 += obj_1.offsetTop;
		}
	}
	
	// curtop = height that content_measure div (at bottom of content div) is down page, measuring from the top
	var obj_2 = docRef_withoutstyle('content_measure_2');
	var curleft_2 = curtop_2 = 0;
	if (obj_2.offsetParent) {
		curleft_2 = obj_2.offsetLeft;
		curtop_2 = obj_2.offsetTop;
		while (obj_2 = obj_2.offsetParent) {
			curleft_2 += obj_2.offsetLeft;
			curtop_2 += obj_2.offsetTop;
		}
	}
	//alert('curtop_1 (measurement of content_measure_1 div from top of page) ' + curtop_1 + ',\n curtop_2 (measurement of content_measure div from top of page) ' + curtop_2);
	actual_content_height=curtop_2 - curtop_1;
	actual_menu_height = actual_content_height - menu_margin + top_menu_height + sub_height - 9;
	
	//alert('actual_content_height ' + actual_content_height + ', original_content_height ' + original_content_height + ', menu_height ' + menu_height +'.');
	if ( actual_content_height>original_content_height )
	{
		//alert('actual_content_height ' + actual_content_height + ' > original_content_height ' + original_content_height + '.');
		docRef('main').height=actual_content_height+'px';
		docRef('content').height=actual_content_height+'px';
		docRef('menu').height=actual_menu_height+'px';
		//alert('Setting menu height to ' + actual_menu_height);
	}
	else if ( actual_content_height<original_content_height )
	{
		//alert('actual_content_height ' + actual_content_height + ' < original_content_height ' + original_content_height + '.');
		docRef('menu').height=menu_height+'px';
		//alert('menu_height ' + menu_height);
	}
}

// to go inside other functions
function measure_screen_width()
{
	//if ( window.innerWidth )
	//{
		//screen_width = window.innerWidth;
	//}
	//else 
	if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		screen_width = document.documentElement.clientWidth;
		//screen_height = document.documentElement.clientHeight;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		screen_width = document.body.clientWidth;
		//screen_height = document.body.clientHeight;
	}
	
	//alert('screen_width ' + screen_width);
	if ( screen_width<954 )//817
	{
		//alert('screen_width ' + screen_width);
		screen_width = 954;
	}
	
	width_1 = screen_width - margin - menu_width;// - 10
	width_2 = screen_width - margin - menu_width - right_menu_width;// - 10
	docRef('main').width=width_1+'px';
	docRef('top_menu').width=width_1-6+'px';
	docRef('content').width=width_2+'px';
	docRef('sub').width=width_2+'px';
	
	docRef('main').height=original_content_height+'px';
	docRef('content').height=original_content_height+'px';
}

// to go inside other functions
function resize_product_boxes()
{
	// given content width, calculate how many product boxes in each row and their widths
	var pb_per_row;
	pb_per_row = width_2/(min_width_pb+pb_gap);
	pb_per_row = Math.floor(pb_per_row);
	//alert('pb_per_row ' + pb_per_row);
	if ( pb_per_row<2 ) { pb_per_row=2; }
	actual_width_pb = (width_2-0)/pb_per_row - pb_gap;
	actual_width_pb = Math.floor(actual_width_pb);
	
	var theRules = new Array();
	if (document.styleSheets[0].cssRules)
		theRules = document.styleSheets[0].cssRules;
	else if (document.styleSheets[0].rules)
		theRules = document.styleSheets[0].rules;
	//if ( theRules.length<110 )//currently 89
	//{
		theRules[0].style.width = actual_width_pb+'px';// firefox
	//}
	//else
	//{
		//theRules[0].style.width = actual_width_pb+'px';// IE 6
	//}
	
	//bit to make some rows invisible if required
	//var hide_end_products = new Array();
	//hide_end_products[]='kingston_3d2844';
	//hide_end_products[]='fuji_239451';
	if ( hide_end_products.length>0 )
	{
		var j;
		for (j=0;j<hide_end_products.length;j++)
		{
			var begin_none=hide_end_products[j].length;//-1
			
			//if less products than row length, don't need to hide any
			//if same number of products as row length, don't need to hide any
			
			//if more products than row length, do stuff
			if ( hide_end_products[j].length-1>pb_per_row )
			{
				//if not enough products to complete second row, hide second row
				if ( hide_end_products[j].length-1<pb_per_row*2 )
				{
					begin_none=pb_per_row+1;
				}
				//if exactly two rows of products, don't need to do anything
				//if more than two rows of products
				else if ( hide_end_products[j].length-1>pb_per_row*2 )
				{
					//if there will be more than 10 products displayed, or not enough products to complete third row, hide third row
					if ( pb_per_row*3>10 || hide_end_products[j].length-1<pb_per_row*3 )
					{
						begin_none=(pb_per_row*2)+1;
					}
					//if more than three rows of products, hide fourth row
					else if ( hide_end_products[j].length-1>pb_per_row*3 )
					{
						begin_none=(pb_per_row*3)+1;
					}
				}
			}
			
			if ( begin_none!='' )
			{
				var i;
				for (i=1;i<begin_none;i++)
				{
					//alert('docRef(hide_end_products['+ j +']['+ i +']).display=\'block\'');
					docRef(hide_end_products[j][i]).display='block';
				}
				for (i=begin_none;i<hide_end_products[j].length;i++)
				{
					//alert('docRef(hide_end_products['+ j +']['+ i +']).display=\'none\'');
					docRef(hide_end_products[j][i]).display='none';
				}
			}
			else
			{
				//alert('begin_none==\'\'');
			}
		}
	}
}

function after_menu()
{
	// get height of menu div
	if (docRef_withoutstyle('menu').offsetHeight)
	{
		menu_height=docRef_withoutstyle('menu').offsetHeight;
	}
	else if (docRef('menu').pixelHeight)
	{
		menu_height=docRef('menu').pixelHeight; 
	}
	else
	{
		menu_height=582;
	}
	
	original_content_height = menu_height + menu_margin - top_menu_height - sub_height + 9;
}

function after_div_open()
{
	measure_screen_width();
}

function after_div_close()
{
	// get height of content div, doesnt change in firefox
	//if (docRef_withoutstyle('content').offsetHeight)
	//{
		//original_content_height=docRef_withoutstyle('content').offsetHeight;
	//}
	//else if (docRef('content').pixelHeight)
	//{
		//original_content_height=docRef('content').pixelHeight; 
	//}
	//else
	//{
		//alert('no content div height.');
	//}
	measure_screen_width();// run again, for firefox
	
	resize_product_boxes();
	
	measure_content_div();
}

function resize_main()
{
	measure_screen_width();
	
	resize_product_boxes();
	
	measure_content_div();
}

//product_listing
//product_listing .information
//
//
//

-->