
function dropShadow(eid) {
      if(!document.getElementById || !document.getElementsByTagName || !document.createElement) return;
          var obj = document.getElementById(eid);
      if(!obj|| !obj.offsetParent) return;
 
  /* riferimento al body del documento */
          var body = document.getElementsByTagName('body')[0];
          var left = 0, top = 0;
  /* ottiene la posizione assoluta del div */
  /* distanza dal bordo sinistro della pagina */
          for (var tmpObj = obj; tmpObj.offsetParent; tmpObj = tmpObj.offsetParent)
            left += tmpObj.offsetLeft;
  /* distanza dal bordo superiore */
          for (var tmpObj = obj; tmpObj.offsetParent; tmpObj = tmpObj.offsetParent)
            top += tmpObj.offsetTop;
  /* spessore dell'ombra ovvero dei bordi del div che andremo ad aggiungere */
          var x1 = 2;
  /* crea il nuovo div */
          var ombra   = document.createElement('div');
  /* viene assegnato lo stile al div ombra in modo che si affianchi al div obiettivo */
  /* posizione */
          ombra.style.position      = 'absolute';
          ombra.style.left          = left + x1 + 'px';
          ombra.style.top           = top + x1 + 'px';
  /* dimensioni */
          ombra.style.height        = obj.offsetHeight - x1 + 'px';
          ombra.style.width         = obj.offsetWidth  - x1 + 'px';
  /* bordi (l'ombra effettiva) */
          ombra.style.borderRight   = x1 + 'px solid #eee';
          ombra.style.borderBottom  = x1 + 'px solid #eee';
   /* appende il div creato al corpo del documento */
      if(body.appendChild) body.appendChild(ombra);
}
window.onload = function() { dropShadow('BoxUltimiComunicati'); };
window.onload = function() { dropShadow('BoxDbCalendario'); };
window.onload = function() { dropShadow('BoxDbEuropa'); };
window.onload = function() { dropShadow('BoxDbEuropaSX'); };


//accessibility
window.onload = function(e) {
	var cookie = readCookie("style");
	if (cookie && cookie != "null") {
		setActiveStyleSheet(cookie);
	} else {
		setActiveStyleSheet("small");
	}
	//print page
	if (document.location.href.indexOf("print") > -1) {
		window.print();
	}
}

window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

function setActiveStyleSheet(title) {
	var i, a, main;
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function getActiveStyleSheet() {
	var i, a;
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("title") && !a.disabled
		) return a.getAttribute("title");
	}
	return null;
}

function getPreferredStyleSheet() {
	var i, a;
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("rel").indexOf("alt") == -1
			&& a.getAttribute("title")
		) return a.getAttribute("title");
	}
	return null;
}

function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else expires = "";
	document.cookie = name+ "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

//menu hiligtht
function litMenu(menuId) {
	itemLi = document.getElementById("m" + menuId);
	if (itemLi != null) itemLi.className = "menuon";
}

//home flash
function homeFlash() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="573" height="130" id="movie_loader" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/investor/res/swf/movie_loader.swf?xmlurl=/investor/res/xml/movieloader.xml" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="/investor/res/swf/movie_loader.swf?xmlurl=/investor/res/xml/movieloader.xml" quality="high" bgcolor="#ffffff" width="573" height="130" name="movie_loader" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object>');
}

//stock ticker
function stockTicker(lang) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="350" height="35" id="stockticker" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/investor/res/swf/stockticker.swf?lang=' + lang + '&xml_url=/investor/dati/quotazione_flash.xml" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="/investor/res/swf/stockticker.swf?lang=' + lang + '&xml_url=/investor/dati/quotazione_flash.xml" quality="high" bgcolor="#ffffff" width="350" height="35" name="stockticker" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

//prezzo titolo
function intraDaySmall() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="195" height="170" id="intra_day_piccolo" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/investor/res/swf/intra_day_piccolo.swf?xmlurl=/investor/dati/intraday_flash.xml&xmlindiciurl=/investor/dati/indice_flash.xml" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="/investor/res/swf/intra_day_piccolo.swf?xmlurl=/investor/dati/intraday_flash.xml&xmlindiciurl=/investor/dati/indice_flash.xml" quality="high" bgcolor="#ffffff" width="195" height="170" name="intra_day_piccolo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

//date and time
var dayNamesIt = new Array('domenica','luned&igrave;','marted&igrave;','mercoled&igrave;','gioved&igrave;','venerd&igrave;','sabato')
var monthNamesIt = new Array('gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto','settembre','ottobre','novembre','dicembre')
var dayNamesEn = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')
var monthNamesEn = new Array('January','February','March','April','May','June','July','August','September','October','November','December')

function dateFromInt(datastr,lang) {
	var year = '20'+datastr.substring(6,8)
	var month = datastr.substring(3,5)
	var day = datastr.substring(0,2)
	var date =  new Date(year, month - 1, day)
	if(lang == 'it')
		data = dayNamesIt[date.getDay()] +' '+day+' '+ monthNamesIt[month - 1] + ' ' +year
	else
		data = dayNamesEn[date.getDay()] +' '+day+' '+ monthNamesEn[month - 1] +' '+ year
	document.write(data)
} 
				
function time(datastr){
	var ora = datastr.substring(9,14)
	document.write(ora)
}

/* service */
function readUrl(param){
	var theurl=window.location.toString()+"&";
	var posparam=theurl.indexOf(param+"=");
	if(posparam==-1)return"";
	var sottostringa=theurl.substring(posparam);
	var start=sottostringa.indexOf("=");
	var end=sottostringa.indexOf("&");
	var val=sottostringa.substring(start+1,end);
	return val;
}

/* google */
var ALPHANUMERICS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890אטילעש"
function tok(theObj,lang){
	var text=theObj.value+" ";
	var pos,pos1=0;
	var finale,word,ch=" ";
	var find=true;
	var fword=false;
	for(var i=0;i<text.length;i++){
		ch=text.charAt(i);
		if(ch==" "){
			if(find!=true){
				find=true;
				pos1=i;
				word=text.substring(pos,pos1);
				if(word.substring(0,1)==" ")word=word.substring(1,word.length);
				var wU=word.toUpperCase();
				if(wU=="AND"||wU=="OR"||wU=="NOT"){
					if (lang =='it')
						alert("La parola ' "+wU+" ' non ט ammessa");
					else
						alert("The word ' "+wU+" ' is not allowed");
					theObj.focus();
					return false; 
				}
				pos=pos1;
				if(fword==false){
					finale=word;
					fword=true;
				}else
					finale=finale+" "+word;
			}else
				pos=i+1;  
			}else{
				if(ALPHANUMERICS.indexOf(ch)==-1){
				if(lang=='it')
					alert("Il carattere ' "+ch+" ' non ט ammesso");
				else
					alert("The token ' "+ch+" ' is not allowed");         
				theObj.focus();
				return false;
			}
			find=false; 
			}//end if
	}//end for
	if(fword==false){
		if(lang=='it')
			alert("Inserisci la/e parola/e che vuoi ricercare!");
		else
			alert("Insert the words that you want to search!");     
		theObj.value="";
		theObj.focus();
		return false;
	}
	theObj.value=finale;
	return true; 
}
 
function goSearch(obj, lang) {
	if (obj.q.value.length > 0) {
		if (tok(obj.q, lang) == true) return true;       
	} else {
		if (lang == 'en') {
			alert("Please, insert the text to search!");
		} else {
			alert("Per favore, inserire il testo da cercare!");     
		}
	}
	return false; 
}
/*end google*/

/* send page by email */
function sendByEmail(lang){
	/*
	var pTitle = document.title;
	var pUrl = document.location.href;
	var head = (lang == 'en') ? "Please check the page at the following address:\n" : "Ti segnalo la pagina all'indirizzo:\n";
	var foot = (lang == 'en') ? "Mediaset Group - Investor Center\nhttp://www.mediaset.it/investor/home_en.shtml" : "Gruppo Mediaset - Investor Center\nhttp://www.mediaset.it/investor/home_it.shtml";
	var subj = escape(pTitle);
	var body = escape(head + pUrl + "\n\n=========================\n" + foot);
	var sendmail = window.open("mailto:?subject=" + subj + "&body=" + body, "sendmail");
	*/
	var sendmail = window.open("mailto:mediaset@mediaset.it");
}

/* print page */
function printPage() {
	window.print();
}

/* add to favorites */
function addToFavorites(lang) {
	if (document.all) {
			window.external.AddFavorite(document.location.href, document.title); // Internet Explorer
	} else if (window.sidebar) {
			window.sidebar.addPanel(document.title, document.location.href, ""); // Mozilla Firefox
	} else if (navigator.appName == "Netscape") {
		if (lang == 'en') {
			alert("Puoi aggiungere la pagina all\'elenco dei \'Preferiti\' premendo i tasti CTRL+D");
		} else {
			alert("You can add this page to your \'Favorites\' with the key sequence CTRL+D");
		}     
	}
}                       

