

var Status_RoutePlan_TitleEdit;
var Status_RoutePlan_ToView;
var Status_RoutePlan_MoveDow;
var Status_RoutePlan_SetFrom;
var Status_RoutePlan_SetTo;
var Status_RoutePlan_WPfocus;
var Status_RoutePlan_OverView;   
var Status_RoutePlan_FromView;     
var Status_RoutePlan_ToView;

//var CTO_SystemMapGallery_Table = [];
//var CTO_MyMapGallery_Table = [];



var RoutePlan_WayP_list_SelectedItem = null;

var TRI_QuickDrawVisible= true;


//====================================  Route_Tools_Handler  ====================|
var Route_Tools_Status_InActive=">";
function Route_Tools_Handler(e,MouseEvent) {
var objBotton ;
var objBottonID ;
var tools; 
    if (typeof e == 'string') { 
        objBotton=document.getElementById(e)
    }
    if (typeof e == 'object') { 
        objBotton= GetEventTrigger (e)
    }
    objBottonID = objBotton.id
    tools = objBotton.id.substr(16, 20);
    if (MouseEvent == "inactive" ) {
        //objBotton = document.getElementById("RoutePlan_Route_" + ByNameTools);
        objBotton.src="Images/Route_" + tools + "_inactive.png";
        //setFilter_Opacity(objBottonID, 50);
        Route_Tools_Status_InActive = Route_Tools_Status_InActive.replace(tools+";",'');
        Route_Tools_Status_InActive+=tools+";"
        return
    }
    if (MouseEvent == "active" ) {
        //objBotton = document.getElementById("RoutePlan_Route_" +ByNameTools);
        objBotton.src="Images/Route_" + tools + ".png";
       // RestoreFilter(objBottonID) 
        Route_Tools_Status_InActive = Route_Tools_Status_InActive.replaceAll(tools+";" ,'');
        return
    } 
    //------------------------------------------------------------
    if (Route_Tools_Status_InActive.indexOf(tools+';')>=0){return} 
    if (MouseEvent == "over" ) {
        objBotton.src="Images/Route_" + tools + "_over.png";
    } else if (MouseEvent == "out") {
        objBotton.src="Images/Route_" + tools + ".png";
    } else if (MouseEvent == "down") {
        objBotton.src="Images/Route_" + tools + "_active.png";
        objBotton.src="Images/Route_" + tools + ".png";
        Route_Tools_Actived(tools );
	}  
}
//--------------------------------------------------------------------------




////--------------------------------------------------------------------------
////============================ TRI_RoutePlaning_WayPoint_Redraw   =========================|
//function TRI_RoutePlaning_WayPoint_Redraw() {
//return;
//    var WP_Count= TravelData.WayPoints.length
//    var WP_LastIndex=WP_Count-1
//    if (WP_Count==0){
//        document.getElementById("MapImage_TRI_WayPoint").innerHTML = "";
//        return
//    }
//    var SymbolName ;
//    var WP_X, WP_Y ,WP_W, WP_H;
//    WP_W=40;
//    WP_H=40;
//    var msg="";

//    for (var i=0; i<WP_Count;i++){
//        SymbolName="TRI_WayPoint_WP.png"
//        if (i==0){SymbolName="TRI_WayPoint_From.png"};
//        if (i==WP_LastIndex && i!=0){SymbolName="TRI_WayPoint_To.png"};
//        if (TravelData.WayPoints[0].Label== TravelData.WayPoints[WP_LastIndex].Label && i==WP_LastIndex && i!=0){SymbolName="TRI_WayPoint_FromTo.png"};
//   
//        var WP_Point = new MapPoint(TravelData.WayPoints[i].X, TravelData.WayPoints[i].Y).transform(ctoMap.MapRect, ctoMap.ImageRect);   
//        WP_X =WP_Point.x -WP_W/2;
//        WP_Y =WP_Point.y-WP_H/2;          
//        
//        msg+=  "<div id=\"Wp"+ i +"\" style=\"position: absolute; display: block; visibility: visible; z-index: 1004; ";
//        msg+= "background-image: url(Images_MapSymbol/" + SymbolName + "); background-repeat: no-repeat; " ;
//        msg+= "padding: 0px; margin: 0px; border: none; ";
//        msg+= "left: " + parseInt(WP_X) + "px; top: " + parseInt(WP_Y) + "px; width: " + WP_W + "px; height: " + WP_H + "px;\"";
//       // msg+= " onmouseover=\"TOIItem_Info_Event(event,\'over\')\"/>";    
//        msg+= " />";  
//        msg+= "</div>";
//    }
//    document.getElementById("MapImage_TRI_WayPoint").innerHTML = msg;
//} 
//-------------------------------------------------------------------------- 
//============================ RoutePlan_WayPoint_Clear   =========================|
function RoutePlan_WayPoint_Clear() {
  //  document.getElementById("MapImage_TRI_WayPoint").innerHTML = "";
}

//====================== TRI_RoutePlaning_TestRoute_Redraw   ======================|
function TRI_RoutePlaning_TestRoute_Redraw() {
   // TravelMapDrawTest_container.innerHTML = "";
    if (TravelData.Solution){return};
    var WP_Count = TravelData.WayPoints.length
    if (WP_Count<2){return};
    //setFilter_Opacity("MapImage_TRI_TestRoute", 25);
    //setFilter_Opacity(container.id,50);
   // var WP_LastIndex=WP_Count-1
   
//    var jg = new jsGraphics(TravelMapDrawTest_container.id);
//    jg.setStroke(10);
//    jg.setColor("#00FF00");
         
//    //var msg="";
//    for (var i=1; i<WP_Count;i++){
//        var WP_Point1 = new MapPoint(TravelData.WayPoints[i-1].X, TravelData.WayPoints[i-1].Y).transform(ctoMap.MapRect, ctoMap.ImageRect); 
//        var WP_Point2 = new MapPoint(TravelData.WayPoints[i].X, TravelData.WayPoints[i].Y).transform(ctoMap.MapRect, ctoMap.ImageRect); 
//        jg.drawLine(WP_Point1.x, WP_Point1.y, WP_Point2.x, WP_Point2.y);
//    }
//    jg.paint();
    //container.innerHTML = msg;
//    
//    try{
//    //    var container= document.getElementById("MapImage_TRI_Route");
//    //    Draw.DrawTravel(container,Travel,ctoMap.MapRect,ctoMap.ImageRect);
//    }catch(e){}
} 
//--------------------------------------------------------------------------  
//============================ RoutePlan_TestRoute_Clear   =========================|
function RoutePlan_TestRoute_Clear() {
   // document.getElementById("MapImage_TRI_TestRoute").innerHTML = "";
} 
     
//============================ TRI_RoutePlaning_List_Redraw   =========================|
function TRI_RoutePlaning_List_Redraw() {
    if (CTO_MenuTab!=3){
        CTO_Menu_Tab("TabMenu_Tab3D","click");
    }
    if (Active_VTab_Route!='1'){
        VTab_Route_Handler("VTab_Route_Cell1","click");
    }
    var msg="";
    var DynamicLabel;
    var ToUseImage;
    //for (var i=0; i<TRI_WayPoint_Info.length;i++){
    for (var i=0; i<TravelData.WayPoints.length;i++){
        msg+=  "<div id=\"WayPoint"+ i +"\" style=\"position: static; display: block; vertical-align:middle; visibility:visible; overflow:hidden;";
        msg+= "padding: 0px; margin: 0px; border:none; width:auto; height: 20px;\">";
        
        if (i==0) {
            DynamicLabel="FromHere";
            ToUseImage="Route_SetFromHere.png"
        }else{
             if (i==TravelData.WayPoints.length-1) {
                DynamicLabel= "ToHere" ; 
                ToUseImage="Route_SetToHere.png"
             }else{
                DynamicLabel= "WayPoint" ;
                ToUseImage="Route_SetWayPoint.png"
             }
        }
        msg+= "<img id=\"WayPointI"+ i + "\" title=\"" + GDI_DynamicLabel [DynamicLabel] + "\"  alt=\"" + GDI_DynamicLabel [DynamicLabel]+ "\" " ;  
        msg+= " style=\"position:relative; display: block; overflow:hidden;";
        msg+= "margin: 0px;padding: 0px; border:none; cursor:pointer;";      
        msg+= "left:4px;top:2px;width:15px;height:15px;\" ";
        msg+= "src=\"Images/"+ToUseImage+"\"/>";        
 
        msg+= "<div id=\"WayPointL"+ i + "\" title=\"" + TravelData.WayPoints[i].Label + "\" style=\"position:relative; display: block; overflow:hidden;";
        msg+= "margin: 0px;padding: 0px; border:none; cursor:pointer;";      
        msg+= "left:30px;top:-12px;width:300px;height:15px;"; 
        msg+= "font-family:Verdana,Arial,Verdana,Tahoma;"; 
        msg+= "font-size:11px;font-weight:normal;color:#6495ED;"; 
        msg+= "text-align:left;vertical-align:middle;text-transform:capitalize;\""; 
        msg+= " onclick=\"RoutePlan_WayP_list_Handler(event)\"";
        msg+= " onmouseover=\"RoutePlan_WayP_list_Handler(event)\"";
        msg+= " onmouseout=\"RoutePlan_WayP_list_Handler(event)\"";
        msg+= " >";
        msg+=  GetZeroFrontNumber(i+1,2) + "    " + TravelData.WayPoints[i].Label
        msg+= "</div>";
        
        msg+=  "<div id=\"WayPointT"+ i + "\" title=\"" + TravelData.WayPoints[i].Time + "\" style=\"position:relative; display: block; overflow:hidden;";
        msg+= "margin: 0px;padding: 0px; border:none; cursor:pointer;";        
        msg+= "left:330px;top:-26px;width:160px;height:15px;"; 
        msg+= "font-family:Verdana,Arial,Verdana,Tahoma;"; 
        msg+= "font-size:11px;font-weight:normal;color:#6495ED;"; 
        msg+= "text-align:left;vertical-align:middle;text-transform:capitalize;\">"; 
        if (i==0) {
            msg+=  TravelData.WayPoints[i].Time + "  ["+ GDI_DynamicLabel ['DepartureTime'] + "]" ; 
        }else{
             if (i==TravelData.WayPoints.length-1) {
                msg+= TravelData.WayPoints[i].Time + "  ["+ GDI_DynamicLabel ['ArrivalTime'] + "]" ; 
             }else{
                msg+=  TravelData.WayPoints[i].Time + "  ["+ GDI_DynamicLabel ['StopDuration'] + "]" ; 
             }
        }
        msg+= "</div>";    
        msg+= "</div>";                  
    }
    var RoutePlan_Container = document.getElementById("RoutePlan_InfoWp");
    RoutePlan_Container.innerHTML = msg;
    TRI_RoutePlaning_Actived_Tools()
}





//*********************************************************************
//ΕΠΙΛΟΓΗ WayPoint                                                      //
//*********************************************************************
function RoutePlan_WayP_list_Handler(e){
var EventTrigger= GetEventTrigger (e)
var MouseEvent= GetEventType (e)
    if (MouseEvent == "mouseover" ) {
        EventTrigger.style.color="#FF9A00";
    } else if (MouseEvent == "mouseout") {
        EventTrigger.style.color="#6495ED"; 
    } else if (MouseEvent == "click") { 
        if(RoutePlan_WayP_list_SelectedItem != null){
            RoutePlan_WayP_list_SelectedItem.Container.style.backgroundColor = "transparent";
            RoutePlan_WayP_list_SelectedItem.Trigger.style.color = "#6495ED";     
        }
        var selected_ID =EventTrigger.id.substr(9,6)
        var selected_Container =document.getElementById(EventTrigger.id.substr(0,8)+ selected_ID);
        var selectedItemProperties ={Trigger:EventTrigger,Container:selected_Container ,SelectID:selected_ID};  
        if(RoutePlan_WayP_list_SelectedItem != null){ 
            if(RoutePlan_WayP_list_SelectedItem.Container== selected_Container){
                RoutePlan_WayP_list_SelectedItem = null
                TRI_RoutePlaning_Actived_Tools()
                return
            }
        }
        RoutePlan_WayP_list_SelectedItem = selectedItemProperties;
        RoutePlan_WayP_list_SelectedItem.Container.style.backgroundColor = "#C6DBFF";
        RoutePlan_WayP_list_SelectedItem.Trigger.style.color = "#FF9A00";  
        TRI_RoutePlaning_Actived_Tools() 
      }   
}




//============================ Route_Tools_Actived   =========================|
function Route_Tools_Actived(ActiveTools) {
    switch (ActiveTools){
    
    case "SetFromHere": 
        TRI_WayPoint_Info_Add ("FromHere", TOIItem_Info[TOI_ID].Name + " [ " + TOILayer_Label [TOIItem_Info[TOI_ID].Layer] + " ] ", TOIItem_Info[TOI_ID].Layer, TOIItem_Info[TOI_ID].ID, TOIItem_Info[TOI_ID].Xm, TOIItem_Info[TOI_ID].Ym,"08:30:00");
        TRI_RoutePlaning_List_Redraw();
        TravelData.MapWayPoint.Draw(TravelMapWayPoint_container,ctoMap.MapRect,ctoMap.ImageRect);
        //TRI_RoutePlaning_WayPoint_Redraw();
        TRI_RoutePlaning_TestRoute_Redraw();
        break;
    case "SetWayPoint": 
        TRI_WayPoint_Info_Add ("WayPoint", TOIItem_Info[TOI_ID].Name + " [ " + TOILayer_Label [TOIItem_Info[TOI_ID].Layer] + " ] ", TOIItem_Info[TOI_ID].Layer,TOIItem_Info[TOI_ID].ID, TOIItem_Info[TOI_ID].Xm , TOIItem_Info[TOI_ID].Ym,"00:30:00");
        TRI_RoutePlaning_List_Redraw();
        TravelData.MapWayPoint.Draw(TravelMapWayPoint_container,ctoMap.MapRect,ctoMap.ImageRect);
        //TRI_RoutePlaning_WayPoint_Redraw();
        TRI_RoutePlaning_TestRoute_Redraw();
        break;
    case "SetToHere": 
        TRI_WayPoint_Info_Add ("ToHere", TOIItem_Info[TOI_ID].Name + " [ " + TOILayer_Label [TOIItem_Info[TOI_ID].Layer] + " ] ", TOIItem_Info[TOI_ID].Layer,TOIItem_Info[TOI_ID].ID, TOIItem_Info[TOI_ID].Xm , TOIItem_Info[TOI_ID].Ym,"00:00:00");
        TRI_RoutePlaning_List_Redraw();
        TravelData.MapWayPoint.Draw(TravelMapWayPoint_container,ctoMap.MapRect,ctoMap.ImageRect);
        //TRI_RoutePlaning_WayPoint_Redraw();
        TRI_RoutePlaning_TestRoute_Redraw();
    break;
    
    case "DelWayPoint": 
        if(RoutePlan_WayP_list_SelectedItem != null){ 
            TRI_WayPoint_Info_DelWayPoint(RoutePlan_WayP_list_SelectedItem.SelectID);
            TRI_RoutePlaning_List_Redraw();
            TravelData.MapWayPoint.Draw(TravelMapWayPoint_container,ctoMap.MapRect,ctoMap.ImageRect);
            //TRI_RoutePlaning_WayPoint_Redraw();
            TRI_RoutePlaning_TestRoute_Redraw();
        }
        break;    
    
    case "TitleEdit": 	
        
        break;
    case "MoveUp": 	
        
        break;
    case "MoveDow": 	
        
        break;
    case "SetFrom": 	
        
        break;  
    case "SetTo": 	
       
        break; 
        
    case "QuickDrawOn": 	
        document.getElementById("RoutePlan_Route_QuickDrawOn" ).style.display="none";
        document.getElementById("RoutePlan_Route_QuickDrawOff" ).style.display="block";    
        TRI_QuickDrawVisible=false;
        break;          
    case "QuickDrawOff": 	
        document.getElementById("RoutePlan_Route_QuickDrawOn" ).style.display="block";
        document.getElementById("RoutePlan_Route_QuickDrawOff" ).style.display="none";
        TRI_QuickDrawVisible=true;
        break;        
    case "WPfocus": 	
       
        break; 
    case "OverView": 	
        
        break;  
    case "FromView": 	
           
        break; 
    case "ToView": 	
       
        break;
     case "SetTOI_Visible": 	
        document.getElementById("RoutePlan_Route_SetTOI_Visible" ).style.display="none";
        document.getElementById("RoutePlan_Route_SetTOI_Hide" ).style.display="block";
        TOIVisible=false;
        document.getElementById("Map_Visible_TOI").src="Images_tree2/CTO_Tree_TOI_Hide.gif";
        document.getElementById("M000^Map^MapImage_TOI").style.display = "none";        
        break;       
    case "SetTOI_Hide": 	
        document.getElementById("RoutePlan_Route_SetTOI_Visible" ).style.display="block";
        document.getElementById("RoutePlan_Route_SetTOI_Hide" ).style.display="none";
        TOIVisible=true;
        document.getElementById("Map_Visible_TOI").src="Images_tree2/CTO_Tree_TOI_Visible.gif";
        document.getElementById("M000^Map^MapImage_TOI").style.display = "block";         
        break;         
     case "SetTRI_Visible": 	
        document.getElementById("RoutePlan_Route_SetTRI_Visible" ).style.display="none";
        document.getElementById("RoutePlan_Route_SetTRI_Hide" ).style.display="block";
        TRIVisible=false;
        document.getElementById("Map_Visible_TRI").src="Images_tree2/CTO_Tree_TOI_Hide.gif";
        //document.getElementById("MapImage_TRI").style.display="none" ; 
        // document.getElementById("MapImage_TRI_WayPoint").style.display="none" ; 
         document.getElementById("M000^MapTravelLine").style.display="none" ; 
        // document.getElementById("MapImage_TRI_TestRoute").style.display="none" ; 
                 
        break;       
    case "SetTRI_Hide": 	
        document.getElementById("RoutePlan_Route_SetTRI_Visible" ).style.display="block";
        document.getElementById("RoutePlan_Route_SetTRI_Hide" ).style.display="none";
        TRIVisible=true;
        document.getElementById("Map_Visible_TRI").src="Images_tree2/CTO_Tree_TOI_Visible.gif";
        //document.getElementById("MapImage_TRI").style.display="block" ; 
       // document.getElementById("MapImage_TRI_WayPoint").style.display="block" ; 
        document.getElementById("M000^MapTravelLine").style.display="block" ; 
       // document.getElementById("MapImage_TRI_TestRoute").style.display="block" ;        
        break;         
    default:
       // return 0
    }
}
//--------------------------------------------------------------------------


//============================   Route_Command    =========================|
var Route_WordCommand_Status_InActive=">";
function Route_WordCommand(e,MouseEvent,ByNameWordCommand) {
var objBotton ;

    if (MouseEvent == "inactive" ) {
        objBotton = document.getElementById("Route_WordCommand_" + ByNameWordCommand);
        objBotton.style.background = "url(\'Images_Navigator/CTO_WordComand20X98_inactive.png\')";
      //  objBotton.style.paddingTop="0px";
        objBotton.style.fontWeight="normal";
        objBotton.style.color="#8C8A8C";
        Route_WordCommand_Status_InActive+=ByNameWordCommand+";"
        return
    }
    if (MouseEvent == "active" ) {
        objBotton = document.getElementById("Route_WordCommand_" +ByNameWordCommand);
        objBotton.style.background= "url(Images_Navigator/CTO_WordComand20X98.png)";
     //   objBotton.style.paddingTop="0px";
        objBotton.style.fontWeight="normal";
        objBotton.style.color="#0065b3";
        ByNameWordCommand = ByNameWordCommand+';'
        Route_WordCommand_Status_InActive = Route_WordCommand_Status_InActive.replace(ByNameWordCommand,'');
        return
    } 
    
var objBottonID ;
var WordCommand;     
    objBotton= GetEventTrigger(e);
    objBottonID = objBotton.id
    WordCommand = objBotton.id.substr(18, 20);
    if (Route_WordCommand_Status_InActive.indexOf(WordCommand+';')>=0){return}
        
    if (MouseEvent == "over" ) {
        objBotton.style.background= "url(Images_Navigator/CTO_WordComand20X98_over.png)";
     //   objBotton.style.paddingTop= "1px";
        objBotton.style.fontWeight="bold";
    } else if (MouseEvent == "out") {  
        objBotton.style.background= "url(Images_Navigator/CTO_WordComand20X98.png)";
      //  objBotton.style.paddingTop="0px";
        objBotton.style.fontWeight="normal";
    } else if (MouseEvent == "click") {    
        objBotton.style.background= "url(Images_Navigator/CTO_WordComand20X98_active.png)";
        objBotton.style.fontWeight="bold";
        Route_WordCommand_Actived(WordCommand );
//        if (WordCommand=="Optimaze"){ 
//            alert(WordCommand)
//        }
        
    }
    objBotton.style.backgroundRepeat = "no-repeat"; 
    objBotton.style.backgroundPosition= "left top"; 
}  

//--------------------------------------------------------------------------
//============================ Route_WordCommand_Actived   =========================|
function Route_WordCommand_Actived(ActiveWordCommand) {
    switch (ActiveWordCommand){
    case "Optimaze": 	
        alert(ActiveWordCommand)
        break;
    case "Save": 	
        alert(ActiveWordCommand)
        break;
    case "Clear": 	
        alert(ActiveWordCommand)
        break;
    default:
        return 0
    }
}
//--------------------------------------------------------------------------




//============================ Route_Command   =========================|
var Route_Command_Status_InActive=">";
function Route_Command(e,MouseEvent,ByNameCommand) {
var objBotton ;

    if (MouseEvent == "inactive" ) {
        objBotton = document.getElementById("Route_Command_" + ByNameCommand);
        objBotton.style.background = "url(Images_Navigator/CTO_Command20X98_Inactive.png";
        objBotton.style.paddingTop="0px";
        objBotton.style.fontWeight="normal";
        objBotton.style.color="#8C8A8C";
        Route_Command_Status_InActive+=ByNameWordCommand+";"
        return
    }
    if (MouseEvent == "active" ) {
        objBotton = document.getElementById("Route_Command_" +ByNameCommand);
        objBotton.style.background= "url(Images_Navigator/CTO_Command20X98.png)";
        objBotton.style.paddingTop="0px";
        objBotton.style.fontWeight="normal";
        objBotton.style.color="#0065b3";
        ByNameCommand = ByNameCommand+';'
        Route_Command_Status_InActive = Route_Command_Status_InActive.replace(ByNameCommand,'');
        return
    }
var objBottonID ;
var Command;    
    var objBotton= GetEventTrigger (e)
    var objBottonID=objBotton.id;
    Command = objBotton.id.substr(14, 20);
    if (Route_Command_Status_InActive.indexOf(Command+';')>=0){return} 
      
    if (MouseEvent == "over" ) {
        objBotton.style.background= "url(Images_Navigator/CTO_Command20X98_over.png)";
        objBotton.style.paddingTop= "3px";
        objBotton.style.paddingLeft= "1px";
        objBotton.style.fontWeight="bold";
    } else if (MouseEvent == "out") {
        objBotton.style.background= "url(Images_Navigator/CTO_Command20X98.png)";
        objBotton.style.paddingTop="2px";
        objBotton.style.paddingLeft= "0px";
        objBotton.style.fontWeight="normal";
    } else if (MouseEvent == "click") { 
        objBotton.style.background= "url(Images_Navigator/CTO_Command20X98_active.png)";
        objBotton.style.fontWeight="bold";
        Route_Command_Actived(Command );
    }
    objBotton.style.backgroundRepeat = "no-repeat"; 
    objBotton.style.backgroundPosition= "left top"; 
}
//--------------------------------------------------------------------------
//============================ Route_Command_Actived   =========================|
function Route_Command_Actived(ActiveCommand) {
    switch (ActiveCommand){
    case "Calculate": 	
        alert(ActiveCommand)
        break;
    case "qqqqMoveUp": 	
        alert(ActiveCommand)
        break;
    case "qqqMoveDow": 	
    alert(ActiveCommand)
    default:
        return 0
    }
}





//--------------------------------------------------------------------------
////********************************************************************
////ΠΡΟΣΘΕΤΕΙ ΣΤΟΝ ΠΙΝΑΚΑ CTO_MyMapGallery_Table ΕΝΑ ΝΕΟ ΧΑΡΤΗ ,   //
////ΕΝΗΜΕΡΩΝΕΙ ΤΟ COOKIE ΚΑΙ ΧΑΝΑΦΤΙΑΧΝΕΙ ΤΟ TEMPLATE                 //
////********************************************************************
//function CTO_MyMapGallery_AddMap(mapString)
//{
//    if(CTO_MyMapGallery_Table.length > 99) {return}
//    var lastCode = Right("0" + (CTO_MyMapGallery_Table.length + 1),2);
//    CTO_MyMapGallery_Table[CTO_MyMapGallery_Table.length] = lastCode + "," + mapString ; //ΕΝΗΜΕΡΩΣΗ ΤΟΥ ΠΙΝΑΚΑ
//    
//    var cookieVal = CTO_MyMapGallery_TableToString();
//    createCookie("CTO_MyMapGallery",cookieVal,60);                                          //ΕΝΗΜΕΡΩΣΗ ΤΟΥ COOKIE
//  
//    //ΕΝΗΜΕΡΩΣΗ ΤΟΥ TEMPLATE
//    document.getElementById("MyMapGalery_InfoDIV").innerHTML = CTO_MapGallery_CreateTemplate("My");
//}
////********************************************************************
////ΔΙΑΓΡΑΦΕΙ ΕΝΑ ΧΑΡΤΗ ΑΠΟ ΤΟΝ ΠΙΝΑΚΑ                                //
////ΕΝΗΜΕΡΩΝΕΙ ΤΟ COOKIE ΚΑΙ ΧΑΝΑΦΤΙΑΧΝΕΙ ΤΟ TEMPLATE                 //
////********************************************************************
//function CTO_MyMapGallery_DeleteMap(){
//    if(CTO_MapGallery_SelectedItem==null) {return}
//    var SelectedGalery=CTO_MapGallery_SelectedItem.Trigger.id.substring(0,1);
//    if(SelectedGalery=="S") {return}
//    if(CTO_MyMapGallery_Table.length <1 ) {return}
//    
//    var count=1;
//    var cookieVal="";
//    
//    var SelectedCode = CTO_MapGallery_SelectedItem.Code;
//    
//    for(var i=0;i < CTO_MyMapGallery_Table.length;i++) //ΔΗΜΙΟΥΡΓΙΑ COOKIE ΜΕ ΝΕΑ ΑΡΙΘΜΙΣΗ ΧΩΡΙΣ ΤΟ ΔΙΕΓΡΑΜΜΕΝΟ
//    {
//        var CurrentCode = CTO_MyMapGallery_Table[i].split(',')[0];
//        
//        if(SelectedCode != CurrentCode) 
//        {
//            var c = Right("0" + count,2)
//            cookieVal += c + "," + CTO_MyMapGallery_Table[i].substring(3,CTO_MyMapGallery_Table[i].length) + "@" ; 
//            count+=1;
//        }
//    }

//    
//    if(count==1) //ΑΝ ΔΕΝ ΥΠΑΡΧΕΙ ΑΛΛΟΣ ΧΑΡΤΗΣ ΚΑΘΑΡΙΣΤΑ ΟΛΑ
//    {
//      createCookie("CTO_MyMapGallery","",60);
//      document.getElementById("MyMapGalery_InfoDIV").innerHTML = "";
//      CTO_MapGallery_SelectedItem=null;
//      CTO_MyMapGallery_Table = [];
//      return;  
//    }
//    createCookie("CTO_MyMapGallery",cookieVal,60);           //ΕΝΗΜΕΡΩΣΗ ΤΟΥ COOKIE
//    CTO_MyMapGallery_FillTable();                                 //ΕΝΗΜΕΡΩΣΗ ΤΟΥ ΠΙΝΑΚΑ AΠΟ COOKIE
//     //ΕΝΗΜΕΡΩΣΗ ΤΟΥ TEMPLATE
//    document.getElementById("MyMapGalery_InfoDIV").innerHTML = CTO_MapGallery_CreateTemplate("My");  
//    
//    CTO_MapGallery_SelectedItem=null;
//}

//function CTO_MyMapGallery_Initial()
//{
//   //"@code=01,description=Cyprus Map,ID=231,Lang=En,TIString=AA1_AA2_AA3,BackStatus=1,x1=344,y1=344,x2=34,y2=344@code=02,description=Cyprus Map,ID=232,Lang=En,TIString=AA1_AA2_AA3,BackStatus=1,x1=344,y1=344,x2=34,y2=344"
//   // createCookie("CTO_MyMapGallery","01,Cyprus Map1,231,En,AA1_AA2_AA3,1,344,344,34,344@02,Cyprus Map2,232,En,AA1_AA2_AA3,1,344,344,34,344@",60);
//    
//    CTO_MyMapGallery_FillTable();
//    var User_Container = document.getElementById("MyMapGalery_InfoDIV");
//    User_Container.innerHTML = CTO_MapGallery_CreateTemplate("My");
//   // CTO_MapGallery_selectItemByNum(1);
//    var User_Container = document.getElementById("SystemMapGalery_InfoDIV");
//    User_Container.innerHTML = CTO_MapGallery_CreateTemplate("System");  
//   
//   
//}
////*********************************************************************
////ΦΤΑΙΧΝΕΙ ΤΟΝ ΠΙΝΑΚΑ ΧΑΡΤΩΝ CTO_MyMapGallery_Table ΑΠΟ ΤΟ COOKIE //
////*********************************************************************
//function CTO_MyMapGallery_FillTable()
//{
//    var cookie = readCookie("CTO_MyMapGallery");
//    if(cookie==null || cookie.length < 1) //ΕΑΝ ΤΟ COOKIE ΕΙΝΑΙ ΚΕΝΟ ΦΥΓΕ
//    {
//        return
//    }
//    cookie = cookie.substring(0,cookie.length-1);
//    CTO_MyMapGallery_Table = cookie.split('@');
//    
//}

////*********************************************************************
////ΔΗΜΙΟΥΡΓΕΙ ΤΟ TEMPLATE ΑΠΟ ΤΟΝ ΠΙΝΑΚΑ                              //
////*********************************************************************
//function CTO_MapGallery_CreateTemplate(MapGalleryCode)
//{
//    var _iwRegex =  /([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^@]+)@/g;
//    var cookieVal ;
//    if (MapGalleryCode=="My")
//    {
//        cookieVal = CTO_MyMapGallery_TableToString();
//    }
//    if (MapGalleryCode=="System")
//    {
//        cookieVal = CTO_SystemMapGallery_TableToString();
//    }    
//    var str = cookieVal.replace(
//	_iwRegex, '<div id="'+ MapGalleryCode + 'MapGallery_Map$1" onclick="MapGalleryList_Handler(event,\'$1\',\'$2\',\'$3\',\'$4\',\'$5\',\'$6\',\'$7\',\'$8\',\'$9\',\'$10\');"' +
//	                'onmouseover="MapGalleryList_Handler(event)" ' +
//	                'onmouseout="MapGalleryList_Handler(event)"' +
//	                ' style="position:static; display: block; border: 0px; margin: 0px; ' +
//                    ' padding-right:0px;padding-left:2px; padding-bottom:2px;padding-top:2px; ' +
//                    ' font-family: Verdana,Arial,Verdana,Tahoma; font-weight: normal; font-size: 11px; ' +
//                    'text-transform: capitalize; color: #6495ed; text-align: left; ' +
//                    'width: 380px; height: 16px; cursor: pointer; vertical-align: middle; overflow: auto;">' +
//                    '$1 $2 </div>\n');
//                    
//	
//                        
//	return str
//}

////*********************************************************************
////ΚΑΝΕΙ ΤΟΝ ΠΙΝΑΚΑ ΧΑΡΤΩΝ STRING ΓΙΑ ΝΑ ΜΠΕΙ ΣΤΟ COOKIE              //
////*********************************************************************
//function CTO_MyMapGallery_TableToString()
//{
//    var str="";
//    for(var i=0;i < CTO_MyMapGallery_Table.length;i++) 
//    {
//        str += CTO_MyMapGallery_Table[i] + "@" ;
//    }
//    return str
//}
////*********************************************************************
////ΚΑΝΕΙ ΤΟΝ ΠΙΝΑΚΑ ΧΑΡΤΩΝ STRING ΓΙΑ ΝΑ ΜΠΕΙ ΣΤΟ COOKIE              //
////*********************************************************************
//function CTO_SystemMapGallery_TableToString()
//{
//    var str="";
//    for(var i=0;i < CTO_SystemMapGallery_Table.length;i++) 
//    {
//        str += CTO_SystemMapGallery_Table[i] + "@" ;
//    }
//    return str
//}

////*********************************************************************
////ΕΠΙΛΟΓΗ ΧΑΡΤΗ                                                      //
////*********************************************************************
//function MapGalleryList_Handler(e,code,description,Lang,activeID,TIString,BackStatus,x1,y1,x2,y2){
//var EventTrigger= GetEventTrigger (e)
//var MouseEvent= GetEventType (e)
//    if (MouseEvent == "mouseover" ) {
//        EventTrigger.style.color="#FF9A00";
//    } else if (MouseEvent == "mouseout") {
//        EventTrigger.style.color="#0065b3"; 
//    } else if (MouseEvent == "click") { 
//        if(CTO_MapGallery_SelectedItem != null){
//            CTO_MapGallery_SelectedItem.Trigger.style.backgroundColor = "transparent";
//            CTO_MapGallery_SelectedItem.Trigger.style.color = "#6495ed";     
//        }
//        var selectedItemProperties ={Trigger:EventTrigger,Code:code,Description:description,Language:Lang,Active:activeID,TIString:TIString,Background:BackStatus,X1:x1,Y1:y1,X2:x2,Y2:y2};
//        CTO_MapGallery_SelectedItem = selectedItemProperties;
//        CTO_MapGallery_SelectedItem.Trigger.style.backgroundColor = "#6495ed";
//        CTO_MapGallery_SelectedItem.Trigger.style.color = "#FF9A00";
//        
//      }   
//}








////------------------------------------------------------------------------------------------------
////------------------------------------------------------------------------------------------------



//------------------------------------------------------------------------------------------------
function TRI_RoutePlaning_TitleDraw(Route_Title) {
    document.getElementById("RoutePlan_RouteTitle").innerHTML =Route_Title;
    document.getElementById("TravelSolution_RouteTitle").innerHTML =Route_Title;
}

function TRI_RoutePlaning_Actived_Tools() {
//
//        CTO_Menu_Tab("TabMenu_Tab3D","click");
//        VTab_Route_Handler("VTab_Route_Cell1","click");

     //   Route_Tools_Handler("RoutePlan_Route_TitleEdit" ,"active") ;
        Route_Tools_Handler("RoutePlan_Route_NewRoute" ,"active");
        
        if (TRI_WayPoint_Info.length >=2){
            Route_Tools_Handler("RoutePlan_Route_SaveRoute" ,"active");
        }else{
             Route_Tools_Handler("RoutePlan_Route_SaveRoute" ,"inactive");
        }
        if(RoutePlan_WayP_list_SelectedItem != null){ 
            Route_Tools_Handler("RoutePlan_Route_DelWayPoint" ,"active");
            Route_Tools_Handler("RoutePlan_Route_WPfocus" ,"active");
            if (TRI_WayPoint_Info.length ==2){
                Route_Tools_Handler("RoutePlan_Route_MoveUp" ,"inactive");
                Route_Tools_Handler("RoutePlan_Route_MoveDow" ,"inactive");
                Route_Tools_Handler("RoutePlan_Route_SetFrom" ,"active");
                Route_Tools_Handler("RoutePlan_Route_SetTo" ,"active");
                Route_Tools_Handler("RoutePlan_Route_SetFromTo" ,"inactive");
            }
            if (TRI_WayPoint_Info.length >2){
                Route_Tools_Handler("RoutePlan_Route_MoveUp" ,"active");
                Route_Tools_Handler("RoutePlan_Route_MoveDow" ,"active");
                Route_Tools_Handler("RoutePlan_Route_SetFrom" ,"active");
                Route_Tools_Handler("RoutePlan_Route_SetTo" ,"active");
                Route_Tools_Handler("RoutePlan_Route_SetFromTo" ,"inactive");         
            }
        }else{
            Route_Tools_Handler("RoutePlan_Route_DelWayPoint" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_WPfocus" ,"inactive");
            
            Route_Tools_Handler("RoutePlan_Route_MoveUp" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_MoveDow" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_SetFrom" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_SetTo" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_SetFromTo" ,"inactive"); 
        }
        if (TRI_WayPoint_Info.length >=2){
            Route_Tools_Handler("RoutePlan_Route_QuickDrawOn" ,"active");
            Route_Tools_Handler("RoutePlan_Route_QuickDrawOff" ,"active");
            Route_Tools_Handler("RoutePlan_Route_OverView" ,"active");
        }else{    
            Route_Tools_Handler("RoutePlan_Route_QuickDrawOn" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_QuickDrawOff" ,"inactive");
            Route_Tools_Handler("RoutePlan_Route_OverView" ,"inactive");
        }
        
        
        
        
     //   Route_Tools_Handler("RoutePlan_Route_FromView" ,"active");
     //   Route_Tools_Handler("RoutePlan_Route_ToView" ,"active");
        
        Route_Tools_Handler("RoutePlan_Route_SetTRI_Visible" ,"active");
        Route_Tools_Handler("RoutePlan_Route_SetTRI_Hide" ,"active");
      //  document.getElementById("RoutePlan_Route_SetTRI_Label").style.color="#0065b3";
        
        var e=""
        Route_WordCommand(e,"active","Optimaze");
      //  Route_WordCommand(e,"active","Save");
      //  Route_WordCommand(e,"active","Clear");
}

function TRI_RoutePlaning_DeActived_Tools() {
return
var e=""
   //     Route_Tools_Handler("RoutePlan_Route_TitleEdit" ,"inactive") ;
    //    Route_Tools_Handler("RoutePlan_Route_NewRoute" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_SaveRoute" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_DelWayPoint" ,"inactive");
        
        Route_Tools_Handler("RoutePlan_Route_MoveUp" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_MoveDow" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_SetFrom" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_SetTo" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_SetFromTo" ,"inactive");
        
        
        Route_Tools_Handler("RoutePlan_Route_QuickDrawOn" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_QuickDrawOff" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_WPfocus" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_OverView" ,"inactive");
   //     Route_Tools_Handler("RoutePlan_Route_FromView" ,"inactive");
   //     Route_Tools_Handler("RoutePlan_Route_ToView" ,"inactive");
        
        Route_Tools_Handler("RoutePlan_Route_SetTRI_Visible" ,"inactive");
        Route_Tools_Handler("RoutePlan_Route_SetTRI_Hide" ,"inactive");
       // document.getElementById("RoutePlan_Route_SetTRI_Label").style.color="#8C8A8C";
        
        Route_WordCommand(e,"inactive","Optimaze");
      //  Route_WordCommand(e,"inactive","Save");
      //  Route_WordCommand(e,"inactive","Clear");

}




