var locCount = 0
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 lng=myURL.length
if (myURL.substring(lng-1,lng)=='#'){myURL=myURL.substring(0,lng-1)}

var locAddress = myURL+'/Library/'
var locMainAddress = myURL
if(myDomain.toLowerCase().indexOf('ecat_') != -1 || myURL.toLowerCase().indexOf('ecat_') != -1 ||  myURL.toLowerCase().indexOf('file://') != -1){
   locMainAddress = 'http://www.epublisher.co.za'
   locAddress = 'http://www.epublisher.co.za/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()",1000)
	
function TimerLoad(){
  var locData = document.getElementById('ECAT_ID')
  if (locData != null){
     WindowEventLoad(locMainAddress)
     LocalInit()
  }
  else{setTimeout("TimerLoad()",100)}  
}
function LocalInit(){
   GlobalPopup_XPos = Utility_ScreenMiddle(1,600)
   GlobalPopup_YPos = 150
   GlobalPopup_ProductDetails = 1
   GlobalPopup_Login = 1
   GlobalPopup_Register = 1

   var locTitle = window.location.href
   var locSearch = document.getElementById('txtsearch')   
   if (locTitle.toLowerCase().indexOf('electrical_supplies.html') != -1&&locTitle.indexOf('autosearch')==-1){
   LocalCatalogueDisplaySummary(3,' ')   	
   }
} 
function ElectricalSupplies(){
   var locURL = window.location.href
   if (locURL.toLowerCase().indexOf('electrical_supplies.html') == -1){
   	 locURL = Utility_URL()	
       window.location.href = locURL+'/electrical_supplies.html'
   }
   else{
	   WebTree_HistoryDisplay(0)
   }
}
function LocalSearch(){
   var locTitle = window.location.href
   var locSearch = document.getElementById('txtsearch')   
   if (locTitle.toLowerCase().indexOf('electrical_supplies.html') == -1){
       setTimeout("LocalOnLoad()", 1000);
	   var locURL = Utility_URL()
       window.location.href = locURL+'/electrical_supplies.html?autosearch='+locSearch.value
   }    
   else{
	  WebSearch_Clear()
	  var locFilter = ''
	  WebDisplay_DataSearch('Search_Item.xsl','Divider_SearchDetails',2,'txtsearch',locFilter,GlobalMemory_Search,Tree_RowPerPage('Tree_ecat'),1)
   }
}
function LocalEnterKey(event){
   var locKey = Utility_EnterKey(event,'txtsearch',1)
   if (locKey == 13)
   {
      LocalSearch()
   }
}
function Local_TopLink(pInfo1,pInfo2){
   if (pInfo1==1){return}
	if (pInfo1==2){
		var locObj=document.getElementById('txtsearch')
		locObj.value=pInfo2
		LocalSearch()
} }
function LocalCatalogueDisplaySummary(pType,pSection){
   var locID=null
   if (pSection==null||pSection.length==0||pSection==' '){locID=Guid_Empty}
   if (locID==null||locID.length==0){
   	  var locStatement = ''; var xmlString=''
   	  var locID = Guid_Empty
   	  	if (pType==3){
   	  		locStatement = 'SELECT ID,NAME,PARENTID FROM dbo.Category WHERE (NAME LIKE \'%'+pSection+'%\' AND ITEMLEVEL <= 2)'
            xmlString = DataFnc_LoadSQL('CATEGORY',1,'',16,locStatement,0,0)
        }    
   	  	if (pType==2){
   	  		locStatement = 'SELECT ID,NAME,PARENTID FROM dbo.Product WHERE (NAME LIKE \'%'+pSection+'%\' AND ITEMLEVEL <= 2)'
            xmlString = DataFnc_LoadSQL('PRODUCT',1,'',16,locStatement,0,0)
        }    
        locID = UtilityXML_ExtractValue(xmlString,'id')
   }
   if (locID!=null&&locID.length>0){
      WebFnc_TransformItemSummary(pType,'Product_ChildrenSummary.xsl','Divider_ProductDetails',locID,pSection,'ID,PARENTID,CHILDCOUNT,ISLEAF,NAME,SEQUENCE,IMAGENAME,IMAGEPATH')
   }
}


