var spwdRand=Math.floor(Math.random()*100000);
var spwdRadioLangs = ["Inglese", "Francese", "Tedesco", "Spagnolo", "Portoghese", "Polacco", "Albanese", "Turco", "Filippino"];
var spwdPageInFrame = false;


if (typeof(spwdTarget) === 'undefined' || (spwdTarget != '_top' && spwdTarget != '_self')) {
  spwdTarget = "_blank";
}
else {
  var spwdTarget = "_blank";
}


function spwdGoDiz(spwdRandIn) {
  document.getElementById('spwdEnciclopediaTab'+spwdRandIn).style.borderBottom = "1px solid #fff";
  document.getElementById('spwdEnciclopediaTab'+spwdRandIn).style.backgroundColor = "#fff";
  document.getElementById('spwdDizionariTab'+spwdRandIn).style.borderBottom = "1px solid #bdbdbd";
  document.getElementById('spwdDizionariTab'+spwdRandIn).style.backgroundColor = "#e9edf3";
  document.getElementById('spwdEnciclopedia'+spwdRandIn).style.display = "none";
  document.getElementById('spwdDizionari'+spwdRandIn).style.display = "block";
}
function spwdGoEnc(spwdRandIn) {
  document.getElementById('spwdEnciclopediaTab'+spwdRandIn).style.borderBottom = "1px solid #bdbdbd";
  document.getElementById('spwdEnciclopediaTab'+spwdRandIn).style.backgroundColor = "#e9edf3";
  document.getElementById('spwdDizionariTab'+spwdRandIn).style.borderBottom = "1px solid #fff";
  document.getElementById('spwdDizionariTab'+spwdRandIn).style.backgroundColor = "#fff";
  document.getElementById('spwdEnciclopedia'+spwdRandIn).style.display = "block";
  document.getElementById('spwdDizionari'+spwdRandIn).style.display = "none";
}

function spwdCompDizSel(spwdVal, spwdRandIn) {
  if (spwdVal == "Italiano" || spwdVal == "Sinonimi" || spwdVal == "Contrari") {
    document.getElementById('spwdCompDizCerca'+spwdRandIn).value = 'dizionari';
    document.getElementById('spwdCompDizDizionario'+spwdRandIn).value = spwdVal;
    document.getElementById('spwdCompDizTraduzione'+spwdRandIn).value = '';
  }
  else {
    document.getElementById('spwdCompDizCerca'+spwdRandIn).value = 'traduzioni';
    document.getElementById('spwdCompDizDizionario'+spwdRandIn).value = '';
    document.getElementById('spwdCompDizTraduzione'+spwdRandIn).value = spwdVal;
  }
}

function spwdselDictLang(spwdRandIn, spwdPosIn) {
  var spwdIPos = spwdPosIn*20;
  if (spwdIPos != 0) { spwdIPos = spwdIPos+'px'; }
  document.getElementById('spwdDotP'+spwdRandIn).style.backgroundPosition= spwdIPos +' 0';

  for (var spwdPosI=0; spwdPosI<spwdRadioLangs.length; spwdPosI++) {
    spwdIPos = spwdPosI*-21;
    if (spwdIPos != 0) { spwdIPos = spwdIPos+'px'; }

    if (spwdPosI == spwdPosIn) {
      document.getElementById('spwdFlag'+ spwdPosI +'-'+spwdRandIn).style.backgroundPosition= spwdIPos+' -15px';
      document.getElementById('spwdDictCho'+ spwdPosI +'-'+spwdRandIn).style.display = 'block';
      document.getElementById('spwdDictChoCho'+ spwdPosI +'-'+spwdRandIn).checked = true;
    }
    else {
      document.getElementById('spwdFlag'+ spwdPosI +'-'+spwdRandIn).style.backgroundPosition= spwdIPos+' 0';
      document.getElementById('spwdDictCho'+ spwdPosI +'-'+spwdRandIn).style.display = 'none';
    }
  }
}

var spwdSmallBoxtemplate = false;
var spwdDixTabW = 60;
var spwdMaxDict = spwdRadioLangs.length;
if (spwdWidth < 208) { spwdDixTabW = 80 - (208-spwdWidth); }
else if (spwdWidth < 300) { spwdDixTabW = 80; }

if (typeof(spwdBoxSize) !== 'undefined' && spwdBoxSize == 'small') {
   spwdSmallBoxtemplate = true;
}


if (spwdWidth < 200) { spwdWidth = 200; }
document.write('<div style="display:block;width:'+spwdWidth+'px">');
document.write('<div style="font-family: Arial, SansSerif; font-size: 12px; color:#3f3f3f;border:1px solid #ccc;">');
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background:#cddcf3 url(http://www.sapere.it/web/widget/img/box-ricerca/dot.gif) repeat-x left bottom;"><tr>');
document.write('<td width="125" style="padding:4px 0 ');
if (spwdWidth < 300) { document.write('1px'); } else { document.write('4px'); }
document.write(' 4px;font-family:  Arial, SansSerif; font-size: 12px;"><a href="http://www.sapere.it/"><img src="http://www.sapere.it/web/widget/img/box-ricerca/saplogo.gif" width="120" height="25" alt="Sapere.it" border="0" style="border:0;margin:0;padding:0"></a></td>');

if (spwdWidth < 300) {
  document.write('</tr><tr>');
}

document.write('<td valign="bottom" align="right" style="padding:4px 4px 0 4px;font-family:  Arial, SansSerif; font-size: 11px; color:#3f3f3f">');


spwdMaxDict = parseInt((spwdWidth-60)/21);


document.write('  <div style="height:20px;overflow:hidden;">');
document.write('  <a id="spwdEnciclopediaTab'+spwdRand+'" href="#" onclick="spwdGoDiz('+spwdRand+');return false;" style="background-color:#e9edf3;border:1px solid #bdbdbd;-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;border-top-right-radius:4px;0;display:block;width:'+spwdDixTabW+'px;float:right;text-align:center;color:#3f3f3f;text-decoration:none;line-height:18px">Dizionari</a>');
document.write('  <a id="spwdDizionariTab'+spwdRand+'" href="#" onclick="spwdGoEnc('+spwdRand+');return false;" style="background-color:#fff;border:1px solid #bdbdbd;-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;border-top-right-radius:4px;padding:0;display:block;width:80px;float:right;margin-right:4px;text-align:center;color:#3f3f3f;text-decoration:none;border-bottom:1px solid #fff;line-height:18px;">Enciclopedia</a>');
document.write('  </div>');
document.write('</td></tr></table>');




document.write('<div id="spwdEnciclopedia'+spwdRand+'" style="padding:8px 4px '+(spwdSmallBoxtemplate?'8px':'4px')+' 4px;background:#fff url(bkg.jpg) no-repeat '+(spwdSmallBoxtemplate?'0 -25px':'left bottom')+''+(spwdSmallBoxtemplate?'':';height:245px')+'">');
  document.write('<form target="'+spwdTarget+'" style="padding:0;margin:0" action="http://www.sapere.it/sapere/search.html" method="GET">');
  document.write('<table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td id="spwdEnciclopediaBorder'+spwdRand+'" style="border:1px solid #ccc">');
  document.write('<table border="0" cellspacing="0" cellpadding="0">');
  document.write('<tr><td>');
  document.write('<input onfocus="document.getElementById(\'spwdEnciclopediaBorder'+spwdRand+'\').style.borderColor = \'#004a9d\';" onblur="document.getElementById(\'spwdEnciclopediaBorder'+spwdRand+'\').style.borderColor = \'#cccccc\';" type="text" name="q" size="34" maxlength="255" title="Inserisci un termine" style="width:'+(spwdWidth-32)+'px;font-family: Arial, SansSerif; font-size:14px; font-weight:bold;color:#3f3f3f;border:0;outline:none;">');
  document.write('<input type="hidden" value="enc" name="cerca">');
  document.write('</td><td style="padding-right:3px">');
  document.write('<input type="image" class="button" src="http://www.sapere.it/web/widget/img/box-ricerca/cerca.gif" alt="Cerca">');
  document.write('</td></tr></table>');
  document.write('</td></tr></table></form>');

  var spwdEcats = [
    ["http://www.sapere.it/sapere/enciclopedia/animali-e-piante.html", "Animali e piante"],
    ["http://www.sapere.it/sapere/enciclopedia/arte-e-architettura.html", "Arte e architettura"],
    ["http://www.sapere.it/sapere/enciclopedia/letteratura-e-media.html", "Letteratura e media"],
    ["http://www.sapere.it/sapere/enciclopedia/scienza.html", "Scienza"],
    ["http://www.sapere.it/sapere/enciclopedia/scienze-umane.html", "Scienze umane"],
    ["http://www.sapere.it/sapere/enciclopedia/spettacolo.html", "Spettacolo"],
    ["http://www.sapere.it/sapere/enciclopedia/sport-e-hobby.html", "Sport e hobby"],
    ["http://www.sapere.it/sapere/enciclopedia/storia-e-societ\u00e0.html", "Storia e societ\u00e0"],
    ["http://www.sapere.it/sapere/enciclopedia/tecnica.html", "Tecnica"],
    ["http://www.sapere.it/sapere/enciclopedia/terra-e-universo.html", "Terra e universo"]
  ];



  if (!spwdSmallBoxtemplate) {
    document.write('<div style="padding:12px 2px 2px 2px;">');
    document.write('<table width="'+(spwdWidth-14)+'" border="0" cellspacing="0" cellpadding="0"><tr>');
    document.write('<td width="15" style="background:#e3e3e3 url(categorie.gif) no-repeat left bottom;"></td><td style="padding-left:12px">');

    for (var spwdI=0; spwdI < spwdEcats.length; spwdI++) {
      document.write('<a onmouseover="this.style.backgroundColor=\'#cddcf3\';this.style.fontWeight=\'bold\';this.style.paddingLeft=\'5px\';this.style.color=\'#004a9d\'" onmouseout="this.style.backgroundColor=\'transparent\';this.style.fontWeight=\'normal\';this.style.paddingLeft=\'0\';this.style.color=\'#3f3f3f\';" style="display:block; padding:2px 0;font-family: Arial, SansSerif; font-size: 12px; border-bottom:1px solid #ececec; color:#3f3f3f; text-decoration:none" target="'+spwdTarget+'" href="'+spwdEcats[spwdI][0]+'">'+spwdEcats[spwdI][1]+'</a>');
    }
    document.write('</td></tr></table>');
    document.write('</div>');
  }



document.write('</div>');
document.write('<div id="spwdDizionari'+spwdRand+'" style="display:none;padding:8px 4px 4px 4px;background:#fff url(bkg.jpg) no-repeat '+(spwdSmallBoxtemplate?'0 -25px':'left bottom')+''+(spwdSmallBoxtemplate?'':';height:245px')+'">');


  document.write('<div style="padding:0 0 4px 0">');
  if (spwdSmallBoxtemplate) {

    document.write('<form target="'+spwdTarget+'" style="padding:0;margin:0" action="http://www.sapere.it/sapere/search.html" method="GET">')
    document.write('<table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td id="spwdDizBorder'+spwdRand+'" style="border:1px solid #ccc">');
    document.write('<table border="0" cellspacing="0" cellpadding="0">');
    document.write('<tr><td>');
    document.write('<input onfocus="document.getElementById(\'spwdDizBorder'+spwdRand+'\').style.borderColor = \'#004a9d\';" onblur="document.getElementById(\'spwdDizBorder'+spwdRand+'\').style.borderColor = \'#cccccc\';" type="text" name="q" size="34" maxlength="255" title="Inserisci un termine" style="width:'+(spwdWidth-32)+'px;font-family: Arial, SansSerif; font-size:14px; font-weight:bold;color:#3f3f3f;border:0;outline:none;">');
    document.write('</td><td style="padding-right:3px">');
    document.write('<input type="image" class="button" src="http://www.sapere.it/web/widget/img/box-ricerca/cerca.gif" alt="Cerca">');
    document.write('</td></tr></table>');
    document.write('</td></tr></table>');

    document.write('<div style="padding-top:4px" align="center">');

    document.write('<input id="spwdCompDizCerca'+spwdRand+'" type="hidden" name="cerca" value="dizionari">');
    document.write('<input id="spwdCompDizDizionario'+spwdRand+'" type="hidden" name="tipo_dizionario" value="Italiano">');
    document.write('<input id="spwdCompDizTraduzione'+spwdRand+'" type="hidden" name="tipo_traduzione" value="">');

    document.write('<select id=\"spwdCompDizSelect'+spwdRand+'\" onchange=\"spwdCompDizSel(this.value, \''+spwdRand+'\')\"  style="width:'+(spwdWidth-12)+'px;font-family: Arial, SansSerif; font-size:14px;color:#3f3f3f;border:1px solid #ccc">');

      document.write('<optgroup label="Italiano">');
        document.write('<option value="Italiano" selected="selected">Dizionario di italiano</option>');
        document.write('<option value="Sinonimi">Dizionario dei sinonimi</option>');
        document.write('<option value="Contrari">Dizionario dei contrari</option>');
      document.write('</optgroup>');
      document.write('<optgroup label="Lingue">');
        for (var spwdPosI=0; spwdPosI<spwdRadioLangs.length; spwdPosI++) {
           document.write('<option value="Italiano-' + spwdRadioLangs[spwdPosI] + '">Italiano-' + spwdRadioLangs[spwdPosI] + '</option>');
           document.write('<option value="' + spwdRadioLangs[spwdPosI] + '-Italiano">' + spwdRadioLangs[spwdPosI] + '-Italiano</option>');
        }
      document.write('</optgroup>');
    document.write('</select>');
    document.write('</div>');

    document.write('</form>');
  }
  else {
    document.write('<table width="'+(spwdWidth-14)+'" border="0" cellspacing="0" cellpadding="0"><tr>');
    document.write('<td width="15" style="background:#e3e3e3 url(categorie.gif) no-repeat -16px bottom;"></td><td style="padding-left:12px">');
  
    document.write('<form target="'+spwdTarget+'" style="padding:0;margin:0" action="http://www.sapere.it/sapere/search.html" method="GET">');

    document.write('<table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td id="spwdDictItaBorder'+spwdRand+'" style="border:1px solid #ccc">');
    document.write('<table border="0" cellspacing="0" cellpadding="0">');
    document.write('<tr><td>');
    document.write('<input type="text" onfocus="document.getElementById(\'spwdDictItaBorder'+spwdRand+'\').style.borderColor = \'#004a9d\';" onblur="document.getElementById(\'spwdDictItaBorder'+spwdRand+'\').style.borderColor = \'#cccccc\';" class="inputText" name="q" size="34" maxlength="255" title="Inserisci un termine" style="width:'+(spwdWidth-60)+'px;font-family: Arial, SansSerif; font-size:14px;color:#3f3f3f;border:0;outline:none;">');
    document.write('<input type="hidden" value="dizionari" name="cerca">');
    document.write('</td><td style="padding-right:3px">');
    document.write('<input type="image" class="button" src="http://www.sapere.it/web/widget/img/box-ricerca/cerca.gif" alt="Cerca">');
    document.write('</td></tr></table>');
    document.write('</td></tr></table>');
  
    document.write('<div style="padding-top:8px">');

    
    document.write('<div style="font-family: Arial, SansSerif; font-size: 12px; color:#3f3f3f;padding: 3px 0; border-bottom:1px solid #ececec;">');
    document.write('<input id="spwdRadioIT'+spwdRand+'" name="tipo_dizionario" type="radio" value="Italiano" checked="checked" style="vertical-align: middle; margin: 0; height:14px;"> <label style="display:inline" for="spwdRadioIT'+spwdRand+'">Dizionario di italiano</label>');
    document.write('</div>');
    document.write('<div style="font-family: Arial, SansSerif; font-size: 12px; color:#3f3f3f;padding: 3px 0; border-bottom:1px solid #ececec;">');
    document.write('<input id="spwdRadioSI'+spwdRand+'" name="tipo_dizionario" type="radio" value="Sinonimi" style="vertical-align: middle; margin: 0; height:14px;"> <label style="display:inline" for="spwdRadioSI'+spwdRand+'">Dizionario dei sinonimi</label>');
    document.write('</div>');
    document.write('<div style="font-family: Arial, SansSerif; font-size: 12px; color:#3f3f3f;padding: 3px 0; border-bottom:1px solid #ececec;">');
    document.write('<input id="spwdRadioCO'+spwdRand+'" name="tipo_dizionario" type="radio" value="Contrari" style="vertical-align: middle; margin: 0; height:14px;"> <label style="display:inline" for="spwdRadioCO'+spwdRand+'">Dizionario dei contrari</label>');
    document.write('</div>');
    document.write('</div></form>');
    document.write('</td></tr></table>');
    document.write('</div>');


    document.write('<div style="padding:16px 2px 8px 2px;">');
    document.write('<table width="'+(spwdWidth-14)+'" border="0" cellspacing="0" cellpadding="0"><tr>');
    document.write('<td width="15" style="background:#e3e3e3 url(http://www.sapere.it/web/widget/img/box-ricerca/categorie.gif) no-repeat -32px bottom;"></td><td style="padding-left:12px">');
  
    document.write('<form target="'+spwdTarget+'" style="padding:0;margin:0" action="http://www.sapere.it/sapere/search.html" method="GET">');

    document.write('<table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td id="spwdDictLangBorder'+spwdRand+'" style="border:1px solid #ccc">');
    document.write('<table border="0" cellspacing="0" cellpadding="0">');
    document.write('<tr><td>');
    document.write('<input onfocus="document.getElementById(\'spwdDictLangBorder'+spwdRand+'\').style.borderColor = \'#004a9d\';" onblur="document.getElementById(\'spwdDictLangBorder'+spwdRand+'\').style.borderColor = \'#cccccc\';" type="text" class="inputText" name="q" size="34" maxlength="255" title="Inserisci un termine" style="width:'+(spwdWidth-60)+'px;font-family: Arial, SansSerif; font-size:14px;color:#3f3f3f;border:0;outline:none;">');
    document.write('<input type="hidden" value="traduzioni" name="cerca">');
    document.write('</td><td style="padding-right:3px">');
    document.write('<input type="image" class="button" src="http://www.sapere.it/web/widget/img/box-ricerca/cerca.gif" alt="Cerca">');
    document.write('</td></tr></table>');
    document.write('</td></tr></table>');
  
  
    document.write('<div style="padding-top:8px">');
  
    document.write('<div style="background:transparent url(http://www.sapere.it/web/widget/img/box-ricerca/dot.gif) repeat-x left bottom;">');
    document.write('<div id="spwdDotP'+spwdRand+'" style="background:transparent url(http://www.sapere.it/web/widget/img/box-ricerca/dotp.gif) no-repeat 0 0;padding:0 1px;height:22">');
  
    document.write('<table border="0" cellspacing="0" cellpadding="0"><tr>');
    for (spwdI = 0; spwdI < spwdRadioLangs.length; spwdI++) {
      var spwdIPos = spwdI*-21;
      if (spwdIPos != 0) { spwdIPos = spwdIPos+'px'; }
  
      if (spwdI > spwdMaxDict) {
        document.write('<td><div id="spwdFlag'+ spwdI + '-' + spwdRand + '" style="display:none;background:#ccc url(http://www.sapere.it/web/widget/img/box-ricerca/flags.gif) no-repeat '+spwdIPos+' 0"></div></td>');
      }
      else {
        spwdIPosZero = '0';
        if (spwdI == 0) { spwdIPosZero = '-15px'; }
        document.write('<td height="15" width="16"><div title="' + spwdRadioLangs[spwdI] + '" id="spwdFlag'+ spwdI + '-' + spwdRand + '" onclick="spwdselDictLang(\''+spwdRand+'\','+spwdI+')"  style="cursor:pointer;display:block;height:11px;overflow:hidden;width:16px;background:#ccc url(http://www.sapere.it/web/widget/img/box-ricerca/flags.gif) no-repeat '+spwdIPos+' '+spwdIPosZero+'"></div></td>');
        document.write('<td width="4"></td>');
      }
    }
    document.write('</tr></table>');
    document.write('</div></div>');
  
    document.write('<div style="padding-top:6px">');
    for (spwdI = 0; spwdI < spwdRadioLangs.length; spwdI++) {
      document.write('<div id="spwdDictCho'+ spwdI + '-' + spwdRand + '"');
      if (spwdI != 0) {
        document.write(' style="display:none"');
      }
      document.write('>');
  
      document.write('<div style="font-family: Arial, SansSerif; font-size: 12px; color:#3f3f3f;padding: 3px 0; border-bottom:1px solid #ececec;">');
      document.write('<input id="spwdDictChoCho'+ spwdI + '-' + spwdRand + '" style="vertical-align: middle; margin: 0; height:14px;" ');
      if (spwdI == 0) {
        document.write('checked="checked" ');
      }
      document.write(' name="tipo_traduzione" type="radio" value="Italiano-'+spwdRadioLangs[spwdI]+'"> <label style="display:inline" for="spwdDictChoCho'+ spwdI + '-' + spwdRand + '">Italiano-'+spwdRadioLangs[spwdI]+'</label>');
      document.write('</div>');
      document.write('<div style="font-family: Arial, SansSerif; font-size: 12px; color:#3f3f3f;padding: 3px 0; border-bottom:1px solid #ececec;">');
      document.write('<input style="vertical-align: middle; margin: 0; height:14px;" id="spwdRadio'+spwdRadioLangs[spwdI]+'Italiano-'+spwdRand+'" name="tipo_traduzione" type="radio" value="'+spwdRadioLangs[spwdI]+'-Italiano"> <label style="display:inline" for="spwdRadio'+spwdRadioLangs[spwdI]+'Italiano-'+spwdRand+'">'+spwdRadioLangs[spwdI]+'-Italiano</label>');
      document.write('</div>');
  
      document.write('</div>');
    }
    document.write('</div>');
  
    document.write('</div>');
    document.write('</td></tr></table></form>');
  }

document.write('</div>');


document.write('</div>');
document.write('</div>');
document.write('</div>');




if (typeof(spwdInitTab) !== 'undefined' && spwdInitTab == 'dizionari') {
  spwdGoDiz(spwdRand);
}
if (typeof(spwdInitLang) !== 'undefined' && spwdInitLang != '') {
  if (spwdSmallBoxtemplate) {
    for (var spwdPosI=0; spwdPosI<spwdRadioLangs.length; spwdPosI++) {
      if (spwdRadioLangs[spwdPosI].toLowerCase() == spwdInitLang.toLowerCase()) {
        document.getElementById('spwdCompDizSelect'+spwdRand).options[3+(spwdPosI*2)].selected = true;
        spwdCompDizSel(document.getElementById('spwdCompDizSelect'+spwdRand).options[3+(spwdPosI*2)].value, spwdRand);
        break;
      }
    }
  }
  for (var spwdPosI=1; spwdPosI<spwdRadioLangs.length; spwdPosI++) {
    if (spwdPosI < spwdMaxDict && spwdRadioLangs[spwdPosI].toLowerCase() == spwdInitLang.toLowerCase()) {
      spwdselDictLang(spwdRand, spwdPosI);
      break;
    }
  }
}
