/*
  * @ (#)coursecatalog.js 1.0 19-May-2006 1.0
  * Copyright (c) 2001-2002 KESDEE Systems(India) PVT. LTD.
  * # 6, 3rd floor,Esteem Regency, Richmond road, Bangalore, India
  * All rights reserved.
  *
  * This software is the confidential and proprietary information of KESDEE Systems(India) PVT. LTD. ("Confidential Information"). 
  * You shall not disclose such Confidential Information and shall use it only in
  * accordance with the terms of the license agreement you entered into
  * with KESDEE.
*/
  
/*
  * @author Venkata Ramana.D
  * @Version: 1.0 19-05-2006
  
  * Decription :- This js file is used to get the courselist from the server and displays the course catalog.
  * It communicates between the server and client by sending the XMLHTTPRequest object for getting course list 
  * by receiving the response object and also when the user clicks on the product or SCO. 
  * This is also implemented for expanding and collapsing the course list.
*/ 
var xmlHttp
var gprodid=0;
var descid=0;
var prid=0;
var scid=0;
var imgid
function prodList()
{ 
	document.getElementById("prodid").innerHTML="<b>Please Wait......</b>"
	var url="productcatalog.jsp"
	loadFile(url);
}//end prodList

function prodPartnerList(TMID)
{ 
	document.getElementById("prodid").innerHTML="<b>Please Wait......</b>"
	var url="productpartnercatalog.jsp?TMID="+TMID;
	loadFile(url);
}//end prodPartnerList

function scoList(sco,prodid) 
{ 
	//alert("SCO & Productid"+prodid)
	gprodid = prodid;
	
	if (document.getElementById("sco"+prodid).style.display == "block"){ 
	  document.getElementById("sco"+prodid).style.display = "none" 
	  document.getElementById("img"+prodid).src = 'icons/folder.gif'
	}else{ 
	  if(prid != "sco"+prodid && prid != 0){
	    document.getElementById(imgid).src = 'icons/folder.gif'
		document.getElementById(prid).style.display = "none"
	  }//end if
	 document.getElementById("sco"+prodid).style.display = "block" 
	 document.getElementById("img"+prodid).src = 'icons/textfolder.gif'
	 prid="sco"+prodid;
	 imgid="img"+prodid;
	}//end else 
	
	document.getElementById("sco"+prodid).innerHTML="<b>Please Wait......</b>"
	var url="scolist.jsp?desc="+sco+"&prodid="+prodid
	loadFile(url);
}//end scoList 

function description(desc,scoid)
{ 
	//alert("Desc & SCOid"+scoid)
	descid = scoid;
	if (document.getElementById("desc"+scoid).style.display == "block"){ 
	   document.getElementById("desc"+scoid).style.display = "none"; 
	}else{ 
	   if(scid != "desc"+scoid && scid != 0)
	      document.getElementById(scid).style.display = "none";	
	   document.getElementById("desc"+scoid).style.display = "block"; 
	   scid="desc"+scoid;
	}//end else 
	document.getElementById("desc"+scoid).innerHTML="<b>Please Wait......</b>";
	var url="scolist.jsp?desc="+desc+"&prodid="+scoid;
	loadFile(url);
}//end description

function loadFile(url)
{
  xmlHttp=GetXmlHttpObject(stateChanged)
  xmlHttp.open("GET", url , true)
  xmlHttp.send(null)
}//end loadFile

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		if(gprodid == 0)
		  document.getElementById("prodid").innerHTML=xmlHttp.responseText 
		else if(descid == 0 && gprodid != 0)
		{
	     // alert("Productid"+gprodid)	
		  document.getElementById("sco"+gprodid).innerHTML=xmlHttp.responseText 
		 
		}//end elseif  
		else if(descid != 0)
		{
	    //  alert("SCOid"+descid)	 
		  document.getElementById("desc"+descid).innerHTML=xmlHttp.responseText 
		  descid=0;
		}//end elseif  
	}//end if 
}//end stateChanged 

function GetXmlHttpObject(handler) 
{ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This example doesn't work in Opera") 
		return 
	}//end if
	if (navigator.userAgent.indexOf("MSIE")>=0){ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP"
		}//end if 
		try{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		}catch(e){ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	}//end if 
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}//end if
}//end GetXmlHttpObject 


