function ViewPollResults(afterVoting, siteUrl) {
    var rbgAnswers = document.getElementsByName("IDAnketaOdgovor");

    var pollId = document.getElementById("hfPollId");

    var checkedAnswerId;
    for (i = 0; i < rbgAnswers.length; i++) {
        if (rbgAnswers[i].checked) {
            checkedAnswerId = rbgAnswers[i].value;
            break;
        }
    }
    if (afterVoting) {

        window.location.href = siteUrl + "/PollResults.aspx?PollId=" + pollId.value + "&AnswerId=" + checkedAnswerId;
    }
    else {
        window.location.href = siteUrl + "/PollResults.aspx?PollId=" + pollId.value;
    }
}

function Submit(currentPage) {

    document.getElementById('ctl00_hfCurrentPage').value = currentPage;
    var theForm = document.forms[0];
    if (!theForm) {
        theForm = document.form;
    }

    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.submit();
    }
}

function SubmitForm(currentPage, itemCount) {
    document.getElementById('hfCurrentNewsPage').value = currentPage;
    document.getElementById('hfNewsItem').value = itemCount;


    var theForm = document.forms[0];
    if (!theForm) {
        theForm = document.form;
    }

    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.submit();
    }
}

//function Submit(currentPage, itemCount)
//{
//         document.getElementById( 'hfCurrentGalleryPage' ).value = currentPage;
//         document.getElementById( 'hfGalleryItem' ).value = itemCount;
//  
//           
//        var theForm = document.forms[0];
//        if ( !theForm )
//        {
//            theForm = document.form;
//        }
//        
//        if ( !theForm.onsubmit || (theForm.onsubmit() != false) )
//        {
//            theForm.submit();
//        }
//    }


function ClearTextInTextbox(textBoxID, defaultText) {
    var textBox = document.getElementById(textBoxID);
    if (textBox == null) {
        return;
    }

    if (textBox.value == defaultText) {
        textBox.value = "";
    }
}

function AddProductToBasket(idItem) {
    var url = window.location.href;
    jQuery.facebox(RagusServices.AddItemToBasket(idItem, url, OnAddItemToBasketSuccess));
}

function OpenWindow(url) {
    window.location.href = url;
}

function OnAddItemToBasketSuccess(result) {
    ShowMessage(result);
    RagusServices.UpdateBasketInformation(OnUpdateBasketInformationSuccess);
}

function OnUpdateBasketInformationSuccess(result) {
    jQuery("#basketAmountInfo").html(result[0] + ' kom');
    jQuery("#basketPriceInfo").html(result[1] + ' kn');
}

function ShowMessage(result) {
    jQuery.facebox(result);
}







