﻿
//get element by id
function $(id) {
    //return
    return document.getElementById(id);
}

//add load event on page load
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

//set values
function setPostSendValue(type)
{
	//1.active Slovenia
    if (($("country").value == "0" && $("data").value == "0") || type==1)
	{
		$("__VIEWSTATE").value="/wEPDwULLTE3MTI1OTg2MTYPZBYCAgEPZBYCAgEPZBYCZg9kFhQCEw8QZGQWAWZkAhUPEGRkFgFmZAIbDw8WAh4HVmlzaWJsZWdkFgICBQ8QZGQWAQIBZAIdDw8WAh8AZ2RkAh8PZBYQAgEPDxYCHgRUZXh0ZWRkAgMPDxYCHwBoZGQCBQ8PFgQfAQUQVm5vcyBqZSBvYnZlemVuIB8AaGRkAgkPDxYCHwFlZGQCDQ8PFgIfAWVkZAIPDw8WAh8AaGRkAhEPDxYEHwEFEVZub3MgamUgb2J2ZXplbiAgHwBoZGQCGQ8PFgIfAWVkZAIjDw8WBB8BBQ9OYXphaiBuYSBzZXpuYW0fAGhkZAIlDw8WAh8AaGQWAgIFDzwrAAsBAA8WAh8AaGRkAikPDxYCHwBoZBYCAgUPDxYCHwFlZGQCKw9kFgQCAQ8QZGQWAWZkAg8PDxYCHwFlZGQCLg8PFgIfAGhkFgICBQ88KwALAQAPFgIfAGhkZGSP+ahYo6CYXWcTKnS8amSAitDjEg==";
		$("__EVENTVALIDATION").value = "/wEWDgLSrukMAtXVk8sIAsrVk8sIAsW6uaUEAoaZuIsOApmZuIsOApb2kuUCAsH7wvAPAtGU6J4DAs6U6J4DAs+U6J4DAtTU2coBApuDq+wDApuDn+wDOPgMboemVnO0VuntehT5uQ3LOQs=";
		$("tracenumber").name = "Track1:txtStPosiljke";
		$("type").value = "1";
    }

    //2.archive Slovenia
    if (($("country").value == "0" && $("data").value == "1") || type == 2)
	{
	    $("__VIEWSTATE").value = "/wEPDwULLTE3MTI1OTg2MTYPZBYCAgEPZBYCAgEPZBYCZg9kFhYCEw8QZGQWAQIBZAIVDxBkZBYBZmQCFw8PFgQeBFRleHQFQVphcmFkaSBrb2xpxI1pbmUgcG9kYXRrb3YgdiBBUkhJVlUgamUgbGFoa28gaXNrYW5qZSB1cG/FoWFzbmplbm8uHgdWaXNpYmxlZ2RkAhsPDxYCHwFnZBYCAgUPEGRkFgECAWQCHQ8PFgIfAWdkZAIfD2QWEAIBDw8WAh8AZWRkAgMPDxYCHwFoZGQCBQ8PFgQfAAUQVm5vcyBqZSBvYnZlemVuIB8BaGRkAgkPDxYCHwBlZGQCDQ8PFgIfAGVkZAIPDw8WAh8BaGRkAhEPDxYEHwAFEVZub3MgamUgb2J2ZXplbiAgHwFoZGQCGQ8PFgIfAGVkZAIjDw8WBB8ABQ9OYXphaiBuYSBzZXpuYW0fAWhkZAIlDw8WAh8BaGQWAgIFDzwrAAsBAA8WAh8BaGRkAikPZBYCAgUPDxYCHwBlZGQCKw9kFgQCAQ8QZGQWAWZkAg8PDxYCHwBlZGQCLg8PFgIfAWhkFgICBQ88KwALAQAPFgIfAWhkZGRin+80In+lzmTIGRM5f1lzRtkZFg==";
	    $("__EVENTVALIDATION").value = "/wEWDgKKi6kQAtXVk8sIAsrVk8sIAsW6uaUEAoaZuIsOApmZuIsOApb2kuUCAsH7wvAPAtGU6J4DAs6U6J4DAs+U6J4DAtTU2coBApuDq+wDApuDn+wD1orVqxt5wdcdMzNE4qKZ9oynmUc=";
	    $("tracenumber").name = "Track1:txtStPosiljke";
	    $("type").value = "2";
    }

    //3.active other
    if (($("country").value == "1" && $("data").value == "0") || type == 3)
    {
        $("__VIEWSTATE").value = "/wEPDwULLTE3MTI1OTg2MTYPZBYCAgEPZBYCAgEPZBYCZg9kFhgCEw8QZGQWAWZkAhUPEGRkFgECAWQCFw8PFgQeBFRleHQFQVphcmFkaSBrb2xpxI1pbmUgcG9kYXRrb3YgdiBBUkhJVlUgamUgbGFoa28gaXNrYW5qZSB1cG/FoWFzbmplbm8uHgdWaXNpYmxlaGRkAhsPDxYCHwFoZBYCAgUPEGRkFgFmZAIdD2QWAgIDDw8WAh8AZWRkAh8PZBYQAgEPDxYCHwBlZGQCAw8PFgIfAWhkZAIFDw8WBB8ABRBWbm9zIGplIG9idmV6ZW4gHwFoZGQCCQ8PFgIfAGVkZAINDw8WAh8AZWRkAg8PDxYCHwFoZGQCEQ8PFgQfAAURVm5vcyBqZSBvYnZlemVuICAfAWhkZAIZDw8WAh8AZWRkAiMPDxYEHwAFD05hemFqIG5hIHNlem5hbR8BaGRkAiUPDxYCHwFoZBYCAgUPPCsACwEADxYCHwFnZGQCKQ8PFgIfAWdkZAIrD2QWBAIBDxBkZBYBZmQCDw8PFgIfAGVkZAIuDw8WAh8BaGQWAgIFDzwrAAsBAA8WAh8BaGRkAjAPDxYEHwAFEU5lIG5hamRlbSB6YXBpc2EuHwFnZGRkglkah+T8/88AJ7aNElosneODx8w=";
        $("__EVENTVALIDATION").value = "/wEWCgLRsZGHCALV1ZPLCALK1ZPLCALFurmlBAKGmbiLDgKZmbiLDgKW9pLlAgLL3sHqBwLUwPYqAuGX++4Bq4ioWL5BJGK9V87hjH0qtHKOR08=";
        $("tracenumber").name = "Track1:txtRegODMednarodni";
        $("type").value = "3";
    }

    //4.archive other
    if (($("country").value == "1" && $("data").value == "1") || type == 4)
    {
        $("__VIEWSTATE").value = "/wEPDwULLTE3MTI1OTg2MTYPZBYCAgEPZBYCAgEPZBYCZg9kFhgCEw8QZGQWAQIBZAIVDxBkZBYBAgFkAhcPDxYEHgRUZXh0BUFaYXJhZGkga29sacSNaW5lIHBvZGF0a292IHYgQVJISVZVIGplIGxhaGtvIGlza2FuamUgdXBvxaFhc25qZW5vLh4HVmlzaWJsZWdkZAIbD2QWAgIFDxBkZBYBZmQCHQ9kFgICAw8PFgIfAGVkZAIfD2QWEAIBDw8WAh8AZWRkAgMPDxYCHwFoZGQCBQ8PFgQfAAUQVm5vcyBqZSBvYnZlemVuIB8BaGRkAgkPDxYCHwBlZGQCDQ8PFgIfAGVkZAIPDw8WAh8BaGRkAhEPDxYEHwAFEVZub3MgamUgb2J2ZXplbiAgHwFoZGQCGQ8PFgIfAGVkZAIjDw8WBB8ABQ9OYXphaiBuYSBzZXpuYW0fAWhkZAIlDw8WAh8BaGQWAgIFDzwrAAsBAA8WAh8BZ2RkAikPDxYCHwFnZGQCKw9kFgQCAQ8QZGQWAWZkAg8PDxYCHwBlZGQCLg8PFgIfAWhkFgICBQ88KwALAQAPFgIfAWhkZAIwDw8WBB8ABRFOZSBuYWpkZW0gemFwaXNhLh8BZ2RkZHgDFMHwkVGtuuMjab9CmJ5HBg1c";
        $("__EVENTVALIDATION").value = "/wEWCgLbwqOpBQLV1ZPLCALK1ZPLCALFurmlBAKGmbiLDgKZmbiLDgKW9pLlAgLL3sHqBwLUwPYqAuGX++4BNUkcbYD91sImZQ1JH0WMXV4F0NY=";
        $("tracenumber").name = "Track1:txtRegODMednarodni";
        $("type").value = "4";
    }
}

//show default news document
function showDefaultNews(docid, parentdocid, validate, newsnodeid) {
    //start scroll
    if (validate == 1) 
    {
        sendAjaxRequest(rooturl + "ajaxdefaultnews.aspx?parentdocid=" + parentdocid + "&docid=" + docid + "&newsnodeid=" + newsnodeid, "newsdiv", "");
        timer = setTimeout("showDefaultNews(0," + parentdocid + ",2," + newsnodeid + ")", miliseconds);
    }

    //get next
    if (validate == 2) 
    {
        //if next exist
        if (i + 2 <= newscount)
            i++;
        else
            i = 0;
        
        //set index
        sendAjaxRequest(rooturl + "ajaxdefaultnews.aspx?parentdocid=" + parentdocid + "&docid=" + news[i] + "&newsnodeid=" + newsnodeid, "newsdiv", "");
        timer = setTimeout("showDefaultNews(0," + parentdocid + ",2," + newsnodeid + ")", miliseconds);
    }

    //set item
    if (validate == 3) 
    {
        //set index
        clearTimeout(timer);
        sendAjaxRequest(rooturl + "ajaxdefaultnews.aspx?parentdocid=" + parentdocid + "&docid=" + docid + "&newsnodeid=" + newsnodeid, "newsdiv", "");
    }
}


//-- accordion -------------------------------

//accordion settings
var contentHeight = 180;
var heightStep = 36; //must be: contentHeight / something
var time = 50;

//variables
var lastOpenedId = 'accordion1content';
var currentOpenedId = null;
var accordion = false;
var height = 0;

//run accordion
function runAccordion(index) 
{
    var currentId = "accordion" + index + "content";
    if (lastOpenedId == currentId)
        currentId = '';

    if (accordion == false && currentId!='') 
    {
        accordion = true;
        currentOpenedId = currentId;
        animate();
    }
}

//animate
function animate() 
{
    if (accordion == true && height < contentHeight) 
    {
        height += heightStep;
        document.getElementById(lastOpenedId).style.height = (contentHeight - height) + "px";
        document.getElementById(currentOpenedId).style.height = height + "px";

        if (height == contentHeight) 
        {
            accordion = false;
            height = 0;
            lastOpenedId = currentOpenedId;
        }
        else
            setTimeout("animate()", time);
    }
}

//shippment item
function selectShippmentItem(position, last) 
{
    if (accordion == false) 
    {
        //deselect 1.item
        if (document.getElementById("lastselectedshippment").value == "1") 
        {
            document.getElementById("shippmentleft1").className = "shippment1off";
            document.getElementById("shippmentcenter1").style.backgroundImage = "url('" + rooturl + "images/shippment2_off.png')";
            document.getElementById("shippmentright1").className = "shippment2off";
            document.getElementById("shippmenttitleoff1").style.display = "block";
            document.getElementById("shippmenttitle1").style.display = "none";
        }
        //deselect other item
        if (document.getElementById("lastselectedshippment").value > 1 && document.getElementById("lastselectedshippment").value < last) 
        {
            document.getElementById("shippmentleft" + document.getElementById("lastselectedshippment").value).className = "shippment4";
            document.getElementById("shippmentcenter" + document.getElementById("lastselectedshippment").value).style.backgroundImage = "url('" + rooturl + "images/shippment5.png')";
            document.getElementById("shippmentright" + document.getElementById("lastselectedshippment").value).className = "shippment6";
            document.getElementById("shippmenttitleoff" + document.getElementById("lastselectedshippment").value).style.display = "none";
            document.getElementById("shippmenttitle" + document.getElementById("lastselectedshippment").value).style.display = "block";
        }
        //deselect last item
        if (document.getElementById("lastselectedshippment").value == last) 
        {
            document.getElementById("shippmentleft" + document.getElementById("lastselectedshippment").value).className = "shippment7";
            document.getElementById("shippmentcenter" + document.getElementById("lastselectedshippment").value).style.backgroundImage = "url('" + rooturl + "images/shippment8.png')";
            document.getElementById("shippmentright" + document.getElementById("lastselectedshippment").value).className = "shippment9";
            document.getElementById("shippmenttitleoff" + document.getElementById("lastselectedshippment").value).style.display = "none";
            document.getElementById("shippmenttitle" + document.getElementById("lastselectedshippment").value).style.display = "block";
        }

        //select 1.item
        if (position == 1) 
        {
            document.getElementById("shippmentleft1").className = "shippment1";
            document.getElementById("shippmentcenter1").style.backgroundImage = "url('" + rooturl + "images/shippment2.png')";
            document.getElementById("shippmentright1").className = "shippment2";
            document.getElementById("shippmenttitleoff1").style.display = "none";
            document.getElementById("shippmenttitle1").style.display = "block";
        }
        //select other item
        if (position > 1) 
        {
            document.getElementById("shippmentleft" + position).className = "shippment4on";
            document.getElementById("shippmentcenter" + position).style.backgroundImage = "url('" + rooturl + "images/shippment5_on.png')";
            document.getElementById("shippmentright" + position).className = "shippment6on";
            document.getElementById("shippmenttitleoff" + position).style.display = "block";
            document.getElementById("shippmenttitle" + position).style.display = "none";
        }

        if (document.getElementById("accordion" + position + "content").style.display != "block")
            runAccordion(position);

        //set last selected
        document.getElementById("lastselectedshippment").value = position;
    }
}

// --------------------------------




var lastselectedfaqemelent = null;
var lastselectedfaqright = null;

//show faq
function faq(docid)
{
    //show / hide
    if (document.getElementById("right" + docid)) 
    {
        if (document.getElementById("right" + docid).className == "questionright") 
        {
            if (lastselectedfaqemelent == null && lastselectedfaqright == null) {
                lastselectedfaqemelent = document.getElementById("content" + docid);
                lastselectedfaqright = document.getElementById("right" + docid);
            }
            else {
                lastselectedfaqemelent.style.display = "none";
                lastselectedfaqright.className = "questionright";
            }
            
            document.getElementById("content" + docid).style.display = "block";
            lastselectedfaqemelent = document.getElementById("content" + docid);
            lastselectedfaqright = document.getElementById("right" + docid);
            
            document.getElementById("right" + docid).className = "questionright2";
            closeid = document.getElementById("right" + docid);
            //load document
            if (document.getElementById("content" + docid).innerHTML.length < 2) 
            {
                sendAjaxRequest(rooturl + "ajaxfaq.aspx?docid=" + docid, "content" + docid, "");
                
            }
        }
        else {
            document.getElementById("content" + docid).style.display = "none";
            document.getElementById("right" + docid).className = "questionright";
        }
    }
}

//show events, procurement
function events(docid) {
    //show / hide
        if (document.getElementById("content" + docid).style.display == "none") {
            document.getElementById("content" + docid).style.display = "block";
            document.getElementById("right" + docid).className = "questionright2";
            document.getElementById("title" + docid).className = "selectectitle event_link";
        }
        else {
            document.getElementById("content" + docid).style.display = "none";
            document.getElementById("right" + docid).className = "questionright";
            document.getElementById("title" + docid).className = "arialdarkgrey12u event_link";
        }
    
}


//show glossary
function toggleGlossary(docid) {
    //show / hide
    if (document.getElementById("right" + docid)) {
        if (document.getElementById("right" + docid).className == "questionright") {
            document.getElementById("content" + docid).style.display = "block";
            document.getElementById("right" + docid).className = "questionright2";
            document.getElementById("title" + docid).className = "selectectitle";
        }
        else {
            document.getElementById("content" + docid).style.display = "none";
            document.getElementById("right" + docid).className = "questionright";
            document.getElementById("title" + docid).className = "arialdarkgrey12u";
        }
    }
}

function togglePostarcaGlossary(docid) {
    //show / hide
    if (document.getElementById("right" + docid)) {
        if (document.getElementById("right" + docid).className == "questionright") {
            document.getElementById("content" + docid).style.display = "block";
            document.getElementById("right" + docid).className = "questionright2";
            document.getElementById("title" + docid).className = "selectectitle";
        }
        else {
            document.getElementById("content" + docid).style.display = "none";
            document.getElementById("right" + docid).className = "questionright";
            document.getElementById("title" + docid).className = "arialdarkgrey12u";
        }
    }
}

function togglePostarcaOffer(fileid) {
    //show / hide
    if (document.getElementById("offercontent_" + fileid)) {
        if (document.getElementById("offercontent_" + fileid).className == "none") {
            document.getElementById("offercontent_" + fileid).className = "content1";
            document.getElementById("more_" + fileid).style.display = "none";
        }
        else {
            document.getElementById("offercontent_" + fileid).className = "none";
            document.getElementById("more_" + fileid).style.display = "block";
        }
    }
}


//set faq page
function setPage(url, faqgroupid, page) 
{
    window.location = url + "?faqgroupid=" + faqgroupid + "&page=" + page;
}

//glossary navigation
function setPageGlossary(url, page) {
    window.location = url + "?page=" + page;
}

//set search page
function setSearchPage(url, searchstring, page) 
{
    window.location = url + "?page=" + page + "&searchstring=" + escape(searchstring);
}

//set newslist page
function setPageNewsList(url, year, page) 
{
    window.location = url + "?year=" + year + "&page=" + page;
}
//postagestamppricelist
function setPagePostageStampsPticeList(url, articletypeid, page) {
    window.location = url + "?articletypeid=" + articletypeid + "&page=" + page;
}

//set EVENTS page
function setPageEvents(url, year, page) {
    window.location = url + "?year=" + year + "&page=" + page;
}

//set procurement page
function setPageProcurement(url, enddatemonth, datecreatedmonth, catpos, page) {
    window.location = url + "?enddatemonth=" + enddatemonth + "&datecreatedmonth=" + datecreatedmonth + "&catpos=" + catpos + "&page=" + page;
}

//set Page Photogalleries
function setPagePhotogalleries(url, page) {
    window.location = url + "?page=" + page;
}

//set Page Photogallery
function setPagePhotogallery(url, page) 
{
    window.location = url + "?page=" + page;
}

//set faq page
function setPagePhilatelicSocieties(url, page) 
{
    window.location = url + "?page=" + page;
}

//set stamps first day covers
function setPageStampsFirstDayCovers(url, year, page) 
{
    window.location = url + "?year=" + year + "&page=" + page;
}

//set stamps faces page
function setPageStampsFaces(url, year, page) 
{
    window.location = url + "?year=" + year + "&page=" + page;
}

//on faq question
function onFaqQuestion(e) 
{
    var keyIndex = 0;
    if (navigator.appName == "Netscape")
        keyIndex = e.which;
    else
        keyIndex = window.event.keyCode;

    if (keyIndex == 13) 
    {
        if (document.getElementById("name").className == "blue") document.getElementById("name").value = "";
        if (document.getElementById("email").className == "blue") document.getElementById("email").value = "";
        if (document.getElementById("question").className == "blue") document.getElementById("question").value = "";
    
        ajaxQuestionSend(document.getElementById("docid").value, document.getElementById("name").value, document.getElementById("email").value, document.getElementById("faqgroupid").value, document.getElementById("question").value);
    }
}

function ajaxQuestionSend(docid, name, email, faqgroupid, question) 
{
    sendAjaxRequest(rooturl + "ajaxfaqquestion.aspx?docid=" + docid + "&name=" + name + "&email=" + email + "&faqgroupid=" + faqgroupid + "&question=" + question + "&validate=1", "sendcontactbox", "");
}

//mediaspot
function showDescription() 
{
    var display = document.getElementById("descriptiondiv").style.display;
    if (display == "none") 
    {
        document.getElementById("descriptiondiv").style.display = "block";
        document.getElementById("descriptionright").className = "descriptionright2";
    }
    else 
    {
        document.getElementById("descriptiondiv").style.display = "none";
        document.getElementById("descriptionright").className = "descriptionright";
    }
}

//newsletter navigation
function setPageNewsletter(url, year, page) 
{
    window.location = url + "?page=" + page + "&year=" + year;
}


//postoffices search
function sendAJaxPostOffices(city, zip, service, type, recipientpostoffice, settlement, address) {
    sendAjaxRequest(rooturl + "ajaxpostoffices.aspx?city=" + escape(city) + "&zip=" + escape(zip) + "&service=" + service + "&type=" + type + "&recipientpostoffice=" + recipientpostoffice + "&settlement=" + escape(settlement) + "&address=" + escape(address), "postofficesajaxdiv", "");
}

//ajax delivery times top
function sendAjaxDeliveryTimes(sourcepostcode, deliverypostcode, sourcetimeto, deliverytype, type) 
{
    sendAjaxRequest(rooturl + "ajaxdeliverytimes.aspx?type=" + type + "&sourcepostcode=" + sourcepostcode + "&deliverypostcode=" + deliverypostcode + "&sourcetimeto=" + sourcetimeto + "&deliverytype=" + deliverytype, "deliverytimesajaxdivsmall", "");
}



//show banner
function showBanner(parentdocid, validate) {
    //start scroll
    if (validate == 1) {

        sendAjaxRequest(rooturl + "ajaxbanner.aspx?docid=" + parentdocid + "&bannerpos=" + headeri + "&width=520", "headerbannerajaxdiv", "");
        headertimer = setTimeout("showBanner(" + parentdocid + ",2)", headermiliseconds);
    }

    //get next
    if (validate == 2) {
        //deselect
        if (document.getElementById("headerbanner" + headeri))
            document.getElementById("headerbanner" + headeri).className = "arialgray11";

        //if next exist
        if (headeri + 1 <= headerbannercount)
            headeri++;
        else
            headeri = 1;

        //select
        if (document.getElementById("headerbanner" + headeri))
            document.getElementById("headerbanner" + headeri).className = "arialdarkgray11";

        //set index
        sendAjaxRequest(rooturl + "ajaxbanner.aspx?docid=" + parentdocid + "&bannerpos=" + banners[headeri] + "&width=520", "headerbannerajaxdiv", "");
        headertimer = setTimeout("showBanner(" + parentdocid + ",2)", headermiliseconds);
    }
}

//stop banner
var lastSelectedHeaderBanner = 0;
function stopBanner(parentdocid, nodepos) {
    //deselect
    if (lastSelectedHeaderBanner == 0)
        lastSelectedHeaderBanner = headeri;

    if (document.getElementById("headerbanner" + lastSelectedHeaderBanner))
        document.getElementById("headerbanner" + lastSelectedHeaderBanner).className = "arialgray11";

    //clear and set banner
    clearTimeout(headertimer);
    sendAjaxRequest(rooturl + "ajaxbanner.aspx?docid=" + parentdocid + "&bannerpos=" + nodepos + "&width=520", "headerbannerajaxdiv", "");

    lastSelectedHeaderBanner = nodepos;
    if (document.getElementById("headerbanner" + lastSelectedHeaderBanner))
        document.getElementById("headerbanner" + lastSelectedHeaderBanner).className = "arialdarkgray11";
}

function onSourceDownloadProgressChanged(sender, eventArgs) {
    //alert(eventArgs.progress);
    sender.findName("progressBar").Width = eventArgs.progress * 300;
    sender.findName("tbProgress").Text = "" + Math.round(eventArgs.progress * 100);
}


//stamps description
function showStampsDescription() {
    var display = document.getElementById("descriptiondiv").style.display;
    if (display == "none") {
        document.getElementById("descriptiondiv").style.display = "block";
        document.getElementById("descriptionright").style.display = "none";
        document.getElementById("descriptionright2").style.display = "block";
        
    }
    else {
        document.getElementById("descriptiondiv").style.display = "none";
        document.getElementById("descriptionright").style.display = "block";
        document.getElementById("descriptionright2").style.display = "none";
    }
}

//send/get survey
function sendSurvey(nDocId, nValidate) {
    var nNodePos = 0;
    var sTarget = "surveycontent";

    //show survey
    if (nValidate == 0) {
        sTarget = "survey";
    }
    //vote
    else if (nValidate == 1) {
        //get radio buttons
        var inputs = $(sTarget).getElementsByTagName('input');

        //loop radio buttons
        for (i = 0; i < inputs.length; i++) {
            //set checked value
            if (inputs[i].checked == true) nNodePos = inputs[i].value;
        }        
    }
    else if (nValidate == 2) {
        //nop
    }
    
    //show hide buttons
    if ($('surveybackbutton').style.display == 'none') {
        //hide survey button
        $('surveysubmitbutton').style.display = 'none';
        $('surveyresultbutton').style.display = 'none';
        $('surveybackbutton').style.display = 'inline';
    }
    else {
        $('surveysubmitbutton').style.display = 'inline';
        $('surveyresultbutton').style.display = 'inline';
        $('surveybackbutton').style.display = 'none';
    }

    //send ajax
    sendAjaxRequest(rooturl + "ajaxsurvey.aspx?docid=" + nDocId + "&nodepos=" + nNodePos + "&validate=" + nValidate, sTarget, "");
}

//show hide surveys
function surveys(docid) {
    //hide all opened contents
    var ulelements = $('surveys').getElementsByTagName('ul');
    for (var i = 0; i < ulelements.length; i++) {
        var tmpul = ulelements[i];
        if (tmpul.id.substring(0, 8) == 'content_') {
            tmpul.style.display = 'none';
        }
    }
    //set arrows to default
    var arrows = $('surveys').getElementsByTagName('span');
    for (var i = 0; i < arrows.length; i++) {
        var tmparrow = arrows[i];
        if (tmparrow.id.substring(0, 14) == 'questionarrow_') {
            tmparrow.className = "questionarrow";
        }
    }
    //show / hide
    if ($("content_" + docid).style.display == "none" || $("content_" + docid).style.display == "") {
        $("content_" + docid).style.display = "block";
        $("questionarrow_" + docid).className = "questionarrowactive";
        $("title_" + docid).className = "selectectitle question";
    }
    else {
        $("content_" + docid).style.display = "none";
        $("questionarrow_" + docid).className = "questionarrow";
        $("title_" + docid).className = "arialdarkgrey12u question";
    }

}

//cancel submit on enter
function cancelOnEnter(e)
{
    if (navigator.appName == "Netscape")
        var key_index = e.which;
    else
        var key_index = window.event.keyCode;

    if (key_index == 13)
        return false;
    else
        return true;
}

//questionary clear field
function clearField(element) {
    if (element.value == " ") element.value = "";

    if (element.className == "bluelarge") {
        element.value = "";
        element.className = "bluelarge2";
    }
}

//shippment module redirect
function shippmentRedirect() {
    window.open("http://sledenje.posta.si/?tracenumber=" + $('tracenumber').value + "&type1=" + $('type1').value + "&type2=" + $('type2').value, "_self");
}

function toggleContact(postofficeunitid) {
	// open / close
	if($('linkcontact' + postofficeunitid).className == 'arialgray12u') {
		$('divcontact' + postofficeunitid).style.display = 'block';
		$('linkcontact' + postofficeunitid).className = 'arialgray12b';
		$('imagecontact' + postofficeunitid).src = rooturl + 'images/down_up.png';
	} else {
		$('divcontact' + postofficeunitid).style.display = 'none';
		$('linkcontact' + postofficeunitid).className = 'arialgray12u';
		$('imagecontact' + postofficeunitid).src = rooturl + 'images/down.png';
	}
}


var lastselectedmypostfaqelement = null;
var lastselectedmypostfaqright = null;
var lastselectedmypostfaqtitle = null;

//show my post faq
function myPostFaq(position) {
    //show / hide
    if (document.getElementById("right" + position)) {
        if (document.getElementById("right" + position).className == "questionright") {
            if (lastselectedmypostfaqelement == null && lastselectedmypostfaqright == null && lastselectedmypostfaqtitle == null) {
                lastselectedmypostfaqelement = document.getElementById("content" + position);
                lastselectedmypostfaqright = document.getElementById("right" + position);
                lastselectedmypostfaqtitle = document.getElementById("title" + position);
            }
            else {
                lastselectedmypostfaqelement.style.display = "none";
                lastselectedmypostfaqright.className = "questionright";
                lastselectedmypostfaqtitle.className = "arial2gray12u";
            }

            //show
            document.getElementById("content" + position).style.display = "block";
            lastselectedmypostfaqelement = document.getElementById("content" + position);
            lastselectedmypostfaqright = document.getElementById("right" + position);
            lastselectedmypostfaqtitle = document.getElementById("title" + position);
            document.getElementById("right" + position).className = "questionright2";
            document.getElementById("title" + position).className = "timesnewromandarkgray18l";
            closeid = document.getElementById("right" + position);
        }
        else {
            document.getElementById("content" + position).style.display = "none";
            document.getElementById("right" + position).className = "questionright";
            document.getElementById("title" + position).className = "arial2gray12u";
        }
    }
}

//track shippment
function newTrackShippment(url, localeid) {
    window.location = url + "?tracenumber=" + document.getElementById("tracenumber").value + "&lang=" + localeid.substring(3, 5);
}
