/*
* Mark and unmark all checkboxes by name ...
* used in user msg
*/
function mark(name, state){
    $("input[name="+ name +"]").checkBox('changeCheckStatus', state);
    return false;
}
/*
* mark radio by class used in permissions
*/
function markRadio(c){
    $('.horizontal').each(function() {
        $('.'+c+' input[type=radio]').checkBox('changeCheckStatus', true);
    });
}
/**
* open new window
*/
function popup(url, width, height, name)
{
    if (!name)
    {
        name = 'pop';
    }
    if (!width)
    {
        width = '980';
    }
    if (!height)
    {
        height = '570';
    }
    window.open(url,name,'height='+height+',resizable=yes,scrollbars=yes,width='+ width);
    /*window.open(url,'name','width=980,height=570,menubar=no,status=yes,location=no,toolbar=no,scrollbars=yes')*/
    return false;
}
/* page reload by time in seconds
*********************************/
function reloadPage(sec){
    var t = sec * 1000;
    setTimeout("window.location.reload( false );",t);
}
function redirectTo(url)
{
  document.location = url;
}
/**
* processing url like ajax
*/
function ajaxProcess(url){
    $.get(url);
}; //end change of admin view
/**
* Submiting form with jquery by id of form 
*/
function submitForm(id){
    $(".pholder",'#'+id).hidePholder(); //jfwPholder
    $("#"+id).submit();
}
// toogle by id
function toggleIt(id){
    $('#' + id).toggle("blind",{},1000);
    return false;
}
function clearInput(id){
    $('#' + id).val('');
    $('#' + id).focus();
}
//return euro price from cents
function returnEuro(cents) {
  if (cents > 0) {
    cents = Math.round(cents);
    big=Math.floor(cents / 100);
    small=cents-big*100;
  } else {
    big = 0;
    small = 0;
  }
  if (small < 10) {
    if (small < 0) {
      small = 0;
    }
    small = '0' + small;
  }
  return big + "\u20AC " + small + "&cent; ";
}
function scrollToId(id){
    $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
    return false;
}
function scrollToTop(){
    $('html').animate({ scrollTop: 0 }, 'slow'); return true; 
    $('body').animate({ scrollTop: 0 }, 'slow'); return true; 
    $('document').animate({ scrollTop: 0 }, 'slow'); return true; 
    $('window').animate({ scrollTop: 0 }, 'slow'); return true; 
    return false;
}
//replace comma int to dot presentation in input fields
function commaToDot(field){
    field.value = field.value.replace(",",".");
}

function inqVote(id,vote,size){
    size = (size != null) ? size : 300;
    $.ajax({
        type: 'GET',
        url: baseUrl + 'ajax/inquiry.php',
        async: true,
        cache: false,
        dataType : "json",
        data: 'id=' + id + '&vote=' + vote + '&size=' + size,
        success: function(jsonData)
        {
            $.each(jsonData, function(i, item){
                $("#" + id).children(".options").text('');
                $("#" + id).children(".options").append(item.opt);
                $("#" + id).children(".msg").text(item.msg);
                setTimeout(function(){$("#" + id).children(".msg").text('');},2000);
            });
            
        },
        error: function(request, error, errThrown) {
            alert("Error: " + request + "\n" + "Desc.: " + error + "Thrown: " + errThrown);
        }
    });  
}
