// open window with the stone closeup view
function zoomS(fldName,imgName) {
var file;
var imgSrc = fldName + "/" +imgName + "_slab_l.jpg";
function getReq() {
if (window.XMLHttpRequest){
return new XMLHttpRequest();
}
}
file = getReq();
file.open('GET',imgSrc,true);
file.onreadystatechange = testImg;
file.send(null);
function testImg(){
if (file.readyState==4){;
if (file.status==200) {

var display = window.open ("", "imagelarge", "width=445,height=650,toolbar=0,status=0,resizable=0");
display.document.open("text/html","replace");
display.document.write("<html><head>");
display.document.write("<style type='text/css'>");
display.document.write("body {background: #000000; color: #707070; font-weight: bold;}");
display.document.write("a {color: #808080; font-family: arial,sans-serif; text-decoration: none;}");
display.document.write("a:visited {color: #808080; font-family: arial,sans-serif; text-decoration: none;}");
display.document.write("img {border: none;}");
display.document.write("#message {position: absolute; top: 50px;}");
display.document.write(".pics {float: left; width: 100px; background: #9c482a; color: #000000; font-family: arial,sans-serif; font-size: 10pt; cursor: pointer; margin: 0px; padding: 1px; z-index: 1111;}");
display.document.write("</style>");
display.document.write("<script>");
display.document.write("function closeWindow() {");
display.document.write("window.close();");
display.document.write("}");
display.document.write("function deleteMessage() {");
display.document.write("document.getElementById('message').style.display = 'none';");
display.document.write("}");
display.document.write("function swapSlab() {");
display.document.write("var img = document.getElementById('swap');");
display.document.write("img.src = '"+fldName+"/"+imgName+"_slab_l.jpg';");
display.document.write("}");
display.document.write("function swapCloseup() {");
display.document.write("var img = document.getElementById('swap');");
display.document.write("img.src = '"+fldName+"/"+imgName+"_l.jpg';");
display.document.write("}");
display.document.write("</script>");
display.document.write("</head><body style='background-color: rgb(0,0,0)'><p id='message'>Loading image has higher resolution for better stone's details view. Please, be patient .</p>");
display.document.write("<div><p id='slab' class='pics' onclick='swapSlab()'>Slab<img src='" + fldName + "/" + imgName + "_slab_s.jpg' height='43px' width='100px'></p>");
display.document.write("<p class='pics' onclick='swapCloseup()'>Closeup<img src='" + fldName + "/" + imgName + ".jpg' height='43px' width='100px'></p><p align='right'><a href='#' onclick='closeWindow()'><img src='images/close.gif'> Close</a></p></div>");
display.document.write("<div><img id='swap' onload='deleteMessage()' src='" + fldName + "/" + imgName + "_l.jpg'></div>");
display.document.write("</body></html>");
display.document.close();
}
}

else {

var display = window.open ("", "imagelarge", "width=445,height=600,toolbar=0,status=0,resizable=0");
display.document.open("text/html","replace");
display.document.write("<html><head>");
display.document.write("<style type='text/css'>");
display.document.write("body {background: #000000; color: #707070; font-weight: bold;}");
display.document.write("a {color: #808080; font-family: arial,sans-serif; text-decoration: none;}");
display.document.write("a:visited {color: #808080; font-family: arial,sans-serif; text-decoration: none;}");
display.document.write("img {border: none;}")
display.document.write("#message {position: absolute; top: 50px;}");
display.document.write("</style>");
display.document.write("<script>");
display.document.write("function closeWindow() {");
display.document.write("window.close()");
display.document.write("}");
display.document.write("function deleteMessage() {");
display.document.write("document.getElementById('message').style.display = 'none'");
display.document.write("}");
display.document.write("</script>");
display.document.write("</head><body style='background-color: rgb(0,0,0)'><p id='message'>Loading image has higher resolution for better stone's details view. Please, be patient .</p>");
display.document.write("<p align='right'><a href='#' onclick='closeWindow()'><img src='images/close.gif'> Close</a></p><img onload='deleteMessage()' src='" + fldName + "/" + imgName + "_l.jpg'>");
display.document.write("</body></html>");
display.document.close();
}



}
}



// show current submenu and hide others

function showSubMenu(subMenuName) {
if (!document.getElementById) return;
var name1 = document.getElementById("stonesMenu");
var name2 = document.getElementById("specialtiesMenu");
var name3 = document.getElementById("accentsMenu");
var name4 = document.getElementById("informationMenu");
var name5 = document.getElementById("sanitaryMenu");
var name6 = document.getElementById("cabinetsMenu");
var nameNone = document.getElementById("");

var subMenu = document.getElementById(subMenuName);

if (subMenu == name1) {
document.getElementById("display").style.zIndex = 1;
name1.style.visibility = "visible";
name2.style.visibility = "hidden";
name3.style.visibility = "hidden";
name4.style.visibility = "hidden";
name5.style.visibility = "hidden";
name6.style.visibility = "hidden";
}

else {
if (subMenu == name2) {
document.getElementById("display").style.zIndex = 1;
name1.style.visibility = "hidden";
name2.style.visibility = "visible";
name3.style.visibility = "hidden";
name4.style.visibility = "hidden";
name5.style.visibility = "hidden";
name6.style.visibility = "hidden";
}

else {
if (subMenu == name3) {
document.getElementById("display").style.zIndex = 1;
name1.style.visibility = "hidden";
name2.style.visibility = "hidden";
name3.style.visibility = "visible";
name4.style.visibility = "hidden";
name5.style.visibility = "hidden";
name6.style.visibility = "hidden";
}

else {
if (subMenu == name4) {
document.getElementById("display").style.zIndex = 1;
name1.style.visibility = "hidden";
name2.style.visibility = "hidden";
name3.style.visibility = "hidden";
name4.style.visibility = "visible";
name5.style.visibility = "hidden";
name6.style.visibility = "hidden";
}

else {
if (subMenu == name5) {
document.getElementById("display").style.zIndex = 1;
name1.style.visibility = "hidden";
name2.style.visibility = "hidden";
name3.style.visibility = "hidden";
name4.style.visibility = "hidden";
name5.style.visibility = "visible";
name6.style.visibility = "hidden";
}

else {
if (subMenu == name6) {
document.getElementById("display").style.zIndex = 1;
name1.style.visibility = "hidden";
name2.style.visibility = "hidden";
name3.style.visibility = "hidden";
name4.style.visibility = "hidden";
name5.style.visibility = "hidden";
name6.style.visibility = "visible";
}

else {
if (subMenu == nameNone){
document.getElementById("display").style.zIndex = 1111;
name1.style.visibility = "hidden";
name2.style.visibility = "hidden";
name3.style.visibility = "hidden";
name4.style.visibility = "hidden";
name5.style.visibility = "hidden";
name6.style.visibility = "hidden";
}
}
}
}
}
}
}
}

// hide submenu
function hideSubMenu(subMenuName) {
if (!document.getElementById) return;
var subMenu = document.getElementById(subMenuName);
subMenu.style.visibility = "hidden";
}


//change color of "_" to black
function changeColor() {
var x = document.getElementById("titleText");
var txt = x.innerHTML;
var text = txt.replace(/\s/g,"<font color='#000000'>_</font>");
document.getElementById("titleText").innerHTML = text;
}


function validate(form)	{
var firstName = form.FirstName.value;
var phone = form.Phone.value;
var email = form.Email.value;
var comments = form.Comment.value;
var errors = [];

	if (!checkLength(firstName))	{
		errors[errors.length] = "enter First Name";
	}
	
	if (!checkLength(phone))	{
		errors[errors.length] = "phone number";
	}
	
	if (!checkLength(email))	{
		errors[errors.length] = "email";
	}
	
	if (!checkLength(comments))	{
		errors[errors.length] = "comments";
	}

	if (errors.length > 0)	{
		reportErrors(errors);
		return false;
	}
return true;
}

function checkLength(text, min, max)	{
	min = min || 1;
	max = max || 10000;
	if (text.length < min || text.length > max)	{
		return false;
	}
	return true;
}

function reportErrors(errors)	{
	var msg = "Please provide missing information: \n";
	var numError;
	for (var i = 0; i<errors.length; i++)	{
	numError = i + 1;
	msg += "\n" + numError + ". " + errors[i];
	}
	alert(msg);
}

