// JavaScript Document



// 0 = bighat1link, 1=bighat2link, 2=bighat3link, 3=linktarget, 4=title, 5=desc, 6=price 

//hat_table[0]=["Images/photo1.jpg", "Images/photo1.jpg","Images/photo1.jpg","", "Title 0", "Description 0", "Price 0", "0"]
//hat_table[1]=["Images/photo2.jpg", "Images/photo2.jpg","Images/photo2.jpg","", "Title 1", "Description 1", "Price 1", "1"]
//hat_table[2]=["Images/photo3.jpg","Images/photo3.jpg","Images/photo3.jpg", "", "Title 2", "Description 2", "Price 2", "2"]
//hat_table[3]=["Images/photo4.jpg","","", "", "Title 3", "Description 3", "Price 3", "3"]

var preloadimage="no"	//Preload images ("yes" or "no") - preloading causes some page display delay
var optlinktarget="" 	//Set optional link target to be added to all images with a link:
var imageborderwidth=0	//Set image border width- 0 = none
//Optionally, change GradientSize and Duration below to affect Wipe gradient size and duration in seconds in IE5.5+:
var displayfilter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)"
//var displayfilter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=2)"

if (preloadimage=="yes"){
	loadtableimages()
}



// <td width="30%"> <img src="Images/F05/F0501T.gif" alt="" name="I1" width="100" height="100"  id="I1" onMouseOver="showhatinfo(0)" a href="#"></a></td>
function initcells(page) {
	var count = 0;
	for (ix=0; ix<hat_table.length; ix++) {
		if ((page == hat_table[ix][ix_page]) && (hat_table[ix][ix_show] == "1")) {
		var cell = document.getElementById("Cell"+ count.toString());
		if (cell != null) {
		var elImg = document.createElement("img");
//		var src = "Images/" + hat_table[ix][ix_page] + "/" + hat_table[ix][ix_bighat1];
		var src = "Images/Hats/" + hat_table[ix][ix_bighat1];
	  	elImg.setAttribute("src", src);  
		elImg.setAttribute("width","100");
		elImg.setAttribute("height","100");	

		var ela = document.createElement("a");
		ela.setAttribute("href","#");
		ela.setAttribute("title",hat_table[ix][ix_title]);
		ela.setAttribute("id","HAT" + ix.toString());
		ela.setAttribute("onmouseover", "showhatinfo(" + ix.toString() + ")");
		ela.appendChild(elImg);
		cell.appendChild(ela);
		cell.innerHTML +='&nbsp;'; // this line has to be added to correct an IE problem with dynamic content
		}
		count +=1;
	}

	}
}

//<img src="Images/Fall/F05MAIN.JPG" width="100" height="100" border="0">
function initmaincells(page, topage) {
	var count = 0;
	// clear any existing hat entries
	for (count=0; count<=24; count++) {
		var cell = document.getElementById("Cell"+ count.toString());
		if (cell != null) {
			cell.innerHTML ='&nbsp;'; // this line has to be added to correct an IE problem with dynamic content
		}
	}

	count = 0;
	for (ix=0; ix<hat_table.length; ix++) {
		if ((page == hat_table[ix][ix_page]) && (hat_table[ix][ix_show] == "1")) {
			var cell = document.getElementById("Cell"+ count.toString());
			if (cell != null) {
				var src = "Images/" + hat_table[ix][ix_page] + "/" + hat_table[ix][ix_bighat1];
				var text = '<a href="' + topage + '"><img src="' + src + '" width="100" height="100" border="0"><\a>';
				cell.innerHTML = text; // this line has to be added to correct an IE problem with dynamic content
			}
			count +=1;
		}
	}
}

function addCollection(page, pagename) {
	var tbl = document.getElementById('collectiontable');
	var hdrow = tbl.insertRow(tbl.rows.length);
	var cell = hdrow.insertCell(0);
	hdrow.insertCell(1);
	cell.setAttribute("colspan","2");
	var text = '<div align="left" class="collectionnames"><font size="6">' + pagename + '</font></div>';
	cell.innerHTML = text;
	for (ix=0;ix< hat_table.length; ix++) {
		if ((page == hat_table[ix][ix_page]) && (hat_table[ix][ix_show] == "1")) {
			var hdrow = tbl.insertRow(tbl.rows.length);
			var cell = hdrow.insertCell(0);
			var text = '<div align="left" class="collectionnames">' + hat_table[ix][ix_title] + '</div>';
			cell.innerHTML = text;
			var cell = hdrow.insertCell(1);
			var elImg = document.createElement("img");
//			var src = "Images/" + hat_table[ix][ix_page] + "/" + hat_table[ix][ix_bighat1];
			var src = "Images/Hats/" + hat_table[ix][ix_bighat1];
	  		elImg.setAttribute("src", src);  
			elImg.setAttribute("width","100");
			elImg.setAttribute("height","100");	
			cell.appendChild(elImg);
			
			var cell = hdrow.insertCell(2);
			var elImg = document.createElement("img");
//			var src = "Images/" + hat_table[ix][ix_page] + "/" + hat_table[ix][ix_bighat2];
			var src = "Images/Hats/" + hat_table[ix][ix_bighat2];
	  		elImg.setAttribute("src", src);  
			elImg.setAttribute("width","100");
			elImg.setAttribute("height","100");	
			cell.appendChild(elImg);
			
			var cell = hdrow.insertCell(3);
			var elImg = document.createElement("img");
//			var src = "Images/" + hat_table[ix][ix_page] + "/" + hat_table[ix][ix_bighat3];
			var src = "Images/Hats/" + hat_table[ix][ix_bighat3];
	  		elImg.setAttribute("src", src);  
			elImg.setAttribute("width","100");
			elImg.setAttribute("height","100");	
			cell.appendChild(elImg);
			
			var cell = hdrow.insertCell(4);
			cell.innerHTML = hat_table[ix][ix_desc];
			var cell = hdrow.insertCell(5);
			cell.innerHTML = hat_table[ix][ix_price];
		}
	}
}


function buildAllCollections() {
	addCollection("C","Cocktail 1");
	addCollection("C2","Cocktail 2");
	addCollection("W","Wedding");
	addCollection("Other","Other");
}

function initpage(page) {
	if (preloadimage == "no") {
		loadtableimages();
	}
	initcells(page);
}

function displayloadingmsg(count, numitems) {
	if (document.getElementById){
		var textobj=document.getElementById("bighat1")
		textobj.innerHTML= "Loading image " + x + " of " + (numitems -1 )
//		if (count == (numitems -1)) {
//			textobj.innerHTML= "Loading finished - hover over thumbnails to see an expanded view"
//		}
	}
}

function loadtableimages() {
	for (x=0; x<hat_table.length; x++){
		var loadtheimage=new Image()
//		displayloadingmsg(x, hat_table.length)
		loadtheimage.src=hat_table[x][ix_bighat1]
	}
}

function get_image_html(thehatrow, colindex){
	var imghtml=""
//	var src = "Images/" + thehatrow[ix_page] + "/" + thehatrow[colindex];
	var src = "Images/Hats/" + thehatrow[colindex];
	if (thehatrow[ix_link]!="") imghtml='<a href="'+thehatrow[ix_link]+'" target="'+optlinktarget+'">'
	if (thehatrow[colindex]!="") imghtml+='<img src="'+ src +'" border="'+imageborderwidth+'">'
	if (thehatrow[ix_link]!="") imghtml+='</a>'
	return imghtml
}

function changetext(textarea, rowindex, colindex){
if (document.getElementById){
	var texthtml=""
	var textobj=document.getElementById(textarea)
	texthtml = hat_table[rowindex][colindex]
	textobj.innerHTML=texthtml   
	return false
}
}

function showloadmsg(textarea, rowindex){
if (document.getElementById){
	var texthtml=""
	var textobj=document.getElementById(textarea)
	texthtml = "Loading " + hat_table[rowindex][ix_bighat1]
	textobj.innerHTML=texthtml   
	return false
}
}

function showhatinfo(hatindex){
if (document.getElementById){
	modifyimage("bighat1", hatindex, ix_bighat1)
	modifyimage("bighat2", hatindex, ix_bighat2)
	modifyimage("bighat3", hatindex, ix_bighat3)
//	changetext("picturetitlearea", hatindex, ix_bighat1);
	changetext("titlearea", hatindex, ix_title);
	changetext("descriptoinarea", hatindex, ix_desc);
	changetext("pricearea", hatindex, ix_price);
	return false
}
}

function modifyimage(loadarea, imgindex, colindex){
if (document.getElementById){
	var imageobj=document.getElementById(loadarea)
	if (imageobj.filters && window.createPopup){
		imageobj.style.filter=displayfilter;
		imageobj.filters[0].Apply();
	}
	imageobj.innerHTML=get_image_html(hat_table[imgindex],colindex);
	if (imageobj.filters && window.createPopup) imageobj.filters[0].Play();
	return false;
}
}

function showcdesc(coll_title) {
	if (document.getElementById) {
		for (ix=0;ix< a_cat_desc.length; ix++) {
			if ((coll_title == a_cat_desc[ix][0])) {
				var texthtml="";
				var textobj=document.getElementById("titlearea");
				texthtml = a_cat_desc[ix][1];
				textobj.innerHTML=texthtml;  
				var textobj=document.getElementById("descriptoinarea");
				texthtml = a_cat_desc[ix][2];
				textobj.innerHTML=texthtml;  
			} 
		}
	}
}



