    var myAnim1 = null;var myAnim2 = null;var GlobalInputID = 'txtsearch';
    var GlobalAnim = null;var GlobalImgBanner_BtnSelect = '';var GlobalMainClosed = 0;var GlobalImgBanner_Timer = 1
    var GlobalImgBanner_Duration = 5500;var GlobalImgBanner_Reset = 0;var GlobalImgBanner_SelectTD = ''
    var GlobalImgBanner_Array = new Array();var GlobalImgBanner_StartCount = 0;var GlobalImgCurrent = '';var GlobalImgBanner_Mode = 1    
    var GlobalImgBanner_Max = 6;var GlobalPage_Home = 0; var GlobalImgNew = ''
    var GlobamXml_CAT = '';var GlobamXml_COM = ''
    
    GlobalImgBanner_Array.push('images/banner/Banner1_Engineer.jpg')
    GlobalImgBanner_Array.push('images/banner/Banner2_Engineer.jpg')    
    GlobalImgBanner_Array.push('images/banner/Banner3_Industrial.jpg')
    GlobalImgBanner_Array.push('images/banner/Banner4_SolarPanel.jpg')   
    GlobalImgBanner_Array.push('images/banner/Banner5_Mechanical.jpg')        
    GlobalImgBanner_Array.push('images/banner/Banner6_Foundery.jpg')        
    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 locAddress = myURL+'/Library/'
	var locMainAddress = myURL
	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/' 
	}
    else 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/' 
	}
	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()",200)
	
function TimerLoad(){
  var locData = document.getElementById('MainVariable_(ID)')
  if (locData == null){locData = document.getElementById('CatalogueID)')}
  if (locData != null){
      WindowEventLoad(locMainAddress)
      LocalInit()  
  }
  else{setTimeout("TimerLoad()",100)}
}  
function LocalInit(){
   GlobalPopup_XPos = Utility_ScreenMiddle(1,400)+'px'
   GlobalPopup_YPos = 30+'px'
   var locObj = document.getElementById('Divider_Home')
   if (locObj != null){GlobalPage_Home = 1}
   var locURL = document.URL.toLowerCase()
   if (locURL.indexOf('optimizer') != -1){GlobalPopup_ProductDetails = 1}
   if (locURL.indexOf('energy') != -1) { 
      Utility_HighlightSet(3,'TD_Menu3','TD_Menu','midbtn')
   }	     
   else if (locURL.indexOf('electrical_supplies') != -1){ 
      Utility_HighlightSet(3,'TD_Menu2','TD_Menu','midbtn')   	
      var locTreeType = 3
      var locTreeType = Utility_URLRetrieveParam('treetype')	
      var locTreeParent = Utility_URLRetrieveParam('treeparent')	
      if (locTreeType.length==0){locTreeType=3}
      LocalTreeInit(locTreeType,locTreeParent)
   }	     
   else if (locURL.indexOf('engineering') != -1){ 
      Utility_HighlightSet(3,'TD_Menu4','TD_Menu','midbtn')   	
   }	     
   else if (locURL.indexOf('panel') != -1){ 
      Utility_HighlightSet(3,'TD_Menu5','TD_Menu','midbtn')   	
   }	     
   else if (locURL.indexOf('contracting') != -1){ 
      Utility_HighlightSet(3,'TD_Menu6','TD_Menu','midbtn')   	
   }	     
   else if (locURL.indexOf('contact') != -1){ 
      Utility_HighlightSet(3,'TD_Menu8','TD_Menu','midbtn')   	
   }	     
   else if (locURL.indexOf('enquiry') != -1){ 
      Utility_HighlightSet(3,'TD_Menu7','TD_Menu','midbtn')   	   	   	
      var locObj = document.getElementById('Enquiry_Product')
      var locProduct = Utility_URLRetrieveParam('autofill')	
      if (locObj != null) {locObj.value = locProduct}
   }else{Utility_HighlightSet(3,'TD_Menu1','TD_Menu','midbtn')}
   LocalInit_Anim()
}
function LocalLoginStart(){
	Screen_DividerDisplay('otherPages',1)
	Utility_Divider(1,'Div_ImgBanner1')
	Utility_Divider(1,'Div_ImgBanner2')
}
function LocalPage(pMode){
  LocalImgBanner_Hide()
  if (pMode==1){WebDisplay_UserLogin()}
  if (pMode==2){WebDisplay_UserRegister()}  
  if (pMode==3){BasketDisplayCurrent(1,'QuoteDebtor')}  
  if (pMode==4){BasketDisplayHistory(1,'QuoteDebtor')}    
}
function LocalTreeInit(pType,pSection,pDivider){
    ProgressImageDisplay(true)
    var locStatement = '';var xmlString='';var locCount=1
    var locParentID = ''
    GlobalTimerParam4 = 0
    GlobalTimerParam5 = 3
    GlobalTimerParam6 = ''
	if (pType == 1){
       if (GlobamXml_COM.length==0){
          locStatement = 'SELECT ID,PARENTID,NAME FROM dbo.Company WHERE (Name LIKE \'%'+pSection+'%\')'
          xmlString = DataFnc_LoadSQL('COMPANY',1,'',16,locStatement,0,0)
          var locParentID = UtilityXML_ExtractValue(xmlString,'id')          
          GlobalTimerParam6 = ''
          locStatement = 'SELECT ID,PARENTID,NAME,ISLEAF,CHILDCOUNT,ITEMLEVEL FROM dbo.Product WHERE (CompanyID = \''+locParentID+'\' AND PARENTID IS NULL)'
          xmlString = DataFnc_LoadSQL('PRODUCT',1,'',16,locStatement,0,0)
          GlobamXml_COM = xmlString
          
       }else{xmlString=GlobamXml_COM} 
       GlobalTimerParam4 = 1
       GlobalTimerParam5 = 2
    }
    if (pType == 3){
       if (GlobamXml_CAT.length == 0){
          locStatement = 'SELECT ID,PARENTID,NAME,ISLEAF,CHILDCOUNT,ITEMLEVEL FROM dbo.Category WHERE (ITEMLEVEL<=2 AND TYPE=2)'
          xmlString = DataFnc_LoadSQL('CATEGORY',1,'',16,locStatement,0,0)       
          xmlString = UtilityText_Replace(xmlString,'<type>2</type>','<type>3</type>')       
          GlobamXml_CAT = xmlString
       }else{
          if (pSection!=null&&pSection.length>0){
          	 var locResponse = DataFnc_Locate(1,0,pSection,'name',GlobamXml_CAT)
          	 var locID = UtilityXML_ExtractValue(locResponse,'id')
          	 locParentID = locID
          	 GlobalTimerParam6 = locParentID
          	 xmlString = DataFnc_MemoryExtract_Routine(GlobamXml_CAT,0,'parentid',locID,1,500)
          	 GlobalTimerParam4 = 1
          }	 
          else{xmlString=GlobamXml_CAT}	 
    }  }  
    locCount=DataFnc_Locate(4,0,'parentid',locParentID,xmlString)    
    GlobalTimerParam1 = xmlString
    GlobalTimerParam2 = locCount
    GlobalTimerParam3 = ''
    if (pDivider!=null){GlobalTimerParam3=pDivider}
    var locObjT = document.getElementById('Divider_TreeTitle')
    if (locObjT!=null){
       if (pSection!=null&&pSection.length>0){locObjT.innerHTML = pSection}
       else{locObjT.innerHTML='Electric Products'}
    }
    if (pDivider != null){
       for (var i=0;i<GlobalDivider_Array.length;i++){
       	  var locObj = document.getElementById(GlobalDivider_Array[i])
       	  locObj.style.visibility='hidden'
       	  locObj.style.position='absolute'
       }
       var locObjN=document.getElementById('Divider_ElectricalProduct_'+pDivider)
       locObjN.style.visibility='visible'
       locObjN.style.position='static'
    }
    if (pSection!=null){LocalImgBanner_Hide()}
    setTimeout("LocalTreeInit_Build()",100);
}    
function LocalTreeInit_Build(){
    ProgressImageDisplay(false)
    var xmlString = GlobalTimerParam1
    var locCount = Utility_RoundFloat(GlobalTimerParam2,0)
    if (GlobalTimerParam4==0){
	    for (var i=1;i<=locCount+1;i++){
	   	  var locTreeName = 'Tree_ecat'+i
	      var locObjTree = document.getElementById(locTreeName)
	      if (locObjTree==null){break}
	      locObjTree.innertHTML=''
	      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')
	      WebDisplay_TreeSectionInsert(locResponse,'TreeBase',locObjTree.id,GlobalTimerParam5,1,Guid_Empty)    	
	      xmlString_Items = DataFnc_MemoryExtract_Routine(xmlString,0,'parentid',locParentID,1,500)
	      var locNodeID = 'TreeDivider_['+locParentID+']'
	      Tree_AddParam(2,2,locParentID,'status(0)','status(1)')    
	      WebDisplay_TreeSectionInsert(xmlString_Items,locNodeID,locObjTree.id,GlobalTimerParam5,2,locParentID)
	    }   
	}  
    if (GlobalTimerParam4==1){	  
    	WebDisplay_TreeSectionInsert(xmlString,'TreeBase','Tree_ecat1',GlobalTimerParam5,1,GlobalTimerParam6)    	
    }
}	
function LocalTree(pType,pParentName){
   var locTitle = window.location.href
   if (locTitle.toLowerCase().indexOf('products') == -1){
	   var locURL = Utility_URL()
       window.location.href = locURL+'/electrical_supplies.html?treetype=1&treeparent='+pParentName
   }
   else{
      GlobamXml_COM = ''
      LocalTreeInit(pType,pParentName)
   }

}
function LocalLoadSupplier(){
   var xmlString = DataFnc_LoadSQL('COMPANY',100,'',16,'SELECT ID,NAME,ParentID FROM dbo.Company WHERE (ParentID is NULL AND DATABASEID = \'EC-ZA-0-28\')',1)
   xmlString = DataFnc_FieldSort(xmlString,'name')
   Utility_ListFillXML('supplist',xmlString)
   locList = document.getElementById('supplist')
   if (locList != null){
       var elOptNew = document.createElement('option')
       elOptNew.text = 'All Suppliers'
       elOptNew.value = ''
       locList.options.add(elOptNew,0)
       locList.selectedIndex = 0
}  }       
function LocalImgBanner_Hide(){
	var locMain = document.getElementById('Divider_Main')
	if (GlobalPage_Home==1 && myAnim5 != null && locMain.style.visibility != 'hidden'){
       var locObjDiv3 = document.getElementById('Divider_Btn')
       locObjDiv3.style.visibility = 'hidden'
	   myAnim1.set('from', { opacity:1,height:180 });	           
	   myAnim1.set('to', { opacity:0,height:0 });	
	   myAnim2.set('from', {opacity:1, height:180 });	           
	   myAnim2.set('to', { opacity:0,height:0 });		    
       myAnim1.set('duration', 2)        
       myAnim2.set('duration',2)
	   myAnim5.set('duration',2)
	   GlobalImgBanner_Timer = -1
	   myAnim1.run()
	   myAnim2.run()
   	   myAnim5.run()
   	   GlobalMainClosed = 1
   	} 
}

function LocalInit_Anim(){
	if (GlobalPage_Home == 0) {return}
	YUI().use('anim', function(Y) {
		myAnim1 = new Y.Anim({
			node: '#Div_ImgBanner1',
			from: { opacity: 1},																				
			to: { opacity: 0 },
			easing: Y.Easing.backIn
		});
		myAnim2 = new Y.Anim({
			node: '#Div_ImgBanner2',
			from: { opacity: 0 },										
			to: { opacity: 1},
			easing: Y.Easing.backIn
		});
		myAnim3 = new Y.Anim({
			node: '#Divider_Btn',
			from: { opacity: 0 },										
			to: { opacity: 1},
			easing: Y.Easing.backIn
		});
		myAnim5 = new Y.Anim({
			node: '#Divider_Main',
			from: { opacity: 1 },										
			to: { height: 0, opacity:0},
			easing: Y.Easing.backIn
		});
	    function handleStart2(){
		   GlobalImgBanner_StartCount = 1
		}
	    function handleTween2(){
		   if (GlobalImgBanner_StartCount > 0)
		   {
		      GlobalImgBanner_StartCount += 1
			  if (GlobalImgBanner_StartCount  > 5)
			  {
			      GlobalImgBanner_StartCount = 0
			  	  var locObjImg = document.getElementById('images_Banner2')
			      locObjImg.style.visibility = 'visible'
			   }
		   }	  
        }
	    function handleEnd5(){
          var locObjDiv1 = document.getElementById('Div_ImgBanner1')
	      var locObjDiv2 = document.getElementById('Div_ImgBanner2')	   
	      var locMain = document.getElementById('Divider_Main')
          locMain.style.visibility = 'hidden'
          locObjDiv1.style.visibility = 'hidden'
          locObjDiv2.style.visibility = 'hidden'
        }
        GlobalAnim = Y
        var locObjTbl = document.getElementById('Tbl1')
        var locObjDiv1 = document.getElementById('Div_ImgBanner1')
        var locObjDiv2 = document.getElementById('Div_ImgBanner2')
        var locObjDiv3 = document.getElementById('Divider_Btn')
        var x=Utility_getXpos(locObjDiv1)
        var y=Utility_getYpos(locObjDiv1)
        locObjDiv2.style.position = 'absolute'
        locObjDiv2.style.left = x+'px'
        locObjDiv2.style.top = y+'px'
        Utility_setPos(locObjDiv3,600,420,locObjTbl)
        locObjDiv3.style.visibility = 'visible'
	myAnim1.set('duration', 2)
	myAnim2.set('duration',2)
	myAnim2.on('start',handleStart2)
	myAnim2.on('tween',handleTween2)									
        myAnim5.on('end',handleEnd5)		
	LocalImgBanner_Init()
    })
}
function LocalImgBanner_Init(){
	GlobalImgCurrent = GlobalImgBanner_Array[0]
	var locObj1 = document.getElementById('Div_ImgBanner1')	
	var locObj2 = document.getElementById('Div_ImgBanner2')
	if (locObj1 != null && locObj2 != null){
	   //--------------- Overlap Images --------		
       locObj2.style.top  = Utility_getYpos(locObj1)
       locObj2.style.left = Utility_getXpos(locObj1)
       //------------ Set Opacity -------
       GlobalAnim.one('#Div_ImgBanner2').setStyle('opacity',0)
       locObj2.style.visibility = 'visible'
   	   setTimeout("LocalImgBanner_Timer()",GlobalImgBanner_Duration);
    }
}
function LocalImgBanner_Timer(){
	if (GlobalImgBanner_Reset==1){
		//-------- Reset Mode ---------
		GlobalImgBanner_Reset = 0
		setTimeout("LocalImgBanner_Timer()",GlobalImgBanner_Duration);
		return
	}
	GlobalImgBanner_Timer += 1
	if (GlobalImgBanner_Timer > GlobalImgBanner_Max) {GlobalImgBanner_Timer = 1}
    LocalImgBanner_Select()
	setTimeout("LocalImgBanner_Timer()",GlobalImgBanner_Duration);
}
function LocalImgBanner_Index(pIndex){
	GlobalImgBanner_Reset = 1
	GlobalImgBanner_Timer = pIndex
	LocalImgBanner_Select()
}
function LocalImgBanner_Select(){
	if (GlobalMainClosed==1 || GlobalPage_Home==0){return}
	GlobalImgCurrent = GlobalImgBanner_Array[GlobalImgBanner_Timer-1]
	var locObjDiv1 = document.getElementById('Div_ImgBanner1')	
	var locObjDiv2 = document.getElementById('Div_ImgBanner2')
	var locObjImg1 = document.getElementById('images_Banner1')	
	var locObjImg2 = document.getElementById('images_Banner2')
    Utility_setPos(locObjDiv2,0,0,locObjDiv1)
	if (GlobalImgBanner_Mode == 1){
		GlobalImgBanner_Mode = 2
	    locObjImg2.src = GlobalImgCurrent	
	    myAnim1.set('from', { opacity:1 });		    	
	    myAnim1.set('to', { opacity:0 });	
	    myAnim2.set('from', { opacity:0 });		    
	    myAnim2.set('to', { opacity:1 });	
	    GlobalAnim.one('#Div_ImgBanner2').setStyle('opacity',0)			    
	}
    else{
		GlobalImgBanner_Mode = 1
	    locObjImg1.src = GlobalImgCurrent
	    myAnim1.set('from', { opacity:0 });		    
	    myAnim1.set('to', { opacity:1 });	
	    myAnim2.set('from', { opacity:1 });	
	    myAnim2.set('to', { opacity:0 });		    
	    GlobalAnim.one('#Div_ImgBanner1').setStyle('opacity',0)		
	}
	myAnim1.run()
	myAnim2.run()
	//------------ Column Selection ---------
	var locTD_Select = 'TD_Banner'+GlobalImgBanner_Timer
	var locObjTable = document.getElementById('Table_Banner')
	var locObjTD = locObjTable.getElementsByTagName('td')
	for (var i=0; i<locObjTD.length; i++){
		if (locObjTD[i].id.length>0){
			if (locObjTD[i].id.toLowerCase() == locTD_Select.toLowerCase())
			{
				locObjTD[i].className = 'bannerbutton_selected'
			}
		    else{locObjTD[i].className = 'bannerbutton_normal'}
	    }
	}
}
function LocalTreeTitle(pTitle){
	var locObj = document.getElementById('span_TreeTitle')
	if (locObj != null){locObj.innerHTML = pTitle}
}
function LocalTreeParentName(pTreeID,pSection){
	var locObjTree = document.getElementById(pTreeID)
	if (locObjTree != null){
	   var locTreeParam = Utility_TreeParam(0,locObjTree)
	   var locTreeParent = UtilityText_ExtractText(locTreeParam,'TreeParentName(',')') 
	   if (locTreeParent.length == 0){locTreeParam = locTreeParam+'TreeParentName('+pSection+')'}
       else{locTreeParam = UtilityText_Replace(locTreeParam,'TreeParentName('+locTreeParent+')','TreeParentName('+pSection+')')}
 	   Utility_TreeParam(1,locObjTree,locTreeParam)
	}
}
function LocalSearch(pInputID,pEvent){
   GlobalInputID = pInputID
   if (pEvent != null){
      var locKey = Utility_EnterKey(pEvent,pInputID,1)
      if (locKey != 13){return}
   }
   GlobalInputID = pInputID
   var locTitle = window.location.href
   if (locTitle.toLowerCase().indexOf('electrical_supplies') == -1)
   {
	   var locURL = Utility_URL()
	   var locSearch = document.getElementById(GlobalInputID)
       window.location.href = locURL+'/electrical_supplies.html?autosearch='+locSearch.value
   }    
   else{
      var locSearch = document.getElementById('txtsearch')   
      WebDisplay_DataSearch('Search_Item.xsl','Divider_SearchDetails',2,GlobalInputID,'',GlobalMemory_Search,Tree_RowPerPage('Tree_ecat'),1,'','','ID, Name, Code, ChildCount, InfoAmount1, InfoAmount2, ImageName, ImagePath')
   }
}
function LocalEnterKey(pInputID,event){
   var locKey = Utility_EnterKey(event,'txtsearch',1)
   if (locKey == 13){LocalSearch(pInputID)}
}
function LocalUserDetails(){
}
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];}
}
