// Javascript for 3DVNZ menus

// Checks for DOM compatibility...
if (document.getElementById) { dom = true; } else { dom = false; }
var counter;
var contact_form = 'sales_div';
var total_price = 0;
var chosen_opt = new Array(0,0,0,0,0,0,0,0,0,0);

// *********************************************************************

// checks the form to see if legitimate details have been entered...
function checkForm() {
	errmsg='';
	if (document.mainform.name.value=='') {
		errmsg+='Please Enter your name...\n';
	}
	if (document.mainform.compname.value=='') {
		errmsg+='Please Enter your Company name...\n';
	}
	if (document.mainform.phone.value=='') {
		errmsg+='Please Enter your Phone Number...\n';
	}
	if (document.mainform.address.value=='') {
		errmsg+='Please Enter your Postal Address...\n';
	}
	if (document.mainform.email.value=='') {
		errmsg+='Please Enter your Email address...\n';
	}
	
	if (errmsg!='') {
		alert(errmsg);
	} else { // submit form
		document.mainform.submit();
	}
}

// Updates the chosen inputbox on the Pricing page 
// to show what numbers have been chosen...
function showChosen() {
	var chosenText = '';
	var first = true;
	for (i=0; i<10; i++) {
		if (chosen_opt[i]==1) {
			if (first) {
				chosenText += (i+1);
				first=false;
			} else {
				chosenText += ','+(i+1);
			}
		}
	}
	document.getElementById('chosen').value=chosenText;
}

// Totals the chosen details for the pricing form...
function pricingForm(checkBox) {
	cost = new Number(checkBox.value);
	var str = checkBox.id;
	idno = str.substr((str.length-1),1);
	if (idno==0) idno=10;
	if (checkBox.checked) {
		total_price += cost;
		chosen_opt[idno-1] = 1;
	} else {
		total_price -= cost;
		chosen_opt[idno-1] = 0;
	}
	
	if (dom) {
		showChosen();
		document.getElementById('total').value = '$'+total_price+'.00 US';
	}
}

// Shows a larger image of a picture...
function showImage(imgName,x,y) {
	options_str = 'width='+x+',height='+y+',menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,left=10,top=10';
	window.open('img/gallery/'+imgName+'_l.jpg','',options_str);
}

// Clears the counter and then shows the menu
function showMenu(id) {
	if (counter) clearTimeout(counter);
	show(id);
	if (document.getElementById('menu-op').style.background != "url(img/menu-over.jpg)") {
		document.getElementById('menu-op').style.background = "url(img/menu-over.jpg)"
	}
}

// Goes to hide the menu, but sets a delay timer first...
function delayHide(id, delay) {
	counter = setTimeout("hideMenu('"+id+"')", delay);
}

// Hides the menu
function hideMenu(id) {
	hide(id);
	document.getElementById('menu-op').style.background = "url(img/spacer.gif)";
}

// Hides/Shows a certain element that has been targeted...
function newOption(obj,value,id) {
	formValue = obj.options[obj.selectedIndex].value;
	if (formValue==value) {
		show(id);
	} else {
		hide(id);
	}
}

// Checks the contact form, hides/shows appropriate layers...
function checkFormLayers(formLayer) {
	if (contact_form!=formLayer) {
		hide(contact_form);
		show(formLayer);
		contact_form=formLayer;
	}
}

// Shows/Hides the various contact forms...
function changeContact(obj) {
	formLayer = obj.options[obj.selectedIndex].value;
	checkFormLayers(formLayer);
}

// *********************************************************************

// Show the menu layer
function show(id) {
	if (dom) document.getElementById(id).style.visibility = "visible";
}
// Hide the menu layer
function hide(id) {
	if (dom) document.getElementById(id).style.visibility = "hidden";
}

// Opens a new window for preview movie
function newWindow() {
		movWindow = window.open("/downloads/preview.wmv")
	}


// Opens a new window for main movie
function newWin() {
		movWindow = window.open("/downloads/main.wmv")
	}
