function $(id) {
	return document.getElementById(id);
}

function displayApplet(codeApplet, idElement){
	$(idElement).innerHTML = codeApplet;
}

function select_value(select,value){
	for(i=0;i < select.options.length;i++){
		if(select.options[i].value==value){
			select.options[i].selected=true;
			return true;
		}
	}

	return false;
}

function select_radio(radio,value){
	if (radio.length) {
	   for(i=0;i<radio.length;i++){
	      if(radio[i].value==value){
	         radio[i].checked=true;
	         return;
	      }
	   }
	}
	else {
		radio.checked=true;
	}
}


//fonction smart ad server
sas_tmstp=Math.round(Math.random()*10000000000);
function SmartAdServer(sas_pageid,sas_formatid,sas_master,sas_target,sas_id) {
	document.write('<SCR'+'IPT ID="SmartScr' + sas_id + '" SRC="'+ document.location.protocol +'//ads.boursorama.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) +'"></SCR'+'IPT>');
}

sas_tmstp=Math.round(Math.random()*10000000000);

function SmartMoveEndPageDiv(sas_id) {
 	try {
        var scr = document.getElementById('SmartScr'+sas_id);
        scr.parentNode.removeChild(scr);
        var secureDiv = document.getElementById('SmartEndPage'+sas_id);
        document.getElementById('Smart'+sas_id).innerHTML = '';
        document.getElementById('Smart'+sas_id).appendChild(secureDiv);
        secureDiv.style.display='block';
 	} catch(e) {
         //alert(e);
 	}
}


function popup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
   myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=yes,top='+top+',left='+left +',width=' + w + ',height=' + h );
   myWin.focus();
}

function tinypopup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
   myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=no,menubar=no,top='+top+',left='+left +',width=' + w + ',height=' + h );
   myWin.focus();
}

function littlepopup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
   myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=no,top='+top+',left='+left +',width=' + w + ',height=' + h );
   myWin.focus();
}

function centeredpopup(f,nom, w, h) {
  var posX = (screen.width / 2) - (w / 2);
  var posY = (screen.height / 2) - (h / 2);
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
   myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=no,menubar=no,top='+posY+',left='+posX +',width=' + w + ',height=' + h );
   myWin.focus();
}


function adjustIFrameSize (iframeWindow,adjustX) {
	if (adjustX == undefined) {
		adjustX = false;
	}

	if (iframeWindow.document.height) {
		var iframeElement = parent.document.getElementById(iframeWindow.name);
		iframeElement.style.height = iframeWindow.document.height + 'px';
		if (adjustX)
			iframeElement.style.width = iframeWindow.document.width + 'px';
	}
	else if (document.all) {
		var iframeElement = parent.document.all[iframeWindow.name];
		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat')  {
			iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight +  5 +  'px';
			if (adjustX)
				iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth +  5 +  'px';
		}
		else {
			iframeElement.style.height = iframeWindow.document.body.scrollHeight  + 5 +  'px';
			if (adjustX)
				iframeElement.style.width = iframeWindow.document.body.scrollWidth  + 5 +  'px';
		}
	}
}