var locCount = 0;var GlobalMemberName='Electro Base';var GlobalMemberSub='eBase'; var GlobalIsLogin=0;var GlobalLogin_Mode=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('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('localhost') != -1 || myURL.toLowerCase().indexOf('localhost') != -1 || myURL.toLowerCase().indexOf('epublisher.co.za') != -1 || myDomain.toLowerCase().indexOf('epublisher.co.za') != -1 || myURL.toLowerCase().indexOf('file://') != -1){
  locMainAddress = 'http://www.epublisher.co.za'
  locAddress = 'http://www.epublisher.co.za/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('ProgressBar')
  if (locData != null){
      WindowEventLoad(locMainAddress)
      LocalInit()
  }
  else{setTimeout("TimerLoad()",1000)}
}   
function LocalAuction(){
  w=800 
  h=600 
  if (window.screen) { 
     w = window.screen.availWidth-10; 
     h = window.screen.availHeight-10; 
  } 
  window.open('index_eBaseAuction.html','Auction','width='+w+',height='+h+',top=0,left=0,resizable=yes,scrollbars=yes')
}
function LocalInit(){
     var locURL = document.URL.toLowerCase()	 
     if (locURL.indexOf('landing_page.html')!= -1){
		 var locMode=Utility_URLRetrieveParam('page','#')
		 if (locMode.length==0){
  		    LocalDisplay_ConfidentPage(0)			 
		 }else {
			 LocalDisplay_ConfidentPage(locMode)
			 LocalLogin_AccessMain()
	     }
	 }
}
function LocalDisplay_ConfidentPage(pMode){
  Utility_Divider(2,'Divider_LoginWindow')	
  if (pMode==0){
     LocalLogin_Display()
     return
  }
  var locMode=pMode
  var locObj = document.getElementById('frame_cnf')
  locObj.src = 'Confidential_Page_'+locMode+'.html'
  locObj.style.visibility='visible'
}
function LocalLogin_Display(pStylesheet){
   var locStylesheet = 'User_Login.xsl'
   if (pStylesheet != null) {locStylesheet = pStylesheet}
   WebDisplay_UserLogin(locStylesheet)
}
function LocalSignIn(pHeader,pUser,pPassword,pMemberName){
	ProgressImageDisplay(true)
	GlobalTimerParam1 = pHeader
	GlobalTimerParam2 = pUser
	GlobalTimerParam3 = pPassword
    GlobalTimerParam4 = pMemberName
    setTimeout("LocalSignTimer()",200)	
}
function LocalSignTimer(){ 
   var pHeader=GlobalTimerParam1
   var pUser=GlobalTimerParam2
   var pPassword=GlobalTimerParam3
   var pMemberName=GlobalTimerParam4
   GlobalMemberName = pMemberName
   GlobalMemberSub = pUser   
   var locObj1=document.getElementById(pHeader+'Username')
   var locObj2=document.getElementById(pHeader+'Password')
   if (!Screen_Validation('Login_'+GlobalMemberSub,'Divider_LoginWindow','_MustFill_')){ProgressImageDisplay(false);return 0}   
   GlobalMemberSub = pUser   
   if (locObj1!=null&&locObj2!=null && locObj1.value.toLowerCase() == pUser.toLowerCase() && locObj2.value.toLowerCase() == pPassword.toLowerCase()){
      ProgressImageDisplay(true)
      WebDisplay_EnquiryForm('Divider_UserLogin','Good Day '+GlobalMemberName+' Member',pHeader,1,1)
	  GlobalLogin_Mode = 1
      setTimeout("LocalLogin_AccessMain()",200)
   }
   else{ProgressImageDisplay(false);alert('Invalid Username/Password')}
}

function LocalLogin_AccessMain(){
   GlobalIsLogin=1
   ProgressImageDisplay(false)
   var locBtn=document.getElementsByTagName('div'); var locID=''
   for (var i=0;i<locBtn.length;i++){
      locID=locBtn[i].id
      if (locID.indexOf('BtnConfidential')!=-1){locBtn[i].style.visibility='visible'}
   }
   if (GlobalLogin_Mode==1){
	   LocalDisplay_ConfidentPage(3)
   }   
}
function LocalBranches(pRegion){
   var locRegion = 'Gauteng'
   if (pRegion != null && pRegion.toLowerCase().indexOf('select')==-1) {locRegion = pRegion}
   else {locRegion='Gauteng'}
   WebDisplay_CompanyList('EC-ZA-0-101-ElectroBase Members',locRegion)
}
	


