	
	var docLocation  =top.docLocation;
	//var urlLocation=top.urlLocation;
	//var urlLocation='C:/backup/softAge/softAgeSite/newSiteDocs/';
	var urlLocation='http://www.softage.co.il';
	var imgLocation='http://www.softage.co.il/images';
	//var imgLocation='C:/backup/softAge/softAgeSite/newSiteDocs/images';
	//var imgLocation=top.imgLocation;
	
	//var xml = new ActiveXObject("microsoft.xmldom");
	var theTable;
 var brTr=4;
var counter=1;				
	
	 var xmlhttp;
	var docroot;
	theTable = document.createElement("TABLE");
	theTable.setAttribute("cellpadding","2");
	theTable.setAttribute("cellspacing","2");
	theTable.setAttribute("width","100%");
	theTable.setAttribute("border","0");
	theTable.setAttribute("bordercolor","white");
	//theTable.setAttribute("dir","rtl");
	theTable.setAttribute("align","center");
	
	function checkLoading()
	{
		//alert(xmlhttp.status);
		if (xmlhttp.readyState==4) 
		{

			 docroot=xmlhttp.responseXML;
			 docroot.load(xmlhttp.responseStream);
			// alert(docroot.documentElement);
			if (!docroot.documentElement && xmlhttp.responseStream){
			//alert(docroot.documentElement );
			docroot.load(xmlhttp.responseStream);
			//alert(docroot.documentElement );
			}


		}

}

function verify(){ 
	 if (xmlhttp.readyState != 4)
		  return false; 
}


// new one

function docs(){
	try{
		docroot= document.all("writersXML").XMLDocument;
		if(docroot)
			makeTheTable(docroot);
		else
			alert('תקלה בקריאת הנתונים ');
	}catch(err){
		try{
			alert(4);
			xmlhttp = new ActiveXObject("Microsoft.XMLDOM");
			xmlhttp.async="false";
			 xmlhttp.onreadystatechange=verify;
			 xmlhttp.load(urlLocation +'/'+xmlName);
			 docroot=xmlhttp.documentElement;
		     }
				catch (e)  
				  {
					try  
					 {  
					 alert(3);
					  // Internet Explorer 
					  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					  xmlhttp.open("GET",xmlName,true);
					  xmlhttp.onreadystatechange = checkLoading;
					xmlhttp.send(null);
					docroot=xmlhttp.documentElement;
					  }  catch (e) 
					  	{   
						   try     
						    {      
						    alert(2);
						    xmlhttp= new ActiveXObject("MSXML2.XMLHTTP.3.0");
						    xmlhttp.open("GET",xmlName,true);
						    xmlhttp.onreadystatechange = checkLoading;
						   xmlhttp.send(null);
						   docroot=xmlhttp.documentElement;
						     }    
						   catch (e)  {      
						   		try{
						   		alert(1);
						   			xmlhttp = new window.XMLHttpRequest();
									xmlhttp.open("GET",xmlName,false);
									xmlhttp.send(null);
									docroot = xmlhttp.responseXML.documentElement;
						   		}  catch (e)  {      
							   	    alert("Your browser does not support AJAX!");      
							    return false;      
						  				 }    
								}
						  }
			
					  if(!docroot)
						alert('נא להמתין');

					if(docroot)
						makeTheTable(docroot);
					else
						alert('תקלה בקריאת הנתונים ');
				}
	}	
}
	
	function makeTheTable(docroot)
	{
		 

		//var test = document.all.activeMainDiv.innerHTML;
		//alert(test);
		if (docroot.getElementsByTagName("SOFTAGE").length!=0)
		{
			
			//main active list
			for (i=0;i<docroot.getElementsByTagName("SOFTAGE").length;i++){
			
						var theTr = theTable.insertRow();
						var theTd = theTr.insertCell();
						theTd.valign="middle"
						var activeTitle = docroot.getElementsByTagName("TITLE").item(i).text;
						var activeName = docroot.getElementsByTagName("SOFTAGE").item(i).getAttribute('name');
						theTd.innerHTML =activeTitle;
						if(docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").length!=0)
						theTd.innerHTML +='&#160;<img style="cursor:hand;" id="oredrIcon'+activeName+' " src="images/orderIcon.gif" onClick="showHideSitesList(this,'+activeName+');"/>';
						theTd.innerHTML +='<DIV id="'+activeName+'" dir="rtl" style="width:100%;color:black;height:80%;display:inline;"><LABEL id="label'+activeName+'"/><TABLE cellSpacing=0 cellPadding=1 border=1 width="100%" height=100%  bordercolor="#90B71C"  id="table'+activeName+'"></TABLE></DIV>';
						theTd.innerHTML +='<hr  style="color:#057CB7;"/>';
				
				}
			document.all.activeMainDiv.appendChild(theTable);
			//sub active list
			
			for (i=0;i<docroot.getElementsByTagName("SOFTAGE").length;i++){
				counter=1;
			for (j=0;j<docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").length;j++){
					
					if(parseInt(counter)!=parseInt(brTr))
						counter=parseInt(counter)+1;
					else
						counter=1;
					
					var mainActiveName =docroot.getElementsByTagName("SOFTAGE").item(i).getAttribute('name');
					var subActiveTitle = docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").item(j).text;
					var subSoftageImageDescription = docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").item(j).getAttribute('description');
					var subActiveimageSmallHref = docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").item(j).getAttribute('imageSmallHref');
					var subSoftageImageCost=docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").item(j).getAttribute('price');
					var subSoftageImageLink=docroot.getElementsByTagName("SOFTAGE").item(i).getElementsByTagName("SUB_SOFTAGE").item(j).getAttribute('link');

					var temp = eval('document.all.label'+mainActiveName);
					
					var tempTable = eval('document.all.table'+mainActiveName);
					if(parseInt(counter)==parseInt(2)){
						var tempTableTr = tempTable.insertRow();
						tempTableTr.id='tr'+activeName
						}
						var tempTableTd = tempTableTr.insertCell();
						tempTableTd.valign="top";
						tempTableTd.align="center";
						if((subSoftageImageDescription!=null)&&(subActiveimageSmallHref!=null)){
							//show function previewImgText
							//tempTableTd.innerHTML +=subActiveTitle+'<BR/><IMG style="cursor:hand;" value="'+subSoftageImageDescription+'"  alt="'+subSoftageImageDescription+'" height="100" border="0" src="'+subActiveimageSmallHref +'" onclick="previewImgText(this)" /><BR/>'+subSoftageImageDescription				
							tempTableTd.innerHTML +=subActiveTitle+'<BR/><a href="'+subActiveimageSmallHref +'"rel="lightbox" title="'+subSoftageImageDescription+'"> <IMG style="cursor:hand;" value="'+subSoftageImageDescription+'"  alt="'+subSoftageImageDescription+'" height="100" border="0" src="'+subActiveimageSmallHref +'" /></a><BR/>'+subSoftageImageDescription				

						//alert(subSoftageImageCost)
					/*
						if (subSoftageImageCost!='')
							tempTableTd.innerHTML += '<BR/>מחיר לצרכן:  '+subSoftageImageCost
						else
							tempTableTd.innerHTML += '<BR/>&#160;'
					*/
						if (subSoftageImageLink!=null){
							tempTableTd.innerHTML += '<BR/><a href="'+urlLocation+'/'+subSoftageImageLink+'"/>לחץ/י למוצרים דומים</a> '
						}
							
					}	
					//if(subActiveExpHref!=null)
					//	temp.innerHTML +='<A href="'+subActiveExpHref+'">&#160;<IMG border="0" src="images/explorer.gif"/></A> ';
					//temp.innerHTML +='<br/>';
				}
			}
		}
		else
			alert('no active xml');

}
function node(hrefDoc,titleDoc)
{
	this.docHref = hrefDoc;
	this.docLoc = docLocation;
	this.title = titleDoc;
}

function open_form(imgHref,docTitle)
{
	
	var selectedDoc =new node(imgHref,docTitle);
	var returnValue = showModalDialog(urlLocation+"/doc.html",selectedDoc,"dialogWidth:43em;dialogHeight:30em;status:no");
	
}
function showHideSitesList(imgObj,activeDivName)
{
	//alert(imgLocation);
	if (activeDivName.style.display=='none')
		{
		
		imgObj.src = imgLocation + '/orderIconUp.gif';
		activeDivName.style.display = 'inline';
		}
		else
			{
			imgObj.src = imgLocation + '/orderIcon.gif';
			activeDivName.style.display = 'none';
			//document.all.activePreviewDoc.src= imgLocation + '/empty.gif';
			}
}
	
function previewDoc(IframeImageSrc,iframeDocSrc)
{
	
	document.all.activePreviewDoc.src =urlLocation +'\\activedocs\\'+ IframeImageSrc;
	document.all.activePreviewDoc.href = docLocation + '/'+iframeDocSrc;
	//document.all.activePreviewDoc.attachEvent('onclick',goHref);
}

/*
function goHref()
{
	window.open(document.all.activePreviewDoc.href,'','');
}
*/
