var partnumber = new Array();
var pageref;


//the function is the dollar sign function which is a shortcut method of calling getElementbyID
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}//function $() 


//================================================
//			GetXmlHttpObject()
//  This function retrieves XmlHttpObject 
//================================================
function GetXmlHttpObject()
{
//this function retrieves an XmlHttpObject
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
//================End GetXmlHttpObject()=================




//================================================
//			ExpandAssoc()
//================================================
function ExpandAssoc(obj){

  var sRow = obj.id.substr(10);   // The control is of the format plus_assoc#, retrieve#
  var iRow = parseInt(sRow);  //convert to integer

  //find if the object image is a plus sign we expand other wise we reduce
  if (obj.src.indexOf("plus") !=-1){ //expand
   // *** find asscoites
    $("div_assoc"+iRow).innerHTML = "<table><tr><td><img src=/images/spacer.gif width=16 height=1 border=0></td><td colspan=5><img src=images/t.gif height=2 width=590 border=0></td></tr><tr><td><img src=/images/spacer.gif width=16 border=0></td><td width=630 colspan=5 align=left bgcolor=#cfe0f1><font color=333333><i>People who bought the " + partnumber[iRow] + " also bought...</i></font></td></tr></table>";
	obj.src = "http://omega.com/ppt/images/minus.gif";
	ShowAssociates(obj,iRow);
  }
  else { //reduce
   $("div_assoc" + sRow).innerHTML = "";
   obj.src = "http://omega.com/ppt/images/plus.gif"

  }
}//function ExpandAssoc(obj){
//================ End ExpandAssoc() ==================



//================================================
//			ShowAssociates()
//	This function passes reference and partnumber to 
//	and ASP page through AJAX.  A string is returned
// formated(as table) with associate partnumbers
//================================================
function ShowAssociates(obj,iRow){
    var sReponse
	params = "partnumber=" + partnumber[iRow] + "&ref=" + pageref;
	params = encodeURI(params);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 //alert ("could not get GetXmlHttpObject");
	 return;
	 } 
	
	 xmlHttp.open("POST","../ppt/includes/ppt_assocpn.asp",true);
	 //Send the proper header information along with the request
	 
	 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	 xmlHttp.setRequestHeader("Content-length", params.length);
	 xmlHttp.setRequestHeader("Connection", "close");
     xmlHttp.onreadystatechange=function()
     {
		//get the ajax resonse 
	     if(xmlHttp.readyState==4)
	      {
			sResponse = xmlHttp.responseText;
			$("div_assoc"+iRow).innerHTML = sResponse;
			obj.src = "http://omega.com/ppt/images/minus.gif"
		  }//if(xmlHttp.readyState==4

	 
	 }//xmlHttp.onreadystatechange=function()
	 
	 xmlHttp.send(params); 

}//function sGetAssociates(pn,
//=============sGetAssociates()================

