// mm open window function

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function drawZTafel(i){


	var elem = document.getElementById('lst');
	var taffel = document.createElement("TABLE");
	var taffelTbody = document.createElement("TBODY");
	var taffelTr = document.createElement("TR");
	var taffelTd = document.createElement("TD");
	var aString = document.createTextNode(" ");
	
	taffelTd.appendChild(aString);

	taffelTd.colSpan=4;
	taffelTd.className ="marg";
	taffelTr.appendChild(taffelTd);
	
	taffelTbody.appendChild(taffelTr);
	taffel.appendChild(taffelTbody);
	
	// the second row
	taffelTbody = document.createElement("TBODY");
	taffelTr = document.createElement("TR");
	
	taffelTd = document.createElement("TD");
	taffelStrong = document.createElement("b");
	aString = document.createTextNode("List Price $ "+prics[i]);
	taffelStrong.appendChild(aString);

	taffelTd.appendChild(taffelStrong);
	taffelTd.setAttribute('align','center');
	taffelTd.className ="style5";
	taffelTr.appendChild(taffelTd); // add the first cell
	
	taffelTd = document.createElement("TD");
	
	var newAnch  = document.createElement('a');	
	newAnch.href="javascript:MM_openBrWindow('http://www.learningecommerce.com/special/mortgage?pr="+prics[i]+ "','mortgage','status=yes,scrollbars=yes,width=540,height=600');";
	//newAnch.target="_new";
	
         //newAnch.addEventListener('click',function (e) {
        //    MM_openBrWindow('http://www.learningecommerce.com/special/mortgage?pr='+prics[i],'mortgage','status=yes,scrollbars=yes,width=440,height=600');
           // e.stopPropagation;
        //},true);
         
         
         
	aString = document.createTextNode("Calculate Mortgage ");
	newAnch.appendChild(aString);
	
	taffelTd.appendChild(newAnch);
	taffelTd.className ="style3";
	taffelTr.appendChild(taffelTd);
	
	taffelTd = document.createElement("TD");
	aString = document.createTextNode("Listing Area "+listares[i]);
	taffelTd.appendChild(aString);
	taffelTd.colSpan=2;
	taffelTr.appendChild(taffelTd);
	// add the row to the table body
	taffelTbody.appendChild(taffelTr);
	taffel.appendChild(taffelTbody);
	
	// the THIRD row
	taffelTbody = document.createElement("TBODY");
	taffelTr = document.createElement("TR");
	taffelTd = document.createElement("TD");
	aString = document.createTextNode("If there\'s a change in the status of this home, you can be ");
	taffelTd.appendChild(aString);
	
	newAnch  = document.createElement('a');

//	newAnch.href = "#";
	//http://go.webrealtor123.com/usr/george/js/index.jsp?fnum=6&amp;addr=2204+%22A%22+Don+Pasqual+Rd.&amp;mls=417440
	//newAnch.href = thedomain+"/usr/"+username+"/js/index.jsp?fnum=6&addr="+addrs[i]+"&mls="+mlss[i];
 
        
	//newAnch.href = "http://www.learningecommerce.com" +"/contact?user_id="+user_id+"&property_id="+lids[i]
	//newAnch.target="_new"
	
         
	newAnch.href="javascript:MM_openBrWindow('http://www.learningecommerce.com/contact?user_id=" + user_id + "&property_id=" + lids[i] + "','contactform','status=yes,scrollbars=yes,width=640,height=600');";
         //newAnch.onclick="onclick=\"MM_openBrWindow(\'http://www.learningecommerce.com/contact?user_id=&amp;property_id=6\',\'contactform\',\'status=yes,scrollbars=yes,width=600,height=600\')\"";
       // newAnch.addEventListener('click',function (e) {
        //    MM_openBrWindow('http://www.learningecommerce.com/contact?user_id=' + user_id + '&property_id=' + lids[i] ,'contactform','status=yes,scrollbars=yes,width=640,height=600');
        //    e.stopPropagation;
        //},true);
	aString = document.createTextNode("Notified Immediately");
	newAnch.appendChild(aString);
	taffelTd.appendChild(newAnch);
	
	
	taffelTd.colSpan=4;
	taffelTd.setAttribute('align','center'); 
	taffelTd.className ="style3";
	
	taffelTr.appendChild(taffelTd);
	// add the row to the table body
	taffelTbody.appendChild(taffelTr);
	taffel.appendChild(taffelTbody);
	
	taffelTbody = document.createElement("TBODY");
	taffelTr = document.createElement("TR");
	taffelTd = document.createElement("TD");
	var taffelTstrong = document.createElement("b");
	aString = document.createTextNode("Address: "+addrs[i]);
	taffelTstrong.appendChild(aString);
	taffelTd.appendChild(taffelTstrong);
	taffelTd.colSpan=2;
	taffelTd.setAttribute('align','center'); 
	//taffelTd.className ="style3";
	
	taffelTr.appendChild(taffelTd);
	//########################################################
	taffelTd = document.createElement("TD");
	var taffelP = document.createElement("p");
	if(ohflags[i]==5){  // sold 
		//######################################################
		aString = document.createTextNode("property status: SOLD");
		taffelP.appendChild(aString);
		taffelP.className ="sold";
		taffelTd.appendChild(taffelP);
		taffelTd.colSpan=2;
		taffelTd.setAttribute('align','center'); 
		taffelTr.appendChild(taffelTd);
		taffelTbody.appendChild(taffelTr);
		taffel.appendChild(taffelTbody);
 	}else if(ohflags[i]==3){  // pending
 		aString = document.createTextNode("property status: Pending");
		taffelP.appendChild(aString);
		taffelP.className ="pending";
		taffelTd.appendChild(taffelP);
		taffelTd.colSpan=2;
		taffelTr.appendChild(taffelTd);
		taffelTbody.appendChild(taffelTr);
		taffel.appendChild(taffelTbody);
		
	}else if(ohflags[i]==2){  // open house
	
		aString = document.createTextNode("Open House");
		taffelP.appendChild(aString);
		taffelP.className ="open";
		taffelTd.appendChild(taffelP);
		taffelTd.colSpan=2;
		taffelTd.setAttribute('align','center'); 
		
		taffelTr.appendChild(taffelTd);
		taffelTbody.appendChild(taffelTr);
		taffel.appendChild(taffelTbody);
		//####################################
		
		taffelTbody = document.createElement("TBODY");
		taffelTr = document.createElement("TR");
		taffelTd = document.createElement("TD");
		taffelTd.colSpan=4;
		aString = document.createTextNode(ohnotes[i]);
	
		taffelTd.appendChild(aString);
		taffelTr.appendChild(taffelTd);
		taffelTbody.appendChild(taffelTr);
		taffel.appendChild(taffelTbody);
	
	}else{   // no image 
	
	
		taffelTd.colSpan=2;
		taffelTd.setAttribute('align','center'); 
		taffelTd.className ="style3";
		taffelTr.appendChild(taffelTd);
		taffelTbody.appendChild(taffelTr);
		taffel.appendChild(taffelTbody);	
	
	
	
	}
	
	// add the row to the table body
	//taffelTbody.appendChild(taffelTr);
	//taffel.appendChild(taffelTbody);
	
	// the row with the image 
	taffelTbody = document.createElement("TBODY");
	taffelTr = document.createElement("TR");
	taffelTd = document.createElement("TD");
	var taffelImg = document.createElement("img");

	//taffelImg.setAttribute('src',thedomain+phots[i]); 
	taffelImg.setAttribute('src','http://www.learningecommerce.com' + phots[i]);
	taffelImg.setAttribute('width',232);
	taffelImg.setAttribute('height',155);
	taffelImg.setAttribute('alt','picture of property');
	
	taffelTd.appendChild(taffelImg);
	taffelTr.appendChild(taffelTd);
	
	taffelTd = document.createElement("TD");
	var taffelUl = document.createElement("ul");

	var taffelLi = document.createElement("li");
	newAnch  = document.createElement('a');

	newAnch.href="javascript:MM_openBrWindow('http://www.learningecommerce.com/property/slideshow?property_id="+lids[i]+"&user_id="+user_id+ "','contactform','status=yes,scrollbars=yes,width=640,height=600');";
	
	//newAnch.addEventListener('click',function (e) {
        //    MM_openBrWindow("http://www.learningecommerce.com/property/slideshow?property_id="+lids[i]+"&user_id="+user_id);
        //    e.stopPropagation;
        //},true);
         
         
	aString = document.createTextNode("Additional Pictures ");
	newAnch.appendChild(aString);
	taffelLi.appendChild(newAnch);
	taffelUl.appendChild(taffelLi);
	taffelUl.className ="style3";
	
	taffelLi = document.createElement("li");
	aString = document.createTextNode("MLS "+mlss[i]);
	taffelLi.appendChild(aString);
	taffelLi.className ="style3a";
	taffelUl.appendChild(taffelLi);
	
	taffelLi = document.createElement("li");
	aString = document.createTextNode("Bedrooms "+beds[i]);
	taffelLi.appendChild(aString);
	taffelUl.appendChild(taffelLi);
	
      	taffelLi = document.createElement("li");
	aString = document.createTextNode("Bathrooms "+bats[i]);
	taffelLi.appendChild(aString);
	taffelLi.className ="style3a";
	taffelUl.appendChild(taffelLi);
	
	
	if(lots[i]!=null && lots[i]!=""){
       	taffelLi = document.createElement("li");
		aString = document.createTextNode("Lot Size "+lots[i]);
		taffelLi.appendChild(aString);
		taffelUl.appendChild(taffelLi);
	}
	
	if(cars[i]!=null && cars[i]!=""){
      	taffelLi = document.createElement("li");
		aString = document.createTextNode("Car Num "+cars[i]);
		taffelLi.appendChild(aString);
		taffelLi.className ="style3a";
		taffelUl.appendChild(taffelLi);
	}
     	taffelTd.appendChild(taffelUl);
     	
     	
     	if(extlinks[i]!=null && extlinks[i]!=""){
     	 taffelLi = document.createElement("li");
     	 
     	 newAnch  = document.createElement('a');
	 newAnch.href= extlinks[i];
	 newAnch.target="_new";
	
	 aString = document.createTextNode("More Info: ");
	 newAnch.appendChild(aString);
     	 
	 //aString = document.createTextNode("more info: "+extlinks[i]);
	 
	 taffelLi.appendChild(newAnch);
	 taffelUl.appendChild(taffelLi);
	}
         
	
	var taffelP = document.createElement("p");
	aString = document.createTextNode("Description: "+descs[i]); 
	taffelP.appendChild(aString);
	taffelTd.appendChild(taffelP);
	taffelTd.colSpan=3;
	taffelTr.appendChild(taffelTd);
	
	// add the row to the table body
	taffelTbody.appendChild(taffelTr);
	taffel.appendChild(taffelTbody);
	
	
	taffelTbody = document.createElement("TBODY");
	taffelTr = document.createElement("TR");
	
	taffelTd = document.createElement("TD");
	aString = document.createTextNode("contact: "+realtor+" "); 
	taffelTd.appendChild(aString)
	newAnch  = document.createElement('a');
	newAnch.href = "mailto:"+email;
	aString = document.createTextNode(email); 
	newAnch.appendChild(aString);
	taffelTd.appendChild(newAnch);
	newBr  = document.createElement('br');
	taffelTd.appendChild(newBr);
	aString = document.createTextNode("or call "+phone);
	taffelTd.appendChild(aString);
	taffelTd.className ="style4";

	taffelTr.appendChild(taffelTd);
	
	taffelTd = document.createElement("TD");
	taffelP = document.createElement("p");
	aString = document.createTextNode("Listing agent:  "+lagents[i]);
	taffelP.appendChild(aString);
	newBr  = document.createElement('br');
	taffelP.appendChild(newBr);
	aString = document.createTextNode(laphons[i])
	taffelP.appendChild(aString);
	taffelTd.appendChild(taffelP);
	taffelTd.className ="style2";
	taffelTd.colSpan=2;
	taffelTr.appendChild(taffelTd);
	
	
	taffelTd = document.createElement("TD");
	taffelImg = document.createElement("img");
	
taffelImg.setAttribute('src','http://www.learningecommerce.com/images/mlsrlogosmall.gif'); 
	taffelImg.setAttribute('width',32);
	taffelImg.setAttribute('height',30);
	taffelImg.setAttribute('alt','mls logo');
	taffelTd.appendChild(taffelImg);
	taffelTr.appendChild(taffelTd);
	
	// add the row to the table body
	taffelTbody.appendChild(taffelTr);
	taffel.appendChild(taffelTbody);
	
	// the bottom row
	taffelTbody = document.createElement("TBODY");
	taffelTr = document.createElement("TR");
	taffelTd = document.createElement("TD");
	aString = document.createTextNode(" ");
	taffelTd.appendChild(aString);
	
	taffelTd.colSpan=4;
	taffelTd.className = "marg";
	
	taffelTr.appendChild(taffelTd);
	
	// add the row to the table body
	taffelTbody.appendChild(taffelTr);
	taffel.appendChild(taffelTbody);

	// set the table attributes
	taffel.setAttribute('border',0);
	taffel.setAttribute('cellPadding',0);
	taffel.setAttribute('cellSpacing',0);
	

	
	elem.appendChild(taffel);


}	

function removeChilds(elemName){
	var el = document.getElementById(elemName);
	while(el.hasChildNodes()){
		 el.removeChild(el.firstChild);
	}
}






