function updateTextNode(nodeName,nodeValue) {
		var	NodePro=document.createTextNode(nodeValue);
		var	forEdit=document.getElementById(nodeName);
		if (forEdit.firstChild) forEdit.removeChild(forEdit.firstChild);
		forEdit.appendChild(NodePro);
}

function updateProWait(proName) {
	updateTextNode("dataName","Проект: "+proName);
	updateTextNode("dataAll","Идет ЗАГРУЗКА");
	updateTextNode("dataLive","Идет ЗАГРУЗКА");
	updateTextNode("dataWall","Идет ЗАГРУЗКА");
	updateTextNode("dataRoof","Идет ЗАГРУЗКА");
	updateTextNode("dataFloor","Идет ЗАГРУЗКА");
	updateTextNode("dataSocleen","Идет ЗАГРУЗКА");
	updateTextNode("dataDesc","");
		
	updateTextNode("dataFund","Идет ЗАГРУЗКА");
	updateTextNode("dataOverlap","Идет ЗАГРУЗКА");
	updateTextNode("dataCover","Идет ЗАГРУЗКА");
	updateTextNode("dataDecorate","Идет ЗАГРУЗКА");
	updateTextNode("dataSocle","Идет ЗАГРУЗКА");
	updateTextNode("dataPrA","Идет ЗАГРУЗКА");
	updateTextNode("dataPrS","Идет ЗАГРУЗКА");
	updateTextNode("dataPrP","Идет ЗАГРУЗКА");
	
	document.getElementById("imgBig").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgPl0").setAttribute("src","./images/ajax-load.gif");;
	document.getElementById("imgPl1").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgPl2").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgPl3").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgFa1").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgFa2").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgFa3").setAttribute("src","./images/ajax-load.gif");
	document.getElementById("imgFa4").setAttribute("src","./images/ajax-load.gif");
}


/* ----------------------------------Создание нового объекта XMLHttpRequest для запросов по проектам */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}


/* ---------------------------------Получение параметров конкретного проекта, где n - номер проекта  */
function getProjectParametrs(n) {
	updateProWait(n);
	var url = "./resp_pro.php?prs=" + escape(n);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}


/* --------------------------------Разбивка полученной информации и запуск изменения отображения проекта */

function updatePage() {
	if (xmlHttp.readyState == 4) {
		var response = xmlHttp.responseText;
		var responseArray=response.split("|");
		updateProView(
			responseArray[0],
			responseArray[1],
			responseArray[2],
			responseArray[3],
			responseArray[4],
			responseArray[5],
			responseArray[6],
			responseArray[7],
			responseArray[8],
			responseArray[9],
			responseArray[10],
			responseArray[11],
			responseArray[12],
			responseArray[13],
			responseArray[14],
			responseArray[15],
			responseArray[16],
			responseArray[17],
			responseArray[18]
			);
	}
}

var proBuy;
function updateProView(proName,proAll,proLive,proWall,proRoof,proFloor,proSocleen,proDesc,proSo,proFl,proFund,proOverlap,proCover,proDecorate,proSocle,proPrA,proPrS,proPrP) {
		proBuy = proName;
		// Заменяем текстовые данные		
		updateTextNode("dataName","Проект: "+proName);
		updateTextNode("dataAll",proAll);
		updateTextNode("dataLive",proLive);
		updateTextNode("dataWall",proWall);
		updateTextNode("dataRoof",proRoof);
		updateTextNode("dataFloor",proFloor);
		updateTextNode("dataSocleen",proSocleen);
		updateTextNode("dataDesc",proDesc);
		
		updateTextNode("dataFund",proFund);
		updateTextNode("dataOverlap",proOverlap);
		updateTextNode("dataCover",proCover);
		updateTextNode("dataDecorate",proDecorate);
		updateTextNode("dataSocle",proSocle);
		updateTextNode("dataPrA",parseFloat(proPrA)/44*50);
		updateTextNode("dataPrS",parseFloat(proPrS)/44*50);
		updateTextNode("dataPrP",parseFloat(proPrP)/44*50);

		document.getElementById("imgPl0").style.visibility="hidden";
		document.getElementById("imgPl2").style.visibility="hidden";
		document.getElementById("imgPl3").style.visibility="hidden";		
		//Меняем пути изображений
		var srcPart="http://allhomes.ru/catalog/"+proName+"/"+proName+"-";
		document.getElementById("imgBig").setAttribute("src",srcPart+"bg.jpg");
		if (proSo==1) {	document.getElementById("imgPl0").setAttribute("src",srcPart+"p0.gif"); document.getElementById("imgPl0").style.visibility="visible"; }
		document.getElementById("imgPl1").setAttribute("src",srcPart+"p1.gif"); 
		if (proFl>1)  { document.getElementById("imgPl2").setAttribute("src",srcPart+"p2.gif"); document.getElementById("imgPl2").style.visibility="visible"; }
		if (proFl>2)  { document.getElementById("imgPl3").setAttribute("src",srcPart+"p3.gif"); document.getElementById("imgPl3").style.visibility="visible"; }
		
		document.getElementById("imgFa1").setAttribute("src",srcPart+"f1.gif"); 
		document.getElementById("imgFa2").setAttribute("src",srcPart+"f2.gif");
		document.getElementById("imgFa3").setAttribute("src",srcPart+"f3.gif"); 
		document.getElementById("imgFa4").setAttribute("src",srcPart+"f4.gif"); 

}


function buy() {
	objectName=window.open("buy.php?proj="+proBuy,"_blank","width=500, height=300, status=NO, toolbar=NO, scrollbars=NO, resizable=NO");
}

function slideIt(divID) {
	divObj=document.getElementById(divID);
	if (divObj.style.visibility=="visible") {
		divObj.style.visibility="hidden";
		divObj.style.height="1";
		
	} else {
		divObj.style.visibility="visible";
		divObj.style.height="auto";
	}
}


function slide(divID,divVis) {
	divObj=document.getElementById(divID);
	if (divVis=="visible") {
		divObj.style.visibility="visible";
		divObj.style.height="auto";
	} else {

		divObj.style.visibility="hidden";
		divObj.style.height="1";
	}
}

function slideOne() {
	var i=0;
	for (i=1; i<arguments.length; i++) {
		divObj=document.getElementById(arguments[i]);
		divObj.style.visibility="hidden";
		divObj.style.height="1";
	}
	divObj=document.getElementById(arguments[0]);
	divObj.style.visibility="visible";
	divObj.style.height="auto";
}

