﻿function dragprod(divid,typefonction,typeproduit,inkmono,inkbi)
{
//Apparition du div contenant le visuel au bon emplacement
document.getElementById("typeproduit").value=typeproduit;
document.getElementById("inkmono").value=inkmono;
document.getElementById("inkbi").value=inkbi;
posxdiv=document.getElementById(divid).offsetLeft;
posydiv=document.getElementById(divid).offsetTop;
divtodrag=document.getElementById('drag');
divtodrag.style.left=posxdiv;
divtodrag.style.top=posydiv;
if (typefonction==1)
{
divtodrag.style.width='120px';
divtodrag.style.height='130px';
}
if (typefonction==0)
{
divtodrag.style.width='30px';
divtodrag.style.height='30px';
}
divtodrag.innerHTML=document.getElementById(divid).innerHTML.replace(">"," width=100% height=100% >");
divtodrag.name=divid;
a=(document.getElementById("putdrag").offsetLeft+10)-posxdiv;
b=posydiv-document.getElementById("putdrag").offsetTop;
hypocarre=(a*a+b*b);
hypotenuse=Math.sqrt(hypocarre);

divtodrag.style.zIndex=hypotenuse;

divtodrag.style.display='block';
//Boucle pour déplacement du DIV
boucle ();
}

function boucle ()
{
x = document.getElementById("drag").offsetLeft;
y = document.getElementById("drag").offsetTop;
x1 = document.getElementById("putdrag").offsetLeft+10;
y1 = document.getElementById("putdrag").offsetTop;


a=(document.getElementById("putdrag").offsetLeft+1)-x;
b=y-document.getElementById("putdrag").offsetTop;
hypocarre=(a*a+b*b);
hypotenuse=Math.sqrt(hypocarre);
linit=document.getElementById("drag").style.zIndex;
coeff=hypotenuse/linit;
winit=parseInt(document.getElementById("drag").style.width);
hinit=parseInt(document.getElementById("drag").style.height);
w=parseInt((winit*coeff)+(100*coeff));
h=parseInt((hinit*coeff)+(100*coeff));

grid=20;
deltax=x1-x;
deltay=y-y1;
posx = (x+(grid*(deltax/deltay)));
posy = (y-grid);

document.getElementById("drag").style.left = posx;
document.getElementById("drag").style.top = posy;
document.getElementById("drag").style.width=w+"px";
document.getElementById("drag").style.height=h+"px";
if (posy>=155) {setTimeout("boucle()",20)}

else

{
document.getElementById("drag").style.display='none';
document.getElementById("drag").innerHTML='';

MM_goToURL('parent','/default2.asp?caddie=ok&productid='+document.getElementById("drag").name.replace("imgprod","")+'&action=addproduct&action2=first&addqte=+1&step=1&inkmono='+document.getElementById("inkmono").value+'&inkbi='+document.getElementById("inkbi").value+'&typeproduit='+document.getElementById("typeproduit").value+'&panier=on');return document.MM_returnValue

//affiche_detail_commande('/viewpanier_france_tampon.asp?productid='+document.getElementById("drag").name.replace("imgprod","")+'&action=addproduct&addqte=+1&step=1&inkmono='+document.getElementById("inkmono").value+'&inkbi='+document.getElementById("inkbi").value+'&typeproduit='+document.getElementById("typeproduit").value+'');

place_zoom();
}

}

function scrolltop()
            {
				var scrollTop = (document.documentElement&&document.documentElement.scrollTop
								?document.documentElement.scrollTop
								:document.body.scrollTop);
				
				document.getElementById("Div_zoom2").style.top = scrollTop + "px";}
		   
		   function code_div_zoom(url)
		    {
		        code = '<table cellpadding="0" cellspacing="0" border="0"><tr><td align="right"><a href="javascript:retour();"><img src="/template/fermer.gif"  border="0"></a></td></tr>';
                code +='<tr><td height="530" valign="top"><iframe name="if_panier" id="if_panier" src="' + url + '" ALLOWTRANSPARENCY="true" height="530" width="940" align="center" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" style="border:2px solid #101A42"></iframe></td></tr></table>';				
		    
		        return code;
		    
		    }
		
			function affiche_zoom(url) {
			document.getElementById('Div_zoom2').innerHTML = code_div_zoom(url);
			document.getElementById("Div_zoom").style.height= document.body.scrollHeight;
			document.getElementById("Div_zoom").style.display='block';
			document.getElementById("Div_zoom2").style.display= 'block';
			}
			
			function affiche_detail_commande(url) {
			document.getElementById('Div_zoom2').innerHTML = code_div_zoom(url);
			document.getElementById("Div_zoom").style.height= document.body.scrollHeight;
			document.getElementById("Div_zoom").style.display='block';
			document.getElementById("Div_zoom2").style.display= 'block';
			}
			

			function place_zoom() {
			  var scrOfX = 0, scrOfY = 0;
			  if( typeof( window.pageYOffset ) == 'number' ) {
				//Netscape compliant
				scrOfY = window.pageYOffset;
				scrOfX = window.pageXOffset;
			  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
				//DOM compliant
				scrOfY = document.body.scrollTop;
				scrOfX = document.body.scrollLeft;
			  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
				//IE6 standards compliant mode
				scrOfY = document.documentElement.scrollTop;
				scrOfX = document.documentElement.scrollLeft;
			  }
			var MyDiv = document.getElementById("Div_zoom2") ;
			MyDiv.style.left  = (document.body.scrollWidth - 940 ) /2 ;
			MyDiv.style.top  = scrOfY + 25;
			}

			function retour() {
			document.getElementById("Div_zoom2").style.display= 'none';
			document.getElementById("Div_zoom").style.display='none';
			window.frames[0].location.href ='/blank.asp';
			}
			

			//onresize = new Function('setTimeout("window.location.reload()",0)');
