sas_tmstp = Math.round(Math.random()*10000000000);
sas_masterflag=1;
function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
	//("Process1");
  if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else {sas_master='S';};

  var v_movie = 'http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?';
 
  jQuery(function($) {
	//("Process2");
	var FO = { movie:v_movie};
	UFO.create(FO,"pub"+sas_tmstp+"");

});
  document.write('<SCR'+'IPT id="SmartScr'+sas_formatid+'" SRC="http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');
}

function SmartAdServerPub(sas_pubid, sas_pageid, sas_formatid, sas_target) {
		//("Process3");
	if (sas_masterflag == 1) {
		sas_masterflag = 0;
		sas_master = 'M';
	} else {
		sas_master = 'S';
	}
	
	document.write('<SCR'+'IPT id="SmartScr'+sas_formatid+'" SRC="http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');
}

function SmartAdServerAjax(sas_pageid,sas_formatid,sas_target) {
		//("Process4");
  if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else {sas_master='S';};
  
  document.write('<div style="z-index:10" id="pub'+sas_tmstp+'+">'+nohetoAjaxCross('http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?')+'</div>');
}

/* 
 * fonction permettant de charger la pub dans des divs visibles pr?vus ? cet effet 
 * permet de charger la pub en fin de page 
*/
function SmartMoveEndPageDivs() {

	// Pub Format
	var formatIds = [["pub1",4819],
					 ["pubboutonhaut",4831],
					 ["pubsky",4821]
					];
	
	for(i=0; i< formatIds.length;i++)
	{
		if($("#"+formatIds[i][0]))
		{
			try {
				var scr = document.getElementById("SmartScr"+formatIds[i][1]);
				scr.parentNode.removeChild(scr);

				var secureDiv = document.getElementById(formatIds[i][0]+"Script");
				
				document.getElementById(formatIds[i][0]).appendChild(secureDiv);
				$("#"+formatIds[i][0]+"Script").show();
			} 
			catch(e) {
				// alert(e);
			}
		}

	}
		/*
		//("Process5");
	if( $("#pub1") &&  $("#pub1Script")){
	
		var newElement = $("#pub1Script").clone();
		newElement.children("script:first-child").remove();
		newElement.children("script:first-child").remove();

		$("#pub1").html(newElement.html());
	}

	if( $("#pubboutonhaut") &&  $("#pubboutonhautScript")){
	
		var newElement = $("#pubboutonhautScript").clone();
		newElement.children("script:first-child").remove();
		newElement.children("script:first-child").remove();

		$("#pubboutonhaut").html(newElement.html());
	}

	if( $("#pubsky") &&  $("#pubskyScript")){
	
		var newElement = $("#pubskyScript").clone();
		newElement.children("script:first-child").remove();
		newElement.children("script:first-child").remove();

		$("#pubsky").html(newElement.html());
	}

	if( $("#pubcarre1") &&  $("#pubcarre1Script")){
	
		var newElement = $("#pubcarre1Script").clone();
		newElement.children("script:first-child").remove();
		newElement.children("script:first-child").remove();

		$("#pubcarre1").html(newElement.html());
	}

	if( $("#pubcarre2") &&  $("#pubcarre2Script")){
	
		var newElement = $("#pubcarre2").clone();
		newElement.children("script:first-child").remove();
		newElement.children("script:first-child").remove();

		$("#pubcarre2").html(newElement.html());
	}

	if( $("#pubcarre3") &&  $("#pubcarre3Script")){
	
		var newElement = $("#pubcarre3").clone();
		newElement.children("script:first-child").remove();
		newElement.children("script:first-child").remove();

		$("#pubcarre3").html(newElement.html());
	}*/
}