	var locCount = 0
    var GlobalInputID = 'txtsearch'		            	
	var myDomain = document.domain 
	var myURL = document.URL 
	if (myURL.toLowerCase().indexOf('.htm') != -1){
	   var pu1 = myURL.lastIndexOf('/')  
	   var pu2 = myURL.lastIndexOf('\\')  
	   if (pu1 != -1 && pu1 > pu2){myURL = myURL.substring(0,pu1)}
	   else {myURL = myURL.substring(0,pu2)}
	}
	var locAddress = myURL+'/Library/'
	var locMainAddress = myURL
	if(myDomain.toLowerCase().indexOf('websites_ecatalogue') != -1 || myURL.toLowerCase().indexOf('websites_ecatalogue') != -1 ||  myURL.toLowerCase().indexOf('file://') != -1)
	{
        locMainAddress = 'http://196.30.166.51/qaCatalogue'
        locAddress = 'http://196.30.166.51/qaCatalogue/Library/' 
	}
	if(myDomain.toLowerCase().indexOf('localhost_ecat') != -1 || myURL.toLowerCase().indexOf('localhost_ecat') != -1)
	{
    	locMainAddress = 'http://localhost/onlinecatalogue/electronic%20catalogue' 
	    locAddress = 'http://localhost/onlinecatalogue/electronic%20catalogue/Library/' 
	}
	document.write('<sc'+'ript');document.write(' type="text/javascript"');document.write(' language="JavaScript"');document.write(' src="'+locAddress+'JavaScriptWindowEvent.js">');document.write('</sc'+'ript>')
    document.write('<sc'+'ript');document.write(' type="text/javascript"');document.write(' language="JavaScript"');document.write(' src="'+locAddress+'JavaScriptLibrary.js">');document.write('</sc'+'ript>')
    document.write('<sc'+'ript');document.write(' type="text/javascript"');document.write(' language="JavaScript"');document.write(' src="'+locAddress+'JavaScriptDataFnc.js">');document.write('</sc'+'ript>')
    document.write('<sc'+'ript');document.write(' type="text/javascript"');document.write(' language="JavaScript"');document.write(' src="'+locAddress+'JavaScriptTree.js">');document.write('</sc'+'ript>')
    document.write('<sc'+'ript');document.write(' type="text/javascript"');document.write(' language="JavaScript"');document.write(' src="'+locAddress+'JavaScriptUtility.js">');document.write('</sc'+'ript>')
    document.write('<sc'+'ript');document.write(' type="text/javascript"');document.write(' language="JavaScript"');document.write(' src="'+locAddress+'JavaScriptBasket.js">');document.write('</sc'+'ript>')
    setTimeout("TimerLoad()",500)
	
function TimerLoad(){
  var locData = document.getElementById('MainVariable_(ID)')
  if (locData == null){locData = document.getElementById('CatalogueID)')}
  if (locData != null){
  	  WindowEventLoad(locMainAddress)
      LoadTreeInit()
  }
  else{setTimeout("TimerLoad()",100)}
}  
function LoadTreeInit(){
    GlobalPopup_XPos = Utility_ScreenMiddle(1,400)
    GlobalPopup_YPos = 30
    /*
    var locStatement = 'SELECT ID,PARENTID,NAME,ISLEAF,CHILDCOUNT,ITEMLEVEL FROM dbo.Category WHERE (ITEMLEVEL<=4 AND TYPE=2)'
    ProgressImageDisplay(true)
    var xmlString = DataFnc_LoadSQL('CATEGORY',1,'',16,locStatement,0,0)
    xmlString = UtilityText_Replace(xmlString,'<type>2</type>','<type>3</type>')
    GlobalTimerParam1 = xmlString
    setTimeout("LoadTreeInit_Build()",100);
    */
}    
function LoadTreeInit_Build(){
    ProgressImageDisplay(false)
    var xmlString = GlobalTimerParam1
    for (var i=1;i<=8;i++){
   	  var locTreeName = 'Tree_ecat'+i
      var locObjTree = document.getElementById(locTreeName)
      if (locObjTree==null){break}
      var locTreeParam = Utility_TreeParam(0,locObjTree)
      var paramParentName = UtilityText_ExtractText(locTreeParam,'TreeParentName(',')')
      paramParentName = UtilityText_Replace(paramParentName,'\'','')
      var locResponse = DataFnc_Locate(1,0,paramParentName,'name',xmlString)
      locResponse = '<ajaxresponse>'+locResponse+'</ajaxresponse>'
      var locParentID = UtilityXML_ExtractValue(locResponse,'id')
      locResponse = UtilityXML_ReplaceValue(locResponse,'<parentid>','</parentid>',Guid_Empty)      
      WebDisplay_TreeSectionInsert(locResponse,'TreeBase',locObjTree.id,3,1,Guid_Empty)    	
      xmlString_Items = DataFnc_MemoryExtract_Routine(xmlString,1,'parentid',locParentID,1,500)
      var locNodeID = 'TreeDivider_['+locParentID+']'
      Tree_AddParam(2,2,locParentID,'status(0)','status(1)')    
      WebDisplay_TreeSectionInsert(xmlString_Items,locNodeID,locObjTree.id,3,2,locParentID)
}   } 

function LocalSearch(pInputID,pKeyEvent){
	GlobalInputID = pInputID
	if (pKeyEvent != null){
       if (pKeyEvent != null && pKeyEvent != 0){
         var locKey = Utility_EnterKey(pKeyEvent,'',1)
         if (locKey != 13) {return}
       } 
    } 
    var locSearch = document.getElementById(pInputID)   
    var locTitle = window.location.href    
    if (locTitle.toLowerCase().indexOf('electrical_cable.html') == -1){
	   var locURL = Utility_URL()
       window.location.href = locURL+'/electrical_cable.html?autosearch='+locSearch.value
    }    
    ProgressImageDisplay(true)
    setTimeout("TimerSearch1()",100)	
}
function TimerSearch1(){
    var locFilter = ''
	WebDisplay_DataSearch('Search_Item.xsl','Divider_SearchDetails',2,GlobalInputID,locFilter,GlobalMemory_Search,Tree_RowPerPage('Tree_ecat'),1,'navsearch',null,'',0)
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
