//////////////////////////////////////////////////////////
// Fonctions de POPUP envoyer a un ami
// Auteur   : Jean-Baptiste Landry  août 2005
// Révision : Ellis Antaya - avril 2008     - resume
// Révision : Ellis Antaya - septembre 2008 - sfl
function popEnvoyerAmi(titre, emission, url, resume) {

	// relative links 
	// -------------------
	if (url != null
	&&  typeof(url) != "undefined") {
		if (url.toString().substring(0,7) != "http://") {
			if (url.toString().substring(0,1) == "/") {
				url = "http://" + window.location.host + url;
			} else {
				var pathname = '';
				var splitParam = window.location.pathname.toString().split("/");

				for (i=0; i<(splitParam.length-1); i++) {
					 pathname = pathname + splitParam[i] + "/";
				}
							
				url = "http://" + window.location.host + pathname + url;
			}	    
		}
	} else {
	    url = window.location;
	}


	// from other servers
	// --------------------
	if (emission == 'mysterecanoecom'
	||  emission == 'ideesdemartin'
	||  emission == 'sfl'
	||  emission == 'beachclub_petitmonde')	{
		popDomain = 'tva.canoe.ca';
	} else if (!(/tva\.canoe\.ca/.test(window.location.host))                                  // prod
	&&         !(/[a-zA-Z]+tva-[0-9][0-9]\.dev\.canoe\.com/.test(window.location.host))        // ex: devtva-01.dev.canoe.com || stagingtva-01.dev.canoe.com
	&&         !(/[a-zA-Z]+tva-int-[0-9][0-9]\.dev\.canoe\.com/.test(window.location.host))) { // ex: devtva-int-01.dev.canoe.com
		popDomain = "tva.canoe.ca";
	} else {
		popDomain = window.location.host;
	}
	

	
	// base parameters
	// -------------------
	popUrl = 'http://'+popDomain+'/cgi-bin/envoyeraunami/index.pl?titre='+escape(titre)+'&emission='+escape(emission)+'&url='+escape(url)+'&resume='+escape(resume);
	var width  = 460;
	var height = 350;
	var top    = 200;
	var left   = 200;
	var scrollb ='no';

		

	// custom
	// -------------------
	if (emission == "toutsimplementclodine") {
		width  = 535;
		height = 665;
	}
	

	
	if (emission == "classe5e") {
                width  = 500;
                height = 500;
        }

	if (emission == "stations_cfcm" || emission == "stations_cfer" || emission == "stations_chlt" || emission == "stations_chem" || emission == "stations_cjpm") {
		width  = 500;
		height = 600;
	}

	if (emission == "sfl") {
		width  = 349;
		height = 550;
	}

	if (emission == "sucresale") {
		width  = 576;
		height = 450;
	}
	
	if (emission == "lanceetcompte") {
		width  = 590;
		height = 720;		
		scrollb ='yes';
	}
	
	if (emission == "beachclub_petitmonde") {
		width  = 695;
		height = 900;
		top    = 50;
		left   = 200;
		scrollb ='yes';
	}
	
	if (emission == "sucresale2008") {
		width  = 581;
		height = 560;
	}

	if (emission == "ideesdemartin") {
		width  = 380;
		height = 550;
	}
	
	if (emission == "concours_energetique") {
		width  = 578;
		height = 529;
	}

/*
	if (emission == "pourlemeilleuretpourlepire") {
		popUrl = "http://ads5.canoe.ca/event.ng/Type=click&FlightID=12168&AdID=22179&TargetID=1973&Segments=2371,3502,4176,4788,7005&Targets=439,1973&Values=31,43,51,60,72,85,91,100,110,150,155,213,224,266,332,334,353,379,380,392,490,493,659,722,1086,1286,1315,1379,1380,1444,1467,1545,1549,1551,1567,1570,1620,1946,2234,2293,2307,2553,2670,2686,2698,2700,2702,2703,2788&RawValues=USERID%2Cc0a8dccd-11176-1094842570-1&Redirect="+popUrl;
		width  = 519;
		height = 453;
	}
*/

	popEnvoyeramiWin = window.open(popUrl, emission, 'scrollbars='+scrollb+', location=no, menubar=no, width='+width+',height='+height+',top='+top+',left='+left);
	setTimeout('popEnvoyeramiWin.focus();',250);
	
	return false;
}

