var hrss=new Object();

hrss.ContentLoader=function(getRequest,onload){	this.getRequest=getRequest;
	this.xmlHttp=null;
	this.onload=onload;
	this.loadDoc(getRequest);
}

hrss.ContentLoader.prototype={	loadDoc:function(getRequest){			try	{
				this.xmlHttp = new XMLHttpRequest();
			}
			catch(e) {
				var XmlHttpVersions=new Array("MSXML2.XMLHTTP.6.0",
									"MSXML2.XMLHTTP.5.0",
									"MSXML2.XMLHTTP.4.0",
									"MSXML2.XMLHTTP.3.0",
									"MSXML2.XMLHTTP",
									"Microsoft.XMLHTTP");
				for (var i=0;i < XmlHttpVersions.length && !this.xmlHttp; i++)	{
					try	{
						this.xmlHttp=new ActiveXObject(XmlHttpVersions[i]);
					}
					catch(e) {}
				}
		}
		if (this.xmlHttp) {
			try {
				var loader=this;
				this.xmlHttp.onreadystatechange=function(){					loader.onReadyState.call(loader);
				}
				this.xmlHttp.open("GET",getRequest,true);
				this.xmlHttp.send(null);
			}
			catch (e) {}
		}
	},
	onReadyState:function(){		var xmlHttp=this.xmlHttp;
		var ready=xmlHttp.readyState;
		if (ready==4){			var httpStatus=xmlHttp.status;
			if (httpStatus==200 || httpStatus==0){				this.onload.call(this);
			}
		}
	}
}

function NextClayart( ClayartNum )
{
	var next=new hrss.ContentLoader("/ajax/clayart.php?p="+ClayartNum,ClayartResponse);
}

function NextNews( NewsNum )
{
	var next=new hrss.ContentLoader("/ajax/nextnews.php?p="+NewsNum,NewsResponse);
}


function NextAnnounce( AnnounceNum )
{
	var next=new hrss.ContentLoader("/ajax/nextannounce.php?p="+AnnounceNum,AnnounceResponse);
}


function ClayartResponse(){
	var xmlResponse=this.xmlHttp.responseXML;
	var xmlroot=xmlResponse.documentElement;
	var html="<b>";
	html+= xmlroot.getElementsByTagName("navigation")[0].firstChild.nodeValue+" &nbsp;";
	html+= xmlroot.getElementsByTagName("date")[0].firstChild.nodeValue+".  ";
	html+= xmlroot.getElementsByTagName("author")[0].firstChild.nodeValue+"</b><br>";
	html+= xmlroot.getElementsByTagName("theme")[0].firstChild.nodeValue+"<p>";
	html+= xmlroot.getElementsByTagName("text")[0].firstChild.nodeValue+"</p>";
	ClayartDiv=document.getElementById("clayart");
	ClayartDiv.innerHTML=html;
}

function NewsResponse()
{
	var xmlResponse=this.xmlHttp.responseXML;
	var xmlroot=xmlResponse.documentElement;
	var CurColor= new Array("#FFFFDE","#e8e8e8");
	var ChColor=0;
	var html="<table class='txtComment' width=100% border=0 cellpadding=10 cellspacing=0>";
	var NewsCount=xmlroot.getElementsByTagName("title").length;
	for (i=0;i < NewsCount; i++) {
		html+="<tr><td bgcolor='"+CurColor[ChColor]+"'><table width=100% cellspacing=0 cellpadding=0 border=0 class='txtComment'><tr><td><b>";
		if (ChColor==1) ChColor=0;
		else ChColor=1;
		html+= xmlroot.getElementsByTagName("date")[i].firstChild.nodeValue+"</b><br><b>";
		html+= xmlroot.getElementsByTagName("title")[i].firstChild.nodeValue+"</b></td></tr><tr><td>";
		html+= xmlroot.getElementsByTagName("pichandle")[i].firstChild.nodeValue;
		html+= xmlroot.getElementsByTagName("text")[i].firstChild.nodeValue+"</td></tr></table></td></tr>";
	}
	html+="<tr><td bgcolor='"+CurColor[ChColor]+"'><p><b>У</b>дачных обжигов!<br>";
	html+="<a href='mailto:Gennady%20Surkov%3csurkov@horss.ru%3e'><b>Г</b>еннадий Сурков.";
	html+="<img src='letter_03.gif' border=0 hspace=4 align='absmiddle' width=14 height=11></a>";
	html+="<tr><td bgcolor=#DEDEDE height=4></td></tr>";
	html+="<tr><td class='txtComment'>&nbsp;<p>Если Вы знаете шифр или наименование материала, которым интересуетесь, введите его здесь:";
	html+="<form action=item.php method=get><input id='keyword' type=text class='txtComment' name=s value='' maxlength=26 size=25 onFocus='init();' onkeyup='handleKeyUp(event)' autocomplete='off'>&nbsp;&nbsp;";
	html+="<input type=submit name=go value='Открыть' class='txtComment' height=20>";
	html+="\r\n<div id='scroll'><div id='suggest'></div></div></form></td></tr></table>";
	NewsDiv=document.getElementById("news");
	NewsDiv.innerHTML=html;
	NewsImgDiv=document.getElementById("imgnews");
	html=xmlroot.getElementsByTagName("imgnews")[0].firstChild.nodeValue
	NewsImgDiv.innerHTML=html;
}

function AnnounceResponse()
{
	var xmlResponse=this.xmlHttp.responseXML;
	var xmlroot=xmlResponse.documentElement;
	var CurColor= new Array("#edecde","#ffffff");
	var CurWidth= new Array("30%","70%");
	var ChColor=1;
	var html="";
	var AnnounceCount=xmlroot.getElementsByTagName("pic").length;
	for (i=0;i < AnnounceCount; i++)
	{
		html+="<table border=0 width=100% class=p16 bgcolor='"+CurColor[ChColor]+"' cellspacing=0 cellpadding=10>";
		html+="<tr><td width='"+CurWidth[ChColor]+"' valign='middle'>";
		if (ChColor==1)
		{
			html+= xmlroot.getElementsByTagName("text")[i].firstChild.nodeValue;
			ChColor=0;
			html+="</td><td width='"+CurWidth[ChColor]+"'>";
			html+= xmlroot.getElementsByTagName("pic")[i].firstChild.nodeValue;
		}
		else
		{
			html+= xmlroot.getElementsByTagName("pic")[i].firstChild.nodeValue;
			ChColor=1;
			html+="</td><td width='"+CurWidth[ChColor]+"'>";
			html+= xmlroot.getElementsByTagName("text")[i].firstChild.nodeValue;
		}
		html+="</td></tr></table>";
	}
	AnnounceDiv=document.getElementById("announce");
	AnnounceDiv.innerHTML=html;
	AnnounceImgDiv=document.getElementById("imgannounce");
	html=xmlroot.getElementsByTagName("imgannounce")[0].firstChild.nodeValue
	AnnounceImgDiv.innerHTML=html;
}

