                var plastactive = "NA";
                var clastactive = "NA";
                var mlastactive = "NA";
                var blastactive = "NA";
                var elastactive = "NA";
				var plastActiveName = "NA";
				var clastActiveName = "NA";
				var mlastActiveName = "NA";
				var blastActiveName = "NA";
				var elastActiveName = "NA";
                var activeId = "";
				var activeTopicName = "";
                var activePath  = "";
                var csmPath = ""
                var browType = "";
                function setActive(id,path,detId,sTopic)
                {
                     //alert("detid::::;"+detId);
                     //alert("set activecvvcxv"+id+":::lastactive::"+lastactive);
                      if(detId == 'phydetails')
                      {
                          if(plastactive != "NA")
                          {
                            document.getElementById(plastactive).className = "";
							document.getElementById(plastactive).innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play"  />&nbsp;&nbsp;<a href="javascript:void(0);">'+plastActiveName+'</a> </h2>'
								//alert("1");
                          }
                         //alert("2");
						 document.getElementById(id).className  = "active";
						 document.getElementById(id).innerHTML = '<h2 id="'+id+'h2"><a href="javascript:void(0);">'+sTopic+'</a></h2>';
                         plastactive = id;
						 plastActiveName = sTopic;
                      }
					  else  if(detId == 'acbdetails')
                      {
                          if(clastactive != "NA")
                          {
                            document.getElementById(clastactive).className = "";
							document.getElementById(clastactive).innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play"  />&nbsp;&nbsp;<a href="javascript:void(0);">'+clastActiveName+'</a> </h2>'
                          }
                          document.getElementById(id).className  = "active";
						  document.getElementById(id).innerHTML = '<h2 id="'+id+'h2"><a href="javascript:void(0);">'+sTopic+'</a></h2>';
                          clastactive = id;
						  clastActiveName = sTopic;
                      }
                      else  if(detId == 'chemdetails')
                      {
                          if(clastactive != "NA")
                          {
                            document.getElementById(clastactive).className = "";
							document.getElementById(clastactive).innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play"  />&nbsp;&nbsp;<a href="javascript:void(0);">'+clastActiveName+'</a> </h2>'
                          }
                          document.getElementById(id).className  = "active";
						  document.getElementById(id).innerHTML = '<h2 id="'+id+'h2"><a href="javascript:void(0);">'+sTopic+'</a></h2>';
                          clastactive = id;
						  clastActiveName = sTopic;
                      }
                      else  if(detId == 'mathdetails')
                      {
                          if(mlastactive != "NA")
                          {
                            document.getElementById(mlastactive).className = "";
							document.getElementById(mlastactive).innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play"  />&nbsp;&nbsp;<a href="javascript:void(0);">'+mlastActiveName+'</a> </h2>'
                          }
                          document.getElementById(id).className  = "active";
						  document.getElementById(id).innerHTML = '<h2 id="'+id+'h2"><a href="javascript:void(0);">'+sTopic+'</a></h2>';
                           mlastactive = id;
						   mlastActiveName = sTopic;
                      }
                      else  if(detId == 'biodetails')
                      {
                          if(blastactive != "NA")
                          {
                            document.getElementById(blastactive).className = "";
							document.getElementById(blastactive).innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play"  />&nbsp;&nbsp;<a href="javascript:void(0);">'+blastActiveName+'</a> </h2>'
                          }
                          document.getElementById(id).className  = "active";
						  document.getElementById(id).innerHTML = '<h2 id="'+id+'h2"><a href="javascript:void(0);">'+sTopic+'</a></h2>';
                          blastactive = id;
						  blastActiveName = sTopic;
                      }
                      else  if(detId == 'engdetails')
                      {
                          if(elastactive != "NA")
                          {
                            document.getElementById(elastactive).className = "";
							document.getElementById(elastactive).innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play"  />&nbsp;&nbsp;<a href="javascript:void(0);">'+elastActiveName+'</a> </h2>'
                          }
                          document.getElementById(id).className  = "active";
						  document.getElementById(id).innerHTML = '<h2 id="'+id+'h2"><a href="javascript:void(0);">'+sTopic+'</a></h2>';
                        
                          elastactive = id;
						  elastActiveName = sTopic;
                      }
                         // if(lastactive != "NA")
                         //{
                         //document.getElementById(lastactive).className = "";
                         //}
                         //document.getElementById(id).className  = "active";
                         //lastactive = id;
                    parseXML(path,detId,id);
                  }
                function parseXML(filePath,detId,id)
                  {
                  
                    filePath = csmPath + filePath
                   	if(browType.indexOf("chrome")!=-1)
					{
						var xmlhttp = new window.XMLHttpRequest();
						xmlhttp.open("GET",filePath,false);
						xmlhttp.send(null);
						xmlDoc = xmlhttp.responseXML;
						
						
					}else if(browType.indexOf("firefox")!=-1)
					{
						xmlDoc=document.implementation.createDocument("","",null);
						xmlDoc.async=false;
						xmlDoc.load(filePath);
						xmlObj=xmlDoc.documentElement;
					    

						
					}else if(browType.indexOf("ie")!=-1)
					{
						xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
						xmlDoc.async=false;
						xmlDoc.load(filePath);
					 }
                 
					setListData(xmlDoc,detId,id);
                 }

                 function setListData(xmlDoc,detId,id)
                  {
                    var obj = document.getElementById(detId);
                    obj.innerHTML = "";
                    var xmlObj=xmlDoc.documentElement;
                    var demoPath = csmPath + xmlObj.getAttribute("d");
					demoPath = replaceAll(demoPath, " ", "$");
					//demoPath = replaceAll(demoPath, "_", "#");
					//alert("demoPath"+demoPath)
                    //alert("attribute value:::"+xmlObj.getAttribute("d"));
                    var length = xmlObj.childNodes.length;
                    if(browType == "firefox" || browType == "chrome")
                    {
                        length = (length-1)/2
                        //alert("mozila:::"+length);
                    }
                    var el_div = document.createElement('div');
                   
				    var e2_div = document.getElementById(id+"h2");
					//alert("id"+ id)
					var p = document.createElement('img');
                    //e2_div.style.border ="1px solid black";
					var innerData = e2_div.innerHTML;
					
					var innerData1 = '<img src="images/wdemo.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play" onclick=showDemo("'+demoPath+'") />&nbsp;&nbsp;';
					innerData = innerData1 + innerData;
					//alert("innerData:::::::::"+innerData);
					
					e2_div.innerHTML=innerData;
					//alert(innerData);
					p.style.cursor = "pointer";
					p.style.verticalAlign="middle";
					p.style.marginLeft="0px";
                    p.src="images/wdemo.gif"
					p.title ="Play";
                                    
                   
                       
                    var ul = document.createElement('ul');
                    var i=0;
                    for(ctr=0;ctr<length;ctr+=1,i++)
                    {
                        var subtopic = xmlDoc.getElementsByTagName('s')[i].firstChild.data;
                        var li = document.createElement('li');
                        var txt = document.createTextNode(subtopic);
                        li.appendChild(txt);
                        ul.appendChild(li);
                     }
                    
					
                    el_div.appendChild(ul);
					
                    obj.appendChild(el_div);
                    //document.getElementById("googleadframe").src="pages/topchalks/product/consume/googlead.html";
                  }
                function showDemo(downloadPath)
                  {
					  //deletecook();
                   // alert(downloadPath);
                    downloadPath = replaceAll(downloadPath, "$", " ");
					//downloadPath = replaceAll(downloadPath, "#", "_");
					var pos = downloadPath.lastIndexOf("/");
                    var qname= downloadPath.substring(pos+1,downloadPath.length);
                    downloadPath = downloadPath + "/" + qname + ".sdz"
                  // alert("complete path:"+downloadPath);
                    if(downloadPath!=null && downloadPath!="" && downloadPath!="NA" && downloadPath!="NODATA"){
                            var sw = window.screen.width;
                            var sh = window.screen.height;
                            if(navigator.appName == "Microsoft Internet Explorer"){
                                sw = window.screen.availWidth;
                                sh = window.screen.availHeight;
                            }
                            //alert("width="+sw +" height="+sh +" availWidth="+aw +" availHeight="+ah);
                            //alert("width="+sw +" height="+sh )
                            var uri='pages/topchalks/flexreader/downloadreader.jsp?path='+downloadPath+'&demo=demo' ;
                           
							var newwindow = window.open(uri,'DownLoadSolution','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,left=0,top=0,screenX=0,screenY=0,width='+sw+',height='+sh)
                            if (window.focus)
                            {
                                newwindow.focus();
                            }
                    }

                  }
                function deletecook()
				{
					var d = new Date();
					var cookie_name = "";
					for(var i=0;i<10;i++)
					{
						 cookie_name="topchalks"+i;
					//alert(d.toGMTString() )
						document.cookie = cookie_name+"=;expires="+ d.toGMTString();
					}
					cookie_name = "topchalksCount";
					document.cookie = cookie_name+"=;expires="+ d.toGMTString();
					alert("cookie deletd");
					results = document.cookie.match ( '(^|;) ?' + "topchalks" + '=([^;]*)(;|$)' );

				}
                  function getProduct()
                  {
                    //alert("submit");
                      document.GetAllProductForm.submit();
                  }
                function showChpater(parId,childId,path,detId,couresbox,imgid)
                {
                    //alert("showChpater()"+path)
                    var obj = document.getElementById(imgid);
                    var str = obj.src;
                    var pos=str.lastIndexOf("/");
                    var image = str.substring(pos+1,str.length);
                    str = str.substring(0,pos+1);
                    //alert(str)
                        if(image == "closebttn.gif")
                        {
                            //alert("open")
                            showChapDetails(childId,path,detId);
                            obj.src = str + "open_bttn.gif";
                            document.getElementById(parId).style.display = "block";
                            document.getElementById(couresbox).className  = "openbox";
                        }
                        else if(image == "open_bttn.gif")
                        {
                            obj.src = str + "closebttn.gif"
                            document.getElementById(parId).style.display = "none";
                            document.getElementById(couresbox).className  = "closebox";
                        }
                    //animatedcollapse.toggle(parId)
                }
                function showChapDetails(id,path,detId)
                {
					browType = navigator.userAgent.toLowerCase();
					var xmlDoc;
					var xmlObj;
					var length;
					//alert(browType);
					path = csmPath + path;
					var obj = document.getElementById(id);
                    obj.innerHTML = "";
                    var str  = '<p>Chapters Details</p><div class="vs5"></div>'
                    obj.innerHTML = obj.innerHTML + str;
                    var ul = document.createElement('ul');
                    var i = 0;
                    var subTopic = "";
                    var ctr = 0;
					if(browType.indexOf("chrome")!=-1 || browType.indexOf("safari")!=-1)
					{
						//alert("chrome");
						browType = "chrome";
						var xmlhttp = new window.XMLHttpRequest();
						xmlhttp.open("GET",path,false);
						xmlhttp.send(null);
						xmlDoc = xmlhttp.responseXML;
						
					}else if(browType.indexOf("firefox")!=-1 || browType.indexOf("opera")!=-1)
					{
						//alert("firefox");
						browType = "firefox";
						xmlDoc=document.implementation.createDocument("","",null);
						xmlDoc.async=false;
						xmlDoc.load(path);
					

						
					}else if(browType.indexOf("ie")!=-1)
					{
						//alert("ie");
						browType = "ie";
						xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
						xmlDoc.async=false;
						xmlDoc.load(path);
						
						
					}
                 				
					xmlObj=xmlDoc.documentElement;
					length = xmlObj.childNodes.length;
					if(browType == "firefox" || browType == "chrome")
                    {
                        length = (length-1)/2
                    }
					
					for(ctr=0;ctr<length;ctr+=2,i++)
					{
						 subTopic = xmlObj.getElementsByTagName('c')[i].firstChild.data
						 //alert("subTopic"+subTopic)
						 path = xmlObj.getElementsByTagName('p')[i].firstChild.data
						
						 li = createElementLi(i,subTopic,path,detId);
						 //alert("path"+path)
						 ul.appendChild(li);
					}

					obj.appendChild(ul);
                    setActive(activeId,activePath,detId,activeTopicName);
					//alert("comp")
                }
                function createElementLi(ctr,sTopic,pth,detId)
                {
                    var li = document.createElement('li');
                    var idd = sTopic + ctr;
                        li.id = idd;
                        if(ctr == 0)
                        {
                            activeId = idd;
							activeTopicName = sTopic;
                            //alert("activeId::::"+activeId);
                            activePath = pth;
                              li.innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play" />&nbsp;&nbsp;<a href="javascript:void(0);">'+sTopic+'</a></h2>';
                        }
                        else
                        {
                            li.className  = "";
                              li.innerHTML = '<h2><img src="images/wdemo1.gif" style="vertical-align:middle;margin-left:5px;cursor:pointer" border="0" alt="Play" title="Play" />&nbsp;&nbsp;<a href="javascript:void(0);">'+sTopic+'</a></h2>';
                        }
                        //li.innerHTML = '<h2>'+sTopic+'</h2>'
                        if(li.addEventListener)
                                { // W3C method
                                li.addEventListener('click',function(){setActive(idd,pth,detId,sTopic);},false);
                                }else {// IE method
                                    li.attachEvent('onclick',function(){setActive(idd,pth,detId,sTopic);});
                                }
                          return li;
                }
                function showInstructorDetails(path,data)
                {
                    document.InstructorForm.xmlPath.value =   path;
                    document.InstructorForm.input.value =   data;
                    //alert("Rajesh:"+document.InstructorForm.xmlPath.value);
                    document.InstructorForm.submit();
                }
                
                function setCSMPath()
                {
                    csmPath = "http://" + window.location.hostname +"/CSM/";
					//alert("CSM PATH"+csmPath);
                }
               function goToBuyProduct(id)
               {
               	  document.GetAllProductForm.channelId.value =   id;
                  //alert("goToBuyProduct:"+id);
                  document.GetAllProductForm.submit();
               }
			  
			 function replaceAll(str, param1, param2)
			{
					while(str.indexOf(param1) !=-1)
					{
						str = str.replace(param1,param2);
					}
					//alert("fff:"+str);
					return str;
			}
			function onlineTestFunction(channelid,testid)
			{
			//alert("hiiiiiiiiii:::::::"+channelid);
			document.OnlineTestactionForm.channelId.value = channelid;
			document.OnlineTestactionForm.testId.value = testid;
           //alert(1);
			
			document.OnlineTestactionForm.submit();
			}
			