// JavaScript Document

addLoadEvent(fadeMessage);
addLoadEvent(blurLinks);


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}



/* remove all focus lines from links when clicked */
function blurLinks() {
	var links = document.getElementsByTagName('a');
	for (i=0;i<links.length;i++) {
		links[i].onfocus = function() {
			this.blur();
		}
	}
}



function fadeMessage() {

	if ($('headerMessageStack')) {
		setTimeout("Effect.Puff('headerMessageStack')",3500)
	} 
	
}




g_attrImgs = Array();
g_attrSelect = Array();

function getAttrImgs () {
	
	// get number of images listed inside #c_productAttributes assign them to global array: g_attrImgs
	var attrImgs = $$('#c_productAttributes img');
	for (i=0;i<attrImgs.length;i++) {
		g_attrImgs[i] = attrImgs[i];
	}
	
	// get listing of select list options and assign them to global array: g_attrSelect
	var attrSel = $$('#c_attrSelect option');
	for (j=0;j<attrSel.length;j++) {
		g_attrSelect[j] = attrSel[j].value;
	}
	
	// map array index of selected option to image array to choose big picture for display
	$('c_attrSelect').onchange = function() {
		
		// get array index of selected option
		for (z=0;z<attrSel.length;z++) {
			
			// compare to g_attrSelect array
			if (g_attrSelect[z] == this.value) {
				
				// match == selected index (+1 to convert to actual place value vs index array started at 0)
				
				// assign big image based on small img src
				// change image
				var prodImg = $$('#productMainImage img');
				prodImg[0].src= g_attrImgs[z].src;
			}
		}
		
	}
}


function changeImageOptions(id,img) {
	
	// change image
	var prodImg = $$('#productMainImage img');
	prodImg[0].src=img;
	
	// change value option
	var selectList = $$('#c_attributeList select');
	selectList[0].value=id;
	
	
}



function showHairServiceDetail(id) {
	
	var sections = $$('.sectionDetails');
	for(i=0;i<sections.length;i++) {
		sections[i].style.display='none';
		//if (sections[i].style=='block') {
		//	Effect.BlindUp(sections[i].id);
		//}
	}
	
	$(id).style.display='block';
	
}


