﻿
//function getDiv(div) {
//    var inp = document.getElementById('hemliginput');
//    var obj = document.getElementById(div);
//    inp.value = obj.innerHTML;
//    document.PDFForm.submit();
//}

function openNewWin(url) {

    var x = window.open(url, 'PDFWin', 'width=800,height=600,toolbar=1');
    x.focus();

}

function getDiv(div) {

    var obj         = document.getElementById(div);
    var objHTML     = obj.innerHTML;
    var firstResult = null;
    var counter = 0;
    
    if (objHTML.indexOf("PrintThis>") > 0)
        firstResult = objHTML.split("PrintThis>");
    else if (objHTML.indexOf("PrintThis\">") > 0)
        firstResult = objHTML.split("PrintThis\">");
        
    firstResult = firstResult[1];
    var result = firstResult.split("<PuffBodyArea");

    var myWindowToPrint = window.open('/ShowPdfDocument.aspx', 'PDFWindow', 'width=800,height=600,toolbar=0,scrollbars=-1,status=0,resizable=-1,location=0,directories=0');
    myWindowToPrint.document.forms[0].PfdData.value = result[0];
    myWindowToPrint.document.forms[0].submit();
    
//    myWindowToPrint.print();
//    myWindowToPrint.close();

//    inp.value = result[0];
//    document.PDFForm.submit();
}

function PrintDiv() {
    var myContentToPrint = document.getElementById("dv01");
}

function DoTheChoka(myWindowToPrint, formData) {

    var form = myWindowToPrint.document.forms[0];

    alert(form);
    if (form) {
    
        form.PfdData.value = formData;
        form.submit();
    }
    else {
        return false;
    }
    return true;
}


var zCount = 0;
function ShowTab(tabName) {
    //            //hämta objectet
    var tab = document.getElementById(tabName);
    var activeLink = document.getElementById("OrderLink");
    var inactiveLink = document.getElementById("DownloadLink");

    if (tabName.toString().toLowerCase().startsWith("download")) {

        document.getElementById("DownloadBlankett").style.display = "block";
        document.getElementById("OrderBlankett").style.display = "none";

        document.getElementById("MainBody").style.paddingBottom = "140px";
        activeLink = document.getElementById("DownloadLink");
        inactiveLink = document.getElementById("OrderLink");


    }
    else {
        
        document.getElementById("DownloadBlankett").style.display = "none";
        document.getElementById("OrderBlankett").style.display = "block";

        document.getElementById("MainBody").style.paddingBottom = "340px";
        inactiveLink = document.getElementById("DownloadLink");
        activeLink = document.getElementById("OrderLink");
    
    }

    activeLink.className = "MenuItemSelected";
    inactiveLink.className = "MenuItem";
    
    //            //öka vårt z-index, etta måste göras så att vi varje gång kommer ett steg högre än det förra zindexet.           
    //zCount++;
    //sätt vårt nya z-index på vår flik
    //tab.style.zIndex = zCount;
}


