var myAnim1 = null;var myAnim2 = null;var myAnim3 = null;var myAnim4 = null;var myAnim5 = null;var myAnim6 = null;var myAnim7 = null;var myAnim8 = null;var myAnim9 = null;var myAnim10 = null;var myAnim11 = null
var GlobalInputID = 'txtsearch';var myAnimCounter = 0;var GlobalPage_Home = 0;var AnimArray = new Array(); 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('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()",1000)
	
function TimerLoad(){
  var locData = document.getElementById('MainVariable_(ID)')
  if (locData == null){locData = document.getElementById('CatalogueID)')}
  if (locData != null){
      GlobalDisplayDivider.push('Divider_CatalogueSection')
      WindowEventLoad(locMainAddress)
      LocalInit()
      LocalLoadSupplier()      
      LocalInit_Anim()  	  	  
  }
  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}
    var locObjDiv = document.getElementById('Divider_Main')
    if (GlobalPage_Home == 1){
        locObjDiv.style.visibility = 'visible'
        locObjDiv.style.position = 'static'
    }else{LocalHideMain()}
     var locURL = document.URL.toLowerCase()	 
     if (locURL.indexOf('enquiry.html') != -1) { 
        var locObj = document.getElementById('Enquiry_Product')
        var locProduct = Utility_URLRetrieveParam('autofill','#')	
        if (locObj != null) {locObj.value = locProduct}
     }	     
}
function LocalInit_Anim(){
	YUI().use('anim', function(Y) {
	    myAnim1 = new Y.Anim({node: '#Divider_Anim1',from: {opacity: 0},to: { opacity: 0.5},easing: Y.Easing.backBoth});
	    myAnim2 = new Y.Anim({node: '#Divider_Anim2',from: {opacity: 0},to: { opacity: 0.5},easing: Y.Easing.backBoth});
	    myAnim3 = new Y.Anim({node: '#Divider_Anim3',from: {opacity: 0},to: { opacity: 0.5},easing: Y.Easing.backBoth});
	    myAnim4 = new Y.Anim({node: '#Divider_Anim4',from: {opacity: 0},to: { opacity: 0.5},easing: Y.Easing.backBoth});
	    myAnim5 = new Y.Anim({node: '#Divider_Anim5',from: {opacity: 0},to: { opacity: 0.5},easing: Y.Easing.backBoth});
	    myAnim6 = new Y.Anim({node: '#Divider_Anim6',from: {opacity: 0},to: { opacity: 1},easing: Y.Easing.backBoth});
	    myAnim7 = new Y.Anim({node: '#Divider_Anim7',from: {opacity: 0},to: { opacity: 1},easing: Y.Easing.backBoth});
	    myAnim8 = new Y.Anim({node: '#Divider_Anim8',from: {opacity: 0},to: { opacity: 1},easing: Y.Easing.backBoth});
	    myAnim9 = new Y.Anim({node: '#Divider_Anim9',from: {opacity: 0},to: { opacity: 1},easing: Y.Easing.backBoth});
	    myAnim10 = new Y.Anim({node: '#Divider_Anim10',from:{opacity: 0},to: { opacity: 1},easing: Y.Easing.backBoth});
	    myAnim11 = new Y.Anim({node: '#Divider_Main',from: { opacity: 1 },to: { height: 0, opacity:0},easing: Y.Easing.backIn});
            GlobalAnim =Y
		var locTime = 1
		Y.one('#Divider_Anim1').setStyle('opacity',0)		
		Y.one('#Divider_Anim2').setStyle('opacity',0)		
		Y.one('#Divider_Anim3').setStyle('opacity',0)		
		Y.one('#Divider_Anim4').setStyle('opacity',0)		
		Y.one('#Divider_Anim5').setStyle('opacity',0)		
		Y.one('#Divider_Anim6').setStyle('opacity',0)					
		Y.one('#Divider_Anim7').setStyle('opacity',0)					
		Y.one('#Divider_Anim8').setStyle('opacity',0)					
		Y.one('#Divider_Anim9').setStyle('opacity',0)								
		Y.one('#Divider_Anim10').setStyle('opacity',0)																	
	    myAnim6.set('duration', 2); 			
	    myAnim7.set('duration', 2); 			
	    myAnim8.set('duration', 2); 			
	    myAnim9.set('duration', 2); 			
	    myAnim10.set('duration', 2); 					    		    		    		    
            document.getElementById('Divider_Anim1').style.visibility = 'visible'
            document.getElementById('Divider_Anim2').style.visibility = 'visible'
            document.getElementById('Divider_Anim3').style.visibility = 'visible'
            document.getElementById('Divider_Anim4').style.visibility = 'visible'
            document.getElementById('Divider_Anim5').style.visibility = 'visible'
            if (GlobalPage_Home == 1) 
            { 
                var locObjTree = document.getElementById('Tree_ecat')
                var locOffset = Utility_getXpos(locObjTree)
		myAnim1.set('duration', 1); 
		myAnim2.set('duration', 1); 
		myAnim3.set('duration', 1); 
		myAnim4.set('duration', 1); 
		myAnim5.set('duration', 1); 
		myAnim1.set('from', { xy: [locOffset+10, 1], opacity:0 });	
		myAnim1.set('to', { xy: [locOffset+10, 300], opacity:0.75 });
		myAnim2.set('from', { xy: [locOffset+200, 1], opacity:0 });	
		myAnim2.set('to', { xy: [locOffset+200, 300], opacity:0.75 });
		myAnim3.set('from', { xy: [locOffset+390, 1], opacity:0 });	
		myAnim3.set('to', { xy: [locOffset+390, 300], opacity:0.75 });
		myAnim4.set('from', { xy: [locOffset+580, 1], opacity:0 });	
		myAnim4.set('to', { xy: [locOffset+580, 300], opacity:0.75 });
		myAnim5.set('from', { xy: [locOffset+770, 1], opacity:0 });	
		myAnim5.set('to', { xy: [locOffset+770, 300], opacity:0.75 });
                myAnim1.run()	
                myAnimCounter = 1
                setTimeout("LocalTimer_Animation()",100)
        	}
   		})
}		
function LocalHideMain(){
   document.getElementById('Divider_Anim1').style.visibility = 'hidden'
   document.getElementById('Divider_Anim2').style.visibility = 'hidden'   
   document.getElementById('Divider_Anim3').style.visibility = 'hidden'   
   document.getElementById('Divider_Anim4').style.visibility = 'hidden'   
   document.getElementById('Divider_Anim5').style.visibility = 'hidden'   
   if (GlobalPage_Home == 1){myAnim11.run()}   
}
function LocalActiveSection(pSection){
   Utility_Divider(2,'otherPages')
   Utility_Divider(2,'Divider_Anim6')
   Utility_Divider(2,'Divider_Anim7')   
   Utility_Divider(2,'Divider_Anim8')   
   Utility_Divider(2,'Divider_Anim9')   
   Utility_Divider(2,'Divider_Anim10')   
   Utility_Divider(1,'Divider_CatalogueSection')   
   if (pSection == 1){
   	  document.getElementById('Divider_Anim6').style.visibility = 'visible'
   	  document.getElementById('Divider_Anim6').style.position = 'static'
   	  if (Utility_ArrayGet(AnimArray,pSection) == 0){  myAnim6.run()}
   }
   if (pSection == 2){
   	  document.getElementById('Divider_Anim7').style.visibility = 'visible'   	
   	  document.getElementById('Divider_Anim7').style.position = 'static'   	  
   	  if (Utility_ArrayGet(AnimArray,pSection) == 0){  myAnim7.run()}   	  
   }
   if (pSection == 3){
   	  document.getElementById('Divider_Anim8').style.visibility = 'visible'   	
   	  document.getElementById('Divider_Anim8').style.position = 'static'   	  
   	  if (Utility_ArrayGet(AnimArray,pSection) == 0){  myAnim8.run()}   	  
   }
   if (pSection == 4){
   	  document.getElementById('Divider_Anim9').style.visibility = 'visible'
   	  document.getElementById('Divider_Anim9').style.position = 'static'   	  
   	  if (Utility_ArrayGet(AnimArray,pSection) == 0){  
   	  	myAnim9.run()}   	  
   }
   if (pSection == 5){
   	  document.getElementById('Divider_Anim10').style.visibility = 'visible'
   	  document.getElementById('Divider_Anim10').style.position = 'static'   	  
   	  if (Utility_ArrayGet(AnimArray,pSection) == 0){myAnim10.run()}   	  
   }
   Utility_ArraySet(AnimArray,pSection) 
   LocalHideMain()
}
function LocalTimer_Animation(){
	myAnimCounter += 1
	if (myAnimCounter > 5) {return}
	if (myAnimCounter == 2){myAnim2.run()}
	if (myAnimCounter == 3){myAnim3.run()}
	if (myAnimCounter == 4){myAnim4.run()}
	if (myAnimCounter == 5){myAnim5.run()}
	setTimeout("LocalTimer_Animation()",100)
}
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}
   } }
   LocalHideMain()
   ProgressImageDisplay(true)
   setTimeout("TimerSearch1()",100)	
}
function TimerSearch1(){
    var locFilter = 'DATABASEID = \'EC-ZA-0-27\'' 	
    var locList = document.getElementById('supplist')
    if (locList != null){
     var locIndex = locList.selectedIndex
     if (locIndex != null && locIndex > 0){
        locFilter = locList.options[locIndex].text
        locFilter = 'CompanyName = \''+locFilter+'\''
     }   
    }
    WebDisplay_DataSearch('Search_Item.xsl','Divider_SearchDetails',2,GlobalInputID,locFilter,GlobalMemory_Search,Tree_RowPerPage('Tree_ecat'),1,'navsearch',null,'',0)
}
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-27\')',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 LocalEnterKey(event){
   var locKey = Utility_EnterKey(event,'txtsearch',1)
   if (locKey == 13){LocalSearch()}
}
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];}
}
