//    var Qview_LoadImageStatus = new Array();
    var Qview_Mode;
    var Qview_Draw_Inticator ;
    var Qview_Draw_Rectacle ;
    
    var Qview_Timer;
    
    var ScaleGaleryImage = new Array()
    var Qview_InticatorPos;
   
    var Qview_ViewFrame_Left;
    var Qview_ViewFrame_Top;
    var Qview_IgnoreCol_Left ;
    var Qview_IgnoreRow_Top ; 

    var Qview_ActiveScale;
    var Qview_PreviousScale;

    var ScaleGaleryMax =5;
    var ScaleGalery = new Array();    
    
    
    function ScaleGalery_Rec(X, Y,Res,ImageSize, cX, cY,MapFocus){
        this.UnitialX = X;
        this.UnitialY = Y;
        this.Res = Res;
        this.ImageSize = ImageSize;
        this.FocusX = cX;
        this.FocusY = cY;
        this.MapFocus = MapFocus;

    }  
    ScaleGalery_Add (-413613.34,4839724.42,7934.470,60,538523,3887588,'Default');
    ScaleGalery_Add (205275.25,4125622.11,1983.618,60,538523,3887588,'Default');
    ScaleGalery_Add (379833.60,4046277.40,1322.412,60,538523,3887588,'Default');
    ScaleGalery_Add (379833.60,4046277.40,661.206,60,538523,3887588,'Auto');
    ScaleGalery_Add (411571.48,3982801.64,264.482,60,538523,3887588,'Auto');
    ScaleGalery_Add (395702.54,3982801.64,198.362,60,538523,3887588,'Auto');
 
    function ScaleGalery_Add(X, Y,Res,ImageSize,cX, cY,MapFocus){    
        ScaleGalery[ScaleGalery.length] = new ScaleGalery_Rec(X, Y,Res,ImageSize,cX, cY,MapFocus);
    }
     
     var ViewFrame = 
    {
        Left: 0, 
        Top: 0,
        Width: 0,
        Height: 0 ,
        Resoloution: 0,
        
        MapLeft: 0, 
        MapTop: 0,
        MapWidth: 0,
        MapHeight: 0
    };   
    var MapFrameQv = 
    {
        Col: 0, 
        Row: 0,   
        ImageSize: 0,
        Resoloution: 0,
         
        IgnoreCol: 0, 
        IgnoreRow: 0,
        IgnoreLeft: 0, 
        IgnoreTop: 0,
 
        PixelLeft : 0,
        PixelTop : 0,       
        PixelWidth: 0,
        PixelHeight: 0,
        
        MapLeft: 0, 
        MapTop: 0,
        MapWidth: 0,
        MapHeight: 0
    };

    //-------------------------------------------------------------------------------------   
    function GetQViewParametre (ScaleID,ZoomVal,FocusX,FocusY,Status) {
        var Resoloution =ScaleGalery[ScaleID].Res / (ZoomVal/100)
        var ImageSize =ScaleGalery[ScaleID].ImageSize *(ZoomVal/100) 
        MapFrameQv.ImageSize = ImageSize ;
        MapFrameQv.Resoloution = Resoloution ;
        //------------------------------
        var PixelLeft = ((FocusX - ScaleGalery[ScaleID].UnitialX) / Resoloution)- ViewFrame.Width / 2;
        var PixelTop = ((ScaleGalery[ScaleID].UnitialY - FocusY) / Resoloution)- ViewFrame.Height / 2;         
            if (PixelLeft<0.00001) {PixelLeft=0};
            if (PixelTop<0.00001) {PixelTop=0};
        MapFrameQv.PixelLeft = PixelLeft;
        MapFrameQv.PixelTop = PixelTop ;      
        //------------------------------ 
        if (Status=="All"){   
            var IgnoreCol= parseInt(PixelLeft / ImageSize);
            var IgnoreRow= parseInt(PixelTop / ImageSize); 
                if (IgnoreCol<0) {IgnoreCol=0};
                if (IgnoreRow<0) {IgnoreRow=0}; 
            MapFrameQv.IgnoreCol = IgnoreCol ;
            MapFrameQv.IgnoreRow = IgnoreRow; 
        }      
        //------------------------------ 
        var IgnoreLeft = parseInt( PixelLeft - MapFrameQv.IgnoreCol * ImageSize)  ;
        var IgnoreTop = parseInt( PixelTop - MapFrameQv.IgnoreRow * ImageSize)   ; 
        MapFrameQv.IgnoreLeft = IgnoreLeft;
        MapFrameQv.IgnoreTop =  IgnoreTop;   
        //------------------------------
        MapFrameQv.MapLeft= ScaleGalery[ScaleID].UnitialX + MapFrameQv.IgnoreCol * ImageSize * Resoloution; 
        MapFrameQv.MapTop= ScaleGalery[ScaleID].UnitialY - MapFrameQv.IgnoreRow* ImageSize * Resoloution;
        MapFrameQv.MapWidth= MapFrameQv.Col * ImageSize * Resoloution;
        MapFrameQv.MapHeight= MapFrameQv.Row * ImageSize * Resoloution;
        //------------------------------
        ViewFrame.Resoloution = Resoloution ;
        ViewFrame.MapLeft= MapFrameQv.MapLeft + MapFrameQv.IgnoreLeft * Resoloution; 
        ViewFrame.MapTop= MapFrameQv.MapTop - MapFrameQv.IgnoreTop * Resoloution;
        ViewFrame.MapWidth= ViewFrame.Width * Resoloution;
        ViewFrame.MapHeight= ViewFrame.Height * Resoloution;             
 //var msgString = document.getElementById("DivTest").innerHTML ;
 //msgString =  msgString + "<p><<"+ScaleID+"/" + ZoomVal + ">>" + "[PixelLeft:" + PixelLeft +"/ImageSize:" + ImageSize +"]   " + PixelLeft / ImageSize + "|||" +IgnoreCol + "|||"
 //document.getElementById("DivTest").innerHTML = msgString;   
       //  <p>Also, don't forget the <a href="/newsletter/">free ELATED Extra Newsletter</a>, where you can get more great Web-building articles and tips sent straight to your inbox!</p>
    }         
 
    //-------------------------------------------------------------------------------------  
    function GetQView_MapPointInPixel (MapX,MapY) { 
        var x = 0;
		var y = 0;
        x = parseInt((MapX - MapFrameQv.MapLeft)/MapFrameQv.Resoloution);
        y = parseInt((MapFrameQv.MapTop - MapY)/MapFrameQv.Resoloution);
        return {x: x, y: y};
    } 
    //-------------------------------------------------------------------------------------  
    function GetQView_MapPointInMeter (PixelX,PixelY) { 
        var x = 0;
		var y = 0;
        x = (ViewFrame.MapLeft + PixelX * ViewFrame.Resoloution);
        y = (ViewFrame.MapTop - PixelY * ViewFrame.Resoloution);
        return {x: x, y: y};
    } 
    //-------------------------------------------------------------------------------------    
    function GetQView_ActiveScale(Scale){
        var ActiveScale = 2;
        if (Scale>=2000000){ActiveScale=0}
        if (Scale<2000000&&Scale>=1000000){ActiveScale=1};
        if (Scale<1000000&&Scale>=500000){ActiveScale=2}
        if (Scale<500000&&Scale>=100000){ActiveScale=3}
        if (Scale<100000&&Scale>=50000){ActiveScale=4}
        if (Scale<50000){ActiveScale=5}        
        return ActiveScale ;
        
    } 
    //------------------------------------------------------------------------------------- 
    function Qview_Refresh(Action) { 
        switch (Action){
        case "Refresh":  
            Qview_PreviousScale=Qview_ActiveScale
		    Qview_ActiveScale=Qview_ActiveScale ;
		    break;
        case "ZoomIn":    
            Qview_PreviousScale=Qview_ActiveScale
	        Qview_ActiveScale=Qview_ActiveScale+1;
	        break;
        case "ZoomOut":
	        Qview_PreviousScale=Qview_ActiveScale
		    Qview_ActiveScale=Qview_ActiveScale-1;
            break;        
        default:
            Qview_PreviousScale=Qview_ActiveScale
		    Qview_ActiveScale=Qview_ActiveScale ;
        } 
        clearTimeout(Qview_Timer);
        if (ScaleGalery[Qview_ActiveScale].MapFocus=='Default'||!Qview_Draw_Inticator){
            var FocusX = ScaleGalery[Qview_ActiveScale].FocusX;
            var FocusY =  ScaleGalery[Qview_ActiveScale].FocusY;
        }else{
            if (Qview_Mode == "Navigator"){
                var FocusX =  ctoMap.MapRect.x();
                var FocusY =  ctoMap.MapRect.y();    
            }else{
                var FocusX = TI_activeInfo.X;
                var FocusY = TI_activeInfo.Y;  
            }                 
        }
        
        var ActiveX = TI_activeInfo.X;
        var ActiveY = TI_activeInfo.Y; 
        GetQViewParametre(Qview_ActiveScale,100,FocusX,FocusY,"All");

        for (var i=0;i<MapFrameQv.Row;i++){
            for (var j=0;j<MapFrameQv.Col ;j++){
                var ElementID = "QViewImage" + Qview_GetZeroFrontNumber(i,2) + Qview_GetZeroFrontNumber(j,2)
                ImageName ="Image_QView/QViewS" + Qview_ActiveScale + "_"  + Qview_GetZeroFrontNumber(i+ MapFrameQv.IgnoreRow,4) + Qview_GetZeroFrontNumber(j+MapFrameQv.IgnoreCol,4) + ".png";
                ScaleGaleryImage[ElementID] = new Image()
                ScaleGaleryImage[ElementID].src = ImageName ;
            }
        } 
        document.getElementById('QViewLocator').style.visibility="hidden" ; 
        document.getElementById('Nav_MapZoomRec').style.visibility="hidden" ; 
        
        if(Action=="Refresh"){
            GetQViewParametre(Qview_ActiveScale,100,FocusX,FocusY,"All");
            Qview_Redraw_action(Qview_ActiveScale,100,FocusX,FocusY,"Redraw")
            Qview_Refresh_Inticator(ActiveX,ActiveY); 
            Qview_Refresh_Rectacle(ctoMap.MapRect); 
        }      
        if(Action=="ZoomIn"){
            GetQViewParametre(Qview_PreviousScale,100,FocusX,FocusY,"All");
            document.getElementById("Qview_MapFrame_Img").style.visibility="visible";
            document.getElementById("Qview_MapFrame_Div").style.visibility="hidden" ; 
            Qview_ZoomIn(Qview_PreviousScale,100,FocusX,FocusY,ActiveX,ActiveY)
        }
        if(Action=="ZoomOut"){
            GetQViewParametre(Qview_PreviousScale,100,FocusX,FocusY,"All");
            document.getElementById("Qview_MapFrame_Img").style.visibility="visible";
            document.getElementById("Qview_MapFrame_Div").style.visibility="hidden" ;
            Qview_ZoomOut(Qview_PreviousScale,100,FocusX,FocusY,ActiveX,ActiveY)
        }
    }  
    //-------------------------------------------------------------------------------------
    function Qview_ZoomIn(ScaleID,ZoomVal,FocusX,FocusY,ActiveX,ActiveY) {
        if (ZoomVal < 200) {
            ZoomVal += 10;
            GetQViewParametre(ScaleID,ZoomVal,FocusX,FocusY,"Part");
            Qview_Redraw_action(ScaleID,ZoomVal,FocusX,FocusY,"Resize")
            Qview_Timer = setTimeout("Qview_ZoomIn("+ScaleID+","+ZoomVal+","+FocusX+","+FocusY +","+ActiveX+","+ActiveY +")", 10);
        }else{
         clearTimeout(Qview_Timer);
            GetQViewParametre(ScaleID+1,100,FocusX,FocusY,"All");
            Qview_Redraw_action(ScaleID+1,100,FocusX,FocusY,"Redraw")
            //document.getElementById("Qview_MapFrame_Img").style.visibility="hidden";
            document.getElementById("Qview_MapFrame_Div").style.visibility="visible";
            FadeIn_Qview_MapFrame_Div("Qview_MapFrame_Div",50)
            Qview_Refresh_Inticator(ActiveX,ActiveY); 
            if (Qview_Mode == "Navigator"){
                Qview_Refresh_Rectacle(ctoMap.MapRect); 
            }
        }
    }    
    //-------------------------------------------------------------------------------------
    function Qview_ZoomOut(ScaleID,ZoomVal,FocusX,FocusY,ActiveX,ActiveY) {
        if (ZoomVal > 50) {
            ZoomVal -= 10;
            GetQViewParametre(ScaleID,ZoomVal,FocusX,FocusY,"Part");
            Qview_Redraw_action(ScaleID,ZoomVal,FocusX,FocusY,"Resize")
            Qview_Timer = setTimeout("Qview_ZoomOut("+ScaleID+","+ZoomVal+","+FocusX+","+FocusY +","+ActiveX+","+ActiveY +")", 10);
        }else{
            clearTimeout(Qview_Timer);
            GetQViewParametre(ScaleID-1,100,FocusX,FocusY,"All");
            Qview_Redraw_action(ScaleID-1,100,FocusX,FocusY,"Redraw");
           // document.getElementById("Qview_MapFrame_Img").style.visibility="hidden";
            document.getElementById("Qview_MapFrame_Div").style.visibility="visible";
            FadeIn_Qview_MapFrame_Div("Qview_MapFrame_Div",50);
            Qview_Refresh_Inticator(ActiveX,ActiveY); 
          //  Qview_Refresh_Rectacle(ctoMap.MapRect); 
            if (Qview_Mode == "Navigator"){
                Qview_Refresh_Rectacle(ctoMap.MapRect); 
            }
        }
    } 
    //-------------------------------------------------------------------------------------
  //  function Qview_Qview_MapFrame_Div_SetVisible {  
  //      document.getElementById("Qview_MapFrame_Div").style.visibility="visible";
  //      fadeIn_Qview_MapFrame_Div("Qview_MapFrame_Div",50)
  //  } 
        //-------------------------------------------------------------------------------------

    function FadeIn_Qview_MapFrame_Div(objId,opacity) {
    if (opacity <= 100) {
      setFilter_Opacity_Qview(objId, opacity);
      opacity += 10;
      window.setTimeout("FadeIn_Qview_MapFrame_Div('"+objId+"',"+opacity+")", 10);
    }else{
        document.getElementById("Qview_MapFrame_Img").style.visibility="hidden";
    }
}

function setFilter_Opacity_Qview(objId, opacity) {
var obj = document.getElementById(objId);

  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}     
    
          
    //-------------------------------------------------------------------------------------
    function Qview_Redraw_action(ScaleID,ZoomVal,FocusX,FocusY,Status){

        var Element_Div= document.getElementById('Qview_MapFrame')
            Element_Div.style.width = MapFrameQv.Col  * MapFrameQv.ImageSize +"px";  
            Element_Div.style.height = MapFrameQv.Row * MapFrameQv.ImageSize +"px"; 
            Element_Div.style.left = -1 * MapFrameQv.IgnoreLeft+ "px";
            Element_Div.style.top = -1* MapFrameQv.IgnoreTop+ "px"; 
        for (var i=0;i<MapFrameQv.Row;i++){
            for (var j=0;j<MapFrameQv.Col ;j++){
                var Element_Img_ID = "QViewImage" + Qview_GetZeroFrontNumber(i,2) + Qview_GetZeroFrontNumber(j,2) 
                var Element_Img= document.getElementById(Element_Img_ID) 
                if (Status=="Redraw"){
                    var Element_Div_ID = "QViewDiv" + Qview_GetZeroFrontNumber(i,2) + Qview_GetZeroFrontNumber(j,2) 
                    var Element_Div= document.getElementById(Element_Div_ID) 
                    Element_Div.style.width = MapFrameQv.ImageSize +"px";  
                    Element_Div.style.height = MapFrameQv.ImageSize +"px"; 
                    Element_Div.style.left = j* MapFrameQv.ImageSize   +"px";  
                    Element_Div.style.top = i* MapFrameQv.ImageSize  +"px";  
                    //Element_Div.src = ScaleGaleryImage[Element_Img_ID].src  ; 
                    Element_Div.style.backgroundImage ="url(" +  ScaleGaleryImage[Element_Img_ID].src  +")";             
                
                    Element_Img.src = ScaleGaleryImage[Element_Img_ID].src  ;                
                }else{
                    Element_Img.style.width = MapFrameQv.ImageSize +"px";  
                    Element_Img.style.height = MapFrameQv.ImageSize +"px"; 
                    Element_Img.style.left = j* MapFrameQv.ImageSize   +"px";  
                    Element_Img.style.top = i* MapFrameQv.ImageSize  +"px";
                }
            }
        } 
    }    
    //-------------------------------------------------------------------------------------
    function Qview_Refresh_Inticator(FocusX,FocusY) { 
            Qview_InticatorPos = GetQView_MapPointInPixel(FocusX,FocusY);    
            document.getElementById('QViewLocator').style.visibility="visible";
            document.getElementById('QViewLocator').style.left = (Qview_InticatorPos.x - 9 ) + "px";
            document.getElementById('QViewLocator').style.top = (Qview_InticatorPos.y- 26)+ "px"; 
    } 
    //-------------------------------------------------------------------------------------
    function Qview_Refresh_Rectacle(QviewMapRect) {  
        var RecPoint_1= GetQView_MapPointInPixel(QviewMapRect.x1,QviewMapRect.y2); 
        var RecPoint_2= GetQView_MapPointInPixel(QviewMapRect.x2,QviewMapRect.y1);         
        document.getElementById('Nav_MapZoomRec').style.visibility="visible";
        document.getElementById("Nav_MapZoomRec").style.left= RecPoint_1.x +"px";  
        document.getElementById("Nav_MapZoomRec").style.top= RecPoint_1.y  +"px"; 
        document.getElementById("Nav_MapZoomRec").style.width=RecPoint_2.x -RecPoint_1.x +"px"; 
        document.getElementById("Nav_MapZoomRec").style.height= RecPoint_2.y -RecPoint_1.y +"px";  
        setFilter_Opacity("Nav_MapZoomRec", 25);  
        
//document.getElementById("TabMenu_Tab1").innerHTML =  "Qview_Refresh_Rectacle=  " + RecPoint_1.x +" , " + RecPoint_1.y + " // " + RecPoint_2.x +" , " + RecPoint_2.y 

    }
 
                   

        



function LoadImage(event,ObjectID){
    var ElementID ="QViewImage" + ObjectID
    var Element= document.getElementById(ElementID) 
    var i=parseInt(ObjectID.substr(0,2 ));
    var j=parseInt(ObjectID.substr(2,2 ));
 //   Qview_LoadImageStatus [ElementID] = "T" 
   // Element.style.width = ScaleGaleryImageSize+"px";  
  //  Element.style.height = ScaleGaleryImageSize +"px"; 
  //  Element.style.left = j* ScaleGaleryImageSize  +"px";  
  //  Element.style.top = i* ScaleGaleryImageSize +"px"; 
    //document.getElementById("DivTest").innerHTML = msgqqq + "---->" +"["+ ObjectID +"]"
}  
   
    
    
 
 
 
   


//function GetEventTrigger2 (e) {
//e = e || window.event;
// //   if (! e)
// //       e = event;
//    return e.target || e.srcElement;
//}

    function Qview_GetZeroFrontNumber (Number,Zero) {
        var R_string= "0000000000" ;
        R_string= R_string +  String(Number);
        R_string= R_string.substr(R_string.length -Zero, Zero);
        return R_string;
    }  
   
    function InitialQView(e) {
     //   document.getElementById('Qview_ViewFrame').style.width= ViewFrame.Width+'px';
     //   document.getElementById('Qview_ViewFrame').style.height= ViewFrame.Height+'px';
     //   Qview_Refresh();
    }
 
    function ShowMapWindow(){
        var parameters ="?ID=" + TI_activeInfo.Gis_ID + "&Lang="+Map_Lang;
        mywindow = window.open ("Default.aspx" + parameters, "mywindow", "sizeable=1,location=1,status=1,width=1024,height=768");
        if (window.focus){mywindow.focus()}
    }
 

 

    
function handle(delta) {
//	var s = delta + ": ";
	if (delta < 0){
	    if (Qview_ActiveScale<ScaleGaleryMax){
	      //  Qview_PreviousScale=Qview_ActiveScale
		  //  Qview_ActiveScale=Qview_ActiveScale+1;
		    Qview_Refresh("ZoomIn");
		}
	}else{
	    if (Qview_ActiveScale>0){
	      //  Qview_PreviousScale=Qview_ActiveScale
		  //  Qview_ActiveScale=Qview_ActiveScale-1;
		    Qview_Refresh("ZoomOut");
		}
	}	
}

function wheel(event){
        var delta = 0;
        //-------  For IE.  
        if (!event) {
            event = window.event;
        }
        //-------  IE/Opera.      
        if (event.wheelDelta) {
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.*/
                if (window.opera)
                    delta = -delta;
        //-------  Mozilla case.             
        } else if (event.detail) { 
                /** In Mozilla, sign of delta is different than in IE. Also, delta is multiple of 3.*/
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it. Basically, delta is now positive if wheel was scrolled up, and negative, if wheel was scrolled down.*/
        if (delta)
                handle(delta);
        /** Prevent default actions caused by mouse wheel. That might be ugly, but we handle scrolls somehow anyway, so don't bother here..*/
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

var Qview_DowPos=null;
var Qview_MovePos=null;
var Qview_UpPos = null;

//--------------------------------------------------------------
function Qview_MapEvent(e) {
var MapID=0;
var Mcode = Map.getMcodeFromMapID(MapID);
var Moptions = Map.MapObj[MapID]
    if (!e) var e = window.event;
    //--------------- handle event
//	e.cancelBubble = true;
//	if (e.stopPropagation) e.stopPropagation();
   
    
    var MouseEventType = e.type;
    var objBotton = document.getElementById("Qview_ViewFrame");
    
//    var m1=GetEventTrigger (e)
//    var m2=GetEventMousebutton(e)
//document.getElementById("TabMenu_Tab2").innerHTML = " Element=  " + m1.id +"/ Mousebutton=  " + m2 + " // " +MouseEventType

  
    if (MouseEventType == "mousedown" ) {
        Qview_DowPos =  getPosition_Cursor(e);
        Qview_DowPos.x=Qview_DowPos.x - ViewFrame.Left;
        Qview_DowPos.y=Qview_DowPos.y - ViewFrame.Top;
        objBotton.style.cursor="crosshair" //"url(Images/CTO_MapPan_active.cur),auto";
        objBotton.onmousemove = Qview_MapEvent 
    }
    if (MouseEventType == "mousemove" ) {
        var Mousebutton= GetEventMousebutton(e);
        if  (Mousebutton=="left"&&Qview_DowPos){
            Qview_MovePos =  getPosition_Cursor(e);
            Qview_MovePos.x=Qview_MovePos.x - ViewFrame.Left;
            Qview_MovePos.y=Qview_MovePos.y - ViewFrame.Top;
            objBotton.style.cursor="s-resize" ;
            
            var NewQview_DowPos =GetQView_MapPointInMeter(Qview_DowPos.x,Qview_DowPos.y);
            var NewQview_MovePos =GetQView_MapPointInMeter(Qview_MovePos.x,Qview_MovePos.y);
            var QviewMapRect =GetMapRect_FromTwoPoint(NewQview_DowPos,NewQview_MovePos)
            Qview_Refresh_Rectacle(QviewMapRect);
        //Qview_Refresh_Inticator(NewQview_MovePos.x,NewQview_MovePos.y)
        }
    }

    if (MouseEventType == "mouseup" ) {
        Qview_UpPos = getPosition_Cursor(e);
        Qview_UpPos.x = Qview_UpPos.x - ViewFrame.Left;
        Qview_UpPos.y = Qview_UpPos.y - ViewFrame.Top
        // click only 
        if (Qview_DowPos.x==Qview_UpPos.x && Qview_DowPos.y==Qview_UpPos.y){
            var NewCentrePos = {x:0, y:0};
            NewCentrePos.x = Qview_DowPos.x +(Qview_UpPos.x-Qview_DowPos.x )/2  ;  
            NewCentrePos.y = Qview_DowPos.y +(Qview_UpPos.y-Qview_DowPos.y )/2 ;  

            var NewMapCentre = GetQView_MapPointInMeter(NewCentrePos.x,NewCentrePos.y)
           // ServerReguest_MapBy_MapScale_MapCenter(srvURL, Map_Lang, ctoMap.ImageSize.w, ctoMap.ImageSize.h, Scale.i, NewMapCentre.x, NewMapCentre.y )
            Map.getMap.By_MapScale_MapCenter(MapID, Moptions.MapLang, Moptions.MapBackGround, Moptions.ImageSize.w, Moptions.ImageSize.h, Scale.i, NewMapCentre.x, NewMapCentre.y);

           // Qview_Refresh_Inticator(NewMap_Center.x,NewMap_Center.y) 
                //function ServerReguest_Map(NewScale, NewImageCenterPos,NewMapCenterPos,NewMapviewRect,RegMap,RegTOI,RegTI_active ) {
            //                ServerReguest_Map(Scale,NewCentrePos,ctoMap.MapCenter,null,true,true,false);  
                //ServerReguest_Map(Scale,ctoMap.ImageCenter,ctoMap.MapCenter,ctoMap.MapRect, true,true,false);
        } else {
            var NewQview_DowPos =GetQView_MapPointInMeter(Qview_DowPos.x,Qview_DowPos.y);
            var NewQview_UpPos =GetQView_MapPointInMeter(Qview_UpPos.x,Qview_UpPos.y);
            var QviewMapRect =GetMapRect_FromTwoPoint(NewQview_DowPos,NewQview_UpPos)
            Qview_Refresh_Rectacle(QviewMapRect);
            
            //ctoMap.MapRect = new MapRect(QviewMapRect.x1,QviewMapRect.y1,QviewMapRect.x2,QviewMapRect.y2) 
           // ctoMap.MapCenter = new MapPoint(ctoMap.MapRect.x(),ctoMap.MapRect.y());
            NewMapRect = new MapRect(QviewMapRect.x1,QviewMapRect.y1,QviewMapRect.x2,QviewMapRect.y2) 
            NewMapCentre = new MapPoint(NewMapRect.x(),NewMapRect.y());
            Scale = Map.Scale.ScaleFromMapViewRect(NewMapRect, Moptions.ImageRect)
   
            //ServerReguest_MapBy_MapBound(srvURL,Map_Lang ,ctoMap.ImageSize.w,ctoMap.ImageSize.h, NewMapRect.x1, NewMapRect.y1,NewMapRect.x2, NewMapRect.y2 )
            Map.getMap.By_MapScale_MapBound(MapID, Moptions.MapLang, Moptions.MapBackGround, Moptions.ImageSize.w, Moptions.ImageSize.h, NewMapRect.x1, NewMapRect.y1, NewMapRect.x2, NewMapRect.y2); 


     //       var NewQview_MovePos =GetQView_MapPointInMeter(Qview_MovePos.x- ViewFrame.Left,Qview_MovePos.y- ViewFrame.Top);
    //    Qview_Refresh_Inticator(NewQview_MovePos.x, NewQview_MovePos.y)
        
        }
        Qview_DowPos=null;
        objBotton.onmousemove=null;
        objBotton.style.cursor="pointer" 
     //   whichElement(e);
       

    } 
    
//defaultStatus = "MapEvent_Handler "+ MouseEvent +  " Qview_DowPos " + Qview_DowPos.x  +"/"+ Qview_DowPos.y +  " Qview_UpPos " + Qview_UpPos.x  +"/"+ UpPos.y
}

function whichElement(e)
{
    var targ
    if (!e) var e = window.event
    if (e.target) targ = e.target
    else if (e.srcElement) targ = e.srcElement
    if (targ.nodeType == 3) // defeat Safari bug
    targ = targ.parentNode
    var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element." + targ.id)
}




function Include_QviewCode(){
    var Element = document.getElementById("Qview_ViewFrame");
    if (Element.addEventListener){
        Element.addEventListener('DOMMouseScroll', wheel, false);
    }else{
        Element.onmousewheel =  wheel;
    }
    Qview_Mode = "Navigator"  
    Qview_Draw_Inticator =true;
    Qview_Draw_Rectacle=true ; 
       
    MapFrameQv.Col =5;
    MapFrameQv.Row =4;
    ViewFrame.Width =207;
    ViewFrame.Height =130;
    Qview_ActiveScale=2;     
    Qview_PreviousScale = Qview_ActiveScale;
                                
    if (ScaleGalery[Qview_ActiveScale].MapFocus=='Default'||!Qview_Draw_Inticator){
        var FocusX = ScaleGalery[Qview_ActiveScale].FocusX;
        var FocusY =  ScaleGalery[Qview_ActiveScale].FocusY;
    }else{
        var FocusX = TI_activeInfo.X;
        var FocusY = TI_activeInfo.Y;                              
    }
    GetQViewParametre(Qview_ActiveScale,100,FocusX,FocusY,"All");
    
    document.writeln("<div id=\"Qview_MapFrame\"");
    document.writeln("style=\"position: absolute; display: block; z-index: 112; visibility: hidden; ");
    document.writeln("border: none; padding: 0px; margin: 0px;" ); 
    document.writeln("width: " + MapFrameQv.Col  * MapFrameQv.ImageSize  + "px; height: " +MapFrameQv.Row * MapFrameQv.ImageSize  + "px; "); 
    document.writeln("left: " + -1* MapFrameQv.IgnoreLeft +"px; top: " + -1*MapFrameQv.IgnoreTop +"px;\">");
    // ----------Qview_MapFrame_Img ---------- visible/hidden
    document.writeln("<div id=\"Qview_MapFrame_Img\"");
    document.writeln("style=\"position: absolute; display: block; z-index: 109; visibility: hidden; ");
    document.writeln("border: none; padding: 0px; margin: 0px;" ); 
    document.writeln("width: " + MapFrameQv.Col  * MapFrameQv.ImageSize  + "px; height: " +MapFrameQv.Row * MapFrameQv.ImageSize  + "px; "); 
    document.writeln("left: 0px; top: 0px;\">");
        var i_string;
        var j_string;
        var ImageName;
        for (var i=0;i<MapFrameQv.Row;i++){
            for (var j=0;j<MapFrameQv.Col ;j++){
                i_string=Qview_GetZeroFrontNumber(i,2);
                j_string=Qview_GetZeroFrontNumber(j,2);
                ImageName ="Image_QView/QView_None.gif";
                //document.writeln("<img id=\"QViewImage" + i_string + j_string +"\" onload=\"LoadImage(event,'" + i_string +j_string + "')\"");
                document.writeln("<img id=\"QViewImage" + i_string + j_string +"\"");
                document.writeln("style=\"position: absolute; display: block;  border: none; z-index: 108; ");
                document.writeln("width: " + MapFrameQv.ImageSize  + "px; height: " + MapFrameQv.ImageSize  + "px; ");
                document.writeln("top: " + i*MapFrameQv.ImageSize  + "px; left: " + j*MapFrameQv.ImageSize  + "px; ");
                document.writeln("src=\"" + ImageName + "\" alt=\"\"/>");
            } 
        } 
    document.writeln("</div> "); 
    // ----------Qview_MapFrame_Div ---------- visible/hidden   
    document.writeln("<div id=\"Qview_MapFrame_Div\"");
    document.writeln("style=\"position: absolute; display: block; z-index: 109; visibility: visible; ");
    document.writeln("border: none; padding: 0px; margin: 0px;" ); 
    document.writeln("width: " + MapFrameQv.Col  * MapFrameQv.ImageSize  + "px; height: " + MapFrameQv.Row * MapFrameQv.ImageSize  + "px; "); 
    document.writeln("left: 0px; top: 0px;\">");
        var i_string;
        var j_string;
        var ImageName;
        for (var i=0;i<MapFrameQv.Row;i++){
            for (var j=0;j<MapFrameQv.Col ;j++){
                i_string=Qview_GetZeroFrontNumber(i,2);
                j_string=Qview_GetZeroFrontNumber(j,2);
                ImageName ="Image_QView/QView_None.gif";
                document.writeln("<div id=\"QViewDiv" + i_string + j_string + "\"");
                document.writeln("style=\"position: absolute; display: block;  border: none; z-index: 108; ");
                document.writeln("width: " + MapFrameQv.ImageSize  + "px; height: " + MapFrameQv.ImageSize  + "px; ");
                document.writeln("top: " + i * MapFrameQv.ImageSize  + "px; left: " + j * MapFrameQv.ImageSize  + "px; ");
                document.writeln("background-image: url(" + ImageName + ");");
                document.writeln("background-repeat: no-repeat; background-color: transparent;\" >");
             //   document.writeln("</div> ");
                document.writeln("</div> ");
            } 
        } 
        document.writeln("</div> "); 
        // ----------      
        document.writeln("<div id=\"Nav_MapZoomRec\" style=\"position: absolute; display: block; z-index: 110;");
        document.writeln("width: 0px; height: 0px; left: 0px; top: 0px;");
        document.writeln("padding: 0px;margin: 0px; border: solid 1px red; background-color: navy;\">");
        document.writeln("</div>");         
        // ----------
        var InticatorPos = GetQView_MapPointInPixel(TI_activeInfo.X,TI_activeInfo.Y);
        document.writeln("<div id=\"QViewLocator\" style=\"position: absolute;display: block; visibility: visible; z-index: 111; ");
        document.writeln("border: medium none; margin: 0px; padding: 0px; ");
        document.writeln("background-image: url(Image_QView/TI_QuickView_S.png); background-repeat: no-repeat; ");
        document.writeln("width: 30px; height: 26px; left: " + (InticatorPos.x - 9 )+ "px; top: " + (InticatorPos.y- 26) + "px;\">");
        document.writeln("</div>");
        // ----------
        document.writeln("</div> ");  
     //   document.writeln("</div> ");
     //   document.writeln("</div>");
     //   document.writeln("</div>"); 
                               
                                 
}



function Include_QviewCode_Loc() {
            document.writeln("<div id=\"Qview_ViewFrame\" style=\"position: absolute; display: block; overflow: hidden; z-index: 103; cursor: pointer;");
            document.writeln("padding: 0px; margin: 0px; border:none;");
            document.writeln("width: " + ViewFrame.Width + "px; height: " + ViewFrame.Height + "px; top: 0px; left:0px;\"");
            document.writeln("onclick=\"ShowMapWindow(Map_Lang, TI_activeInfo.Type)\" >");
                            
            var Element = document.getElementById("Qview_ViewFrame");
            if (Element.addEventListener){
                Element.addEventListener('DOMMouseScroll', wheel, false);
            }else{
                Element.onmousewheel =  wheel;
            }
            //Qview_ActiveScale=2
            if (ScaleGalery[Qview_ActiveScale].MapFocus=='Default'||!Qview_Draw_Inticator){
                var FocusX = ScaleGalery[Qview_ActiveScale].FocusX;
                var FocusY =  ScaleGalery[Qview_ActiveScale].FocusY;
            }else{
                var FocusX = TI_activeInfo.X;
                var FocusY = TI_activeInfo.Y;                              
            }
            GetQViewParametre(Qview_ActiveScale,100,FocusX,FocusY,"All");

            document.writeln("<div id=\"Qview_MapFrame\"");
            document.writeln("style=\"position: absolute; display: block; z-index: 112; visibility: hidden; ");
            document.writeln("border: none; padding: 0px; margin: 0px;" ); 
            document.writeln("width: " + MapFrameQv.Col  * MapFrameQv.ImageSize  + "px; height: " +MapFrameQv.Row * MapFrameQv.ImageSize  + "px; "); 
            document.writeln("left: " + -1* MapFrameQv.IgnoreLeft +"px; top: " + -1*MapFrameQv.IgnoreTop +"px;\">");
            // ----------Qview_MapFrame_Img ---------- visible/hidden
            document.writeln("<div id=\"Qview_MapFrame_Img\"");
            document.writeln("style=\"position: absolute; display: block; z-index: 109; visibility: hidden; ");
            document.writeln("border: none; padding: 0px; margin: 0px;" ); 
            document.writeln("width: " + MapFrameQv.Col  * MapFrameQv.ImageSize  + "px; height: " +MapFrameQv.Row * MapFrameQv.ImageSize  + "px; "); 
            document.writeln("left: 0px; top: 0px;\">");
                var i_string;
                var j_string;
                var ImageName;
                for (var i=0;i<MapFrameQv.Row;i++){
                    for (var j=0;j<MapFrameQv.Col ;j++){
                        i_string=Qview_GetZeroFrontNumber(i,2);
                        j_string=Qview_GetZeroFrontNumber(j,2);
                       // ImageName ="Image_QView/QView_None.gif";
                                                        ImageName ="Image_QView/QViewS" + Qview_ActiveScale + "_"  + Qview_GetZeroFrontNumber(i+ MapFrameQv.IgnoreRow,4) + Qview_GetZeroFrontNumber(j+MapFrameQv.IgnoreCol,4) + ".png";

                        document.writeln("<img id=\"QViewImage" + i_string + j_string +"\"");
                        document.writeln("style=\"position: absolute; display: block;  border: none; z-index: 108; ");
                        document.writeln("width: " + MapFrameQv.ImageSize  + "px; height: " + MapFrameQv.ImageSize  + "px; ");
                        document.writeln("top: " + i*MapFrameQv.ImageSize  + "px; left: " + j*MapFrameQv.ImageSize  + "px; ");
                        document.writeln("src=\"" + ImageName + "\" alt=\"\"/>");
                    } 
                } 
            document.writeln("</div> "); 
    // ----------Qview_MapFrame_Div ---------- visible/hidden   
    document.writeln("<div id=\"Qview_MapFrame_Div\"");
    document.writeln("style=\"position: absolute; display: block; z-index: 109; visibility: visible; ");
    document.writeln("border: none; padding: 0px; margin: 0px;" ); 
    document.writeln("width: " + MapFrameQv.Col  * MapFrameQv.ImageSize  + "px; height: " + MapFrameQv.Row * MapFrameQv.ImageSize  + "px; "); 
    document.writeln("left: 0px; top: 0px;\">");
        var i_string;
        var j_string;
        var ImageName;
        for (var i=0;i<MapFrameQv.Row;i++){
            for (var j=0;j<MapFrameQv.Col ;j++){
                i_string=Qview_GetZeroFrontNumber(i,2);
                j_string=Qview_GetZeroFrontNumber(j,2);
                ImageName ="Image_QView/QViewS" + Qview_ActiveScale + "_"  + Qview_GetZeroFrontNumber(i+ MapFrameQv.IgnoreRow,4) + Qview_GetZeroFrontNumber(j+MapFrameQv.IgnoreCol,4) + ".png";

                document.writeln("<div id=\"QViewDiv" + i_string + j_string +"\"");
                document.writeln("style=\"position: absolute; display: block;  border: none; z-index: 108; ");
                document.writeln("width: " + MapFrameQv.ImageSize  + "px; height: " + MapFrameQv.ImageSize  + "px; ");
                document.writeln("top: " + i * MapFrameQv.ImageSize  + "px; left: " + j * MapFrameQv.ImageSize  + "px; ");
                document.writeln("background-image: url(" + ImageName + ");");
                document.writeln("background-repeat: no-repeat; background-color: transparent;\" >");
                document.writeln("</div> ");
            } 
        } 
        document.writeln("</div> "); 
        // ----------      
        document.writeln("<div id=\"Nav_MapZoomRec\" style=\"position: absolute; display: block; z-index: 110;");
        document.writeln("width: 0px; height: 0px; left: 0px; top: 0px;");
        document.writeln("padding: 0px;margin: 0px; border: solid 1px red; background-color: navy;\">");
        document.writeln("</div>");         
        // ----------
        var InticatorPos = GetQView_MapPointInPixel(TI_activeInfo.X, TI_activeInfo.Y);
        document.writeln("<div id=\"QViewLocator\" style=\"position: absolute;display: block; visibility: visible; z-index: 111; ");
        document.writeln("border: medium none; margin: 0px; padding: 0px; ");
        document.writeln("background-image: url(Image_QView/TI_QuickView_S.png); background-repeat: no-repeat; ");
        document.writeln("width: 30px; height: 26px; left: " + (InticatorPos.x - 9 )+ "px; top: " + (InticatorPos.y- 26) + "px;\">");
        document.writeln("</div>");
        // ----------     
        document.writeln("</div> ");
        document.writeln("</div>");

}