﻿function PrintContent() {

    var WindowObject = window.open('../Shop/ShowWebShopRoba.aspx', "TrackHistoryData",
                              "TrackHistoryData", "toolbars=no,scrollbars=yes,status=no,resizable=no");


    WindowObject.focus();
    /*WindowObject.print();  samo za Mozillu*/

}
function PrintNarudzba0() {
    var WindowObject = window.open('../Shop/ShowNarudzba.aspx', "TrackHistoryData", "TrackHistoryData", "toolbars=no,scrollbars=yes,status=no,resizable=no");
    WindowObject.focus();
}

function PrintNarudzba() {
    var WindowObject = window.open('../Shop/Narudzba.aspx', "Narudzba");
    WindowObject.focus();
}

function PrintNarudzbaProvjera() {
    //mora biti upisan mail ili naziv firme
    if ((document.getElementById('telefon1').value) != '' || (document.getElementById('mail1').value) != '') 
    {
    var WindowObject = window.open('../Shop/Narudzba.aspx', "Narudzba");
    WindowObject.focus();
    }
}


function PrintNarudzba2() {
    var WindowObject = window.open('../Shop/Narudzba1.aspx', "Narudzba1");
    WindowObject.focus();
}



function loadImages() {
    if (document.getElementById) {
        document.getElementById('hidepage').style.visibility = 'hidden';
    }
    //var str=document.location.toString();
    var str = document.referrer;

    //window.alert(str.substring(0,19));  //ono što je upisano  - NE
    //window.alert(window.location.href);  // NE
    //window.alert(document.referrer);   /DA!
    

    
}


function getElementLeft(elm) {
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while (elm != null) {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) {
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while (elm != null) {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}


function downloadFile(nodeId) {

    window.location.search = '';
    var tree = igtree_getTreeById("MyWebTree2");
    var node = tree.getSelectedNode();
    if (navigator.appName == "Netscape") {
        if (node.getTag().length > 2) {
            window.open("Handler.ashx?filename=" + node.getTag(), "DescriptiveWindowName", "width=420,height=230,resizable,scrollbars=yes,status=1");
        }
    }
    else {
        downloadFileLink.href = "Handler.ashx?filename=" + node.getTag();
        downloadFileLink.style.display = 'block';
        downloadFileLink.style.display.visibility = 'hidden';
        if (node.getTag().length > 2) {
            downloadFileLink.click();
        }
    }
}

function downloadfile2(naziv) {
    if (navigator.appName == "Netscape") {
        window.open("Handler.ashx?filename=" + naziv, "DescriptiveWindowName", "width=420,height=230,resizable,scrollbars=yes,status=1");
    }
    else {
        downloadFileLink.href = "Handler.ashx?filename=" + naziv;
        downloadFileLink.style.display = 'block';
        downloadFileLink.style.display.visibility = 'hidden';
        downloadFileLink.click();
    }
}


function Large(obj) {
    var imgbox = document.getElementById("imgbox");
    imgbox.style.visibility = 'visible';
    var img = document.createElement("img");
    img.src = obj.src;
    //img.style.width='200px';
    //img.style.height='200px';

    if (img.addEventListener) {
        img.addEventListener('mouseout', Out, false);
    } else {
        img.attachEvent('onmouseout', Out);
    }
    imgbox.innerHTML = '';
    imgbox.appendChild(img);
    imgbox.style.left = (getElementLeft(obj) - 50) + 'px';
    imgbox.style.top = (getElementTop(obj) - 50) + 'px';
}

function Out() {
    document.getElementById("imgbox").style.visibility = 'hidden';
}

function HideModalSlika() {
    var modal = $find('ModalSlika');
    modal.hide();
}
function HideModalInformacije() {
    var modal = $find('ModalInformacije');
    modal.hide();
}
function HideModalMail() {
    var modal = $find('ModalMail');
    modal.hide();
}
function HideModalPoruka() {
    var modal = $find('ModalPoruka');
    modal.hide();
}

//<ClientSideEvents NodeClick="NodeClick" /> isključeno 21.07.2010.
function NodeClick(treeName, NodeId, button) {
    var node = igtree_getNodeById(NodeId);
    /*window.alert(node.getDataKey());*/
    if ((button == 1))
     {
         var child = node.getFirstChild();
         if (node.WebTree && node.getChildNodes().length > 0) node.setExpanded(!node.getExpanded());
                  
         window.location.search = ('?g=' + node.getDataKey());
    }
    
    /*treeName.CancelPostBack = true;*/
    return false;
}

function NodeClickPro(treeName, NodeId) {
    var node = igtree_getNodeById(NodeId);
    /*window.alert(node.getDataKey());*/
    window.location.search = ('?p=' + node.getDataKey());
    treeName.CancelPostBack = true;
    return false;
}

function UltraWebTree1_NodeClick(treeName, NodeId) {



    var node = igtree_getNodeById(NodeId);
   
    var child = node.getFirstChild();
    if (child != null) {
        treeName.CancelPostBack = true;
    }
    if (node.WebTree && node.getChildNodes().length > 0) node.setExpanded(!node.getExpanded());
    return false;
}

function UltraWebTreeStari_NodeClick(treeId, nodeId) {
    var tree1 = igtree_getTreeById(treeId);
    var Nodeclick = igtree_getNodeById(nodeId);
    var child = Nodeclick.getFirstChild();
    if (child != null) {
        //ako ima djecu ne radi postback i širi
        tree1.CancelPostBack = true;
        Nodeclick.setExpanded(true);
        /*alert("No postback is triggered from this node");*/
    }
}



function f() {
    var hash = location.hash;
    showtime = setInterval(function() {
        if ((location.hash != hash) && (location.hash == "")) {
            //ImageButton12 je ok jer je vidljiv od svugdje
            //window.alert(hash);
            window.location = location;
            //var dok = document.getElementById('ImageButton12');/
                clearInterval(showtime);
        }
    }, 100);
}


/*  PRIMJER ZA SKROLANJE USPOREDBE

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Mr J | http://www.huntingground.net/ */

scrollStep = 10

timerLeft = ""
timerRight = ""

function toLeft(id) {
    document.getElementById(id).scrollLeft = 0
}

function scrollDivLeft(id) {
    clearTimeout(timerRight)
    document.getElementById(id).scrollLeft += scrollStep
    timerRight = setTimeout("scrollDivLeft('" + id + "')", 10)
}

function scrollDivRight(id) {
    clearTimeout(timerLeft)
    document.getElementById(id).scrollLeft -= scrollStep
    timerLeft = setTimeout("scrollDivRight('" + id + "')", 10)
}

function toRight(id) {
    document.getElementById(id).scrollLeft = document.getElementById(id).scrollWidth
}

function stopMe() {
    clearTimeout(timerRight)
    clearTimeout(timerLeft)
}

