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.open(siteUrl + '/PollResults.aspx?PollId=' + pollId.value + '&AnswerId=' + checkedAnswerId,'','scrollbars=yes,width=640,height=650');
     
   }
   else
   {
      window.open(siteUrl + '/PollResults.aspx?PollId=' + pollId.value,'','scrollbars=yes,width=640,height=650');
   }
}

function Submit(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 ClearTextInTextbox(textBoxID, defaultText)
{
    var textBox = document.getElementById( textBoxID );
    if ( textBox == null )
    {
        return;
    }

    if ( textBox.value == defaultText)
    {
        textBox.value = "";
    }
}


function AddProductsToBasket(idItem, textBoxID)
{
   var amount = document.getElementById( textBoxID ).value;
   jQuery.facebox(HartaServices.AddItemsToBasket(idItem, amount, OnAddItemToBasketSuccess));
}

function AddProductToBasket(idItem)
{

   jQuery.facebox(HartaServices.AddItemToBasket(idItem, OnAddItemToBasketSuccess));
}

function OpenProduct( url )
{
window.location.href = url;
}

function OpenQueryForm( url )
{
window.location.href = url;
return false;
}

function OpenShopingBasket()
{
window.location.href = 'ShoppingBasket.aspx'
}

function OnAddItemToBasketSuccess(result)
{
  ShowMessage(result);
  HartaServices.UpdateBasketInformation(OnUpdateBasketInformationSuccess);
}

function OnUpdateBasketInformationSuccess(result)
{
  jQuery("#basketAmountInfo").html('<a href="shopingBasket.aspx"><strong>Ko&scaron;arica (' + result[0] + ')</strong></a>');

}

function ShowMessage(result)
{
   jQuery.facebox(result);
}

function RememberStatus(id) {
    try {
        if (document.getElementById(id).style.display == 'none') {
            document.getElementById(id).style.display = 'block';
            //jQuery.cookie("Expanded", null);
            jQuery.cookie("Expanded", id, { path: '/' });
        }
        else {

            document.getElementById(id).style.display = 'none';
        }
    } catch (ex) {alert(ex);}
}
jQuery(document).ready(function() {
    ExpandMenu()
});

function ExpandMenu() {

    var elementId = jQuery.cookie("Expanded");
    if (elementId != null){
        document.getElementById(elementId).style.display = 'block';
    }
}


