﻿       var container;
       var DivPrint;
       var control=0;
      
function YSliderControl() { }
     
 YSliderControl.prototype = new GControl();

   
// == This gets called bu the API when addControl(new YSlider()) is used ==
YSliderControl.prototype.initialize = function(map) 
    {
        var that=this;
        this.map = map;

        var agent = navigator.userAgent.toLowerCase();
 
        if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false}
       
        container = document.createElement("div");
       
        if (this.ie) 
            {
                var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./images/print.gif', sizingMethod='scale');";
                container.innerHTML = '<div style="text-align:center;" onclick="DisplayDivPrint() "><div  style="height:50px; width:50px; ' +loader+ '" ></div><div style="font-size:smaller;width:130px;background-color:White;border:solid 1px; black">IMPRIMER</div></div>';
            } 
        else 
            {
                container.innerHTML = '<div style="text-align:center;" onclick="DisplayDivPrint() "><div  ><img src="./images/print.gif"  width=50px height=50px " ></div><div style="font-size:smaller;width:130px;background-color:White;border:solid 1px; black">IMPRIMER</div></div>';
            }

        map.getContainer().appendChild(container);
       
        return container;
      }

    
      // == Set the default position for the control ==
YSliderControl.prototype.getDefaultPosition = function() 
    {
        return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(50, 30));
    }

function DisplayDivPrint () 
    {
        if (control==0)
            {
                DivPrint = document.createElement("div");
                DivPrint.innerHTML ='<div id="DivPrint" style="background-color:white;border:solid 1px"><div><input id="Radio1" type="radio" name="ChoixPrint" />Carte<br /><input id="Radio2" type="radio" name="ChoixPrint"  />Feuille de route<br /><div style="text-align:center;"  ><input type="button" value="Ok" onclick="Print(Radio1.checked,Radio2.checked )"/></div></div>'
                container.appendChild(DivPrint);
                control=1;
            }
        else
            {
                container.removeChild(DivPrint);
                control=0;
            }
    }
    
function Print(Radio1,Radio2)
    {
        
        if ((Radio1 == false ) && (Radio2==false))
            {
                alert("Veuillez faire un choix");
            }
        else
            {
                DisplayDivPrint ();
                if (Radio1 == true) {imprime_zone('http://www.infotout.com', 'GoogleMap1_Map');}
                if (Radio2 == true) {imprime_zone('http://www.infotout.com', 'CorpDetails1');}    
            }
    }
    


function imprime_zone(titre, obj) 
    {
        var zi = document.getElementById(obj).innerHTML;

        var height = 500 
        var width = 600
        if (obj=="GoogleMap1_Map") 
             {
                height =  document.getElementById(obj).style.height;
                 width =  document.getElementById(obj).style.width;
             }
            
        var f = window.open("", "ZoneImpr", "height="+ height +", width=" + width +" ,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");

        f.document.body.style.color = '#000000';
        f.document.body.style.backgroundColor = '#FFFFFF';

        f.document.title = titre;
        f.document.body.innerHTML +=  zi ;

        f.window.print();
        f.window.close();
        return true;
    } 
