    var myAnim1 = null;var myAnim2 = null; var myAnim5 = null;var GlobalAnim = null
    var GlobalImgBanner_BtnSelect = ''; var GlobalImgBanner_Timer = 1;var GlobalImgBanner_Duration = 7500;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 = 5;var GlobalMainClosed = 0
    var GlobalPage_Home = 0;var GlobalImgNew = '';var locCount = 0; GlobalDivider_Array=new Array()
    var GlobamXml_CAT = ''
    var GlobamXml_COM = ''
    GlobalImgBanner_Array.push('images/banner/Banner-Engineer.jpg')
    GlobalImgBanner_Array.push('images/banner/Banner-Contractor.jpg')    
    GlobalImgBanner_Array.push('images/banner/Banner-Export.jpg')     
    GlobalImgBanner_Array.push('images/banner/Banner-Mining.jpg') 
    GlobalImgBanner_Array.push('images/banner/Banner-Industrial.jpg')    
    GlobalDivider_Array.push('Divider_ElectricalProduct_Main')   
    GlobalDivider_Array.push('Divider_ElectricalProduct_Safety')   
    GlobalDivider_Array.push('Divider_ElectricalProduct_Control')   
    GlobalDivider_Array.push('Divider_ElectricalProduct_ILM')       
    GlobalDivider_Array.push('Divider_ElectricalProduct_Lighting')       
    GlobalDivider_Array.push('Divider_ElectricalProduct_Switchgear')           
	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()",1000)
	
function TimerLoad(){
  var locData = document.getElementById('MainVariable_(ID)')
  if (locData == null){locData = document.getElementById('CatalogueID)')}
  if (locData != null){
      LocalInit() 
      WindowEventLoad(locMainAddress)
      LocalLoadSupplier()
      LocalTreeInit(3)
      LocalImgBanner_Display(1)
  }else{setTimeout("TimerLoad()",100)}
}  
function LocalInit(){
   GlobalPopup_XPos = Utility_ScreenMiddle(1,400)
   GlobalPopup_YPos = 30
   var locObj = document.getElementById('Divider_Home')
   if (locObj != null) {GlobalPage_Home = 1}
   if (GlobalPage_Home==1){
   	  var locObjDiv = document.getElementById('Divider_Main')
   	  locObjDiv.style.visibility = 'visible'
   	  locObjDiv.style.position = 'static'
   }
   var locURL = document.URL.toLowerCase()
   if (locURL.indexOf('enquiry.html') != -1) { 
      Utility_HighlightSet(3,'TD_MenuTop7','TD_MenuTop','Menutop')   	   	   	
      //-------
      var locObj = document.getElementById('Enquiry_Product')
      var locProduct = Utility_URLRetrieveParam('autofill')	
      if (locObj != null) {locObj.value = locProduct}

   }else{Utility_HighlightSet(3,'TD_MenuTop1','TD_MenuTop','Menutop')}
   LocalInit_Anim()
}
function LocalDate(){var mydate=new Date();var year=mydate.getYear();if (year < 1000){year+=1900}
var day=mydate.getDay();var month=mydate.getMonth();var daym=mydate.getDate();if (daym<10){daym="0"+daym}
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
return dayarray[day]+", "+montharray[month]+" "+daym+", "+year
}
function LocalTreeView(pMode){
    Utility_Divider(2,'otherPages',1)
    //----------- Advert ----------
    Utility_DividerAll(2)
    LocalTreeHide()
	Tree_ParamSet('Tree_ecat1','INIT[0]','INIT[1]')		
	if (pMode == 1){
       WebTree_Table(100,'Tree_ecat1','3');
       WebDisplay_TreeInit('Tree_ecat1',1)		
	}
    else{
	   WebTree_Table(100,'Tree_ecat1','1[2]');
	   WebDisplay_TreeInit('Tree_ecat1',1)
	}
}
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 = \''+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){
       	  if (GlobalPage_Home==1){
             locStatement = 'SELECT ID,PARENTID,NAME,ISLEAF,CHILDCOUNT,ITEMLEVEL FROM dbo.Category WHERE (ITEMLEVEL<=2 AND TYPE=2)'
          }else{
             locStatement = 'SELECT ID,PARENTID,NAME,ISLEAF,CHILDCOUNT,ITEMLEVEL FROM dbo.Category WHERE (ITEMLEVEL<=1 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)
    LocalTreeHide()
    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}
	      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 LocalTreeHide(){
    for (var i=1;i<10;i++){
    	var locObjTree = document.getElementById('Tree_ecat'+i)
    	if (locObjTree!=null){locObjTree.innerHTML=''}
}   }
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 LocalLoginStart(){
	Screen_DividerDisplay('otherPages',1)
	Utility_Divider(1,'Div_ImgBanner1')
	Utility_Divider(1,'Div_ImgBanner2')
}
function LocalBasketUpdate(){
   var locCntItem = BasketTotal(1,'QuoteDebtor')
   var locCntQty  = BasketTotal(2,'QuoteDebtor')
   var locDiv1 = document.getElementById('quote_totalitem')
   var locDiv2 = document.getElementById('quote_totalqty')   
   if (locDiv1 != null && locDiv2 != null){
      if (locCntItem == 0){
	     locDiv1.innerHTML = ' - Nb. of Items:<font style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000080">'+locCntItem+'</font>'
	  }
	  else{
	     locDiv1.innerHTML = ' - Nb. of Items:<font style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#C00000">'+locCntItem+'</font>'	  
	  }
      if (locCntQty == 0)
	  {
	     locDiv2.innerHTML = '- Total Quantity:<font style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000080">'+locCntQty+'</font>'
	  }
	  else
	  {
	     locDiv2.innerHTML = '- Total Quantity:<font style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#C00000">'+locCntQty+'</font>'	  
	  }
   } 
}
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
		});
		myAnim4 = new Y.Anim({
			node: '#Divider_Specials',
			from: { opacity: 0 },										
			to: { opacity: 1},
			easing: Y.Easing.backIn
		});
		myAnim5 = new Y.Anim({
			node: '#Divider_Main',
			from: { opacity: 0 },										
			to: { opacity: 1},
			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'
			   }
		   }	  
        }
        GlobalAnim = Y
        var locObjDiv0 = document.getElementById('Divider_Main')
        var locObjDiv1 = document.getElementById('Div_ImgBanner1')
        var locObjDiv2 = document.getElementById('Div_ImgBanner2')
        var locObjDiv3 = document.getElementById('Divider_BannerBtn')
        var locObjDiv4 = document.getElementById('Divider_Specials')
        locObjDiv1.style.position = 'absolute'
        locObjDiv2.style.position = 'absolute'
        locObjDiv3.style.visibility = 'visible'
        locObjDiv4.style.visibility = 'visible'
        Utility_setPos(locObjDiv1,15,0,locObjDiv0)
        Utility_setPos(locObjDiv2,0,0,locObjDiv1)
        Utility_setPos(locObjDiv3,1,170,locObjDiv1)
		Y.one('#Divider_Specials').setStyle('opacity',0)																	        
	    myAnim1.set('duration', 2)
	    myAnim2.set('duration',2)
	    myAnim4.run()
	    LocalImgBanner_Init()
    })
}
function LocalImgBanner_Hide(){
	var locMain = document.getElementById('Divider_Main')
	if (myAnim5 != null && locMain.style.visibility != 'hidden'){
       Utility_Divider(2,'Divider_BannerBtn',1)
	   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('from', { opacity:1,height:200 });	           
	   myAnim5.set('to', { opacity:0,height:0 });	
	   myAnim5.set('duration',2)
	   myAnim1.run()
	   myAnim2.run()
   	   myAnim5.run()
   	   GlobalMainClosed = 1
   	} 
}
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 (GlobalPage_Home==0 || GlobalMainClosed==1){return}
	if (GlobalImgBanner_Reset==1){
		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()
{
	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')
	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'
			}
	    }
	}
	LocalImgBanner_Display(GlobalImgBanner_Timer)
}
function LocalImgBanner_Display(pIndex){
	var locObjSp1 = document.getElementById('span_title')
	var locObjSp2 = document.getElementById('span_content')
	if (locObjSp1 != null && locObjSp2 != null){
	   Utility_ObjectWrite(locObjSp1,document.getElementById('Divider_Title'+pIndex).innerHTML)
	   Utility_ObjectWrite(locObjSp2,document.getElementById('Divider_Text'+pIndex).innerHTML)
}  }
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 LocalTree(pTreeID,pSection)
{
	LocalTreeTitle(pSection)
	LocalTreeParentName(pTreeID,pSection)
 	WebDisplay_TreeInit(pTreeID)	
}
function LocalSearch(pInputID,pKeyEvent){
	GlobalInputID = pInputID
	if (pKeyEvent != null)
	{
       if (pKeyEvent != null && pKeyEvent != 0)
       {
         var locKey = Utility_EnterKey(pKeyEvent,'',1)
         if (locKey != 13) {return}
       } 
    } 
    LocalImgBanner_Hide()
   var locTitle = window.location.href
   var locSearch = document.getElementById(GlobalInputID)   
   WebDisplay_DataSearch('Search_Item.xsl','Divider_SearchDetails',2,GlobalInputID,'',GlobalMemory_Search,Tree_RowPerPage('Tree_ecat'),1,'','','ID, Name, Code, ChildCount, InfoAmount1, InfoAmount2, ImageName, ImagePath')
}
