
var companies;
var companyViewFlag;
var cRowNum;
var tempHtml;
var cell1,cell2,cell3;

function addCompany(num,c_id,cName,Address,City,State,Zip,cLink,Comment,Phone)
{
	companies[num].c_id=c_id;
	companies[num].cName=cName;
	companies[num].Address=Address;
	companies[num].City=City;
	companies[num].State=State;
	companies[num].Zip=Zip;
	companies[num].cLink=cLink;
	companies[num].Comment=Comment;
	companies[num].Phone=Phone;


}

function deleteCRow ()
{
var c;
	t=document.getElementById("companyTable");
	t.rows[cRowNum].deleteCell(0);
	c=t.rows[cRowNum].insertCell(0);
	c.className='list';
  c.innerHTML=cell1;
	c=t.rows[cRowNum].insertCell(1);
	c.className='list';
  c.innerHTML=cell2;
	c=t.rows[cRowNum].insertCell(2);
	c.className='list';
  c.innerHTML=cell3;
	
}

function close_div ()
{
var estimate_form
	estimate_form=document.getElementById("estimate_form").style;
  estimate_form.visibility="hidden";
}

function showdiv (my_id)
{
var estimate_form
	estimate_form=document.getElementById("estimate_form").style;
  estimate_form.visibility="visible";
  comp_id=document.getElementById("company_id");
  comp_id.value=my_id;
}

function estimate_popup(company_id)
{
	window.popup("estimate_form.html?id="+company_id);
}

function addRowCell (t,info,classType)
{
	if (info=="")
	  info='hello';
	r=t.insertRow(t.rows.length);
	r.className="list_odd";
	c=r.insertCell(0);
	c.innerHTML=info;
	c.className=classType;
	c.align='right';
	return(r);
}

function addCell2Row (r,info,classType)
{
	if (info=="")
	  info='hello';
	c=r.insertCell(r.cells.length);
	c.innerHTML=info;
	c.className=classType;
	c.align='right';
	return(r);
}

function show_profile(num,event)
{
	winBody=document.getElementsByTagName("body");
	
  if (!(yOff=self.pageYOffset))
  {
  	  if (document.documentElement)
    	  yOff=document.documentElement.scrollTop;
      else
      	yOff=document.body.scrollTop;
   }
    	
	var estimate_form;
	estimate_form=document.getElementById("cProfile").style;
  estimate_form.top=yOff+"px";
  estimate_form.visibility="visible";
  comp_id=document.getElementById("profile_frame");
  comp_id.src="CompanyProfile.php?id="+num;
}

function hide_profile ()
{
var estimate_form
	estimate_form=document.getElementById("cProfile").style;
  estimate_form.visibility="hidden";
}


function showCompany(tableRow,num) 
{
	if (companyViewFlag==1)
	   deleteCRow ();
	cRowNum=tableRow.rowIndex;
	t=document.getElementById("companyTable");
	r=t.rows[cRowNum];
	cell1=t.rows[cRowNum].cells[0].innerHTML;
	cell2=t.rows[cRowNum].cells[1].innerHTML;
	cell3=t.rows[cRowNum].cells[2].innerHTML;
	t.rows[cRowNum].deleteCell(2);
	t.rows[cRowNum].deleteCell(1);
	t.rows[cRowNum].deleteCell(0);
	
	//r.innerHTML="<td id=tempcell colspan=3 class=list_even><table id='tempinfo' width=100% class='list_table2' cellSpacing=0 cellPadding=0><tr><td></td></tr></table></td>";
	c=r.insertCell(0);
	c.className="list_even";
	c.colSpan=3;
	table_class="list_table2";
	if (num==1)
	table_class="list_top";
	c.innerHTML="<table border=0 id='tempinfo' width=100% class='list_table2' style='border-right:1px solid #e6e6e6;;' cellSpacing=0 cellPadding=0><tr><td></td></tr></table>";
	
	t=document.getElementById("tempinfo");
	
	//r=t.insertRow(t.rows.length);
	//r.className="list_odd";
	//c=r.insertCell(0);
	r=addRowCell (t,companies[num].cName,"company_name");
	c.align="left";
  c=r.insertCell(1);	
  c.innerHTML="<img src='image.php?id="+companies[num].c_id+"' width=100 height=100>";
  c.rowSpan=6;
  c.vAlign="top";
  c.className="list_noborder";
	c.align='right';
	addRowCell (t,companies[num].Address+"<br>"+companies[num].City+", "+companies[num].State+"  "+companies[num].Zip,"basic_list");
	//addRowCell (t,companies[num].City+", "+companies[num].State+"  "+companies[num].Zip,"basic_list");
	r=addRowCell (t,"&nbsp","basic_list");
	r=addRowCell (t,companies[num].Phone+"<br><a href='"+companies[num].cLink+"'>"+companies[num].cLink+"</a>","basic_list");
/*	if (companies[num].cLink=="")
	r=addRowCell (t,"&nbsp","basic_list");
	else
	addRowCell (t,"<a href='"+companies[num].cLink+"'>"+companies[num].cLink+"</a>","basic_list");*/
	r=addRowCell (t,"&nbsp","basic_list");
	r=addRowCell (t,"&nbsp","list_bottom");
	r.cells[0].colSpan=2;
	if (companies[num].cName=="TreeJob.com")
	r2=addRowCell (t,"<table class=list_table style='border-left:0px;border-top:0px;border-bottom:0px;'><tr class=list_odd><td class=basic_list><a>More Info >></a>&nbsp&nbsp|</td><td class=basic_list> <a href='http://treejob.com/request.html'>Request Quote >></a>&nbsp |</td><td  class=basic_list> <a>Comments >></a></td></tr></table>","");
	else
	r2=addRowCell (t,"<table class=list_table style='border-left:0px;border-top:0px;border-bottom:0px;'><tr class=list_odd><td class=basic_list><a>More Info >></a>&nbsp&nbsp|</td><td class=basic_list> <a>Request Quote >></a>&nbsp |</td><td  class=basic_list> <a>Comments >></a></td></tr></table>","");
	addCell2Row (r2,"<table class=list_table2 style='border-right:1px solid #e6e6e6;'><tr class=list_odd onclick='deleteCRow();'><td align='right' class=button>X Close</td></tr></table>","");
	r2.cells[1].align='right';
	//alert(r2.innerHTML);
	//r2.cells[0].className='basic';
	r2.cells[0].align='left';
	
	companyViewFlag=1;
	
}

function iniCompanies ()
{
	companyViewFlag=0;
	companies=new Array(30);
	
	for (loop=0;loop<30;loop++)
		companies[loop]= new Object();
	
}

