﻿var siteRoot = new String(); // <-- Contiene la "radice" del sito
var afterbitRoot = new String(); // contiene il percorso alle librerie...
siteRoot = document.location.href;
afterbitRoot = "";

if (siteRoot.indexOf("www.studiocelsus.com") != -1) {
    //sono in remoto
    siteRoot = siteRoot.substring(0, siteRoot.indexOf("www.studiocelsus.com") + 21);
    afterbitRoot = "http://www.afterbit.com/libraries/";
}
else {
    //sono in locale
    siteRoot = siteRoot.substring(0, siteRoot.indexOf("studiocelsus") + 13);
    afterbitRoot = "http://127.0.0.1/afterbit/libraries/";
}

//le librerie javascript che mi servono per il sito web
var js_lib_string = "\n <script type=\"text/JavaScript\" src=\"" + siteRoot + "scroll_lay.js\"></script> "
	+ "\n <script type=\"text/javascript\" src=\"" + afterbitRoot + "js_library/ajax_comp.js\"></script> "
	+ "\n <script type=\"text/JavaScript\" src=\"" + afterbitRoot + "js_library/checkBrowser.js\"></script> "
	+ "\n <script type=\"text/JavaScript\" src=\"" + afterbitRoot + "js_library/strings.js\"></script> "
	+ "\n <script type=\"text/JavaScript\" src=\"" + afterbitRoot + "js_library/system.js\"></script> "
	+ "\n <script type=\"text/JavaScript\" src=\"" + afterbitRoot + "js_library/gestioneLivelli.js\"></script> "
	+ "";
document.write(js_lib_string);

function header(lang) {

    var staff = "STAFF";
    var servizi = "SERVIZI";
    var ufficio_virtuale = "UFFICIO<br />BREVETTI";
    var servizi_letterali = "SERVIZI<br />LETTERALI";

    if (lang == "" || lang == undefined) {
        lang = "ita";
    }
    var language = "";
    if (lang == "eng") {
        language = "inglese/";

        staff = "STAFF";
        servizi = "SERVICES";
        ufficio_virtuale = "PATENT<br />OFFICE";
        servizi_letterali = "SERVICES<br />LITERAL";

    }
    else if (lang == "fra") {
        language = "francese/";
        staff = "PERSONNEL";
        servizi = "SERVICES";
        ufficio_virtuale = "BUREAU<br />DES BREVETS";
        servizi_letterali =     "SERVICES<br />LITTÉRAIRES" ;
    }
    else {
        language = "";
    }
    document.write(
    "<table style=\"width: 1004px; margin-left: auto; margin-right: auto\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	+ "		<tr>"
	+ "			<td><div><a href=\"" + siteRoot + language + "index.html\" title=\"Studio Celsus\"><img src=\"" + siteRoot + "images/header_02.jpg\" style=\"width: 390px; height: 63px; border:0px\" alt=\"Studio Celsus\" /></a></div></td>"
	+ "			<td style=\"width: 614px; height: 63px; background-image: url(" + siteRoot + "images/bg_topmenu.jpg); background-repeat: repeat-x\" valign=\"top\">"
	+ "             <div style=\"text-align:center; margin-top:5px\">"
	+ "					<a href=\"javascript:set_lang('ita')\" title=\"ITA\" style=\"color: #1B1B1B\">ITA</a> | <a href=\"javascript:set_lang('eng')\" title=\"ENG\""
	+ "						style=\"color: #1B1B1B\">ENG</a> | <a href=\"javascript:set_lang('fra')\" title=\"FRA\" style=\"color: #1B1B1B\">FRA</a>"
	+ "					</div>"
	+ "				<table style=\"height: 33px; margin-top: 8px\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	+ "					<tr>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "staff/index.html\" title=\"" + staff + "\" class=\"top_menu\">" + staff + "</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\">"
	+ "							<div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "servizi/index.html\" title=\"" + servizi + "\" class=\"top_menu\">" + servizi + "</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "news/index.html\" title=\"NEWS\" class=\"top_menu\">NEWS</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "ufficio/index.html\" title=\"" + ufficio_virtuale + "\" class=\"top_menu\">" + ufficio_virtuale + "</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "sponsor/index.html\" title=\"INTERNET\" class=\"top_menu\">INTERNET</a></div></td>"
    + "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "letterarie/index.html\" title=\"" + servizi_letterali + "\" class=\"top_menu\">" + servizi_letterali + "</a></div></td>"
	+ "					</tr>"
	+ "				</table>"
	+ "			</td>"
	+ "		</tr>"
	+ "		<tr>"
	+ "			<td colspan=\"2\"><div><img src=\"" + siteRoot + "images/header_05_" + lang + ".jpg\" style=\"width: 1004px; height: 164px\" alt=\"\" /></div></td>"
	+ "		</tr>"
	+ "		<tr>"
	+ "			<td colspan=\"2\" style=\"width: 1004px; height: 37px; background-image: url(" + siteRoot + "images/bg_marquee.jpg); background-repeat: repeat-x\">"
	+ "             <marquee align=\"middle\" direction=\"left\" scrolldelay=\"100\"><span id=\"testoscorrevole_txt\" ></span></marquee>"
	+ "			</td>"
	+ "		</tr>"
	+ "	</table>"
    );
}

function set_lang(lang) {
    var url = document.location.href;
    var language = "";
    if (lang == "eng") {
        language = "inglese/";
    }
    else if (lang == "fra") {
        language = "francese/";
    }
    else {
        language = "";
    }


    if ((url.indexOf("guestbook.aspx") != -1) || (url.indexOf("contatti.aspx") != -1)) {
        if (url.indexOf("lang=") != -1) {
            url = url.replace("lang=ita", "lang=" + lang).replace("lang=eng", "lang=" + lang).replace("lang=fra", "lang=" + lang);
        }
        else {
            url = url + "?lang=" + lang;
        }

    }
    else {
        if (url.indexOf("lang=") != -1) {
            url = url.replace("lang=ita", "lang=" + lang).replace("lang=eng", "lang=" + lang).replace("lang=fra", "lang=" + lang);
        }
        else {

            if ((url.indexOf("/inglese/") != -1) || (url.indexOf("/francese/") != -1)) {

                url = url = url.replace("/inglese/", "/" + language);
                url = url.replace("/francese/", "/" + language);
            }
            else {
                url = url.replace(siteRoot, "");
                url = siteRoot + language + url;
            }
        }
    }
    document.location.href = url;
}


function header_ufficio_virtuale(lang) {

    var brevetti = "BREVETTI";
    var marchi = "MARCHI";
    var prototipi = "PROTOTIPI";
    var gestioni = "GESTIONI";

    if (lang == "" || lang == undefined) {
        lang = "ita";
    }
    var language = "";
    if (lang == "eng") {
        language = "inglese/";

        brevetti = "PATENT";
        marchi = "TRADEMARK";
        prototipi = "PROTOTYPES";
        gestioni = "PATENT<br />SALE";

    }
    else if (lang == "fra") {
        language = "francese/";
        brevetti = "BREVETS";
        marchi = "MARQUES";
        prototipi = "PROTOTYPES";
        gestioni = "GESTION<br />DES BREVETS";
    }
    else {
        language = "";
    }
    document.write(
    "<table style=\"width: 1004px; margin-left: auto; margin-right: auto\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	+ "		<tr>"
	+ "			<td><div><a href=\"" + siteRoot + language + "index.html\" title=\"Studio Celsus\"><img src=\"" + siteRoot + "images/header_02.jpg\" style=\"width: 390px; height: 63px; border:0px\" alt=\"Studio Celsus\" /></a></div></td>"
	+ "			<td style=\"width: 614px; height: 63px; background-image: url(" + siteRoot + "images/bg_topmenu.jpg); background-repeat: repeat-x\" valign=\"top\">"
	+ "             <div style=\"text-align:center; margin-top:5px\">"
	+ "					<a href=\"javascript:set_lang('ita')\" title=\"ITA\" style=\"color: #1B1B1B\">ITA</a> | <a href=\"javascript:set_lang('eng')\" title=\"ENG\""
	+ "						style=\"color: #1B1B1B\">ENG</a> | <a href=\"javascript:set_lang('fra')\" title=\"FRA\" style=\"color: #1B1B1B\">FRA</a>"
	+ "					</div>"
	+ "				<table style=\"height: 33px; margin-top: 8px\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	+ "					<tr>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "brevetti/index.html\" title=\"" + brevetti + "\" class=\"top_menu\">" + brevetti + "</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\">"
	+ "							<div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "marchi/index.html\" title=\"" + marchi + "\" class=\"top_menu\">" + marchi + "</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "copyright/index.html\" title=\"COPYRIGHT\" class=\"top_menu\">COPYRIGHT</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "prototipi/index.html\" title=\"" + prototipi + "\" class=\"top_menu\">" + prototipi + "</a></div></td>"
	+ "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "gestioni/index.html\" title=\"" + gestioni + "\" class=\"top_menu\">" + gestioni + "</a></div></td>"
    + "						<td style=\"width: 3px; height: 33px\"><div><img src=\"" + siteRoot + "images/spacer.gif\" alt=\"\" style=\"width: 3px; height: 33px\" /></div></td>"
	+ "						<td style=\"background-image: url(" + siteRoot + "images/bg_topmenu_voce.jpg); background-repeat: no-repeat; height: 33px; width: 97px; text-align: center\">"
	+ "							<div><a href=\"" + siteRoot + language + "index.html\" title=\"HOME\" class=\"top_menu\">HOME</a></div></td>"
	+ "					</tr>"
	+ "				</table>"
	+ "			</td>"
	+ "		</tr>"
	+ "		<tr>"
	+ "			<td colspan=\"2\"><div><img src=\"" + siteRoot + "images/header_05_"+lang+".jpg\" style=\"width: 1004px; height: 164px\" alt=\"\" /></div></td>"
	+ "		</tr>"
	+ "		<tr>"
	+ "			<td colspan=\"2\" style=\"width: 1004px; height: 37px; background-image: url(" + siteRoot + "images/bg_marquee.jpg); background-repeat: repeat-x\">"
	+ "             <marquee align=\"middle\" direction=\"left\" scrolldelay=\"100\"><span id=\"testoscorrevole_txt\" ></span></marquee>"
	+ "			</td>"
	+ "		</tr>"
	+ "	</table>"
    );
}

function footer() {

    document.write(
    "<table style=\"width: 1004px; height:47px; margin-left: auto; margin-right: auto\" border=\"0\" cellpadding=\"0\"cellspacing=\"0\">"
	+ "		<tr>"
	+ "			<td style=\"background-color: #E3E3E3\">"
	+ "			<div class=\"footer\" style=\"margin-left:5px\">(C) Copyright 2008 by Studio Celsus - P. Iva 01327960504 - Ponsacco (Pisa)</div>"
	+ "			</td>"
	+ "			<td style=\"background-color: #E3E3E3; text-align:right;\">"
	+ "			<div class=\"footer\" style=\"margin-right:5px\">Tutti i marchi esposti appartengo ai rispettivi proprietari - credits</div>"
	+ "			</td>"
	+ "		</tr>"
	+ "	</table>"
    );
}

// gestione marquee...
function get_marquee(lang) {
    // ricava e stampa l'elenco dei messaggi...
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        // il browser non supporta xmlHttpRequest
        return;
    }
    else {
        var url = siteRoot + "servizio.aspx?lang=" + lang + "&sid=" + Math.random();

        xmlHttp.onreadystatechange = marquee;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
}
function marquee() {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
        var text = xmlHttp.responseText;
        document.getElementById("testoscorrevole_txt").innerHTML = text;

    }
}

// gestione messaggio promozionale...
function get_promotional(lang) {
    // ricava e stampa l'elenco dei messaggi...
    xmlHttp1 = GetXmlHttpObject();
    if (xmlHttp1 == null) {
        // il browser non supporta xmlHttpRequest
        return;
    }
    else {
        var url = siteRoot + "messaggio_promozionale.aspx?lang=" + lang + "&sid=" + Math.random();
        xmlHttp1.onreadystatechange = promotional;
        xmlHttp1.open("GET", url, true);
        xmlHttp1.send(null);
    }
}

function promotional() {
    if (xmlHttp1.readyState == 4 || xmlHttp.readyState == "complete") {
        var text = xmlHttp1.responseText;
        document.getElementById("messaggio_promozionale").innerHTML = text;
        showmsg();
    }
}

// muove il messaggio promozionale al centro della pagina....
function showmsg() {
    document.getElementById("messaggio_promozionale").style["position"] = "absolute";
    getPageSize();
    var layx = getLayWidth("messaggio_promozionale");
    var layy = getLayHeight("messaggio_promozionale");
    moveLayTo("messaggio_promozionale", 0, 0);
    var meta_pag_y = parseInt((page.Y - layy) / 2);
    window.setTimeout("show_lay('messaggio_promozionale')", 1000);
    for (var i = 0; i < meta_pag_y; i++) {
        window.setTimeout("moveLayTo('messaggio_promozionale', 0, " + i + ")", 1000 + (i * 10));
    }
    var meta_pag_x = parseInt((page.X - layx) / 2);
    for (var i2 = 0; i2 < meta_pag_x; i2++) {
        window.setTimeout("moveLayTo('messaggio_promozionale'," + i2 + ", " + i + ")", 1000 + (i * 10) + (i2 * 10));
    }
}	