var SecondWindow;
var SecondWindowOpened = "n";

var MyFather;
var MyFatherClosed;

function fStopError()
{
	return true;
}
window.onerror = fStopError;


//go to sendtofriend 
function loadSendToFriend(){
//alert('pas bien');
	var X=600;
	var Y=500;
	var sParam = "location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,resizeable=yes,dependant=yes,width=" + X + ",height=" + Y + ",status=yes";
	var sName;
	var dtToday = new Date();
        var sEIPub="";
        var sLSPub="";
	sName = dtToday.getTime();
	if(document.sendtofriend != null)
		window.document.sendtofriend.pagetosend.value=window.location.href;
                  //  if(document.sendtofriend.pagetosend.value.indexOf("zone=")==-1)
                    //    document.sendtofriend.pagetosend.value=document.sendtofriend.pagetosend.value+"&zone=zonecatalogue&idEIPub="+document.calcultotal.idEIPub.value;
if (window.document.sendtofriend.idEIPub.value != null && window.document.sendtofriend.idEIPub.value.length > 0)
                {
                sEIPub = "&amp;idEIPub="+window.document.sendtofriend.idEIPub.value;
                }
        if (window.document.sendtofriend.idLSPub.value != null && window.document.sendtofriend.idLSPub.value.length > 0)
                {
                sLSPub = "&amp;idLSPub="+window.document.sendtofriend.idLSPub.value;
                }
                    if(window.document.sendtofriend.currentzone.value=="zonecatalogue" || window.document.sendtofriend.currentzone.value=="zonelibrairie" ){
                        address=window.document.URL.substring(0,document.URL.indexOf('?')+1 )
                        window.document.sendtofriend.pagetosend.value=address+"zone="+window.document.sendtofriend.currentzone.value+sEIPub+sLSPub;
                        //alert(document.URL);
                        //alert(document.sendtofriend.pagetosend.value);
                    }

                    if(window.document.sendtofriend.currentzone.value=="zoneimpressionsl"){
                        address=window.document.URL.substring(0,document.URL.indexOf('?')+1 )
                        window.document.sendtofriend.pagetosend.value=address+"zone=zonecatalogue"+sEIPub+sLSPub+"&amp;zonetmp="+window.document.sendtofriend.currentzone.value;
                        //alert(document.URL);
                        //alert(document.sendtofriend.pagetosend.value);
                    }

        	sURL2=window.document.sendtofriend.pagetosend.value

            if(sURL2!="")
                { 
                while( sURL2.indexOf('&')!=-1){   
                sURL2=sURL2.replace('&','%26'); 
                } 
                while( sURL2.indexOf('=')!=-1){    
                sURL2=sURL2.replace('=','%3D'); 
                } 
                sURL2=sURL2.replace('?','%3F');                     
                }
            sURL="";
                if(window.document.sendtofriend2!=null){
                    type=window.document.sendtofriend2.pagetosendsubject.value;
                    sURL = "pre?zone=zonecontact&contacttodo=sendtofriend&zonetmp=zonecontactonly&pagetosendsubject="+type+"&pagetosend="+sURL2;
                    }
                else{
                sURL = "pre?zone=zonecontact&contacttodo=sendtofriend&zonetmp=zonecontactonly&pagetosend="+sURL2;
                }

//alert(sURL);
	//window.open(sURL, sName, sParam);
	OpenSecondWindowSendToFriends(sURL, sParam)	
}


function OpenSecondWindowSendToFriends(sURL, sParam)
{
	var sName;
	if(SecondWindowOpened.toLowerCase() == "y")
	{
		CloseSendToFriends();
	}
	var dtToday = new Date();
	sName = dtToday.getTime();

	SecondWindow = window.open(sURL, sName, sParam);
	SecondWindow.focus();
	SecondWindowOpened = "y";
}

// Mere
function CloseSendToFriends()
{
	SecondWindowOpened = "n";
        if(SecondWindow)
        {
	if( !SecondWindow.closed)
	{
		if(SecondWindow.formulairesentofriend != null){
			if(SecondWindow.formulairesentofriend.windowtoclose.value=='y'){
				SecondWindow.close();
			}
		}
	}
        }
}



