﻿// Fichier JScript
    
function test()
{
   alert('test');
   WebServices.wsPanier.HelloWorld('testa',OnSucceeded);
}
  
// This is the callback function that
// processes the Web Service return value.
function OnSucceeded(result)
{
    alert('retour du test '+result);
}



var _offre = "";
function AjouterOffres(offres) {
//var isPanier=<%=iif((HttpContext.Current.Session("UserPanier") Isnot Nothing) andalso (HttpContext.Current.Session("UserPanier").ligneTestee=true),"true","false")%>;
//Type.registerNamespace('Panier');
    _offre=offres;
    //WebServices.Orange.wsPanier.AjouterOffres(offres,OnSucceededAjouterOffres);              
    WebServices.wsPanier.AjouterOffres(offres,OnSucceededAjouterOffres);              
}


function OnSucceededAjouterOffres(result)
{
    if (result>0) {
     //   setTimeout("<%=Page.ClientScript.GetPostBackEventReference(RefreshButton), \"\")%>",500);
      document.location=document.location.href; 
    }else {
        document.location="../abonnement/testLigne.aspx?o="+_offre+"&u="+document.location.href; 
    }
}
    
    function AjouterOffreBDFidelite() 
    {
        WebServices.wsPanier.GetUrlForBDFidelite(OnComplete);
    }
    function AjouterOffreBDSansEngagement() 
    {
       WebServices.wsPanier.GetUrlForBDSSEngagement(OnComplete);
    }
    
    function AjouterOffreAccesLibre() 
    {
        OnComplete('https://secure.orange.fr/sc/abonnez-vous/SEAccess?origine=724391&sale_place_code=19938U&terminal=SEINTERNET');
    }

    function AjouterOffreAccesLibreBooster() 
    {
        OnCompleteBooster('https://secure.orange.fr/sc/abonnez-vous/SEAccess?idboi=-10&origine=104350&sale_place_code=19938U&terminal=SEINTERNET');
    }
        
    function OnComplete(result){

       window.open(result,'','');
    }
    
    function OnCompleteBooster(result){

       window.open(result,'','');
    }
        
        // pour le webservice :
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();


 function getWindowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}
function getWindowHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight || document.documentElement.innerHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}




    function floatPanier() {
//	    startY = 100;
//	    var ns = (navigator.appName.indexOf("Netscape") != -1);
//	    function moveLayer()
//	    {
//	        document.getElementById("panier").style.display="block";
//		    document.getElementById("panier").style.top = startY+'px';
//		    document.getElementById("panier").style.position = "absolute";
//		    //document.getElementById("Tautopromo").style.display="block";
//            //document.getElementById("Tautopromo").style.top = (pY+ 30)+document.getElementById("panier").style.height+'px';
//		    //document.getElementById("Tautopromo").style.position = "absolute";  
//	    }
//	    moveLayer();
//	    doScroll();
   }

   function doScroll()
   {
        var pY =getWindowScrollTopPanier();
        document.getElementById("panier").style.display="block";
        startY = 100;
        var toY = (startY+pY);
        if (pY<startY) {
          pY = startY;
        } else {
          pY += 20; 
        }
        
        setTimeout("doScroll()",100);   
        document.getElementById("panier").style.display="block";
        document.getElementById("panier").style.top = (pY)+'px';
		document.getElementById("panier").style.position = "absolute";  
		try {
	    	document.getElementById("Tautopromo").style.display="block";
            document.getElementById("Tautopromo").style.top = pY+document.getElementById("panier").offsetHeight+'px';
		    document.getElementById("Tautopromo").style.position = "absolute";  
		}
		catch (error)
		{}
		try {
		    document.getElementById("panierhidden").style.height = (document.getElementById("panier").offsetHeight + document.getElementById("Tautopromo").offsetHeight +20) + 'px';
		}
		catch (error)
		{}
   }  
   
   
function getWindowScrollTopPanier() {
  if (document.compatMode && document.compatMode != 'BackCompat') {
    return document.documentElement.scrollTop;
  } else {
    return document.body.scrollTop;
  }
}

function _clignotePanier()
{
    try
    {
        if (flag_timer==0)
        {
             chrono=setInterval('_clignotePanier()',200); 
        }
        
        flag_timer++;
        if (flag_timer<6)
        {
            if ((flag_timer%2)==1)
                {
                    document.getElementById('ctl00_Panier1_GV_Offres').style.border="2px solid #ff6600";
                    clearInterval(chrono);
                    chrono=setInterval('_clignotePanier()',800); 
                }
            else
                {
                    document.getElementById('ctl00_Panier1_GV_Offres').style.border="none";
                    clearInterval(chrono);
                    chrono=setInterval('_clignotePanier()',500); 
                }  
        }
        else
        {
            clearInterval(chrono);
            flag_timer=0;
            document.getElementById('ctl00_Panier1_GV_Offres').style.border="none";
        }
        }
    catch(error)
    {}
}

function RollOverOffres(IdHL, idDiv)
{
    var margingleft = 10;
    with(document.getElementById(idDiv).style){
        position="absolute";
        left = (document.getElementById(IdHL).offsetWidth+findPosX(document.getElementById(IdHL))+margingleft)+"px";
        padding="3";
        zIndex="1000";
    }    
    document.getElementById(idDiv).style.display="block";
    myTop = (findPosY(document.getElementById(IdHL)))-(document.getElementById(idDiv).offsetHeight/2)+(document.getElementById(IdHL).offsetHeight/2);
    if(myTop < 0) myTop = 10;
    document.getElementById(idDiv).style.top=myTop+"px";
    if ((getWindowHeight() + getWindowScrollTop())< (findPosY(document.getElementById(idDiv))+(document.getElementById(idDiv).offsetHeight)))
    {
		myTop = (getWindowHeight() + getWindowScrollTop())-(document.getElementById(idDiv).offsetHeight);
		if(myTop < 0) myTop = 10;
        document.getElementById(idDiv).style.top=myTop+"px";
    }
    else
    {
        myTop =(findPosY(document.getElementById(IdHL)))-(document.getElementById(idDiv).offsetHeight/2)+(document.getElementById(IdHL).offsetHeight/2);
		if(myTop < 0) myTop = 10;
        document.getElementById(idDiv).style.top=myTop+"px";
    }
}

function RollOverEcheancier(IdHL, idDiv)
{   
    //on récupère la taille de la fenetre
    var windowWidth, windowHeight;
    if (self.innerHeight) // all except Explorer
    {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
        scrollTop = window.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
    {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
        scrollTop = document.documentElement.scrollTop;
    }
    else if (document.body) // other Explorers
    {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
        scrollTop = document.body.scrollTop;
    }
    
    document.getElementById(idDiv).style.width="auto";
    document.getElementById(idDiv).style.height="auto";
    document.getElementById(idDiv).style.position="absolute";
    document.getElementById(idDiv).style.border = "solid 1px #f60";
    document.getElementById(idDiv).style.display="block";
    
    var divWidth = document.getElementById(idDiv).offsetWidth;
    var divHeight=document.getElementById(idDiv).offsetHeight;

    var margeLeft = (windowWidth - divWidth) / 2;
    var margeTop = (windowHeight - divHeight) / 2;

    var xPos = findPosX(document.getElementById(IdHL));
    var yPos = findPosY(document.getElementById(IdHL));

    var sTop = margeTop - yPos + scrollTop;

    with(document.getElementById(idDiv).style)
    {
        left = (margeLeft - xPos) + "px";
        top = sTop + "px";
    }
}

function RollOverOffre(idtext, IdHL)
{
    var margingleft = 10;
    document.getElementById('DivOffreText').innerHTML= idtext;
    with(document.getElementById('DivOffreText').style){
        position="absolute";
        left = (document.getElementById(IdHL).offsetWidth+findPosX(document.getElementById(IdHL))+margingleft)+"px";
        padding="3";
        zIndex="1";
    }    
    document.getElementById('DivOffreText').style.display="block";
    myTop = (findPosY(document.getElementById(IdHL)))-(document.getElementById('DivOffreText').offsetHeight/2)+(document.getElementById(IdHL).offsetHeight/2);
    if(myTop < 0) myTop = 10;
    document.getElementById('DivOffreText').style.top=myTop+"px";
    if ((getWindowHeight() + getWindowScrollTop())< (findPosY(document.getElementById('DivOffreText'))+(document.getElementById('DivOffreText').offsetHeight)))
    {
		myTop = (getWindowHeight() + getWindowScrollTop())-(document.getElementById('DivOffreText').offsetHeight);
		if(myTop < 0) myTop = 10;
        document.getElementById('DivOffreText').style.top=myTop+"px";
    }
    else
    {
        myTop =(findPosY(document.getElementById(IdHL)))-(document.getElementById('DivOffreText').offsetHeight/2)+(document.getElementById(IdHL).offsetHeight/2);
		if(myTop < 0) myTop = 10;
        document.getElementById('DivOffreText').style.top=myTop+"px";
    }
   
}

function RollLeave()
{
    document.getElementById('DivOffreText').style.display="none";
}

function RollLeaveOffres(idDiv)
{
    document.getElementById(idDiv).style.display="none";
}



function getWindowScrollTop() {
  if(document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollTop;
  if(document.body && document.body.scrollTop)
    return document.body.scrollTop;
  return 0;
}
