var FontDimension=liesCookie('FriadentFontSize');
function liesCookie(name) {
    if (navigator.cookieEnabled == true){
       var keks = document.cookie;
       // Anfangsposition des Name=Wert-Paars suchen
       var posName = keks.indexOf("; " + name + "=");
       
       if (posName == -1) {
          // vielleicht war's der erste Name in der Liste?
          if (keks.indexOf(name + "=") == 0) posName = 0;
          // nein? dann abbrechen mit Rückgabewert null
          else return null;
       }

       // Anfangs- und Endposition des Krümelwerts suchen
       var wertAnfang = keks.indexOf("=", posName)+1;
       var wertEnde = keks.indexOf(";", posName+1);
       if (wertEnde == -1) wertEnde = keks.length;
       // Krümelwert auslesen und zurückgeben
       var wert = keks.substring(wertAnfang, wertEnde);
       var FontDimension=wert;    
       if(FontDimension==""){
            var FontDimension= "normal";
       }

    return FontDimension;
       
    }
}
// Diese Funktion korrigiert den Datums-Bug von
// Netscape/Mac und liefert den korrekten GMTString:
function fixedGMTString(datum){
   var damals=new Date(1970,0,1,12);
   if (damals.toGMTString().indexOf("02")>0) {
      datum.setTime(datum.getTime()-1000*60*60*24);
   }
   return datum.toGMTString();
}
function schreibCookie(name,wert,verfall,pfad,dom,secure) {
   neuerKeks = name + "=" + escape(wert);
   if (verfall)
      neuerKeks += "; expires=" + fixedGMTString(verfall);
   if (pfad) neuerKeks += "; path=/";
   if (dom) neuerKeks += "; domain=" + dom;
   if (secure) neuerKeks += "; secure";
   document.cookie = neuerKeks;
}
function IniFontSize(){
    if(FontDimension == "middle"){
        var FontSize = "18px"
    }
    else if(FontDimension == "big"){
        var FontSize = "20px"
    }
    else{
        FontDimension = "normal";
        var FontSize = "16px"
    }
    obj = document.getElementById("HtmlBody");
    obj.style.fontSize = FontSize;
    schreibCookie('FriadentFontSize',FontDimension,0,'/'); 
}

function checkemail(s)
{
    var a = false;
    var res = false;
    if(typeof(RegExp) == 'function')
    {
        var b = new RegExp('abc');
        if(b.test('abc') == true){a = true;}
    }
    if(a == true)
    {
        reg = new RegExp('^([a-zA-Z0-9\-\.\_]+)'+'(\@)([a-zA-Z0-9\-\.]+)'+'(\.)([a-zA-Z]{2,4})$');
        res = (reg.test(s));
    }
    else
    {
        res = (s.search('@') >= 1 && s.lastIndexOf('.') > s.search('@') && s.lastIndexOf('.') >= s.length-5)
    }
    return(res);
}

function bookmarksite(){
    if (document.all)
    window.external.AddFavorite(location.href, document.title);
    }

function checkForm() {
    var send = 1;
    var missing_fields = [];
    
    // Name
    if (document.contact.author.value.length == 0) {
        document.contact.author.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.author.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.author.focus();
            send = 0;
        }
    } else {
        document.contact.author.style.backgroundColor='#ffffff';
    }
    
    // email
    if (document.contact.email.value.length == 0 || !checkemail(document.contact.email.value)) {
        document.contact.email.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.email.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.email.focus();
            send = 0;
        }
    } else {
        document.contact.email.style.backgroundColor='#ffffff';
    }    
    // Message
    if (document.contact.message.value.length == 0) {
        document.contact.message.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.message.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.message.focus();
            send = 0;
        }
    } else {
        document.contact.message.style.backgroundColor='#ffffff';
    }    
    if(send == 1) {
        return true;
    } else {
        var messages = {
            DEU: "Diese Felder müssen ausgefüllt werden: ",
            ENG: "These fields are required: ",
            ESN: "Estos campos deben rellenarse obligatoriamente: ",
            FRA: "Ces données doivent être indiquées: ",
            ITA: "Questi dati sono obbligatori: ",
            NLD: "Deze gegevens zijn nodig voor de bewerking: ",
            RUS: "Эти данные необходимыдля обработки: "
        }
        var message = messages[document.contact.language.value]+"\n"+missing_fields.join(", ");
        alert(message);
        return false;
    }
}
function bild_vergroessern(image, wid, hgt, txt) {
    sw=(screen.width-wid)/2;
    sh=(screen.height-hgt)/2;
    hgt=parseInt(hgt);
    hgt=hgt+100;
    newwin=window.open('','newwin','width='+wid+',height='+hgt+',resizable=yes,scrollbars=no,menubars=0,toolbars=0,location=0,directories=0,status=0,top='+sh+',left='+sw+'');
    newwin.document.open();
    newwin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n');
    newwin.document.write('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
    newwin.document.write('\n<html>\n<head><!-- PageID 453 - published by RedDot 9 - 9.0.0.33 - 31309 -->\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n');
    newwin.document.write('<meta http-equiv="Imagetoolbar" content="no" />\n');
    newwin.document.write('<title>Detailansicht</title>\n');
    newwin.document.write('</head>');
    newwin.document.write('<body style="margin:0;padding:0">\n<table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><img src="'+image+'" /></td></tr><tr><td align="left" valign="middle"><font face="arial, verdana" size="2">' + txt + '</font></td></tr></table>');
    newwin.document.write('\n</body></html>');
    newwin.document.close();
    newwin.focus();
}

function swapLink(att1, att2, att3) {}


function initzeile () {
    var tables = document.getElementsByTagName("table");
    for (var i = 0; i < tables.length; i++) {
      if (tables[i].className.match(/tablebg/)) {
        tablebg(tables[i]);
      }
    }
      }
      function tablebg (table) {
    var current = "trgerade";
    var trs = table.getElementsByTagName("tr");
    for (var i = 0; i < trs.length; i++) {
      trs[i].className += " " + current;
      current = current == "trungerade" ? "trgerade" : "trungerade";
    }
}



function T2ClickTracker(Key){
            var eURI = encodeURI("tc3_ClickTrackerAPI.php?eTrackerKey=" + Key);
            http_request = false;
        //    alert(eURI);
        //    Check = prompt("Geben Sie Ihr Passwort fuer diese Seite ein", eURI)
             if (window.XMLHttpRequest) { // Mozilla, Safari,...
                 http_request = new XMLHttpRequest();
             } else if (window.ActiveXObject) { // IE
                 try {
                     http_request = new ActiveXObject("Msxml2.XMLHTTP");
                 } 
                 catch (e) {
                     try {
                         http_request = new ActiveXObject("Microsoft.XMLHTTP");
                     } 
                     catch (e) {}
                 }
             }
            
             if (!http_request) {
        //        alert('Giving up :( Cannot create an XMLHTTP instance');
                 return false;
             }
             http_request.onreadystatechange = alertContents;
             http_request.open('GET', eURI, true);
             http_request.send(null);
}

function alertContents() {
            if (http_request.readyState == 4) {
                if (http_request.status == 200) {
        //            alert(http_request.responseText);
                } else {
        //            alert('Bei dem Request ist ein Problem aufgetreten.');
        //            alert(http_request.responseText);
                }
            }
            else{
        //        alert(http_request.readyState);
            }    
}

function checkForm_pa() {
    var send = 1;
    var missing_fields = [];
    
    // Title
    if (document.contact.Title.value.length == 0) {
        document.contact.Title.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.Title.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.Title.focus();
            send = 0;
        }
    } else {
        document.contact.Title.style.backgroundColor='#ffffff';
    }
    
   
    // Authors
    if (document.contact.Authors.value.length == 0) {
        document.contact.Authors.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.Authors.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.Authors.focus();
            send = 0;
        }
    } else {
        document.contact.Authors.style.backgroundColor='#ffffff';
    } 
     // Language
    
    if (document.contact.AbstractAndDeadline.value.length == 0) {
        document.contact.AbstractAndDeadline.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.AbstractAndDeadline.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.AbstractAndDeadline.focus();
            send = 0;
        }
    } else {
        document.contact.AbstractAndDeadline.style.backgroundColor='#ffffff';
    } 
    
          // AcademicTitle
    if (document.contact.AcademicTitle.value.length == 0) {
        document.contact.AcademicTitle.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.AcademicTitle.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.AcademicTitle.focus();
            send = 0;
        }
    } else {
        document.contact.AcademicTitle.style.backgroundColor='#ffffff';
    }
    
    
    
     // FirstName
    if (document.contact.FirstName.value.length == 0) {
        document.contact.FirstName.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.FirstName.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.FirstName.focus();
            send = 0;
        }
    } else {
        document.contact.FirstName.style.backgroundColor='#ffffff';
    }
    
     // LastName
    if (document.contact.LastName.value.length == 0) {
        document.contact.LastName.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.LastName.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.LastName.focus();
            send = 0;
        }
    } else {
        document.contact.LastName.style.backgroundColor='#ffffff';
    }
    
    // StreetHousePOBox
    if (document.contact.StreetHousePOBox.value.length == 0) {
        document.contact.StreetHousePOBox.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.StreetHousePOBox.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.StreetHousePOBox.focus();
            send = 0;
        }
    } else {
        document.contact.StreetHousePOBox.style.backgroundColor='#ffffff';
    }
    
    // ZIPCode
    if (document.contact.ZIPCode.value.length == 0) {
        document.contact.ZIPCode.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.ZIPCode.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.ZIPCode.focus();
            send = 0;
        }
    } else {
        document.contact.ZIPCode.style.backgroundColor='#ffffff';
    }
    
     // City
    if (document.contact.City.value.length == 0) {
        document.contact.City.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.City.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.City.focus();
            send = 0;
        }
    } else {
        document.contact.City.style.backgroundColor='#ffffff';
    }
    
     // Country
    if (document.contact.Country.value.length == 0) {
        document.contact.Country.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.Country.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.Country.focus();
            send = 0;
        }
    } else {
        document.contact.Country.style.backgroundColor='#ffffff';
    }
    
    // Phone
    if (document.contact.Phone.value.length == 0) {
        document.contact.Phone.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.Phone.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.Phone.focus();
            send = 0;
        }
    } else {
        document.contact.Phone.style.backgroundColor='#ffffff';
    }
    
       
    
     // email
    if (document.contact.email.value.length == 0 || !checkemail(document.contact.email.value)) {
        document.contact.email.style.backgroundColor='#F2EDD0';
        missing_fields.push(document.contact.email.previousSibling.previousSibling.firstChild.nodeValue.slice(0, -1));
        if (send==1) {
            document.contact.email.focus();
            send = 0;
        }
    } else {
        document.contact.email.style.backgroundColor='#ffffff';
    }    
    
    
       
    if(send == 1) {
        return true;
    } else {
        var messages = {
            DEU: "Please fill in the highlighted input fields.",
            ENG: "These fields are required: ",
            ESN: "Estos campos deben rellenarse obligatoriamente: ",
            FRA: "Ces données doivent être indiquées: ",
            ITA: "Questi dati sono obbligatori: ",
            NLD: "Deze gegevens zijn nodig voor de bewerking: ",
            RUS: "Questi dati sono obbligatori: "        }
        var message = messages[document.contact.language.value];
        alert(message);
        return false;
    }
}
