function openWin(https,wid,hei,name){
shopWin = open(https, name, "scrollbars=no,resizable=no,width="+wid+",height="+hei+"");
        shopWin.focus();
}

function openWinScroll(https,wid,hei,name){
shopWin = open(https, name, "scrollbars=yes,resizable=no,width="+wid+",height="+hei+"");
        shopWin.focus();
}

function openWinScrollPrint(https,wid,hei,name){
shopWin = open(https, name, "scrollbars=yes,toolbar=1,resizable=no,width="+wid+",height="+hei+"");
        shopWin.focus();
}

function confirmLink()
{
    confirmMsg  = 'Uzmanību! ';
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm('Uzmanību \ntiešām dzēst?');
    if (is_confirmed) {
       // theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
}


function chimg(r)
{
    var _d = document.getElementById(r);
    _d.src = 'images/inp.jpg';

}

function chimgb(r)
{
    var _d = document.getElementById(r);
    _d.src = 'images/outp.jpg';

}

function chstyle(a, b) {

    var x = document.getElementById(b);
   // alert(x);
    x.className  = a;

}

function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to );
        idx = str.indexOf( from );
    }

    return str;
}

function vis(a) {


    if (a == 0) {
        _sel = 'hidden';
        _sel2 = 'none';
    } else {
        _sel = 'visible';
        _sel2 = 'inline';
    }

    document.getElementById('search').style.visibility = _sel;
    document.getElementById('selvis').style.display = _sel2;
    document.getElementById('selvis').style.visibility = _sel;

}

function checkMail(x)
{
        var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (filter.test(x)) return 1;
        else return 0;
}

function checkFormSendStudio() {

       if (document.form1.T1.value=='') {

           alert('Ievadiet jūsu vārdu!');
           document.getElementById('T11').focus();
           return false;

       }
       if (document.form1.T2.value=='') {

           //
           alert('Ievadiet jūsu uzvārdu!');
           document.getElementById('T2').focus();
           return false;

       }
       if (document.form1.T5.value=='') {

           //
           alert('Ievadiet darba tālrunis!');
           document.getElementById('T5').focus();
           return false;

       }

       if (document.form1.T9.value != '') {
           _ret = checkMail(document.form1.T9.value);
           if (!_ret) {
              ///
              alert('Nepareiza e-pasta adrese!');
              document.getElementById('T9').focus();
              return false;
           }

       }


       return true;
}


function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
}