function GetBrowser()
{
 var agt=navigator.userAgent.toLowerCase();
 if( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) )
 return "IE";
 else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
 return "Netscape";
 else
 return "unknown";
}

function goTo()
{   

  if (document.countryForm.country.value==-1) {
		    alert("Attention! No country selected.");
		}else{
		  
	id = document.countryForm.country.selectedIndex;
	page = document.countryForm.country[id].value;
	
	window.open(page, '');
	//alert(page);
	}
	
}

function get_date(str)
{ 
	dayval=str.substr(0,2);
	yearval=str.substr(6);
	monthval=str.substr(3,2);

	if(monthval=="01"){
	monthval="Jan";
	}
	else if (monthval=="02") {
	monthval="Feb";
	}
	else if (monthval=="03") {
	monthval="Mar";
	}
	else if (monthval=="04") {
	monthval="Apr";
	}
	else if (monthval=="05") {
	monthval="May"; 
	}
	else if (monthval=="06") {
	monthval="Jun"; 
	}
	else if (monthval=="07") {
	monthval="Jul"; 
	}
	else if (monthval=="08") {
	monthval="Aug";  
	}
	else if (monthval=="09") {
	monthval="Sep";  
	}
	else if (monthval=="10") {
	monthval="Oct"; 
	}
	else if (monthval=="11") {
	monthval="Nov"; 
	}
	else if (monthval=="12") {
	monthval="Dec"; 
	}

	return monthval+" "+dayval+", "+yearval;
}

function get_date_IT(str)
{ 
	dayval=str.substr(0,2);
	yearval=str.substr(6);
	monthval=str.substr(3,2);

	if(monthval=="01"){
	monthval="Gen";
	}
	else if (monthval=="02") {
	monthval="Feb";
	}
	else if (monthval=="03") {
	monthval="Mar";
	}
	else if (monthval=="04") {
	monthval="Apr";
	}
	else if (monthval=="05") {
	monthval="Mag"; 
	}
	else if (monthval=="06") {
	monthval="Giu"; 
	}
	else if (monthval=="07") {
	monthval="Lug"; 
	}
	else if (monthval=="08") {
	monthval="Ago";  
	}
	else if (monthval=="09") {
	monthval="Set";  
	}
	else if (monthval=="10") {
	monthval="Ott"; 
	}
	else if (monthval=="11") {
	monthval="Nov"; 
	}
	else if (monthval=="12") {
	monthval="Dic"; 
	}

	return dayval+" "+monthval+" "+yearval;
}

function Scrivi_Flash(){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="773" height="162">')
document.write('<param name="movie" value="http://www.prysmian.com/cartellaflash/header_home_main.swf?pathSwf=http://www.prysmian.com/staticres/flash/&configRoot=http://www.prysmian.com/staticres/config&srcLocalImg=images/investor.jpg"><param name="quality" value="high"><param name="wmode" value="opaque"><param name="menu" value="false">')
document.write('<embed src="http://www.prysmian.com/cartellaflash/header_home_main.swf?pathSwf=http://www.prysmian.com/staticres/flash/&configRoot=http://www.prysmian.com/staticres/config&srcLocalImg=images/investor.jpg" quality="high" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="773" height="162" id="fma" name="fma"></embed></object>')
}

function Scrivi_Flash_param(flashPath){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="773" height="162">')
  document.write('<param name="movie" value="' + flashPath + '"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="menu" value="false">')
  document.write('<embed src="' + flashPath + '" quality="high" wmode="transparent" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="773" height="162" id="fma" name="fma" ></embed></object>')
}


function Scrivi_Flash2(flashPath){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="773" height="162">')
  document.write('<param name="movie" value="' + flashPath + '?&configRoot=config"><param name="pathSwf" value="test/"><param name="configRoot" value="/staticres/config"><param name="quality" value="high"><param name="wmode" value="opaque"><param name="menu" value="false">')
  document.write('<embed src="' + flashPath + '?configRoot=config" quality="high" configRoot="/staticres/config" pathSwf="test/" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="773" height="162" id="fma" name="fma"></embed></object>')
} 


//#############################################################################################################
//# creata per i content editor --> scrivendo questo codice da fckeditor da iexplorer cancella la parte embed #
//#############################################################################################################
function write_Flash(flashPath,width,height){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">')
  document.write('<param name="movie" value="' + flashPath + '"><param name="quality" value="high"><param name="wmode" value="opaque"><param name="menu" value="false">')
  document.write('<embed src="' + flashPath + '" quality="high" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="fma" name="fma"></embed></object>')
}

//###########################################
//# creata per i content editor per i video #
//###########################################
function visualizzaVideo(videoPath,width,height){
document.write('<object id="MediaPlayer1"  name=MediaPlayer1 ')
document.write('classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ')
document.write('width="'+width+'" ')
document.write('height="'+height+'" align="top">')
document.write('     <param name="autostart" value="false" id="MediaPlayer1" />')
document.write('     <param name="URL" value="'+videoPath+'" />')
document.write('       <embed src="'+videoPath+'"')
document.write('           url="'+videoPath+'"')
document.write('           width='+width)
document.write('             height='+height)
document.write(' autostart="0" type="application/x-mplayer2"')
document.write('             pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"')
document.write('             name="MediaPlayer1" id="MediaPlayer1"')
document.write('             showstatusbar="0"')
document.write('             showControls="1">')
document.write('     </embed></object>')
}

/*
function chiudi_apri(oggetto, quanti){
	obzj = oggetto;
	for (var i=0;i<quanti;i++){
		oggetto = obzj + (i+1);
		if ($(oggetto).getStyle('display') != "none"){
			$(oggetto).setStyle({visibility:'hidden',display:'none'});	
			$(obzj).setStyle({'background-image':'url(img/sitemap_meno.gif)'});
		}else{
			$(oggetto).setStyle({visibility:'visible',display:'block'});
			$(obzj).setStyle({'background-image':'url(img/sitemap_piu.gif)'});
		}
	}
	
}
*/

function logga(testo){
  new Insertion.After($('log_testo'), testo + "<br/>")
}
  
function findPosTop(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return curtop;
}
  
function findPosLeft(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return curleft;
}
function PuntoPartenza(layer){
  punto_partenza = 18
  $R(1,layer).each(function(s,index) {
      punto_partenza = parseInt(punto_partenza + parseInt(ButW[index]));
  });
  return punto_partenza
}

function Uscito(layer){
  secondi = 0
  timer_on = true
}
function Entrato(layer){
  secondi = 0
  timer_on = false
}


function Fadizza(layer){
    lay = Top_Sotto_Div + layer
    padre = Top_Div_Bottoni + layer
    if (mostrato != 0) {
      Nascondi(mostrato)
    } 
    Mostra(layer)
    mostrato = layer
    secondi = 0
    timer_on = true
}


function St_Timer(){
  /* 
  if (timer_acceso == false){
      new PeriodicalExecuter(PartiTimer,0.25)
  }
  */
  
}
function PartiTimer(){
      if (timer_on) {
        if (secondi > 10) {
          if (mostrato != 0) {
            Nascondi(mostrato)
            mostrato = 0
          }
        secondi = 0
        }else{
          secondi = secondi + 1
        }
      }
}
//###########################################################################################################################
//# modificando il valore di top nello stile Top_sotto_div_xx si modifica il punto di partenza dall'alto del menù a tendina #
//###########################################################################################################################

function Mostra(layer){
if (mostrato == 0){
  url_tmp = "url('/staticres/img/top_menu/but_sfo.gif')";
  if (layer != 1){
    $('img_top_sx_' + layer).replace('<div id="img_top_sx_' + layer +'"><img src="/staticres/img/top_menu/all_but_sx.gif"  width="9" height="40"></div>');
    $('img_top_dx_' + layer).replace('<div id="img_top_dx_' + layer +'"><img src="/staticres/img/top_menu/left_but_dx.gif"  width="9" height="40"></div>');
    $('img_top_centro_' + layer).setStyle({'background-image': url_tmp});
  }else{
    $('img_top_sx_' + layer).replace('<div id="img_top_sx_' + layer +'"><img src="/staticres/img/top_menu/left_but_sx.gif"  width="9" height="40"></div>');
    $('img_top_dx_' + layer).replace('<div id="img_top_dx_' + layer +'"><img src="/staticres/img/top_menu/left_but_dx.gif"  width="9" height="40"></div>');
    $('img_top_centro_' + layer).setStyle({'background-image': url_tmp});
  }

  lay = Top_Sotto_Div + layer

//  if (GetBrowser() == "Netscape"){
//      $(lay).setStyle({left: findPosLeft($(Top_Div_Bottoni + layer))-9, position:'absolute', top: '109',visibility:'visible'})}
// else{
      $(lay).setStyle({left: PuntoPartenza(layer), position:'absolute', top: '76',visibility:'visible'})
//}
 }else{
  Nascondi(layer)
 }
}

function Nascondi(layer){
    $('img_top_sx_' + layer).replace('<div id="img_top_sx_' + layer +'"><img src="/staticres/img/hp_01.jpg" width="9" height="40"></div>')
    $('img_top_dx_' + layer).replace('<div id="img_top_dx_' + layer +'"><img src="/staticres/img/hp_01.jpg" width="9" height="40"></div>')
    url_tmp = "url('/staticres/img/top_menu/but_sfo_n.gif')";
    $('img_top_centro_' + layer).setStyle({'background-image': url_tmp});
    lay = Top_Sotto_Div + layer
    $(lay).setStyle({visibility:'hidden', position:'absolute',left:'0', top: '0'})
    //$(lay).hide()
    mostrato = 0
}


/* parse the entered query String */
function parseSearchQuery(theForm, message) {
	var queryValue = theForm.elements["query2"].value;
	var testValue = queryValue.replace(/ /g, "");
	if (testValue.length < 3) {
		alert(message);
		return (false);
	}
	theForm.elements["query"].value = queryValue;
	return (true);
}

function MostraSearch(){
	if (Element.getStyle('search','visibility') == 'hidden'){
		Element.setStyle('search', {visibility:'visible'});
		Element.setStyle('search', {display:'inline'});
	}else{
		Element.setStyle('search', {visibility:'hidden'});
		Element.setStyle('search', {display:'none'});
	}
//	Effect.SlideDown('search', {duration:1, scaleX:true, scaleY:false});
}

// this function determines whether the event is the equivalent of the microsoft
// mouseleave or mouseenter events.
function isMouseLeaveOrEnter(e, handler)
{		
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

function UscitoNew(layer,evt, obj){
  if (isMouseLeaveOrEnter(evt, obj))
  {
  	Nascondi(layer);
  }
}

function EntratoNew(layer,evt, obj){
  if (isMouseLeaveOrEnter(evt, obj))
  {
  	Mostra(layer);
  }
}

function FadizzaNew(layer,evt, obj){
  if (isMouseLeaveOrEnter(evt, obj))
  {
  	Fadizza(layer);
  }
}
