var hashSelected = new Array();
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
var intIsSemirimlessProgAvailable;
var intLensH;

function checkAvailable(strType){
	if(!intLensH){
		intLensH = parseInt(document.getElementById('LensH').value);
	}
	if(!intIsSemirimlessProgAvailable){
		intIsSemirimlessProgAvailable = parseInt(document.getElementById('isSemiProgAvailable').value);
	}
	
	var isGIAAvailable = (intLensH >= 27 || intLensH == 0 || intIsSemirimlessProgAvailable)?true:false;
	var isAppolosoftAvailable = (intLensH >= 31 || intLensH == 0 || intIsSemirimlessProgAvailable)?true:false;
	var isGNAvailable = (intLensH >= 29 || intLensH == 0 || intIsSemirimlessProgAvailable)?true:false;
	var is167Available = (intLensH >= 29 || intLensH == 0 || intIsSemirimlessProgAvailable)?true:false;
	var isPrecisionAvailable = (intLensH >= 26 || intLensH == 0 || intIsSemirimlessProgAvailable)?true:false;
	
	if(strType == 'GIA' && isGIAAvailable){
		return true;
	}else if(strType == 'Appolosoft' && isAppolosoftAvailable){
		return true;
	}else if(strType == 'GN' && isGNAvailable){
		return true;
	}else if(strType == '167' && is167Available){
		return true;
	}else if(strType == 'Precision' && isPrecisionAvailable){
		return true;
	}else{
		return false;
	}
}

function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
	el.flt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/4;
		this.cy += (pY + this.sy - this.cy)/4;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.flt()", 40);
	}
	return el;
}
window.onload = function(){
	validate("purpose");
	//setRimless('Original');
	//var objColor = document.getElementById("fcolor");
	//if(objColor.selectedIndex == 0){
	//	selectFrameColor(objColor.options[1].value,objColor.options[1].getAttribute("rel"),objColor.options[1].getAttribute("dir"));	
	//}else{
	//	selectFrameColor(objColor.options[objColor.selectedIndex].value,objColor.options[objColor.selectedIndex].getAttribute("rel"),objColor.options[objColor.selectedIndex].getAttribute("dir"));
	//}
	swap();
	JSFX_FloatDiv("section_pricing", -35 , 180).flt();
	document.getElementById('section_pricing').style.display = '';
	if(document.getElementById("div_rimless_group") != null){
		setRimless(document.getElementById("shape").value);
	}
}
function setEyeglass(strEyeglass){
	var me = thisMovie("objEyeglasses");
	if(me != null){
		//alert(document.getElementById("rowFlash").style.display);
		if(document.getElementById("rowFlash").style.display == 'none'){
			if(document.getElementById("divLinkFlash") != null){
				showFlash();
			}
			setTimeout("setEyeglass('" + strEyeglass + "');",500);
		}else{
			me.setEyeglass(strEyeglass,0,0,0,0,0,0,0);
		}
		
	}
}

var strLastName = "";
function setFace(strName){
	var me = thisMovie("objEyeglasses");
	if(me != null){
		var objFace = arrFace[strName];
		var intWidth = objFace.intWidth;
		var intHeight = objFace.intHeight;
		var intX = objFace.intX;
		var intY = objFace.intY;
		var intCenterX = objFace.intCenterX;
		var intCenterY = objFace.intCenterY;
		var intRotation = objFace.intRotation;
		if(strName != strLastName){
			new Ajax.Request('/util/saveImage.cgi?face=' + strName + '&r=' + Math.round(Math.random() * 100),
			{
				method:'get',
				onSuccess: function(transport){
					//var response = transport.responseText || "no response text";
				},
				onFailure: function(){
					alert('AJAX Error Occur.')
				}
			});
		}
		strLastName = strName;
		me.setFace('./ForbiddenParadise/' + strName,intWidth,intHeight,intX,intY,intCenterX,intCenterY,intRotation);
	}
}

function setSampleFace(strName,intWidth,intHeight,intX,intY,intCenterX,intCenterY,intRotation){
	var me = thisMovie("objEyeglasses");
	if(me != null){
		me.setFace(strName,intWidth,intHeight,intX,intY,intCenterX,intCenterY,intRotation);
	}
}
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}
function getElementsByName_iefix(tag, name) {
	var elem = document.getElementsByTagName(tag);
	var arr = new Array();
	for(i = 0,iarr = 0; i < elem.length; i++) {
		att = elem[i].getAttribute("name");
		if(att == name) {
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	return arr;
}
function validate(strFrom){
	updategroup("framesize");
	updategroup("Lenuse");
	updategroup("Lens");
	updategroup("edge");
	updategroup("OSprism");
	updategroup("ODprism");
	
	var arrDiv = getElementsByName_iefix("div","check_required");
	for(var i = arrDiv.length - 1 ; i >= 0  ; i--){
		if(arrDiv[i].getAttribute("rel") != ""){
			eval(arrDiv[i].getAttribute("rel"));
		}
	}
	setTimeout('updategroup("radcoat");',0);
	setTimeout('updategroup("Lens");',5);
	setTimeout('updategroup("lenscolor");',10);
	setTimeout('updategroup("mirror");',15);
	setTimeout('updategroup("clipon");',20);
	setTimeout('updategroup("clipon2");',25);
	
	//show unavailable message
	if(	hashGroup["156"] == 0 &&
		hashGroup["Polycarbonate"] == 0 &&
		hashGroup["167"] == 0 &&
		hashGroup["174"] == 0 && 
		hashGroup["Myodisc_Plastic"] == 0){
		showUnavailable("plastic_lens");
	}else{
		showAvailable("plastic_lens");
	}
	
	if(	hashGroup["180"] == 0 &&
		hashGroup["190"] == 0 &&
		hashGroup["Myodisc_Glasses"] == 0){
		showUnavailable("mineral_lens");
	}else{
		showAvailable("mineral_lens");
	}
	
	if(	hashGroup["Transition_Color"] == 0){
		showUnavailable("transition");
	}else{
		showAvailable("transition");
	}
	
	if(	hashGroup["Bifocal"] == 0 &&
		hashGroup["Appolosoft"] == 0 &&
		hashGroup["156_GN"] == 0 &&
		hashGroup["Polycarb_Progressive"] == 0 &&
		hashGroup["167_GN"] == 0){
		showUnavailable("normal_lens");
	}else{
		showAvailable("normal_lens");
	}
	
	if(	hashGroup["Precision_150"] == 0 &&
		hashGroup["Precision_SAFEwear"] == 0 &&
		hashGroup["Precision_167"] == 0 &&
		hashGroup["Precision_polarize"] == 0){
		showUnavailable("progressive_lens");
	}else{
		showAvailable("progressive_lens");
	}
	
	if(	hashGroup["GN_Transition_Grey"] == 0){
		showUnavailable("multi_focal_transition");
	}else{
		showAvailable("multi_focal_transition");
	}
	
	if(	hashGroup["GN_Precision_156"] == 0){
		showUnavailable("GN_Precision_156");
	}else{
		showAvailable("GN_Precision_156");
	}
	
	if(	hashGroup["GN_Precision_167"] == 0){
		showUnavailable("GN_Precision_167");
	}else{
		showAvailable("GN_Precision_167");
	}

	
	if(strFrom == "purpose"){
		$('lblErrorUseage').innerHTML = "";
		$('section_prescription').style.display = 'none';
		$('section_lens_option').style.display = 'none';
		$('section_tinting').style.display = 'none';
		$('section_remark').style.display = 'none';
		
		if(document.getElementById("distance_purpose_checkbox").checked == true){
			document.getElementById("form_Lenuse").value = "Distance";	
		}else if(document.getElementById("reading_purpose_checkbox").checked == true){
			document.getElementById("form_Lenuse").value = "Reading";
		}else if(document.getElementById("progressive_purpose_checkbox").checked == true){
			document.getElementById("form_Lenuse").value = "Progressive";
		}else if(document.getElementById("nolens_purpose_checkbox").checked == true){
			document.getElementById("form_Lenuse").value = "Nolens";
			if(document.getElementById("div_rimless_group") != null){
				if(document.getElementById("shape").value != "Original"){
					alert("Sorry, you cannot customize lens shape if you order frame only.");
					setRimless("Original");
				}
			}
		}
	}else if(strFrom == "prescription"){
		$('lblProfileStatus').innerHTML = '';
		$('section_lens_option').style.display = 'none';
		$('section_tinting').style.display = 'none';
		$('section_remark').style.display = 'none';
	}else if(strFrom == "lens_option"){
		$('section_tinting').style.display = 'none';
		$('section_remark').style.display = 'none';
	}
	
}
function showAvailable(strID){
	document.getElementById("div_no_" + strID).style.display = 'none';
}
function showUnavailable(strID){
	document.getElementById("div_no_" + strID).style.display = 'block';
}
function check_reading_purpose(){
	var objReadingCheckbox = document.getElementById("reading_purpose_checkbox");
	var objDistanceCheckbox = document.getElementById("distance_purpose_checkbox");
	if(objReadingCheckbox.checked == true || objDistanceCheckbox.checked == true){
		document.getElementById("reading_purpose").style.display = '';
	}else{
		document.getElementById("reading_purpose").style.display = 'none';
	}
}
function check_bifocal_purpose(){
	var objCheckbox = document.getElementById("progressive_purpose_checkbox");
	if(objCheckbox.checked == true){
		document.getElementById("bifocal_purpose").style.display = '';
	}else{
		document.getElementById("bifocal_purpose").style.display = 'none';
	}
}
function hide(strID){
	document.getElementById(strID).style.display = 'none';
	if(document.getElementById(strID).getElementsByTagName("input")[0].checked == true){
		document.getElementById("radUnselected").checked = true;
	}
}
function hideTinting(strID){
	document.getElementById(strID).style.display = 'none';
	if(strID == "div_radcoat"){
		$('input_radcoat').checked = false;
	}else{
		$('input_clear').checked = true;
	}
	
	
}
function show(strID){
	$(strID).style.display = '';
}
function isBifocalPurpose(){
	var objCheckbox = document.getElementById("progressive_purpose_checkbox");
	return objCheckbox.checked;
}
function isSinglePurpose(){
	var objReadingCheckbox = document.getElementById("reading_purpose_checkbox");
	var objDistanceCheckbox = document.getElementById("distance_purpose_checkbox");
	if(objReadingCheckbox.checked == true || objDistanceCheckbox.checked == true){
		return true;
	}else{
		return false;
	}
}
var hashGroup = new Array();




function check_Bifocal(progressive){

	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -10 || intODSphere > 8 || intOSSphere < -10 || intOSSphere > 8){
		hashGroup["Bifocal"] = 0;
		hide("Bifocal");
	}else{
		if(isBifocalPurpose()){
			hashGroup["Bifocal"] = 1;
			show("Bifocal");
		}else{
			hashGroup["Bifocal"] = 0;
			hide("Bifocal");
		}
	}
}
function check_Appolosoft(progressive){
	if(checkAvailable('Appolosoft')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -10 || intODSphere > 8 || intOSSphere < -10 || intOSSphere > 8){
			hashGroup["Appolosoft"] = 0;
			hide("Appolosoft");
		}else{
			if(isBifocalPurpose()){
				hashGroup["Appolosoft"] = 1;
				show("Appolosoft");
			}else{
				hashGroup["Appolosoft"] = 0;
				hide("Appolosoft");
			}
		}
	}else{
		hashGroup["Appolosoft"] = 0;
		hide("Appolosoft");
	}

}


function check_156_GN(progressive2){
	if(checkAvailable('GN')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
		
		if(intODSphere < -9 || intODSphere > 6 || intOSSphere < -9 || intOSSphere > 6){
			hashGroup["156_GN"] = 0;
			hide("156_GN");
		}else{
			if(isBifocalPurpose()){
				hashGroup["156_GN"] = 1;
				show("156_GN");
			}else{
				hashGroup["156_GN"] = 0;
				hide("156_GN");
			}
		}
	}else{
		hashGroup["156_GN"] = 0;
		hide("156_GN");
	}

}
function check_Polycarb_Progressive(progressive3){
	if(checkAvailable('GIA')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -7 || intODSphere > 6 || intOSSphere < -7 || intOSSphere > 6){
			hashGroup["Polycarb_Progressive"] = 0;
			hide("Polycarb_Progressive");
		}else{
			if(isBifocalPurpose()){
				hashGroup["Polycarb_Progressive"] = 1;
				show("Polycarb_Progressive");
			}else{
				hashGroup["Polycarb_Progressive"] = 0;
				hide("Polycarb_Progressive");
			}
		}
	}else{
		hashGroup["Polycarb_Progressive"] = 0;
		hide("Polycarb_Progressive");
	}
}
function check_167_GN(progressive3){
	if(checkAvailable('167')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -15 || intODSphere > 8 || intOSSphere < -15 || intOSSphere > 8){
			hashGroup["167_GN"] = 0;
			hide("167_GN");
		}else{
			if(isBifocalPurpose()){
				hashGroup["167_GN"] = 1;
				show("167_GN");
			}else{
				hashGroup["167_GN"] = 0;
				hide("167_GN");
			}
		}
	}else{
		hashGroup["167_GN"] = 0;
		hide("167_GN");
	}
}

/*
##  Precision_150 :  intODSphere < -8 || intODSphere > 7.75 
## Precision_SAFEwear :intODSphere < -8 || intODSphere > 5.5
## precisionprog167 : intODSphere < -10 || intODSphere > 10 
## precisionprogpolarize : intODSphere < -8 || intODSphere > 5.5 
## precisionprogtrans150 : intODSphere < -8 || intODSphere > 5.5
## precisionprogtrans167 : intODSphere < -10.5 || intODSphere > 6
##
##
##
*/

function check_Precision_150(precisionprog150){
	if(checkAvailable('Precision')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -8 || intODSphere > 7.75 || intOSSphere < -8 || intOSSphere > 7.75){
			hashGroup["Precision_150"] = 0;
			hide("Precision_150");
		}else{
			if(isBifocalPurpose()){
				hashGroup["Precision_150"] = 1;
				show("Precision_150");
			}else{
				hashGroup["Precision_150"] = 0;
				hide("Precision_150");
			}
		}
	}else{
		hashGroup["Precision_150"] = 0;
		hide("Precision_150");
	}
}
function check_Precision_SAFEwear(precisionprogsafewear){
	if(checkAvailable('Precision')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -8 || intODSphere > 5.5 || intOSSphere < -8 || intOSSphere > 5.5){
			hashGroup["Precision_SAFEwear"] = 0;
			hide("Precision_SAFEwear");
		}else{
			if(isBifocalPurpose()){
				hashGroup["Precision_SAFEwear"] = 1;
				show("Precision_SAFEwear");
			}else{
				hashGroup["Precision_SAFEwear"] = 0;
				hide("Precision_SAFEwear");
			}
		}
	}else{
		hashGroup["Precision_SAFEwear"] = 0;
		hide("Precision_SAFEwear");
	}
}
function check_Precision_167(precisionprog167){
	if(checkAvailable('Precision')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -10 || intODSphere > 10 || intOSSphere < -10 || intOSSphere > 10){
			hashGroup["Precision_167"] = 0;
			hide("Precision_167");
		}else{
			if(isBifocalPurpose()){
				hashGroup["Precision_167"] = 1;
				show("Precision_167");
			}else{
				hashGroup["Precision_167"] = 0;
				hide("Precision_167");
			}
		}
	}else{
		hashGroup["Precision_167"] = 0;
		hide("Precision_167");
	}
}
function check_Precision_polarize(precisionprogpolarize){
	if(checkAvailable('Precision')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -8 || intODSphere > 5.5 || intOSSphere < -8 || intOSSphere > 5.5){
			hashGroup["Precision_polarize"] = 0;
			hide("Precision_polarize");
		}else{
			if(isBifocalPurpose()){
				hashGroup["Precision_polarize"] = 1;
				show("Precision_polarize");
			}else{
				hashGroup["Precision_polarize"] = 0;
				hide("Precision_polarize");
			}
		}
	}else{
		hashGroup["Precision_polarize"] = 0;
		hide("Precision_polarize");
	}
}
function check_GN_Transition_Grey(solamaxtrans){
	if(checkAvailable('GN')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -9 || intODSphere > 6 || intOSSphere < -9 || intOSSphere > 6){
			hashGroup["GN_Transition_Grey"] = 0;
			hide("GN_Transition_Grey");
		}else{
			if(isBifocalPurpose()){
				hashGroup["GN_Transition_Grey"] = 1;
				show("GN_Transition_Grey");
			}else{
				hashGroup["GN_Transition_Grey"] = 0;
				hide("GN_Transition_Grey");
			}
		}
	}else{
		hashGroup["GN_Transition_Grey"] = 0;
		hide("GN_Transition_Grey");
	}
}
function check_GN_Precision_156(precisionprogtrans150){
	if(checkAvailable('Precision')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -8 || intODSphere > 5.5 || intOSSphere < -8 || intOSSphere > 5.5){
			hashGroup["GN_Precision_156"] = 0;
			hide("GN_Precision_156");
		}else{
			if(isBifocalPurpose()){
				hashGroup["GN_Precision_156"] = 1;
				show("GN_Precision_156");
			}else{
				hashGroup["GN_Precision_156"] = 0;
				hide("GN_Precision_156");
			}
		}
	}else{
		hashGroup["GN_Precision_156"] = 0;
		hide("GN_Precision_156");
	}
}
function check_GN_Precision_167(precisionprogtrans167){
	if(checkAvailable('Precision')){
		var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
		var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	
		if(intODSphere < -10.5 || intODSphere > 6 || intOSSphere < -10.5 || intOSSphere > 6){
			hashGroup["GN_Precision_167"] = 0;
			hide("GN_Precision_167");
		}else{
			if(isBifocalPurpose()){
				hashGroup["GN_Precision_167"] = 1;
				show("GN_Precision_167");
			}else{
				hashGroup["GN_Precision_167"] = 0;
				hide("GN_Precision_167");
			}
		}
	}else{
		hashGroup["GN_Precision_167"] = 0;
		hide("GN_Precision_167");
	}
}



function check_156(){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);
	var intOSAdd = isNaN(parseFloat(document.getElementById("OSAdd").value))?0:parseFloat(document.getElementById("OSAdd").value);
	var intODAdd = isNaN(parseFloat(document.getElementById("ODAdd").value))?0:parseFloat(document.getElementById("ODAdd").value);

	//if(document.getElementById("reading_purpose_checkbox").checked == true){
	//var intOSTotal=intOSSphere+intOSAdd;
	//var intODTotal=intODSphere+intODAdd;
	//}else{
	var intOSTotal=intOSSphere;
	var intODTotal=intODSphere;
	//}	
	

	if(intODTotal < -5 || intODTotal > 4 || intOSTotal < -5 || intOSTotal > 4){
		hashGroup["156"] = 0;
		hide("156");
	}else{
		//if(intOSTotal < -6 || intOSTotal > 4 || intODTotal < -6 || intODTotal > 4){
		//	$("input_156").setAttribute("rel",35);
		//}else{
			$("input_156").setAttribute("rel",0);
		//}
		if(isSinglePurpose()){
			hashGroup["156"] = 1;
			show("156");
		}else{
			hashGroup["156"] = 0;
			hide("156");
		}
		
	}
}
function check_Polycarbonate(polysingle,betterpolysingle){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -14 || intODSphere > 8.5 || intOSSphere < -14 || intOSSphere > 8.5){
		hashGroup["Polycarbonate"] = 0;
		hide("Polycarbonate");
	}else{
		if(intODSphere < -7.75 || intODSphere > 1.75 || intOSSphere < -7.75 || intOSSphere > 1.75){
			$('input_Polycarbonate').setAttribute("rel",(polysingle + betterpolysingle));
		}else{
			$('input_Polycarbonate').setAttribute("rel",polysingle);
		}
		if(isSinglePurpose()){
			hashGroup["Polycarbonate"] = 1;
			show("Polycarbonate");
		}else{
			hashGroup["Polycarbonate"] = 0;
			hide("Polycarbonate");
		}
		
	}
}
function check_167(betterlens,higherplus167,higher167){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -17 || intODSphere > 13 || intOSSphere < -17 || intOSSphere > 13){
		hashGroup["167"] = 0;
		hide("167");
	}else{
		if(intODSphere > 10 && intODSphere < 13 || intOSSphere > 10 && intOSSphere < 13){
			$('input_167').setAttribute("rel",( betterlens + higher167 ));
		}else if(intODSphere > 8 || intODSphere < -10 || intOSSphere > 8 || intOSSphere < -10){
			$('input_167').setAttribute("rel",( betterlens + higherplus167 ));
		}else{
			$('input_167').setAttribute("rel", betterlens );
		}
		if(isSinglePurpose()){
			hashGroup["167"] = 1;
			show("167");
		}else{
			hashGroup["167"] = 0;
			hide("167");
		}
		
	}
}
function check_174(super174){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -18 || intODSphere > 1 || intOSSphere < -18 || intOSSphere > 1){
		hashGroup["174"] = 0;
		hide("174");
	}else{
		if(isSinglePurpose()){
			hashGroup["174"] = 1;
			show("174");
		}else{
			hashGroup["167"] = 0;
			hide("174");
		}
		
	}
}
function check_Myodisc_Plastic(myodisc2){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if((intODSphere > 5 && intODSphere <= 20) || (intOSSphere > 5 && intOSSphere <= 20)){
		if(isSinglePurpose()){
			hashGroup["Myodisc_Plastic"] = 1;
			show("Myodisc_Plastic");
		}else{
			hashGroup["Myodisc_Plastic"] = 0;
			hide("Myodisc_Plastic");
		}
	}else{
		hashGroup["Myodisc_Plastic"] = 0;
		hide("Myodisc_Plastic");
		
	}
}
function check_180(betterlens2){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -20 || intODSphere > 7.5 || intOSSphere < -20 || intOSSphere > 7.5){
		hashGroup["180"] = 0;
		hide("180");
	}else{
		if(isSinglePurpose()){
			hashGroup["180"] = 1;
			show("180");
		}else{
			hashGroup["180"] = 0;
			hide("180");
		}
		
	}
}
function check_190(betterlens3){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -25 || intODSphere > 0 || intOSSphere < -25 || intOSSphere > 0){
		hashGroup["190"] = 0;
		hide("190");
	}else{
		if(isSinglePurpose()){
			hashGroup["190"] =1;
			show("190");
		}else{
			hashGroup["190"] = 0;
			hide("190");
		}
		
	}
}
function check_Myodisc_Glasses(myodisc){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if((intODSphere > -40 && intODSphere < -10) || (intOSSphere > -40 && intOSSphere < -10)){
		
		if(isSinglePurpose()){
			hashGroup["Myodisc_Glasses"] = 1;
			show("Myodisc_Glasses");
		}else{
			hashGroup["Myodisc_Glasses"] = 0;
			hide("Myodisc_Glasses");
		}
	}else{
		hashGroup["Myodisc_Glasses"] = 0;
		hide("Myodisc_Glasses");
		
	}
}
function check_Transition_Color(trans1,trans2,spherichigher){
	var intOSSphere = isNaN(parseFloat(document.getElementById("OSSphere").value))?0:parseFloat(document.getElementById("OSSphere").value);
	var intODSphere = isNaN(parseFloat(document.getElementById("ODSphere").value))?0:parseFloat(document.getElementById("ODSphere").value);

	if(intODSphere < -10 || intODSphere > 6 || intOSSphere < -10 || intOSSphere > 6){
		hashGroup["Transition_Color"] = 0;
		hide("Transition_Color");
	}else{
		if(intODSphere < -5 || intODSphere > 2 || intOSSphere < -5 || intOSSphere > 2){
			$('input_Transition_Grey(1.56)').setAttribute("rel",(trans1 + spherichigher));
			$('input_Transition_Brown(1.56)').setAttribute("rel",(trans1 + spherichigher));
			$('input_Transition_Blue(1.56)').setAttribute("rel",(trans2 + spherichigher));
			$('input_Transition_Purple(1.56)').setAttribute("rel",(trans2 + spherichigher));
			$('input_Transition_Green(1.56)').setAttribute("rel",(trans2 + spherichigher));
			$('input_Transition_Red(1.56)').setAttribute("rel",(trans2 + spherichigher));
			$('input_Transition_Orange(1.56)').setAttribute("rel",(trans2 + spherichigher));
		}else{
			$('input_Transition_Grey(1.56)').setAttribute("rel",trans1);
			$('input_Transition_Brown(1.56)').setAttribute("rel",trans1);
			$('input_Transition_Blue(1.56)').setAttribute("rel",trans2);
			$('input_Transition_Purple(1.56)').setAttribute("rel",trans2);
			$('input_Transition_Green(1.56)').setAttribute("rel",trans2);
			$('input_Transition_Red(1.56)').setAttribute("rel",trans2);
			$('input_Transition_Orange(1.56)').setAttribute("rel",trans2);
			
		}
		
		if(isSinglePurpose()){
			hashGroup["Transition_Color"] = 1;
			show("Transition_Color");
		}else{
			hashGroup["Transition_Color"] = 0;
			hide("Transition_Color");
		}
		
	}
}
function check_div_radcoat(){

	switch (hashSelected["Lens"]){
		case '156':
		case '167':
		case 'Myodisc_Plastic':
		case 'Bifocal':
		case 'APPOLO_SOFT':
		case 'SOLAMAX':
		case '1.56_GN':
		case '1.67_GN':		
		case '180':
		case '190':
		case 'Myodisc_Glasses':
		case 'Transition_Grey(1.56)':
		case 'Transition_Brown(1.56)':
		case 'Transition_Blue(1.56)':
		case 'Transition_Purple(1.56)':
		case 'Transition_Green(1.56)':
		case 'Transition_Red(1.56)':
		case 'Transition_Orange(1.56)':
		case 'Appolosoft_Transition_Grey':
		case 'Solamax_Transition_Grey':
		case 'GN_Transition_Grey':
		{show("div_radcoat");}
		break;
		
		case '174':
		case 'Precision_150':
		case 'Precision_160':
		case 'Precision_167':
		case 'Precision_SAFEwear':
		case 'Precision_polarize_grey':
		case 'Precision_polarize_brown':
		case 'Precision_polarize_green':
		case 'Precision_156_grey':
		case 'Precision_156_brown':
		case 'Precision_167_grey':
		case 'Precision_167_brown':
		case 'Polycarbonate':
		case 'Polycarb_Progressive':
		{hideTinting("div_radcoat");}
		break;
	}
}
function check_div_mirror(intOriginalPrice){
	switch (hashSelected["Lens"]){
		case '174':
		case 'Precision_150':
		case 'Precision_160':
		case 'Precision_167':
		case 'Precision_SAFEwear':
		case 'Precision_polarize_grey':
		case 'Precision_polarize_brown':
		case 'Precision_polarize_green':
		case 'Precision_156_grey':
		case 'Precision_156_brown':
		case 'Precision_167_grey':
		case 'Precision_167_brown':
		case 'Polycarbonate':
		case 'Polycarb_Progressive':
		case 'Transition_Grey(1.56)':
		case 'Transition_Brown(1.56)':
		case 'Transition_Blue(1.56)':
		case 'Transition_Purple(1.56)':
		case 'Transition_Green(1.56)':
		case 'Transition_Red(1.56)':
		case 'Transition_Orange(1.56)':
		case 'Appolosoft_Transition_Grey':
		case 'Solamax_Transition_Grey':
		case 'GN_Transition_Grey':
		{
			hideMirror();
			$('div_tinting_extra').style.display = 'none';
		}
		break;
		
		case '180':
		case '190':
		case 'Myodisc_Glasses':
		case '156':
		case '167':
		case 'Myodisc_Plastic':
		case 'Bifocal':
		case 'APPOLO_SOFT':
		case 'SOLAMAX':
		case '1.56_GN':
		case '1.67_GN':
		{
			showMirror();
			$('div_tinting_extra').style.display = '';
		}
		break;
	}
	
	//if(hashSelected["Lens"] == '167'){
	//	$('input_mirror').setAttribute("rel",intOriginalPrice + intAdditionalPrice);
	//}else{
	//	$('input_mirror').setAttribute("rel",intOriginalPrice);
	//}
}
function showMirror(){
	$('div_mirror').style.display = '';
}
function hideMirror(){
	$('div_mirror').style.display = 'none';
}
var isShowClearTintingOption = false;
function check_div_tinting(){
	switch (hashSelected["Lens"]){
		case '156':
		case '167':
		case 'Myodisc_Plastic':
		case 'Bifocal':
		case 'APPOLO_SOFT':
		case 'SOLAMAX':
		case '1.56_GN':
		case '1.67_GN':
		{
			show("div_tinting_normal");
			hideTinting("div_tinting_brown");
			show("div_clear_tinting");
			isShowClearTintingOption = true;
		}
		break;
		
		case '180':
		case '190':
		case 'Myodisc_Glasses':
		{
			hideTinting("div_tinting_normal");
			show("div_tinting_brown");
			show("div_clear_tinting");
			isShowClearTintingOption = true;
		}
		break;
		
		case 'Transition_Grey(1.56)':
		case 'Transition_Brown(1.56)':
		case 'Transition_Blue(1.56)':
		case 'Transition_Purple(1.56)':
		case 'Transition_Green(1.56)':
		case 'Transition_Red(1.56)':
		case 'Transition_Orange(1.56)':
		case 'Appolosoft_Transition_Grey':
		case 'Solamax_Transition_Grey':
		case 'GN_Transition_Grey':	
		case '174':
		case 'Precision_150':
		case 'Precision_160':
		case 'Precision_167':
		case 'Precision_SAFEwear':
		case 'Precision_polarize_grey':
		case 'Precision_polarize_brown':
		case 'Precision_polarize_green':
		case 'Precision_156_grey':
		case 'Precision_156_brown':
		case 'Precision_167_grey':
		case 'Precision_167_brown':
		case 'Polycarbonate':
		case 'Polycarb_Progressive':
		{
			hideTinting("div_tinting_normal");
			hideTinting("div_tinting_brown");
			hideTinting("div_clear_tinting");
			isShowClearTintingOption = false;
		}
		break;
	}
}
function getTotalPrice(){
	var intTotalPrice = 0;
	var strItemDetail = "";
	var arrGroup = document.getElementsByTagName("input");
	arrSelectGroup = document.getElementsByTagName("select");
	
	for(var i = 0 ; i < arrGroup.length ; i++){
		var objInput = arrGroup[i];
		if(objInput.checked == true){
			if(objInput.getAttribute("rel") != null && objInput.getAttribute("rel") != ""){
				//ignore clear tinting options
				if(objInput.getAttribute("name") == "lenscolor" && objInput.value == "clear"){
					if(isShowClearTintingOption){
						strItemDetail += "<b>" + objInput.getAttribute("name") + ": </b><br/>" + objInput.value + ", $" + objInput.getAttribute("rel") + " USD<br/>\n";
						intTotalPrice += parseFloat(objInput.getAttribute("rel"));
					}
				}else{
					strItemDetail += "<b>" + objInput.getAttribute("name") + ": </b><br/>" + objInput.value + ", $" + objInput.getAttribute("rel") + " USD<br/>\n";
					intTotalPrice += parseFloat(objInput.getAttribute("rel"));
				}

			}
		}
	}
	for(i = 0 ; i < arrSelectGroup.length ; i++){
		var objSelect = arrSelectGroup[i];
		if(objSelect.getAttribute("rel") != null && objSelect.getAttribute("rel") != "" && objSelect.value > 0){
			var intSelect = parseFloat(objSelect.getAttribute("rel"));
			intSelect = intSelect * parseFloat(objSelect.value);
			intTotalPrice += intSelect;
			if(objSelect.name == "ODprism" || objSelect.name == "OSprism"){
				strItemDetail += "<b>" + objSelect.name + ":</b><br/>" + objSelect.value + ", $" + intSelect + " USD<br/>\n";
			}else{
				strItemDetail += "<b>" + objSelect.name + ":</b><br/>" + objSelect.value + " item(s), $" + intSelect + " USD<br/>\n";
			}
			
		}
	}
	if($('ODCylinder').value > 2.75 || $('OSCylinder').value > 2.75 || $('ODCylinder').value < -2.75 || $('OSCylinder').value < -2.75){
		//add $ 59 USD
		intTotalPrice += parseFloat(59);
		if($('ODCylinder').value > 2.75 || $('OSCylinder').value > 2.75 ){
			strItemDetail += "<b>Cylindar :</b><br/>&gt; 2.75, $59 USD\n";
		}else{
			strItemDetail += "<b>Cylindar :</b><br/>&st; 2.75, $59 USD\n";
		}
		
	}

	$('div_pricing_detail').innerHTML = strItemDetail;
	$('div_pricing').innerHTML = "<hr/>Total : $" + intTotalPrice + " USD";
}
function updategroup(strGroupName){
	//20080313 adding tinting extra price
	if(strGroupName == "lenscolor" || strGroupName == "mirror"){
		var obj167 = $('input_167');
		var objClearTinting = $('input_clear');
		var objMirror = $('input_mirror');
		if((objMirror.checked == true || objClearTinting.checked != true) && obj167.checked == true){
			document.getElementById("tinting_extra").checked = true;
		}else{
			document.getElementById("tinting_extra").checked = false;
		}
	}
	
	
	var intSelectedPrice = 0;

	arrGroup = getElementsByName_iefix("input",strGroupName);
	arrSelectGroup = getElementsByName_iefix("select",strGroupName);
	for(i = 0 ; i < arrSelectGroup.length ; i++){
		arrGroup.push(arrSelectGroup[i]);
	}
	
	//get total price and selected price
	for(var i = 0 ; i < arrGroup.length ; i++){
		var objInput = arrGroup[i];

		if(objInput.tagName == "INPUT"){
			if(objInput.checked == true && objInput.value != ""){
				if(objInput.parentNode != null){
					objInput.parentNode.parentNode.style.backgroundColor = "#FACABE";
				}
				if((objInput.getAttribute("rel") == null || objInput.getAttribute("rel") == "") && objInput.getAttribute("rel") != 0){
					intSelectedPrice = -1;
				}else{
					intSelectedPrice = parseFloat(objInput.getAttribute("rel"));
					hashSelected[strGroupName] = objInput.value;
				}
				
			}else{
				if(objInput.parentNode != null){
					objInput.parentNode.parentNode.style.backgroundColor = "";
				}
			}
		
		}else if(objInput.tagName == "SELECT"){
			if(objInput.value > 0){
				if(objInput.parentNode != null){
					objInput.parentNode.parentNode.style.backgroundColor = "#FACABE";
				}
				//intSelectedPrice = parseFloat(objInput.getAttribute("rel")) * parseFloat(objInput.value);
				//hashSelected[strGroupName] = intSelectedPrice;
				intSelectedPrice = parseFloat(objInput.getAttribute("rel"));
				hashSelected[strGroupName] = objInput.value;
			}else{
				intSelectedPrice = 0;
				if(objInput.parentNode != null){
					objInput.parentNode.parentNode.style.backgroundColor = "";
				}
			}
		}
		
	}
	if(intSelectedPrice >= 0){
		for(var i = 0 ; i < arrGroup.length ; i++){
			
			var objInput = arrGroup[i];
			if(objInput.value != ""){
				var intPrice = parseFloat(objInput.getAttribute("rel"));
				var strPrice = "";
				if((intPrice - intSelectedPrice) > 0){
					strPrice += " [ + $ " + (intPrice - intSelectedPrice) + " ]";
				}else if((intPrice - intSelectedPrice) == 0){
					if(objInput.value != hashSelected[strGroupName] && strGroupName != 'lenscolor' && !checkIsGroup(strGroupName + '_' + objInput.value)){
						strPrice += " [ + $ 0 ]";
					}
					
				}else{
					strPrice += " [ - $ " + Math.abs(intPrice - intSelectedPrice) + " ]";
				}
				if(objInput.tagName == "SELECT"){
					if(document.getElementById("chk_select_" + strGroupName) != null){
						document.getElementById("chk_select_" + strGroupName).innerHTML = strPrice;
					}
				}else{
					if(document.getElementById("chk_" + strGroupName + "_" + objInput.value) != null){
						document.getElementById("chk_" + strGroupName + "_" + objInput.value).innerHTML = strPrice;
					}
				}
			}
		}
	}

	getTotalPrice();
}
function checkIsGroup(strValue){
	switch(strValue){
		case 'Lens_Precision_polarize_grey':
		case 'Lens_Precision_polarize_brown':
		case 'Lens_Precision_polarize_green':
		
		case 'Lens_GN_Transition_Grey':
		
		case 'Lens_Precision_156_grey':
		case 'Lens_Precision_156_brown':
		case 'Lens_Precision_167_grey':
		case 'Lens_Precision_167_brown':
		
		case 'Lens_Transition_Grey(1.56)':
		case 'Lens_Transition_Brown(1.56)':
		case 'Lens_Transition_Blue(1.56)':
		case 'Lens_Transition_Purple(1.56)':
		case 'Lens_Transition_Green(1.56)':
		case 'Lens_Transition_Red(1.56)':
		case 'Lens_Transition_Orange(1.56)':
		
		case 'edge_Clear':
		case 'edge_Red':
		case 'edge_Pink':
		case 'edge_Orange':
		case 'edge_Green':
		case 'edge_Light_blue':
		case 'edge_Violet_blue':
			return true;
			break;
		default:
			return false;
			break;
	}
	
}
function changeImage(strPath){
	document.getElementById("divBigImage").src = strPath;
	return false;
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
var lastLink = null;
var lastName = "";
var lastOD = 0;
var lastOS = 0;
function getContent(strName,objLink){
	var objPrescription = document.getElementById("section_prescription");
	
	var arrPos = findPos(objLink);
	var intLeft = 0;
	
	if(objPrescription.style.display != "none"){
		var arrPos_Prescription = findPos(objPrescription);
		var intLeft = arrPos_Prescription[0];		
	}else{
		var intLeft = arrPos[0] - 500;
	}
	if(intLeft < 0){
		intLeft = 100;
	}
	var intTop = arrPos[1] + 20;
	
	var objInfoBox = document.getElementById("divInfoBox");
	var objInfoBoxContent = document.getElementById("divContent");
	var objDivTitle = document.getElementById("divTitle");
	
	var intOD = document.getElementById("ODSphere").value;
	var intOS = document.getElementById("OSSphere").value;

	if(lastLink == objLink && lastName == strName && intOS == lastOS && intOD == lastOD){
		showHideBox(objInfoBox);
	}else{
		objDivTitle.innerHTML = "";
		objInfoBoxContent.innerHTML = "";
		
		objInfoBox.style.visibility = "visible";
		
		objInfoBox.style.left = intLeft + 'px';
		objInfoBox.style.top = intTop + 'px';
		

		
		new Ajax.Request("./php/lens_detail.php",
		{
			method:'get',
			parameters: {type: strName, od: intOD , os: intOS},
			onSuccess: function(transport){
				var response = transport.responseText || "no response text"
	  			objInfoBoxContent.innerHTML = response;
	  			//objDivTitle.innerHTML = strName;
	  			lastName = strName;
	  			lastOD = intOD;
				lastOS = intOS;
				lastLink = objLink;
			},
			onFailure: function(){
				alert('Error Occur , Please contact developer.')
			}
		});
		
	}
	return false;
	
}
function showProfileBox(strContent){
	var objProfileBox = document.getElementById("divProfileBox");
	var objWearerName = document.getElementById("wearername");
	
	var arrPos = findPos(objWearerName);
	var intLeft = arrPos[0];
	var intTop = arrPos[1] + 23;
	
	objProfileBox.style.left = intLeft + 'px';
	objProfileBox.style.top = intTop + 'px'; 
	objProfileBox.innerHTML = strContent;
	objProfileBox.style.visibility = "visible";
	return false;
}
function hideProfileBox(){
	if(!isProfileOn){
		document.getElementById("divProfileBox").style.visibility = "hidden";
	}
	
}
function showHideBox(objInfoBox){
	if(objInfoBox.style.visibility == "visible"){
		objInfoBox.style.visibility = "hidden";
		return false;
	}else{
		objInfoBox.style.visibility = "visible";
		return true;
	}
}
function hideBox(strID){
	document.getElementById(strID).style.visibility = "hidden";
	return false;
}
function showStep(strID){
	if(strID == "section_lens_option"){
		if(check_prescription_form()){
			if(bolSaveProfile){
				if(document.getElementById("chkSaveProfile").checked == true){
					saveProfile();
				}
				
			}
			checkAndShow(strID);
		}
	}else if(strID == "section_prescription"){
		if(check_frame_color_rimless()){
			if(document.getElementById("nolens_purpose_checkbox").checked == true){
				document.getElementById("section_remark").style.display = 'block';
			}else{
				checkAndShow(strID);
			}
		}
	}else if(strID == "section_tinting"){
		if(check_lensoption()){
			checkAndShow(strID);
		}
	}else{
		checkAndShow(strID);
	}
	return false;
}
function checkAndShow(strID){
	if(document.getElementById(strID) != null){
		document.getElementById(strID).style.display = 'block';
	}
}
function findAnchor(x){
	a = document.anchors
	for(i=0; i<a.length; i++)
	if(x==a[i].name) return a[i].name
	return a[i-1].name
}
function setPD(intPD){
	document.getElementById('PupillaryDistance').value=intPD;
	hideBox("divInfoBox");
	return false;
}
function setRimless(intRimless){
	if(document.getElementById("nolens_purpose_checkbox").checked == true){
		intRimless = 'Original';
	}
	if(document.getElementById('shape') != null){
		document.getElementById('shape').value = intRimless;
		document.getElementById('form_shape').value = intRimless;		
		document.getElementById('shape_image').src = '../pic/shape/' + intRimless + '.gif';
		document.getElementById('div_rimless_Original').className = "div_rimless_box";
		for(i = 1 ; i <= 20 ; i++){
			document.getElementById('div_rimless_' + i).className = "div_rimless_box";
		}
		document.getElementById('div_rimless_' + intRimless).className = "div_rimless_box_selected";
		hideBox("divInfoBox");
	}
	

	return false;
}
function check_section_prescription(){
	return 
	document.getElementById("distance_purpose_checkbox").checked ||
	document.getElementById("reading_purpose_checkbox").checked ||
	document.getElementById("bifocal_purpose_checkbox").checked;

}
function check_prescription_form(){
	var isPass = true;
	var isJumped = false;
	
	var wearername = document.getElementById("wearername");
	var wearerage = document.getElementById("wearerage");
	var ODCylinder = document.getElementById("ODCylinder");
	var OSCylinder = document.getElementById("OSCylinder");
	var PupillaryDistance = document.getElementById("PupillaryDistance");
	var ODSphere = document.getElementById("ODSphere");
	var OSSphere = document.getElementById("OSSphere");
	var ODAxis = document.getElementById("ODAxis");
	var OSAxis = document.getElementById("OSAxis");
	var ODAdd = document.getElementById("ODAdd");
	var OSAdd = document.getElementById("OSAdd");
	
	
	if (wearername.value == ''){
		$('lblErrorWearername').innerHTML = '* Please Enter Name';
		location.hash = findAnchor("lblErrorWearername_view");
		isPass = false;
		isJumped = true;
	}else{
		$('lblErrorWearername').innerHTML = '';
	}
	
	if (wearerage.value == ''){
		$('lblErrorWearerage').innerHTML = '* Please Enter Age';
		
		isPass = false;
		if(isJumped != true){
			location.hash = findAnchor("lblErrorWearerage_view");
		}
		isJumped = true;
	}else{
		$('lblErrorWearerage').innerHTML = '';
	}
	
	var strErrorMessage = "";
	
	if ((isBifocalPurpose())&&ODAdd.selectedIndex==0){
		strErrorMessage += ' OD ADD';
	}
	
	if ((isBifocalPurpose())&&OSAdd.selectedIndex==0){
		strErrorMessage += ', OS ADD';
	}
	
	if (ODCylinder[ODCylinder.selectedIndex].value!='-' && ODAxis[ODAxis.selectedIndex].value=='-'){
	if (ODCylinder[ODCylinder.selectedIndex].value!='D.S.' && ODCylinder[ODCylinder.selectedIndex].value!='SPH'){
		strErrorMessage += ', OD Axis';

	}}
	
	if (OSCylinder[OSCylinder.selectedIndex].value!='-' && OSAxis[document.myForm2.OSAxis.selectedIndex].value=='-')
	if (OSCylinder[OSCylinder.selectedIndex].value!='D.S.' && OSCylinder[OSCylinder.selectedIndex].value!='SPH'){
		strErrorMessage += ', OS Axis';
	}
	
	if (PupillaryDistance.value == ''){
		strErrorMessage += ', P.D.';
	}
	if(strErrorMessage != ""){
		$('lblErrorPrescription').innerHTML = "* Please enter " + strErrorMessage;
		isPass = false;
		if(isJumped != true){
			location.hash = findAnchor("lblErrorPrescription_view");
		}
		isJumped = true;
	}else{
		$('lblErrorPrescription').innerHTML = "";
	}
	
	if(!isPass){
		//end the checking for missing input
		return false;
	}
	
	
	//CHECK PD Range 50~70
	var PDValue = parseInt(PupillaryDistance.value);
	if(!(PDValue >= 50 && PDValue <= 70)){
		if(!confirm('The P.D. (Pupillary Distance) you entered is out of range of a normal size person. \nThis box comes out just to make sure you\'re making correct P.D. input\n\nYes - Continue\nNo  - Re enter')){
			return 0;
		}
	}
	
	//new ODOS warning parseInt
	//Checking Ossphere +-
	var warning = false;
	if (ODSphere.value && OSSphere.value){
		if(parseFloat(ODSphere.value) > 0){
			if(parseFloat(OSSphere.value) < 0){
				warning = true;
			}
		}else{
			if(parseFloat(OSSphere.value) > 0){
				warning = true;
			}
		}
		if(warning){
			if(!confirm('The Sphere values looks like abnormal . (One is positive and the other is negative) \nPlease double check your sphere values to see if there are any mistakes\n\nYes - Continue\nNo  - Re enter')){
				isPass = false;
			}
		}
	}
	//checking cylinder
	warning = false;
	if (ODCylinder.value && OSCylinder.value){
		if(parseFloat(ODCylinder.value) > 0){
			if(parseFloat(OSCylinder.value) < 0){
				warning = true;
			}
		}else{
			if(parseFloat(OSCylinder.value) > 0){
				warning = true;
			}
		}
		if(warning){
			if(!confirm('Your cylinder values looks like incorrect . (One is positive and the other is negative) \nPlease double check your inputs .\n\nYes - Continue\nNo  - Re enter the cylinder value')){
				isPass = false;
			}
		}
	}
	//checking axis
	warning = false;
	if (ODAxis.value && OSAxis.value){
		var ODAxisValue = parseFloat(ODAxis.value);
		var OSAxisValue = parseFloat(OSAxis.value);
		if(Math.abs(ODAxisValue + OSAxisValue - 180) > 40 && Math.abs(ODAxisValue + OSAxisValue - 180) < 130){
			warning = true;
		}
		if(warning){
			if(!confirm('Your axis value looks like abnormal. \nThere\'s only 3-4% people in the world have the Axis value like this. \nNeed a double check ?\n\nYes - Continue to order\nNo  - Re enter your axis')){
				isPass = false;
			}
		}
	}
	//Checking Add
	warning = false;
	if (ODAdd.value != OSAdd.value){
		warning = true;
	}
	if(warning){
		if(!confirm('Add values of left and right sides are not the same. What about a double check ?\n\nYes - Continue\nNo  - Re enter')){
			isPass = false;
		}
	}
	
	return isPass;
}
function check_frame_color_rimless(){
 	var isPass = true;
 	var isJumped = false;
 	var objColor = document.getElementById("fcolor");
	if(objColor.value == null || objColor.value == ""){
		isPass = false;
		
		$('lblErrorFrameColor').innerHTML = "* Please Select The Frame Color";
		location.hash = findAnchor("lblErrorFrameColor_view");
		isJumped = true;
	}
 	if(	document.getElementById("distance_purpose_checkbox").checked == false && 
 		document.getElementById("reading_purpose_checkbox").checked == false &&
 		document.getElementById("progressive_purpose_checkbox").checked == false &&
 		document.getElementById("nolens_purpose_checkbox").checked == false ){
 		
 		$('lblErrorUseage').innerHTML = "* Please Select The Purpose";
 		if(!isJumped){
 			location.hash = findAnchor("lblErrorUseage_view");
 		}
 		
 		isPass = false;
 	}

	return isPass;
}
function check_lensoption(){
 	var isPass = false;
 	var arrLens = document.getElementsByName("Lens");
 	for(i = 0 ; i < arrLens.length ; i++){
 		if(arrLens[i].checked == true && arrLens[i].value != "" && arrLens[i].value != null){
 			isPass = true;
 		}
 	}
 	if(!isPass){
 		alert("Please Select Lens Option");
 	}
	return isPass;
}
function check_tinting(){
 	var isPass = true;

	return isPass;
}
function hideTabs(){
	document.getElementById("rowFace").style.display = 'none';
	document.getElementById("rowSticky").style.display = 'none';
	document.getElementById("rowTinting").style.display = 'none';
	document.getElementById("menuFace").style.backgroundColor = '#ECECEC'
	document.getElementById("menuSticky").style.backgroundColor = '#ECECEC';
	document.getElementById("menuTinting").style.backgroundColor = '#ECECEC';
}

function showTab(strID){
	hideTabs();
	document.getElementById("row" + strID).style.display = '';
	document.getElementById("menu" + strID).style.backgroundColor = '#CCCCCC';
}

function selectFrameColor(strColorID,strLink,strTryLink){
	//document.getElementById(strColorID).checked = true;
	//if(document.getElementById("rowFlash").style.display == 'none'){
	//	showFlashOnly();
	//}

	var arrDiv = getElementsByName_iefix("div","Color_Frame");
	for(var i = 0 ; i < arrDiv.length ; i++){
		arrDiv[i].className = "div_frame_color_box";
		
	}
	if(strColorID != null && strColorID != ""){
		var objFrameColors = document.getElementById("fcolor");
		for(i = 0 ; i < objFrameColors.options.length ; i++){
			if(objFrameColors.options[i].value == strColorID){
				objFrameColors.selectedIndex = i;
			}
		}
		//if(strTryLink != null && strTryLink != "null"){
			setEyeglass(strTryLink);
		//}
		document.getElementById("div_" + strColorID).className="div_frame_color_box_selected";
		//document.getElementById("lblFrameSelected").innerHTML = document.getElementById(strColorID).value;
		document.getElementById("form_fcolor").value = document.getElementById("fcolor").value;
		$('lblErrorFrameColor').innerHTML = "";
		changeImage(strLink);
		
		return false;
	}
return false;
	
}
function hoverFrameColor(strColorID){
	var objFrame = document.getElementById(strColorID);
	if(objFrame.className != "frameSelected"){
		objFrame.className = "frameHover";
	}
}
function outFrameColor(strColorID){
	var objFrame = document.getElementById(strColorID);
	if(objFrame.className != "frameSelected"){
		objFrame.className = "frameAvailable";
	}
}
function showHidePricing(strID){
	var objPriceBox = document.getElementById(strID);
	if(objPriceBox.style.display == 'none'){
		window["section_pricing_obj"].sx = -180;
		//JSFX_FloatDiv("section_pricing", -175 , 100).flt();
		objPriceBox.style.display = '';
		document.getElementById('section_pricing').style.width = '150px';
		document.getElementById('section_pricing').style.border = '1px solid #CECECE';
		document.getElementById('div_button').src = './php/images/close_dollar_sign.png';
	}else{
		window["section_pricing_obj"].sx = -40;
		//JSFX_FloatDiv("section_pricing", -40 , 100).flt();
		objPriceBox.style.display = 'none';
		document.getElementById('section_pricing').style.width = '10px';
		document.getElementById('section_pricing').style.border = '';
		document.getElementById('div_button').src = './php/images/dollar_sign.png';
	}
	return false;
}
function linkTintingGroup(strObject){
	//alert("here2");
	var objInput = document.getElementById("input_" + strObject);
	var objInputParent = document.getElementById("div_tinting_normal");
	var objInputBrown = document.getElementById("div_tinting_brown");
	if(objInputParent.style.display != 'none' || objInputBrown.style.display != 'none'){
		objInput.checked = true;
		updategroup(objInput.name);
	}

	//alert("here3");
	return false;
}
function linkEdgeTintingGroup(strObject){
	//alert("here2");
	var objInput = document.getElementById("input_" + strObject);
	
	objInput.checked = true;
	updategroup(objInput.name);

	//alert("here3");
	return false;
}
function linkLensOptionGroup(strObject){
	//alert("here2");
	document.getElementById("input_" + strObject).checked = true;
	validate('lens_option')
	//alert("here3");
	return false;
}
function updateFace(strName,intWidth,intHeight,intX,intY,intCenterX,intCenterY,intRotation){
	arrFace[strName] = new Face(intWidth,intHeight,intX,intY,intCenterX,intCenterY,intRotation);
}
function onUpload(){
	document.getElementById("lblUpload").innerHTML = "Uploading...";
	document.getElementById("btnUpload").disabled = "true";
	
	return true;
}

var arrColors = new Array();
arrColors['Hgreen.png'] = new Array();
arrColors['Hgreen.png']['Transparent_25'] = 0x3F50613e;
arrColors['Hgreen.png']['Transparent_50'] = 0x7F50613e;
arrColors['Hgreen.png']['Transparent_75'] = 0x9F50613e;
arrColors['Hgreen.png']['Gradient_25'] = 0x3F50613e;
arrColors['Hgreen.png']['Gradient_50'] = 0x7F50613e;
arrColors['Hgreen.png']['Gradient_75'] = 0x9F50613e;

arrColors['brown.png'] = new Array();
arrColors['brown.png']['Transparent_25'] = 0x3F4b340a;
arrColors['brown.png']['Transparent_50'] = 0x7F4b340a;
arrColors['brown.png']['Transparent_75'] = 0x9F4b340a;
arrColors['brown.png']['Gradient_25'] = 0x3F4b340a;
arrColors['brown.png']['Gradient_50'] = 0x7F4b340a;
arrColors['brown.png']['Gradient_75'] = 0x9F4b340a;

arrColors['grey.png'] = new Array();
arrColors['grey.png']['Transparent_25'] = 0x3F404040;
arrColors['grey.png']['Transparent_50'] = 0x7F404040;
arrColors['grey.png']['Transparent_75'] = 0x9F404040;
arrColors['grey.png']['Gradient_25'] = 0x3F404040;
arrColors['grey.png']['Gradient_50'] = 0x7F404040;
arrColors['grey.png']['Gradient_75'] = 0x9F404040;

arrColors['blue.png'] = new Array();
arrColors['blue.png']['Transparent_25'] = 0x5F7d98eb;
arrColors['blue.png']['Transparent_50'] = 0x7F1b48e1;
arrColors['blue.png']['Transparent_75'] = 0x9F1236a6;
arrColors['blue.png']['Gradient_25'] = 0x5F7d98eb;
arrColors['blue.png']['Gradient_50'] = 0x7F1b48e1;
arrColors['blue.png']['Gradient_75'] = 0x9F1236a6;

arrColors['green.png'] = new Array();
arrColors['green.png']['Transparent_25'] = 0x5F75e26d;
arrColors['green.png']['Transparent_50'] = 0x7F30a923;
arrColors['green.png']['Transparent_75'] = 0x9F1e7419;
arrColors['green.png']['Gradient_25'] = 0x5F75e26d;
arrColors['green.png']['Gradient_50'] = 0x7F30a923;
arrColors['green.png']['Gradient_75'] = 0x9F1e7419;

arrColors['orange.png'] = new Array();
arrColors['orange.png']['Transparent_25'] = 0x3Ffa9900;
arrColors['orange.png']['Transparent_50'] = 0x7Ffa9900;
arrColors['orange.png']['Transparent_75'] = 0x9Ffa9900;
arrColors['orange.png']['Gradient_25'] = 0x3Ffa9900;
arrColors['orange.png']['Gradient_50'] = 0x7Ffa9900;
arrColors['orange.png']['Gradient_75'] = 0x9Ffa9900;

arrColors['red.png'] = new Array();
arrColors['red.png']['Transparent_25'] = 0x3Fd60950;
arrColors['red.png']['Transparent_50'] = 0x7Fd60950;
arrColors['red.png']['Transparent_75'] = 0x9Fd60950;
arrColors['red.png']['Gradient_25'] = 0x3Fd60950;
arrColors['red.png']['Gradient_50'] = 0x7Fd60950;
arrColors['red.png']['Gradient_75'] = 0x9Fd60950;

arrColors['purple.png'] = new Array();
arrColors['purple.png']['Transparent_25'] = 0x3F8201c6;
arrColors['purple.png']['Transparent_50'] = 0x7F8201c6;
arrColors['purple.png']['Transparent_75'] = 0x9F8201c6;
arrColors['purple.png']['Gradient_25'] = 0x3F8201c6;
arrColors['purple.png']['Gradient_50'] = 0x7F8201c6;
arrColors['purple.png']['Gradient_75'] = 0x9F8201c6;

arrColors['yellow.png'] = new Array();
arrColors['yellow.png']['Transparent_25'] = 0x3FEAC809;
arrColors['yellow.png']['Transparent_50'] = 0x7FEAC809;
arrColors['yellow.png']['Transparent_75'] = 0x9FEAC809;
arrColors['yellow.png']['Gradient_25'] = 0x3FEAC809;
arrColors['yellow.png']['Gradient_50'] = 0x7FEAC809;
arrColors['yellow.png']['Gradient_75'] = 0x9FEAC809;

var finalImage = null;
var finalImageName = null;

function selectClear(){
	setLensColor(0x01000000);
	linkTintingGroup('clear')
}
function selectColor(strImage,strMessage){
	finalImage = strImage;
	finalImageName = strMessage;
	//show 2 detail select tools
	
	document.getElementById('imgColorTransparent').src = '/flash/icon/bars/' + strImage;
	document.getElementById('imgColorGradient').src = '/flash/icon/bars/' + 'G' + strImage;
	document.getElementById('imgColorTransparent').style.display = 'block';
	document.getElementById('imgColorGradient').style.display = 'block';
	setMessage('lblColor', strMessage);
	setMessage('lblTransparent', 'Normal');
	setMessage('lblGradient', 'Gradient');
	
}
function selectGradient(strType){
	if(finalImage != null){
		var finalValue = arrColors[finalImage][strType];
		setLensGradient(finalValue);
	}
	var intType = 0;
	if(strType == "Gradient_25"){
		intType = 1;
	}else if(strType == "Gradient_50"){
		intType = 2;
	}else if(strType == "Gradient_75"){
		intType = 3;
	}
	linkTintingGroup("G_" + finalImageName.toLowerCase() + "" + intType);
	setMessage('lblColor', 'Gradient_' + finalImageName + '_' + intType);
}
function selectTransparent(strType){
	if(finalImage != null){
		var finalValue = arrColors[finalImage][strType];
		setLensColor(finalValue);
	}
	var intType = 0;
	if(strType == "Transparent_25"){
		intType = 1;
	}else if(strType == "Transparent_50"){
		intType = 2;
	}else if(strType == "Transparent_75"){
		intType = 3;
	}
	linkTintingGroup(finalImageName.toLowerCase() + "" + intType);
	setMessage('lblColor', finalImageName + '_' + intType);
}
function setMessage(strLabel,strMessage){
	document.getElementById(strLabel).innerHTML = strMessage
}
function setLensColor(intColor){
	var me = thisMovie("objEyeglasses");
	if(me != null){
		me.setLensColor(intColor);
	}
}
function setLensGradient(intColor){
	var me = thisMovie("objEyeglasses");
	if(me != null){
		me.setLensGradient(intColor);
	}
}
function addSticky(strName){
	var me = thisMovie("objEyeglasses");
	if(me != null){
		me.addSticky(strName);
	}
}
var isProfileOn = false;
function getProfile(strName){
	var intCount = 0;
	strOutput = "Quick Profile : <br/>";
	if(strName.length > 1){
		//match the name
		for(i = 0 ; i < arrProfile.length ; i++){
			if(arrProfile[i] != null){
				if(arrProfile[i].match(strName)){
					strOldName = arrProfile[i].replace(/\"/g,"&quot;");
					strOldName = strOldName.replace(/\'/g,"\\'");
					
					strOutput += "<a class=\"a_image_link\" onclick=\"return useProfile('" + strOldName;
					strOutput +="');\" href=\"#\"><div style=\"float:left;width:220px;font-size:14px\" onmouseover=\"isProfileOn=true\" onmouseout=\"isProfileOn=false\">" + arrProfile[i] + "</div></a>\n<br/>";		
					intCount++;
				}
			}
	
		}
		if(intCount > 0){
			showProfileBox(strOutput);
		}
	}else{
		hideProfileBox();
	}

}
function useProfile(strName){
	new Ajax.Request("./php/lens_detail.php",
	{
		method:'get',
		parameters: 
		{
		type : "ProfileJSON",
		wearername : strName
		},
		onSuccess: function(transport){
			var response = transport.responseText.evalJSON() || "no response text";
			// update array
			$("wearername").value = response.wearername;
			$("wearerage").value = response.wearerage;
			$("PupillaryDistance").value = response.PupillaryDistance;
			$("lenswidth").value = response.lenswidth;
			$("lensheight").value = response.lensheight;
			$("templelength").value = response.templelength;
			$("framewidth").value = response.framewidth;
			
			$(response.framesize).checked = "checked"; 
		
			$("prescriptionyr").value = response.prescriptionyr;
			$("wearerheadsize").value = response.wearerheadsize;
			
			$("ODSphere").value = response.odsphere;
			$("ODCylinder").value = response.odcylinder;
			$("ODAxis").value = response.odaxis;
			$("ODAdd").value = response.odadd;
			$("ODprism").value = response.odprism;
			$("ODprismpos").value = response.odprismpos;
			
			$("OSSphere").value = response.ossphere;
			$("OSCylinder").value = response.oscylinder;
			$("OSAxis").value = response.osaxis;
			$("OSAdd").value = response.osadd;
			$("OSprism").value = response.osprism;
			$("OSprismpos").value = response.osprismpos;
			
			validate('prescription');
		},
		onFailure: function(){
			alert('Error Occur , Please contact developer.')
		}
	});
	isProfileOn = false;
	updategroup("framesize");
	hideProfileBox();
	hideBox("divInfoBox");
	return false;
}
function useDirectProfile(wearername,wearerage,PupillaryDistance,lenswidth, lensheight, templelength ,framewidth,framesize,
		prescriptionyr,wearerheadsize,ODSphere,ODCylinder,ODAxis,ODAdd,ODprism,ODprismpos,
		OSSphere,OSCylinder,OSAxis,OSAdd,OSprism,OSprismpos){
	$("wearername").value = wearername;
	$("wearerage").value = wearerage;
	$("PupillaryDistance").value = PupillaryDistance;
	$("lenswidth").value = lenswidth;
	$("lensheight").value = lensheight;
	$("templelength").value = templelength;
	$("framewidth").value = framewidth;
	$(framesize).checked = "checked"; 

	$("prescriptionyr").value = prescriptionyr;
	$("wearerheadsize").value = wearerheadsize;
	
	$("ODSphere").value = ODSphere;
	$("ODCylinder").value = ODCylinder;
	$("ODAxis").value = ODAxis;
	$("ODAdd").value = ODAdd;
	$("ODprism").value = ODprism;
	$("ODprismpos").value = ODprismpos;
	
	$("OSSphere").value = OSSphere;
	$("OSCylinder").value = OSCylinder;
	$("OSAxis").value = OSAxis;
	$("OSAdd").value = OSAdd;
	$("OSprism").value = OSprism;
	$("OSprismpos").value = OSprismpos;
	
	validate('prescription');
	
	isProfileOn = false;
	updategroup("framesize");
	hideProfileBox();
	hideBox("divInfoBox");
	return false;
}
function saveProfile(){
	var strFrameSize;
	if($("current").checked){
		strFrameSize = "current";
	}else if($("professional").checked){
		strFrameSize = "professional";
	}
	$('lblProfileStatus').innerHTML = "Profile Saving...";
	new Ajax.Request("./hplib/profile.cgi",
	{
		method:'get',
		parameters: 
		{
		mode:"save",
		wearername : $("wearername").value,
		wearerage : $("wearerage").value,
		pupillarydistance : $("PupillaryDistance").value,
		lenswidth : $("lenswidth").value,
		lensheight : $("lensheight").value,
		templelength : $("templelength").value,
		framewidth : $("framewidth").value,
		prescriptionyr : $("prescriptionyr").value,
		wearerheadsize : $("wearerheadsize").value,
		framesize : strFrameSize,
		ODSphere : $("ODSphere").value,
		ODCylinder : $("ODCylinder").value,
		ODAxis : $("ODAxis").value,
		ODAdd : $("ODAdd").value,
		ODprism : $("ODprism").value,
		ODprismpos : $("ODprismpos").value,
		OSSphere : $("OSSphere").value,
		OSCylinder : $("OSCylinder").value,
		OSAxis : $("OSAxis").value,
		OSAdd : $("OSAdd").value,
		OSprism : $("OSprism").value,
		OSprismpos : $("OSprismpos").value
		},
		
		onSuccess: function(transport){
			var response = transport.responseText || "no response text"
			// update array
			bolFound = -1;
			for(i = 0 ; i < arrProfile.length ; i++){
				if(arrProfile[i] == $("wearername").value){
					bolFound = i;
				}
			}
			if(bolFound >= 0){
				arrProfile[bolFound] = $("wearername").value;
			}else{
				arrProfile.push($("wearername").value);
			}
			$('lblProfileStatus').innerHTML = "Profile Saved";
			setTimeout('clearSaveMessage()',2000);
		},
		onFailure: function(){
			alert('Error Occur , Please contact developer.')
		}
	});	
}
function clearSaveMessage(){
	$('lblProfileStatus').innerHTML = "";
}
function updateBox(strKey){
	new Ajax.Request("./php/lens_detail.php",
	{
		method:'get',
		parameters:strKey,
		onSuccess: function(transport){
			var response = transport.responseText || "no response text"
			var objInfoBoxContent = document.getElementById("divContent");
			var objDivTitle = document.getElementById("divTitle");
			objInfoBoxContent.innerHTML = response;
			objDivTitle.innerHTML = strName;
		},
		onFailure: function(){
			alert('Error Occur , Please contact developer.')
		}
	});
	return false;
}
function checkEnter(e)
{
	if(window.event) // IE
	{
	  keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	  keynum = e.which;
	}
	if(keynum == 13){
		updateBox({type:'Profile',search:$('txtSearch').value})
	}
    
}
function swap(){
	for(var i = 0 ; i < arrTestmoName.length ; i++){
		for(var j = 0 ; j < arrTestmo[i].length ; j++){
			if(arrTestmoIndex[i] == j){	
				//visible
				var divPhoto = document.getElementById(arrTestmoName[i] + "_" + arrTestmo[i][j]);
				if(divPhoto){
					divPhoto.style.display = "";
				}
			}else{
				var divPhoto = document.getElementById(arrTestmoName[i] + "_" + arrTestmo[i][j]);
				//alert(arrTestmoIndex[i] + " _ " + j);
				if(divPhoto){
					divPhoto.style.display = "none";
				}
			}
		}
	}
	
	for(var i = 0 ; i < arrTestmoIndex.length ; i++){
		if(arrTestmoIndex[i] < arrTestmo[i].length - 1){
			arrTestmoIndex[i]++;
		}else{
			arrTestmoIndex[i] = 0;
		}
	}
	setTimeout("swap()",10000);
}
function showTestmo(){
	document.getElementById("divLinkFlash").style.backgroundColor = '';
	document.getElementById("divLinkTestmo").style.backgroundColor = '#ECECEC';
	document.getElementById("divLinkFlash").style.fontWeight = '';
	document.getElementById("divLinkTestmo").style.fontWeight = 'bold';
	document.getElementById("rowFlash").style.display = 'none';
	document.getElementById("rowTestmo").style.display = 'block';
}
function showFlash(){
	document.getElementById("divLinkFlash").style.backgroundColor = '#ECECEC';
	document.getElementById("divLinkTestmo").style.backgroundColor = '';
	document.getElementById("divLinkFlash").style.fontWeight = 'bold';
	document.getElementById("divLinkTestmo").style.fontWeight = '';
	document.getElementById("rowFlash").style.display = 'block';
	document.getElementById("rowTestmo").style.display = 'none';
	window.setTimeout('loadFlash()',500);
}
function showFlashOnly(){
	document.getElementById("divLinkFlash").style.backgroundColor = '#ECECEC';
	document.getElementById("divLinkTestmo").style.backgroundColor = '';
	document.getElementById("divLinkFlash").style.fontWeight = 'bold';
	document.getElementById("divLinkTestmo").style.fontWeight = '';
	document.getElementById("rowFlash").style.display = 'block';
	document.getElementById("rowTestmo").style.display = 'none';
}
function rimlessBox_Hover(objDiv){
	if(objDiv.className == 'div_rimless_box'){
		objDiv.className = 'div_rimless_box_hover'
	}else if(objDiv.className == 'div_rimless_box_hover'){
		objDiv.className = 'div_rimless_box';
	}else if(objDiv.className == 'div_rimless_box_selected'){
		//objDiv.className = 'div_rimless_box_selected'; 
	}
}
function frameColor_Hover(objDiv){
	if(objDiv.className == 'div_frame_color_box'){
		objDiv.className = 'div_frame_color_box_hover'
	}else if(objDiv.className == 'div_frame_color_box_hover'){
		objDiv.className = 'div_frame_color_box';
	}else if(objDiv.className == 'div_frame_color_box_selected'){
		//objDiv.className = 'div_rimless_box_selected'; 
	}
}
function stepLink_Hover(objDiv){
	if(objDiv.className == 'a_step_link'){
		objDiv.className = 'a_step_link_hover'
	}else if(objDiv.className == 'a_step_link_hover'){
		objDiv.className = 'a_step_link';
	}
}
