/*
Image Preloading ------------------------|
Author: 2Dmedia Ltd
Notes: Build up img_src Array with the list of images you want to preload (usually hovers). Last element mustn't have a comma to close.
*/

img_src = Array(
"/images/brochure_enquire_hover.jpg",
"/images/brochure_next_hover.jpg",
"/images/brochure_prev_hover.jpg",
"/images/contact_send_hover.jpg",
"/images/express_bi_doors_hover.jpg",
"/images/facebook_logo_hover.jpg",
"/images/high_gloss_kitchens_hover.jpg",
"/images/home_and_bargains_hover.jpg",
"/images/home_and_bargains_hover.jpg",
"/images/logo_hover.jpg",
"/images/painted_kitchens_hover.jpg",
"/images/scholtes_hover.jpg",
"/images/twitter_logo_hover.jpg",
"/images/vinyl_kitchens_hover.jpg",
"/images/wooded_kitchens_hover.jpg"
);
 
img_array = new Array();
 
for (counter in img_src) {
img_array[counter] = new Image();
img_array[counter].src = img_src[counter];
}


// Delete contents of a text box
function del_contents(ele, text){
	if (ele.value == text){
		ele.value = "";
	}
}
// ... then add them back in
function add_contents(ele, text){
	if (ele.value == ""){
		ele.value = text;
	}
}

function show_nav(ele, class_name, tag){
	for(var x=0; x< ele.childNodes.length; x++){
		ele.className = class_name;
		if (ele.childNodes[x].nodeName == tag){
			ele.childNodes[x].style.display = 'block';
		}
	}
}

function hide_nav(ele, class_name, tag){
	for(var x=0; x< ele.childNodes.length; x++){
		ele.className = class_name;
		if (ele.childNodes[x].nodeName == tag){
			ele.childNodes[x].style.display = 'none';
		}
	}
}

//product list - adjust row heights
function height_correct(container){
	var height_max = 0;
	var height_cur = 0;
	var rowele = new Array();
	var z = 0;
	var cont = document.getElementById(container);
	for(var x=0; x < cont.childNodes.length; x++){
			var curele = cont.childNodes[x];
			if (curele.nodeName == 'DIV'){
				if (curele.className.indexOf('home_col') > -1){
					rowele[z] = curele;
					z++;
					height_cur = parseInt(curele.offsetHeight);
					if (height_cur > height_max){
						height_max = height_cur;
					}
				}
			}
		
		var curele = cont.childNodes[x];
		if (curele.nodeName == 'DIV'){
			if (curele.className.indexOf('clear') > -1){
				for(z=0; z < rowele.length; z++){
					rowele[z].style.height = height_max + 'px';
				}
				height_max = 0;
				z = 0;
				var rowele = new Array();
			}
		}
	}
}

function height_correct_class(className){
	var highest = 0;
	var height = 0;
	$(className).each(function(){
		height = $(this).height();
		if(height > highest){
			highest = height;	
		}
	});
	$(className).height(highest);
}
