//======= Natural Floorcovering Centre
//======= www.naturalfloor.com.au



//************* ColourTexturePicker **********************






//Global Variables

var onImageColour; // whcih colour option (the actual image control) is selected
var onImageTexture; // same for texture
var nChosenColour ;// the value of the chosen colour
var nChosenTexture;

nChosenColour = -1;
nChosenTexture = -1;

//var txtImagePath;
txtImagePath = "images\\prodselect_";


// Pre-load images
var offImagesColour = new Array();

offImagesColour[0] = new Image;
offImagesColour[0].src = txtImagePath + "white.gif";
offImagesColour[1] = new Image;
offImagesColour[1].src = txtImagePath + "brown.gif";
offImagesColour[2] = new Image;
offImagesColour[2].src = txtImagePath + "green.gif";
offImagesColour[3] = new Image;
offImagesColour[3].src = txtImagePath + "grey.gif";
offImagesColour[4] = new Image;
offImagesColour[4].src = txtImagePath + "reds.gif";
offImagesColour[5] = new Image;
offImagesColour[5].src = txtImagePath + "anyC.gif";


var onImagesColour = new Array();
onImagesColour[0] = new Image;
onImagesColour[0].src = txtImagePath + "whiteon.gif";
onImagesColour[1] = new Image;
onImagesColour[1].src = txtImagePath + "brownon.gif";
onImagesColour[2] = new Image;
onImagesColour[2].src = txtImagePath + "greenon.gif";
onImagesColour[3] = new Image;
onImagesColour[3].src = txtImagePath + "greyon.gif";
onImagesColour[4] = new Image;
onImagesColour[4].src = txtImagePath + "redson.gif";
onImagesColour[5] = new Image;
onImagesColour[5].src = txtImagePath + "anyCon.gif";

			
var offImagesTexture = new Array();
offImagesTexture[0] = new Image;
offImagesTexture[0].src = txtImagePath + "fineribbed.gif";
offImagesTexture[1] = new Image;
offImagesTexture[1].src = txtImagePath + "heavyribbed.gif";
offImagesTexture[2] = new Image;
offImagesTexture[2].src = txtImagePath + "chunky.gif";
offImagesTexture[3] = new Image;
offImagesTexture[3].src = txtImagePath + "wool.gif";
offImagesTexture[4] = new Image;
offImagesTexture[4].src = txtImagePath + "flatweaves.gif";
offImagesTexture[5] = new Image;
offImagesTexture[5].src = txtImagePath + "anyT.gif";

var onImagesTexture = new Array();
onImagesTexture[0] = new Image;
onImagesTexture[0].src = txtImagePath + "fineribbedon.gif";
onImagesTexture[1] = new Image;
onImagesTexture[1].src = txtImagePath + "heavyribbedon.gif";
onImagesTexture[2] = new Image;
onImagesTexture[2].src = txtImagePath + "chunkyon.gif";
onImagesTexture[3] = new Image;
onImagesTexture[3].src = txtImagePath + "woolon.gif";
onImagesTexture[4] = new Image;
onImagesTexture[4].src = txtImagePath + "flatweaveson.gif";
onImagesTexture[5] = new Image;
onImagesTexture[5].src = txtImagePath + "anyTon.gif";
										


function pickOption (thisImage, n, t) {
// when a user clicks one of the options on the colour / texture selector
// this function (1) highlights the option clicked,
// (2)removes the highlight from the option that was highlighted
// (3) stores the value of what was clicked the control c 
// thisImage = an image item that was clicked
// n = that image's value = which is also the place in the array for that images pick
// t = type - either "colour", or "texture"



	if (t == "colour") {
		

		// make the image that was on, off
		if (nChosenColour != -1) {
			onImageColour.src = offImagesColour[nChosenColour].src;
		}

		//make this image on
		thisImage.src = onImagesColour[n].src;

		//store the value of this selection in hiddenTextColour
		nChosenColour = n;
		onImageColour = thisImage;
		document.frmSelector.hiddenTextColour.value = nChosenColour;
	}		

	if (t == "texture") {
		
		// make the image that was on, off
		if (nChosenTexture != -1) {
			onImageTexture.src = offImagesTexture[nChosenTexture].src;
		}

		//make this image on
		thisImage.src = onImagesTexture[n].src;

		//store the value of this selection in hiddenTextTexture
		nChosenTexture = n;
		onImageTexture = thisImage;
		document.frmSelector.hiddenTextTexture.value  = nChosenTexture;
	}		


}

function checkSelector () {


	var c = document.frmSelector.hiddenTextColour.value ; 
	var t = document.frmSelector.hiddenTextTexture.value; 

	//alert("Colour: " + c + " Texture: " + t);


	if ((c == "-1") ||(t == "-1")){

		alert("Please pick a colour and a texture, or select ANY for both");
		return false;
	}

	return true;

}