/* Global javascript functions */


/* Print view function etc. */
function openDruck(url){
    //druck = window.open(url, "druck", "width=590,height=602,left=50,top=50,resizable=no,scrollbars=yes");
    druck = window.open(url, "druck", "width=615,height=640,left=50,top=50,resizable=no,scrollbars=yes");
    druck.focus();
}

/* Tooltip functions etc.*/
tt = null;
document.onmousemove = updateToolTip;
function updateToolTip(e) {
    if (document.documentElement && document.documentElement.scrollTop)    {
        theTop = document.documentElement.scrollTop;
    } else if (document.body) {
        theTop = document.body.scrollTop
    }
    x = (document.all) ? window.event.clientX + document.body.scrollLeft : e.pageX;
    y = (document.all) ? window.event.clientY + theTop  : e.pageY;
    if (tt != null) {
        tt.style.left = (x + 20 - tt.leftPos) + "px";
        //window.status = document.documentElement.scrollTop;
        //window.status = tt.style.left;
        tt.style.top     = (y + 0) + "px";
    }
}
function showToolTip(id,pos) {
    tt = document.getElementById(id);
    tt.leftPos =(pos == "left")?300:0;
    tt.style.display = "block"
}
function hideToolTip() {
    tt.style.display = "none";
}

function setPublicationPageNumber(pageNumber,pageNumberBlock) {
//    var tst = document.pubSearch.elements["user_publications[pageNumber]"].value;
    document.pubSearch.elements["user_publications[pageNumber]"].value = pageNumber;
    document.pubSearch.elements["user_publications[pageNumberBlock]"].value = pageNumberBlock;
    document.pubSearch.submit();
}

function setDealPageNumber(pageNumber,pageNumberBlock) {
    document.dealList.elements["user_deals[pageNumber]"].value = pageNumber;
    document.dealList.elements["user_deals[pageNumberBlock]"].value = pageNumberBlock;
    document.dealList.submit();
}

/*
    Checks the required fields in the contact form
*/
function checkContact(lang) {
    var error = '';
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
    document.getElementById("subject").className="noError";
    document.getElementById("name").className="noError";
    document.getElementById("email").className="noError";
    if(document.contact.subject.value == "")  {
        document.getElementById("subject").className="error";
        error += (lang == 1)?"Bitte wählen Sie den Betreff.<br>":"Please choose a subject.<br>";
        document.contact.subject.focus();
    }
    if(document.contact.name.value == "")  {
        document.getElementById("name").className="error";
        error += (lang == 1)?"Bitte geben Sie Ihren Namen an.<br>":"Please enter your name.<br>";
        document.contact.name.focus();
    }
    if(!filter.test(document.contact.email.value)){
        document.getElementById("email").className="error";
        error += (lang == 1)?"Bitte geben Sie Ihre gültige E-Mail Adresse an.<br>":"Please enter your valid e-mail adress.<br>";
        document.contact.email.focus();
    }
    if(document.contact.captureCode.value == "")  {
        document.getElementById("captureCode").className="error";
        error += (lang == 1)?"Bitte geben Sie das Prüfwort auf dem Bild an.<br>":"Please enter the word displayed on the picture.<br>";
        document.contact.captureCode.focus();
    }
    if (error) {
        document.getElementById("errorMessage").innerHTML = '<span class="error">'+error+'</span><br>';
    } else {
        document.contact.submit();
    }
}

function checkSubscribe(lang) {
    var error = '';
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
    document.getElementById("namelabel").className="labelContent";
    document.getElementById("companylabel").className="labelContent";
    document.getElementById("emaillabel").className="labelContent";

    if(!(document.publicationsSubscribe.checkCorporate.checked || document.publicationsSubscribe.checkFinancial.checked || document.publicationsSubscribe.checkCompetition.checked || document.publicationsSubscribe.checkIt.checked || document.publicationsSubscribe.checkLitigation.checked || document.publicationsSubscribe.checkTax.checked))  {
        error += (lang == 1)?"Bitte wählen Sie mindestens einen Bereich aus.<br>":"Please choose at least one expertise.<br>";
    }

    if(document.publicationsSubscribe.publicationsSubscribeName.value == "")  {
        document.getElementById("namelabel").className="labelContenterror";
        error += (lang == 1)?"Bitte geben Sie Ihren Namen an.<br>":"Please enter your name.<br>";
         document.publicationsSubscribe.publicationsSubscribeName.focus();
    }
    if(document.publicationsSubscribe.publicationsSubscribeCompany.value == "")  {
        document.getElementById("companylabel").className="labelContenterror";
        error += (lang == 1)?"Bitte geben Sie Ihre Firma an.<br>":"Please enter your company.<br>";
         document.publicationsSubscribe.publicationsSubscribeCompany.focus();
    }
    if(!filter.test(document.publicationsSubscribe.publicationsSubscribeMail.value)){
        document.getElementById("emaillabel").className="labelContenterror";
        error += (lang == 1)?"Bitte geben Sie Ihre gültige Email Adresse an.<br>":"Please enter your valid e-mail adress.<br>";
        document.publicationsSubscribe.publicationsSubscribeMail.focus();
    }
    if (error) {
        document.getElementById("errorMessage").innerHTML = '<span class="error">'+error+'</span><br>';
    } else {
        document.publicationsSubscribe.submit();
    }
}

function writeHomeFlash() {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="919" height="239" id="menue_home_marwol" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="movie" value="flash/menue_home_marwol.swf?startId='+STARTID+'&pageId='+PAGEID+'&L='+L+'&xmlPath=flash/&imgPath=" />');
        document.write('<param name="quality" value="high" />');
        document.write('<param name="bgcolor" value="#ffffff" />');
        document.write('<embed src="flash/menue_home_marwol.swf?startId='+STARTID+'&pageId='+PAGEID+'&L='+L+'&xmlPath=flash/&imgPath=" quality="high" bgcolor="#ffffff" width="919" height="239" name="menue_home_marwol" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function writeSubFlash() {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="919" height="209" id="menue_home_new_marwol" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="movie" value="flash/menue_sub_marwol.swf?startId='+STARTID+'&pageID='+PAGEID+'&L='+L+'&xmlPath=flash/&imgPath=&linkLawyerData=lawyer.php%3FL%3D'+L+'%26uid%3D'+UID+'" />');
        document.write('<param name="quality" value="high" />');
        document.write('<param name="bgcolor" value="#ffffff" />');
        document.write('<embed src="flash/menue_sub_marwol.swf?startId='+STARTID+'&pageID='+PAGEID+'&L='+L+'&xmlPath=flash/&imgPath=&linkLawyerData=lawyer.php%3FL%3D'+L+'%26uid%3D'+UID+'" quality="high" bgcolor="#ffffff" width="919" height="209" name="menue_home_new_marwol" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function writeLawyerFlash() {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="539" height="75" id="menue_sub_marwol" align="middle">');
        document.write('<param name="allowScriptAccess" value="sameDomain" />');
        document.write('<param name="movie" value="flash/lawyers_slider.swf?xmlPath=flash/&linkLawyersData=lawyers.php%3Fuid%3D'+UID+'&L='+L+'" />');
        document.write('<param name="quality" value="high" />');
        document.write('<param name="bgcolor" value="#8ab387" />');
        document.write('<param name="allowScriptAccess" value="always" />');
        document.write('<embed src="flash/lawyers_slider.swf?xmlPath=flash/&linkLawyersData=lawyers.php%3Fuid%3D'+UID+'&L='+L+'" allowScriptAccess="always" quality="high" bgcolor="#8ab387" width="539" height="75" name="menue_sub_marwol" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) {
  newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
