// JavaScript Document

var flags = { axisPop: 'closed', cylinderPop: 'closed', spherePop: 'closed', addPowerPop: 'closed', vertexDistancePop: 'closed', keratometryPop: 'closed', rotationPop: 'closed' }

function hideDivs() {
	/*for (x in flags) {
		alert(flags[x].key)
	}*/
	if(flags.axisPop=='open'){
		hideLayer('axisPop');
	}
	if(flags.cylinderPop=='open'){
		hideLayer('cylinderPop');
	}
	if(flags.spherePop=='open'){
		hideLayer('spherePop');
	}
	if(flags.addPowerPop=='open'){
		hideLayer('addPowerPop');
	}
	if(flags.vertexDistancePop=='open'){
		hideLayer('vertexDistancePop');
	}
	if(flags.keratometryPop=='open'){
		hideLayer('keratometryPop');
	}
	if(flags.rotationPop=='open'){
		hideLayer('rotationPop');
	}
}

//Hide Show popup window
function hideLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "hidden";
	} else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "hidden";
	} else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].visibility = "hidden";
	}
	flags[whichLayer]='closed'
}

function showLayer(anchorName,whichLayer) {
	hideDivs();
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "visible";
	} else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "visible";
	} else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].visibility = "visible";
	}
	// Position the div
	var c = getAnchorPosition(anchorName);
	if (document.getElementById) {
		var o = document.getElementById(whichLayer);
		if (o.style) {
			o.style.left = c.x+'px';
			o.style.top = c.y+'px';
		}
	}
	flags[whichLayer]='open'
}

function displayDominantEye()
{
	var productId = document.getElementById('PRODUCT_ID');
	var product = productId.options[productId.selectedIndex].text;
	if (product.toUpperCase() == 'AIR OPTIX MULTIFOCAL')
	{
		document.getElementById('dominantEyeDiv').style.display = "block"; 
	}
	else
	{
		document.getElementById('dominantEyeDiv').style.display = "none"; 
	}
}
/*function handleClick(whichClick,anchorName,divName) {
	if (whichClick == "hide it") {
		// then the user wants to hide the layer
		hideLayer(divName);	
	} else if (whichClick == "show it") {
		// then the user wants to show the layer
		showLayer(anchorName,divName);
	}
}*/
