var SecondWindowOpened = "n";

function loadSendToFriend(page){
    //alert('pas bien');

	var X = 600;
	var Y = 450;
	var sParam = "location=no,toolbar=no,menubar=no,scrollbars=no,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") {
        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);
    }

	if (window.document.sendtofriend2 != null && page == 1)
		{
		sURL2 = window.document.sendtofriend2.pagetosend.value
		}
	else
		{
		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 && page == 1) {
       
		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";
}


function writeTitle () {
	var wTitle = "";
	if (document.title!="") {
		wTitle = document.title;
		return vTitle;
	}
}


function openPortal () {
	var oPortal = "";
	if (window.location.href!="") {
		oPortal = window.location.href;
		return oPortal;
	}
}
