//ENQUIRY FORM
var divtag;
function GetFile(filename, changediv) {
  document.getElementById(changediv).innerHTML = '<p align="center" style="font-weight: bold"><img src="../gallery/images/loading.gif" alt="Loading" width="32" height="32" /><br />Loading...</p>';
  http.open("GET", filename, true);
  http.onreadystatechange = DisplayEnquiryForm;
  http.send(null);
  divtag = changediv;
}


function DisplayEnquiryForm() {
  if (http.readyState == 4) {
	var response = http.responseText;
	document.getElementById(divtag).innerHTML = response;
  }
}




//GET SETTINGS
var url = "get-setting.php"; // The server-side script
function handleHttpResponse() {
  if (http.readyState == 4) {
	var xmlDocument = http.responseXML;
	var name 		= xmlDocument.getElementsByTagName('name').item(0).firstChild.data;
	var setting_id 	= xmlDocument.getElementsByTagName('setting_id').item(0).firstChild.data;
	var imageref_a	= xmlDocument.getElementsByTagName('imageref_a').item(0).firstChild.data;
	var imageref_b	= xmlDocument.getElementsByTagName('imageref_b').item(0).firstChild.data;
	var price		= xmlDocument.getElementsByTagName('price').item(0).firstChild.data;
	var metal 		= xmlDocument.getElementsByTagName('metal').item(0).firstChild.data;
	var designtype 		= xmlDocument.getElementsByTagName('designtype').item(0).firstChild.data;
	
	var selecthref = 'design.php?action=selectdiamond&setting_id=' + setting_id + '&type=' + designtype;
	
    //results = http.responseText.split(",");
    document.getElementById('info').innerHTML = "<p align=\"center\" style=\"font-weight: bold\">" + name + "</p>"+
                "<p align=\"center\"> in " + metal + "</p>"+
                "<p>&nbsp;</p>"+
                "<p align=\"center\" style=\"font-weight: bold\">$" + price + "</p><p class=\"small\" align=\"center\">Setting only price</p>"+
                "<p>&nbsp;</p>"+
              	"<p align=\"center\" style=\"font-weight: bold\" ><a href=\"" + selecthref + "\">Select this  Setting &gt;&gt;</a> </p>"+
				"<br /><p class=\"small\" align=\"center\">NOTE: Actual engagement ring will vary from the photo depending on the diamond you choose</p>";
    document.getElementById('enlargedhref_a').href = selecthref;
    document.getElementById('enlargedhref_b').href = selecthref;
	document.getElementById('enlarged_a').src = imageref_a;
	document.getElementById('enlarged_b').src = imageref_b;
  }
}



function SelectSetting(id, type) {
  parent.location = '#settinganchor';
  document.getElementById('info').innerHTML = '<p align="center" style="font-weight: bold"><img src="../gallery/images/loading.gif" alt="Loading" width="32" height="32" /><br />Loading...</p>';
  http.open("GET", url + '?id=' + escape(id) + '&type=' + escape(type), true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}
function getHTTPObject() {
  /*var xmlhttp;
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;*/
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}
var http = getHTTPObject();

function showhide(commentID) {
	if (document.getElementById(commentID).style.display == 'none' || document.getElementById(commentID).style.display == '') {
		document.getElementById(commentID).style.display = 'block';
	} else {
		if (document.getElementById(commentID).style.display == 'block') {
			document.getElementById(commentID).style.display = 'none';
		}
	}
}

function showError(error_id) {
	document.getElementById(error_id).style.display = 'block';
}


function hideError(error_id) {
	document.getElementById(error_id).style.display = 'none';
}
