
// THIS CODE WAS WRITTEN BY XARD777 AND EXTENSIVELY REVISED BY TZUMAN (CapeCoddah)
// FEEL FREE TO RAPE AND PILLAGE ANY OR ALL OF THIS CODE AS YOU SEE FIT
// FOR THOSE OF YOU THAT IMPROVE UPON THIS HERE CODE I ASK YOU ONE THING
// PLEASE POST A COPY UP ON THE FOREX FORUMS FOR YOUR FELLOW TRADERS

#property indicator_chart_window

extern string  Note1                   = "I want to set my start time to NY 5pm";
extern string  Note2                   = "which is London 10pm";
extern string  Note3                   = "My server is London Midnight +1hr";
extern string  Note4                   = "which is London 11pm, so I want to";
extern string  Note5                   = "shift back one more hour = -60Mins";
extern double  TimeShiftMins           = 0.0;
extern bool    ResetEveryHour          = true;

extern string  Note6                   = "Daily period is 1440";
extern int     period                  = 1440;
extern string  Note7                   = "If using micro account, insert suffix";
extern string  Note8                   = "for example  m or .fx";
extern string  if.micro                = "";
 
extern color   Negative.Pips           = DarkOrange;
extern color   Positive.Pips           = DodgerBlue;
extern color   Neutral.Pips            = DimGray;
extern int     Move.Panel.Left.Right   = -8;
extern int     Move.Panel.Up.Down      = 20;

extern bool    show.background.panel   = true;

int      WhatWindow   = 0;
int      WhatCorner   = 0;
color    PanelColor1  = C'144,144,144';
color    PanelColor2  = C'20,50,70';
datetime StartTime;            
string   buffer.name  = "CM 2:";  
           
string Symbols[];
int    Symbols.Number,Symbols.Index[][2], chartpair[2];
#define Majors.Number 8
#define EUR 0
#define GBP 1
#define CHF 2
#define USD 3
#define CAD 4
#define NZD 5
#define AUD 6
#define JPY 7
double Pips[Majors.Number][Majors.Number],Tally[10],Symbols.Open[];
double Sorted[Majors.Number][2];
string Majors[]  = {"EUR","GBP","CHF","USD","CAD","NZD","AUD","JPY"}; 
string space = "";            
color Colors[]={C'50,225,50',C'50,195,60', C'50,165,70',C'50,135,80',C'135,80,50',C'165,70,50',C'195,60,50',C'235,50,50'};

#import "kernel32.dll"
   void GetLocalTime(int& a0[]);
   void GetSystemTime(int& a0[]);
   int GetTimeZoneInformation(int& a0[]);
   bool SystemTimeToTzSpecificLocalTime(int& a0[], int& a1[], int& a2[]);
#import

color opencolor = C'0,117,213', closecolor = C'150,34,34';
bool Highlight_Market_Open = TRUE;
bool Broker_MMSS_Is_Gold_Standard = TRUE;
bool Suppress_Bar_HH_Below_H1 = TRUE;

bool Weekend_Test_Mode = FALSE;

int gia_216[43];
int gia_220[43];
int gia_224[43];
int gia_228[43];
int gia_232[43];
int gia_236[43];
int gia_240[43];
int gia_244[43];
int gia_248[43];

double g_ibuf_252[];
int gi_256 = 8;
int gi_260 = 17;
int gi_264 = 7;
int gi_268 = 16;
int g_datetime_272;

int init()
   {
   IndicatorShortName("Currency Matrix"); 
       
   Symbols.Number = createPairArray();
   ArrayResize(Symbols.Open,Symbols.Number);
   
   StartTime = iTime(NULL,PERIOD_D1,0)+TimeShiftMins*60.00;
   string sTime=TimeToStr(StartTime,TIME_SECONDS);
   if(sTime != "00:00:00")
      {
    //  Alert("Change TimeShiftMins to correct");
    //  Alert("Value should be 00:00:00, it is "+sTime);
    //  Alert("***Incorrect TimeShiftMins***");
      }
   for(int index=0;index<Symbols.Number;index++)  Symbols.Open[index]=iOpen(Symbols[index], PERIOD_H1, iBarShift(Symbols[index], PERIOD_H1, StartTime));
     
   Show_Panel();
   GetAllTimeZoneInfo(gia_216, gia_220, gia_224, gia_228, gia_232, gia_236, gia_240, gia_244, gia_248);
   return(0);
   }
      
int deinit()
   {
   deleteObjects();
   return(0);
   }
int Reset_OpeningData()
{
   static datetime LastTime;
   
   if(ResetEveryHour && Time[0] != LastTime)
      {
      Print("Time reset  ",TimeToStr(TimeCurrent(),TIME_MINUTES));
      bool Reset=true;
      LastTime=Time[0];
      }
 //   put additional tests here.  May have to change initial  
      
      
      
   if(!Reset)  return(0);
   
   for(int index=0;index<Symbols.Number;index++)             Symbols.Open[index]=iOpen(Symbols[index], PERIOD_H1, 0);
   
   return(1);   
      
   
   
/*   if(TimeToStr(TimeCurrent(),TIME_MINUTES)=="13:36")             //to reset every 24 hours
      {
      for(index=0;index<Symbols.Number;index++)  Symbols.Open[index]=iOpen(Symbols[index], PERIOD_H1, iBarShift(Symbols[index], PERIOD_H1, StartTime));
      }
      
*/      
}
int start()
   { 
   
   int    index,counted_bars=IndicatorCounted();  
   Clock();
   Reset_OpeningData();
   
   for(index=0;index<Symbols.Number;index++)
      {
      double DecNos=10000.;             
      if(Symbols.Index[index,0] == JPY || Symbols.Index[index,1] == JPY) DecNos=100.;
      
      double value = (iClose(Symbols[index], PERIOD_H1,0) - Symbols.Open[index])* DecNos;
          
      Pips[Symbols.Index[index,0],Symbols.Index[index,1]]=-value;  //note that the value is reversed as we are printing by rows NOT columns.
      Pips[Symbols.Index[index,1],Symbols.Index[index,0]]=value;
      }
            
    Tally[EUR] = -( Pips[EUR,GBP]+Pips[EUR,CHF]+Pips[EUR,USD]+Pips[EUR,CAD]+Pips[EUR,NZD]+Pips[EUR,AUD]+Pips[EUR,JPY]);
    Tally[GBP] =    Pips[EUR,GBP]-Pips[GBP,CHF]-Pips[GBP,USD]-Pips[GBP,CAD]-Pips[GBP,NZD]-Pips[GBP,AUD]-Pips[GBP,JPY];
    Tally[CHF] =    Pips[EUR,CHF]+Pips[GBP,CHF]+Pips[USD,CHF]+Pips[CAD,CHF]+Pips[NZD,CHF]+Pips[AUD,CHF]-Pips[CHF,JPY];
    Tally[USD] =    Pips[EUR,USD]+Pips[GBP,USD]-Pips[USD,CHF]-Pips[USD,CAD]+Pips[NZD,USD]+Pips[AUD,USD]-Pips[USD,JPY];
    Tally[CAD] =    Pips[EUR,CAD]+Pips[GBP,CAD]-Pips[CAD,CHF]+Pips[USD,CAD]+Pips[NZD,CAD]+Pips[AUD,CAD]-Pips[CAD,JPY];
    Tally[NZD] =    Pips[EUR,NZD]+Pips[GBP,NZD]+Pips[NZD,CHF]-Pips[NZD,USD]+Pips[NZD,CAD]+Pips[AUD,NZD]-Pips[NZD,JPY];
    Tally[AUD] =    Pips[EUR,AUD]+Pips[GBP,AUD]-Pips[AUD,CHF]-Pips[AUD,USD]-Pips[AUD,CAD]-Pips[AUD,NZD]-Pips[AUD,JPY];
    Tally[JPY] =    Pips[EUR,JPY]+Pips[GBP,JPY]+Pips[CHF,JPY]+Pips[USD,JPY]+Pips[CAD,JPY]+Pips[AUD,JPY]+Pips[NZD,JPY];
      
    for(int currency=0;currency<Majors.Number;currency++)
      {
      Sorted[currency,0]=Tally[currency];
      Sorted[currency,1]=currency;
      }
  
   ArraySort(Sorted,WHOLE_ARRAY,0,MODE_DESCEND);
  
   for(currency=0;currency<Majors.Number;currency++)
      {
      Print_Rows(currency);
      Print_Totals(currency);
      Print_SortedOrder(currency);
      }
// ------------------------------------------------------------------------------------------ //
   }
void  Print_Rows(int row)
   {
   int xpos=61,ypos=60+19*row,nbr=row*16,index;
   index=Sorted[row,1];
   
   for(int col=0;col<Majors.Number;col++)
      {
      Print_Data(Pips[index,col],xpos, ypos, nbr);
      xpos+=46;
      }    
   }

void  Print_SortedOrder(int row)
   {
   color Color=White;
   int xpos=429,index,ypos=60+19*row,nbr=row*4;
   index=Sorted[row,1];
   
   CreateBX1_Labels(buffer.name+"Sorted"+(nbr+0),xpos,  ypos,"ggg", 11, "Webdings",Colors[row]) ;
   CreateBX1_Labels(buffer.name+"Sorted"+(nbr+1),xpos+2,ypos+2,Set_Text(DoubleToStr(Tally[index],0)), 10, "Arial Black", Color);
      
   xpos=15;
   CreateBX1_Labels(buffer.name+"Sorted"+(nbr+2),xpos,  ypos,"ggg", 11, "Webdings",Colors[row]) ;
   CreateBX1_Labels(buffer.name+"Sorted"+(nbr+3),xpos+5,ypos+1,Majors[index], 11, "Arial Black", Color);
   nbr+=4;
   }
   
void Print_Data(double value, int xpos,int ypos, int &nbr)
   {  
   if(value==0.)  return;
   
   if (value <-15)       color col = Negative.Pips; 
   else if (value >15)         col = Positive.Pips;  
   else                       col = Neutral.Pips;
   CreateBX1_Labels(buffer.name+ "Row"+nbr,  xpos,ypos,"ggg", 11, "Webdings", col);
   nbr+=1;
   CreateBX1_Labels(buffer.name+ "Row"+nbr,xpos+1,ypos+2, Set_Text(DoubleToStr(value,0)), 10, "Arial Black", White);
   nbr+=1;
   }    
string Set_Text(string text)
   {
   
   switch(StringLen(text))
      {
      case 1:  text="       "+text;    break; 
      case 2:  text="     "+text;     break;
      case 3:  text="   "+text;      break;
      case 4:  text="  "+text;       break;
      }
   return(text);
   }      
void Print_Totals(int currency)
   {
   int offset=61+currency*46;
   int lPips=currency*4,index;
   color col;
   
   for(index=0;index<Majors.Number;index++)
      if(currency==Sorted[index,1])  break;
      
   if (Tally[currency] >0) col = LimeGreen;           else if (Tally[currency] <0) col = Red; 
   CreateBX1_Labels(buffer.name+ "Tally"+(lPips+0),   offset,212,"ggg", 11, "Webdings", Colors[index]);
   CreateBX1_Labels(buffer.name+ "Tally"+(lPips+1),   offset+1,214, Set_Text(DoubleToStr(Tally[currency],0)), 10, "Arial Black", White);
   CreateBX1_Labels(buffer.name+ "Tally"+(lPips+2),   offset,41,  "ggg", 11, "Webdings", Colors[index]);
   CreateBX1_Labels(buffer.name+ "Tally"+(lPips+3),   offset+5,42, Majors[currency], 11, "Arial Black", White);
   }
         
int createPairArray() {
   string symbol;
   int index = 0;
   for (int base = 0; base < Majors.Number - 1; base++) 
      {
      for (int counter = base + 1; counter < Majors.Number; counter++) {
         symbol = Majors[base] + Majors[counter] + if.micro;
         if (MarketInfo(symbol, MODE_BID) > 0.0) 
            {
            //Print("BaseCounter ",symbol," ",base," ",counter);
            ArrayResize(Symbols, index + 1);
            Symbols[index] = symbol;
            ArrayResize(Symbols.Index, index + 1);
            Symbols.Index[index,0]=base;
            Symbols.Index[index,1]=counter;
            index++;
            }
           
                  
         symbol = Majors[counter] + Majors[base] + if.micro;
         if (MarketInfo(symbol, MODE_BID) > 0.0) 
            {
            //Print("CounterBase ",symbol," ",base," ",counter);
            ArrayResize(Symbols, index + 1);
            Symbols[index] = symbol;
            ArrayResize(Symbols.Index, index + 1);
            Symbols.Index[index,0]=counter;
            Symbols.Index[index,1]=base;
            index++;
            }
         }
   }
   GetLastError();         //to clear legitimate 4106 errors
   return(ArraySize(Symbols));
   }   

// ====.====================================================================================== //
int CreateBX1_Labels( string K, int x, int y, string Text, int FontSize, string Font, color Color ) 
   {
   ObjectCreate( K, OBJ_LABEL, WhatWindow, 0, 0 );
   ObjectSet( K, OBJPROP_CORNER, WhatCorner);
   ObjectSet( K, OBJPROP_XDISTANCE,x+Move.Panel.Left.Right);
   ObjectSet( K, OBJPROP_YDISTANCE,y+Move.Panel.Up.Down);
   ObjectSet( K, OBJPROP_BACK, false );
   ObjectSetText(K, Text, FontSize, Font, Color);
   }   
        
   void deleteObjects(){
   for(int i=0;   i<126;i++) ObjectDelete(buffer.name+"Row" + i);
   for(    i=0;   i<10;i++)  ObjectDelete(buffer.name+"Panel0" + i);
   for(    i=0;   i<34;i++)  ObjectDelete(buffer.name+"Panel" + i);
   for(    i=0;   i<32;i++)  ObjectDelete(buffer.name+"Tally" + i);
   for(    i=0;   i<32;i++)  ObjectDelete(buffer.name+"Sorted" + i);
   GetLastError();
   }
   
void Show_Panel()
   {     
      CreateBX1_Labels(buffer.name+"Panel24",56,10,  "       L O N D O N            U S A ", 12, "Arial Bold", White);
      CreateBX1_Labels(buffer.name+"Panel25",330,10, " A S I A ", 12, "Arial Bold", White);
      
   if(!show.background.panel)  return;    
      CreateBX1_Labels(buffer.name+"Panel01",56,6,    "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel02",190,6,   "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel03",10,58,    "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel04",10,97,   "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel05",236,58,  "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel06",236,97, "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel07",56,116,  "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel08",190,116, "gg", 90, "Webdings", PanelColor1);
      CreateBX1_Labels(buffer.name+"Panel09",58,8,    "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel10",188,8,   "gg", 90, "Webdings", PanelColor2); 
      CreateBX1_Labels(buffer.name+"Panel11",58,114,  "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel12",188,114, "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel13",12,60,    "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel14",12,95,   "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel15",234,60,  "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel16",234,95, "gg", 90, "Webdings", PanelColor2);
      CreateBX1_Labels(buffer.name+"Panel17",130,100, "gg", 90, "Webdings", PanelColor2);    
   }
   
/////////////////////clock subroutines
int Clock()
   {
   int lia_0[4];
   int lia_4[4];
   int lia_8[4];
   int lia_12[4];
   int lia_16[4];
   int li_40;
   int l_datetime_44;
   int li_48;
  
   int NYTime,LondonTime,TokyoTime;
  
   string l_text_88;
   string Time.London,Time.Tokyo,Time.NY;
   int li_176;
   string l_time2str_180;
   if (!IsDllsAllowed()) {
      if (TimeCurrent() - g_datetime_272 >= 7) {
         g_datetime_272 = TimeCurrent();
         Alert(WindowExpertName(), ": ERROR. DLLs are disabled. To enable, select \'Allow DLL Imports\' in the Common Tab of indicator");
      }
   } else {
      if (!Weekend_Test_Mode && TimeCurrent() - g_datetime_272 == 0) return;
      g_datetime_272 = TimeCurrent();
      GetLocalTime(lia_0);
      li_40 = TimeArrayToTime(lia_0);
      l_datetime_44 = TimeCurrent();
      li_48 = 0;
      if (Broker_MMSS_Is_Gold_Standard && !Weekend_Test_Mode) {
         li_48 = 60 * TimeMinute(l_datetime_44) + TimeSeconds(l_datetime_44) - 60 * TimeMinute(li_40) - TimeSeconds(li_40);
         if (li_48 > 1800) li_48 -= 3600;
         else
            if (li_48 < -1800) li_48 += 3600;
      }
      GetSystemTime(lia_4);
      
      SystemTimeToTzSpecificLocalTime(gia_220, lia_4, lia_8);
      NYTime = TimeArrayToTime(lia_8) + li_48;
      SystemTimeToTzSpecificLocalTime(gia_224, lia_4, lia_12);
      LondonTime = TimeArrayToTime(lia_12) + li_48;
      SystemTimeToTzSpecificLocalTime(gia_228, lia_4, lia_16);
      TokyoTime = TimeArrayToTime(lia_16) + li_48;       
      
      Time.London = TimeToString(LondonTime);
      Time.Tokyo = TimeToString(TokyoTime);
      Time.NY = TimeToString(NYTime);
            
      li_176 = 60 * Period() + Time[0] - TimeCurrent();
      if (li_176 >= 0) {
      l_time2str_180 = TimeToStr(60 * Period() + Time[0] - TimeCurrent(), TIME_MINUTES);
         if (Suppress_Bar_HH_Below_H1 && Period() <= PERIOD_H1 && StringLen(l_time2str_180) > 6) l_time2str_180 = StringSubstr(l_time2str_180, 3);
      } 
          
      color ctimes[3];
      for(int i=0;i<3;i++) ctimes[i]=closecolor;
      
       if (TimeDayOfWeek(TokyoTime) != 0 && TimeDayOfWeek(TokyoTime) != 8 && Highlight_Market_Open && TimeHour(TokyoTime) >= gi_256 && TimeHour(TokyoTime) < gi_260) 
       ctimes[2]=opencolor;
      
         if (TimeDayOfWeek(LondonTime) != 0 && TimeDayOfWeek(LondonTime) != 8 && Highlight_Market_Open && TimeHour(LondonTime) >= gi_256 && TimeHour(LondonTime) < gi_260) 
         ctimes[0]=opencolor;
      
         if (TimeDayOfWeek(NYTime) != 0 && TimeDayOfWeek(NYTime) != 8 && Highlight_Market_Open && TimeHour(NYTime) >= gi_256 && TimeHour(NYTime) < gi_260) 
         ctimes[1]=opencolor;
      
   }
   
      CreateBX1_Labels(buffer.name+"Panel18",61,10,   "ggg", 22, "Webdings", ctimes[0]);
      CreateBX1_Labels(buffer.name+"Panel19",108,10,  "ggg", 22, "Webdings", ctimes[0]);
      CreateBX1_Labels(buffer.name+"Panel20",199,10,  "gg", 22, "Webdings", ctimes[1]);
      CreateBX1_Labels(buffer.name+"Panel21",229,10,  "gg", 22, "Webdings", ctimes[1]);
      CreateBX1_Labels(buffer.name+"Panel22",291,10,  "ggg", 22, "Webdings", ctimes[2]);
      CreateBX1_Labels(buffer.name+"Panel23",338,10,  "ggg", 22, "Webdings", ctimes[2]);
      CreateBX1_Labels(buffer.name+"Panel26",95,24,  Time.London, 10, "Arial Black", White);
      CreateBX1_Labels(buffer.name+"Panel27",212,24,  Time.NY, 10, "Arial Black", White);
      CreateBX1_Labels(buffer.name+"Panel28",325,24,  Time.Tokyo, 10, "Arial Black", White);
   return (0);
   }

string TimeToString(int ai_0) {
   string ls_ret_4;
   int l_hour_12 = TimeHour(ai_0);
   
   if (l_hour_12 > 12 || l_hour_12 == 0) ls_ret_4 = TimeToStr(ai_0 - 43200, TIME_MINUTES);
   else ls_ret_4 = TimeToStr(ai_0, TIME_MINUTES);
   if (l_hour_12 >= 12) ls_ret_4 = StringConcatenate(ls_ret_4, " PM");
   else ls_ret_4 = StringConcatenate(ls_ret_4, " AM");
      
   return (ls_ret_4);
   }

string FormatDateTime(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16, int ai_20) {
   string ls_24 = ai_4 + 100;
   ls_24 = StringSubstr(ls_24, 1);
   string ls_32 = ai_8 + 100;
   ls_32 = StringSubstr(ls_32, 1);
   string ls_40 = ai_12 + 100;
   ls_40 = StringSubstr(ls_40, 1);
   string ls_48 = ai_16 + 100;
   ls_48 = StringSubstr(ls_48, 1);
   string ls_56 = ai_20 + 100;
   ls_56 = StringSubstr(ls_56, 1);
   return (StringConcatenate(ai_0, ".", ls_24, ".", ls_32, " ", ls_40, ":", ls_48, ":", ls_56));
   }

int TimeArrayToTime(int aia_0[4]) {
   int l_str2time_44;
   int li_4 = aia_0[0] & 65535;
   int li_8 = aia_0[0] >> 16;
   int li_16 = aia_0[1] >> 16;
   int li_20 = aia_0[2] & 65535;
   int li_24 = aia_0[2] >> 16;
   int li_28 = aia_0[3] & 65535;
   int li_32 = aia_0[3] >> 16;
   string ls_36 = FormatDateTime(li_4, li_8, li_16, li_20, li_24, li_28);
   l_str2time_44 = StrToTime(ls_36);
   return (l_str2time_44);
   }

void GetAllTimeZoneInfo(int aia_0[43], int &aia_4[43], int &aia_8[43], int &aia_12[43], int &aia_16[43], int &aia_20[43], int &aia_24[43], int &aia_28[43], int &aia_32[43]) {
   int li_36 = GetTimeZoneInformation(aia_0);
   aia_4[0] = 300;
   aia_4[17] = 720896;
   aia_4[18] = 65536;
   aia_4[19] = 2;
   aia_4[20] = 0;
   aia_4[21] = 0;
   aia_4[38] = 196608;
   aia_4[39] = 131072;
   aia_4[40] = 2;
   aia_4[41] = 0;
   aia_4[42] = -60;
   aia_8[0] = 0;
   aia_8[17] = 655360;
   aia_8[18] = 327680;
   aia_8[19] = 2;
   aia_8[20] = 0;
   aia_8[21] = 0;
   aia_8[38] = 196608;
   aia_8[39] = 327680;
   aia_8[40] = 1;
   aia_8[41] = 0;
   aia_8[42] = -60;
   aia_12[0] = -540;
   aia_12[17] = 0;
   aia_12[18] = 0;
   aia_12[19] = 0;
   aia_12[20] = 0;
   aia_12[21] = 0;
   aia_12[38] = 0;
   aia_12[39] = 0;
   aia_12[40] = 0;
   aia_12[41] = 0;
   aia_12[42] = 0;
   aia_16[0] = -600;
   aia_16[17] = 262144;
   aia_16[18] = 65536;
   aia_16[19] = 3;
   aia_16[20] = 0;
   aia_16[21] = 0;
   aia_16[38] = 655360;
   aia_16[39] = 65536;
   aia_16[40] = 2;
   aia_16[41] = 0;
   aia_16[42] = -60;
   aia_20[0] = -720;
   aia_20[17] = 262144;
   aia_20[18] = 65536;
   aia_20[19] = 3;
   aia_20[20] = 0;
   aia_20[21] = 0;
   aia_20[38] = 589824;
   aia_20[39] = 327680;
   aia_20[40] = 2;
   aia_20[41] = 0;
   aia_20[42] = -60;
   ArrayCopy(aia_24, aia_8);
   aia_24[0] = -180;
   ArrayCopy(aia_28, aia_8);
   aia_28[0] = -60;
   ArrayCopy(aia_32, aia_4);
   aia_32[0] = 480;
   }        
// ==================================
// LET THERE BE ORDER... XARD777 2011
// AND THERE WILL BE ORDER.....TZUMAN