

function loadingxml(xml){
	
var xmldoc=new ActiveXObject("MICROSOFT.XMLDOM");
		xmldoc.async=false;
		xmldoc.load(xml);
		if(xmldoc.parseError.errorCode!=0)
		alert("Error");
		else
		return xmldoc;
}


function searching(xml,imagePage){

	var recordFound=0;
	var id,name,nquery,imgs;
	var strUrl=location.href;
	query=strUrl.substr(strUrl.indexOf("=")+1);
	query=query.toLowerCase();
	nquery=query;
	q=new Array();
	result=-1;
	a=false;
	for(i=0;i<=query.length;i++){
		if(query.indexOf("+",i)>=0){
			query=query.replace("+"," ");
		}
	}
	q=query.split(" ");

	function checkingQuery(){
		a=query.indexOf(".");
		if(a>0){
			checkingId();
		}
		else
			checkingName();
		}

	function checkingId(){
		var v=false;
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc=loadingxml(xml);
		len=xmldoc.documentElement.childNodes.length;
		for(i=0;i<len;i++){
			len2=xmldoc.documentElement.childNodes.item(i).childNodes.length
			for(k=0;k<len2;k++){
				color="";
							if(k%2==0){
							color="#F2F2F2"
							}
							else{
							color="#f2f2f2";
							}
				name=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(0).text
				id=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(1).text
				fname=name.toLowerCase();
				if(fname.indexOf(q[0])>result || fname.indexOf(q[1])>result  || fname.indexOf(q[2])>result){
				
				document.write("<tr bgcolor="+color+"> <td width=14% ><center><font size=1 face=verdana color=#000000>"+name+"</font></center></td>    <td ><font size=1 face=verdana><a href='"+imagePage+"?value="+name+"'>"+id+"</a></font></td></tr>");
				recordFound=recordFound+1;
				v=true;
				}
						
			}
					
		}
		
			
		if(v==false)	
			document.write("<div align=center><font color=#FF0000><strong><em>NO RECORD FOUND!!!</em></strong></font>");
		else
			document.write("<div align=center><strong><font color=#333333 size=2><em><font color=#000099>Your Query</font></em> : <font color=red>"+nquery+"</font></font></strong></div>");	
			document.write("<div align=center><strong><font color=#333333 size=2><em><font color=#000099>Total Items Found </font></em> : <font color=red>"+recordFound+"</font></font></strong></div>");	
	}
		
	


	function checkingName(){
		var v=false;
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc=loadingxml(xml);
		len=xmldoc.documentElement.childNodes.length;
		for(i=0;i<len;i++){
			len2=xmldoc.documentElement.childNodes.item(i).childNodes.length
			for(k=0;k<len2;k++){
				color="";
							if(k%2==0){
							color="#F2F2F2"
							}
							else{
							color="#f2f2f2";
							}
				id=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(0).text
				name=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(1).text
				fname=name.toLowerCase();
				if(fname.indexOf(q[0])>result || fname.indexOf(q[1])>result  || fname.indexOf(q[2])>result){
				
				document.write("<tr bgcolor="+color+"> <td width=14% ><center><font size=1 face=verdana color=#000000>"+id+"</font></center></td>    <td ><font size=1 face=verdana><a href='"+imagePage+"?value="+id+"'>"+name+"</a></font></td></tr>");
				recordFound=recordFound+1;
				v=true;
				}
						
			}
					
		}
				

		if(v==false)
			document.write("<div align=center><font color=#FF0000><strong><em>NO RECORD FOUND!!!</em></strong></font>");
		else
			document.write("<div align=center><strong><font color=#333333 size=2><em><font color=#000099>Your Query</font></em> : <font color=red>"+query+"</font></font></strong></div>");	
			document.write("<div align=center><strong><font color=#333333 size=2><em><font color=#000099>Total Items Found </font></em> : <font color=red>"+recordFound+"</font></font></strong></div>");	
	}
	
	
	if(query==""){
		document.write("<div align=center><font color=#FF0000><strong><em>NO RECORD FOUND!!!</em></strong></font>");
	}
	else{
		checkingQuery();
	}	
			
			
			
			
			
			
	
}


function gettingUrl(){
	
	strUrl = location.href;
	strValue=strUrl.substr(strUrl.indexOf("=")+1);
	return strValue	
}



function catalog(xmlFile,imagePage,mainCatagory){
	gettingUrl();
	
	var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
	xmldoc=loadingxml(xmlFile);
	
	len=xmldoc.documentElement.childNodes.length;
	for(i=0;i<len;i++){
		id=xmldoc.documentElement.childNodes.item(i).attributes.item(0).value
		CatagoryName=xmldoc.documentElement.childNodes.item(i).attributes.item(1).value
		
		if(id==strValue){
			document.write("<tr bgcolor=#FFFFFF > <td colspan=2 ><div align=center></div><div align=left><font color=#999999 FACE=VERDANA><strong>  "+CatagoryName+"</strong></font></div></td></tr>");
 			document.write(" <tr bgcolor=#A4BFBC>  <td ><div align=center><font size=2 face=VERDANA color=#ffffff><strong>Item No </strong></font></div></td ><td width=78%><div align=center><font size=2 face=VERDANA color=#ffffff><strong>Item Description</strong></font></div></td></tr>");
			len2=xmldoc.documentElement.childNodes.item(i).childNodes.length
			for(k=0;k<len2;k++){
				color="";
							if(k%2==0){
							color="#f2f2f2"
							}
							else{
							color="#f2f2f2";
							}
				ProductId=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(0).text
				name=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(1).text
				document.write("<tr bgcolor="+color+" > <td width=18% ><center><font size=1 face=Verdana font color=#000000>"+ProductId+"</font></center></td>    <td ><font size=1 face=Verdana color=#003399><a href='"+imagePage+".html?value="+ProductId+"&"+strValue+"' class=STYLE1>"+name+"</a></font></td></tr>");
			}
		
		}	
		
	}

}



function catagoryImage(xml,CatagoryName,ImagePath,imagePage,indexpage){
	var a,len,len2,i,k;
	strUrl = location.href;
	strValue=strUrl.substring(strUrl.indexOf("=")+1,strUrl.indexOf("&"));
	strId=strUrl.substr(strUrl.indexOf("&")+1);
	var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async=false;
	xmldoc.load(xml);
	if(xmldoc.parseError.errorCode!=0)
		alert("Error");
	len=xmldoc.documentElement.childNodes.length;
	for(i=0;i<len;i++){
		id=xmldoc.documentElement.childNodes.item(i).attributes.item(0).value
		a=xmldoc.documentElement.childNodes.item(i).attributes.item(1).value
		if(id==strId){
			len2=xmldoc.documentElement.childNodes.item(i).childNodes.length
			break;
		}
	}
	for(k=0;k<len2;k++){
		imageid=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(0).text
		name=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(1).text
		image=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(2).text
		if(imageid==strValue){
			break;
		}
	}
			
	LastChild=xmldoc.documentElement.childNodes.item(i).lastChild.childNodes.item(0).text
	FirstChild=xmldoc.documentElement.childNodes.item(i).firstChild.childNodes.item(0).text
	if(FirstChild==strValue){
		nextimg=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).nextSibling.childNodes.item(0).text
		document.write(" <a href='"+indexpage+".html?value="+strId+"'><img src=images/top1.jpg  alt=Back  border=0></a> <a href='"+imagePage+".html?value="+nextimg+"&"+strId+"'><img src=images/next.jpg  alt=NEXT  border=0></a>");										
	}			
	else if(LastChild==strValue){						
		preimg=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).previousSibling.childNodes.item(0).text
		document.write(" <a href='"+imagePage+".html?value="+preimg+"&"+strId+"'><img src=images/pre.jpg alt=PREVIOUS  border=0></a> <a href='"+indexpage+".html?value="+strId+"'><img src=images/top1.jpg  alt=Back  border=0></a>");
	}
	else{
		n=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).nextSibling.childNodes.item(0).text
		p=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).previousSibling.childNodes.item(0).text
		document.write("<a href='"+imagePage+".html?value="+p+"&"+strId+"'><img src=images/pre.jpg alt=PREVIOUS  border=0></a>  <a href='"+indexpage+".html?value="+strId+"'><img src=images/top1.jpg  alt=Back border=0></a> <a href='"+imagePage+".html?value="+n+"&"+strId+"'><img src=images/next.jpg alt=NEXT  border=0></a>");	
	}												

	document.write("<br>");
	document.write("<br>");
	document.write("<b> <a href='"+indexpage+".html?value="+strId+"'> "+a+" </a> <br><br>"+imageid+"&nbsp;&nbsp;-&nbsp;&nbsp;</b>"+name);
	document.write("<br>");
	document.write("<br>");
	document.write("<img src='images/"+ImagePath+"/"+image+"' alt='"+name+"'>");
	document.write("<br>");
	document.write("<br>");
	LastChild=xmldoc.documentElement.childNodes.item(i).lastChild.childNodes.item(0).text
	FirstChild=xmldoc.documentElement.childNodes.item(i).firstChild.childNodes.item(0).text
	if(FirstChild==strValue){
		nextimg=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).nextSibling.childNodes.item(0).text
		document.write(" <a href='"+indexpage+".html?value="+strId+"'><img src=images/top1.jpg  alt=Back  border=0></a> <a href='"+imagePage+".html?value="+nextimg+"&"+strId+"'><img src=images/next.jpg  alt=NEXT  border=0></a>");										
	}			
	else if(LastChild==strValue){						
		preimg=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).previousSibling.childNodes.item(0).text
		document.write(" <a href='"+imagePage+".html?value="+preimg+"&"+strId+"'><img src=images/pre.jpg alt=PREVIOUS  border=0></a> <a href='"+indexpage+".html?value="+strId+"'><img src=images/top1.jpg  alt=Back  border=0></a>");
	}
	else{
		n=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).nextSibling.childNodes.item(0).text
		p=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).previousSibling.childNodes.item(0).text
		document.write("<a href='"+imagePage+".html?value="+p+"&"+strId+"'><img src=images/pre.jpg alt=PREVIOUS  border=0></a>  <a href='"+indexpage+".html?value="+strId+"'><img src=images/top1.jpg  alt=Back border=0></a> <a href='"+imagePage+".html?value="+n+"&"+strId+"'><img src=images/next.jpg alt=NEXT  border=0></a>");	
	}												

}
						


function CatalogCatagories(xml,itempage){
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc.async=false
		xmldoc.load(xml);
		if(xmldoc.parseError.errorCode!=0)
			alert("Error");
		len=xmldoc.documentElement.childNodes.length;
		for(i=0;i<len;i++){
			color="";
							if(i%2==0){
							color="#E7F1FE"
							}
							else{
							color="#ebeef7";
							}
			id=xmldoc.documentElement.childNodes.item(i).attributes.item(0).value
			name=xmldoc.documentElement.childNodes.item(i).attributes.item(1).value
			document.write("<tr bgcolor="+color+"><td align=center ><font color=#000099 face=Verdana size=2>"+id+"</font></td><td ><font color=#003399 face=Verdana size=2><a  href='"+itempage+".html?value="+id+"'>"+name+"</a></font></td></tr>");
		
		}
	
}




function tableColor(a)
{
	color="";
	if(i%2==0)
	{
		color="#E7F1FE"
		return color;
	}
	else
	{
		color="#DFD0DF";
		return color;
	}	

}
function searchImage(xml,ImagePath,CatagoryName){
	var a,len,len2,k,i;
	strUrl = location.href;
	
	strValue=strUrl.substr(strUrl.indexOf("=")+1);
	var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async=false;
	xmldoc.load(xml);
	if(xmldoc.parseError.errorCode!=0)
		alert("Error");
		len=xmldoc.documentElement.childNodes.length;
		for(i=0;i<len;i++){
			
			a=xmldoc.documentElement.childNodes.item(i).attributes.item(1).value
			len2=xmldoc.documentElement.childNodes.item(i).childNodes.length
				for(k=0;k<len2;k++){
					imageid=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(0).text
					name=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(1).text
					image=xmldoc.documentElement.childNodes.item(i).childNodes.item(k).childNodes.item(2).text
					if(imageid==strValue){
						
					document.write(CatagoryName+"  "+a+" <img src=images/arrow.gif > "+name);
						document.write("<br>");
						document.write("<br>");
						document.write("<img src='images/"+ImagePath+"/"+image+"' alt='"+name+"'>");
						document.write("<br>");
						document.write("<br>");
		

					}
				}
		}
		
				
	}
