/**** FUNZIONI GESTIONE COOKIE ***************************************************/
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;
}

/**** FUNZIONI GESTIONE HELP ****************************************************/
var h_win=null;		//HANDLE FINESTRA HELP APERTA
var bResize=true;

function body_onhelp(sPage){
		
	if(event)event.returnValue=false;
	if(!sPage)sPage="search_main.xml";
	var sWD="toolbar=0,status=0,menubar=0,top=0,resizable=1";

	if(h_win!=null && !h_win.closed){
		bResize=false;
		h_win.location.replace("help/index.asp?xmldoc=" + sPage);
		}
	else
		h_win=window.open("help/index.asp?xmldoc=" + sPage,"",sWD)
			
		
}

/**** FUNZIONI GESTIONE PANNELLO DI SINISTRA LINK ALTRE BANCHE DATI *************/
function showLeftPanel(){
	var tblPanel=document.all["tblLeftPanel"];
	if(tblPanel.style.display=="none")
		tblPanel.style.display="";
	else
		tblPanel.style.display="none";
}

function goToBancaDati(sName){
	var frm=document.getElementById("frmGoTo");
	if(readCookie("strUserName"))
		document.getElementById("txtUserName").value=readCookie("strUserName");
	if(readCookie("strPassword"))
			document.getElementById("txtPassword").value=readCookie("strPassword");
	frm.action="http://www.newtononline.it/" + sName + "/login.asp";	
	frm.target = "_blank";
	frm.submit();
}


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;
		 createCookie("style", title, 365);
	  }
    }
  }
}


function bookmark()
{
window.external.AddFavorite("http://www.newtononline.it/","Newton On-line")
}

function makeDefault(element)
{
element.style.behavior='url(#default#homepage)'; 
element.setHomePage('http://www.newtononline.it/');
}