function IsIE()
{
 return window.navigator.appName.indexOf("Microsoft Internet Explorer", 0) != -1;
}

function IsNetscape()
{
 return window.navigator.appName.indexOf("Netscape", 0) != -1;
}

function gotopage(str)
{
 window.location=str;
}


function displayDate(){
    var this_month = new Array(12);
    this_month[0]  = "stycznia";
    this_month[1]  = "lutego";
    this_month[2]  = "marca";
    this_month[3]  = "kwietnia";
    this_month[4]  = "maja";
    this_month[5]  = "czerwca";
    this_month[6]  = "lipca";
    this_month[7]  = "sierpnia";
    this_month[8]  = "wrze\u015bnia";
    this_month[9]  = "pa\u017adziernika";
    this_month[10] = "listopada";
    this_month[11] = "grudnia";
    var today = new Date();
    var day   = today.getDate();
    var month = today.getMonth();
    var year  = today.getYear();
    if (year < 1900){
        year += 1900;
    }
    return(day+" "+this_month[month]+" " +year);
}

function gotopagenewwin(str)
{
 OpenWindow(str, 800, 600);
}

function checkFields(err1, err2, err3, err4)
{
 var problem = document.getElementsByName("problem")[0];
 var from = document.getElementsByName("from")[0];
 var company = document.getElementsByName("company")[0];
 var phone = document.getElementsByName("phone")[0];
 var email = document.getElementsByName("email")[0];


 if(problem == null || problem.value == "" || problem.value.length < 1)
 {
  alert(err1);
  return false;
 }
 if(from == null || from.value == "" || from.value.length < 1)
 {
  alert(err2);
  return false;
 }

 if(company == null || company.value == "" || company.value.length < 1)
 {
  alert(err4);
  return false;
 }

 if((phone == null || phone.value == "" || phone.value.length < 1) &&
    (email == null || email.value == "" || email.value.length < 1))
 {
  alert(err3);
  return false;
 }

 return true;
}

function addItem(prodCat)
{
 OpenWindow("editProduct.do?prodCat=" + prodCat + "&newProd=true", 600, 438);
}

function editProduct(str)
{
 OpenWindow(str, 600, 438);
}

function addParameter(prodCat, id)
{
 OpenWindow("editParameter.do?prodCat=" + prodCat + "&newParam=true&prodId=" + id, 600, 159);
}

function editParameter(str)
{
 OpenWindow(str, 600, 159);
}

function onannchangerole(roles, str ) {
   window.location="AnnouncementList.jsp?currentRole=" + roles.value + str;
}

function onchangestatus(status, str ) {
   window.location="surveyWavesUpdate.do?status=" + status + str;
}

function onchangedb(db, str) {
   window.location="surveyReload.do?dbId=" + db.value + str;
}

function onchangedbfilter(filter, str) {
   window.location="surveyReload.do?filterId=" + filter.value + str;
}

function onchangesurveyor(sur, str) {
   window.location="SurveyEdit.jsp?surveyorId="+sur.value + str;
}


// editing existing question
function onclickeditquestion(questId, simpleQuestion, str) {
   OpenWindowR("editQuestion.do?questId=" + questId + str, 800,530, 0);
}

function OpenWindowR(url, width, height, resize) {
  var resWidth;
  var resHeight;
  if (browse() == 1){
    // IE
    resWidth = window.screen.Width/2;
    resHeight = window.screen.Height/2;
  }else{
    // Netscape
    // resWidth = window.innerWidth/2;
    // resHeight = window.innerHeight/2;
    resWidth = screen.availWidth/2;
    resHeight = screen.availHeight/2;
  }
  resWidth = resWidth - (width/2);
  resHeight = resHeight - (height/2);

           window.open(url,"displayWindow",'width=' + width +
                                                  ',height=' + height +
                             ',resizable=' + resize + ',scrollbars=yes,menubar=no,left=' + resWidth +
                             ',top=' + resHeight);
}

function OpenWindow(url, width, height) {
  var resWidth;
  var resHeight;

  if (browse() == 1){
    // IE
    resWidth = window.screen.Width/2;
    resHeight = window.screen.Height/2;
  }else{
    // Netscape
    // resWidth = window.innerWidth/2;
    // resHeight = window.innerHeight/2;
    resWidth = screen.availWidth/2;
    resHeight = screen.availHeight/2;
  }
  resWidth = resWidth - (width/2);
  resHeight = resHeight - (height/2);

           window.open(url,"displayWindow",'width=' + width +
                                                  ',height=' + height +
                             ',resizable=1,scrollbars=yes,menubar=no,left=' + resWidth +
                             ',top=' + resHeight);
}

function onWindowClose() {
        window.parent.close();
}

function itemEdit(itemId) {
   window.showModalDialog("../itemEdit.do?itemId=" + itemId, "",
                            "dialogHeight=800px, dialogWidth=530px");
}

function onchangepositiontype(posType, str) {
   window.location="../editItemRotGroup.do?positionType=" + posType.value + str;
}

function onchangegroup(groupId, str) {
   window.location="../editItemRotGroup.do?groupId=" + groupId.value + str;
}

function browse()
{
if (navigator.appName.indexOf("Microsoft Internet Explorer")>=0)
  { return 1; }
else if (navigator.appName.indexOf("Netscape")>=0)
  { return 2; }
}

function AnnoSwitch(listD1, listD2, listE)
{

 if (listD1 != null)
  {
    listD1.selectedIndex = -1;
    listD1.disabled=true;
  }
 if (listD2 != null)
  {
    listD2.selectedIndex = -1;
    listD2.disabled=true;
  }
 if (listE != null)
  {
    listE.selectedIndex = 0;
    listE.disabled=false;
  }
 return true;
}


function validateLists(err, list1, list2, list3)
{
  if ((list1.selectedIndex == -1) && (list2.selectedIndex == -1) && (list3.selectedIndex == -1))
  {
   alert(err);
   return false;
  }
  else {return true;}
}

function onColumnPhone(form, colId, maxId)
{
 var colImportPrefix = "colImport";
 var colTypePrefix = "colType";
 var colImport, colType;
 for(i = 0; i <= maxId; ++i)
 {
  colImport = document.getElementsByName(colImportPrefix + "[" + i + "]")[0];
  colType = document.getElementsByName(colTypePrefix + "[" + i + "]")[0];
  if(colImport == null || colType == null)
   continue;
  if(i == colId)
  {
   colImport.checked = true;
   colImport.disabled = true;
   colType.selectedIndex = 0; //assume: text columntype is first item in list
   colType.disabled = true;
  }
  else
  {
   colImport.disabled = false;
   colType.disabled = false;
  }

 }
}
function onChangePage(pageNooo, buttonElem1, buttonElem2)
{
 var pageNoo = document.getElementsByName(pageNooo);
 var buttonColl1 = document.getElementsByName(buttonElem1);
 var buttonColl2 = document.getElementsByName(buttonElem2);

 var pageNo = pageNoo[0];
 var button1 = buttonColl1[0];
 var button2 = buttonColl2[0];
 if(pageNo.value == 1) {
   button1.disabled = true;
   button2.disabled = false;
 } else {
     button1.disabled = false;
     button2.disabled = true;
   }
}

function onSelChangeEntryValue(selectElem, buttonElem)
{
 var buttonColl = document.getElementsByName(buttonElem);
 var selectColl = document.getElementsByName(selectElem);

 if(buttonColl.length != 1 || selectColl.length != 1)
  return;
 var button = buttonColl[0];
 var select = selectColl[0];

 var oOptions = select.options;
 var hasSelItems = false;
 for(i = 0; i < oOptions.length; i++)
  if(oOptions(i).selected)
  {
   hasSelItems = true;
   break;
  }
 button.disabled = !hasSelItems;
}

function onLengthChangeEntryValue(selectElem, buttonElem)
{
 var buttonColl = document.getElementsByName(buttonElem);
 var selectColl = document.getElementsByName(selectElem);

 if(buttonColl.length != 1 || selectColl.length != 1)
  return;
 var button = buttonColl[0];
 var select = selectColl[0];

 button.disabled = select.options.length <= 0;
}

function updateSaveButton(check0Id, text0Id, check1Id, text1Id, saveId)
{
 var checkColl0 = document.getElementsByName(check0Id);
 var checkColl1 = document.getElementsByName(check1Id);

 var textColl0 = document.getElementsByName(text0Id);
 var textColl1 = document.getElementsByName(text1Id);

 if(checkColl0.length != 1 || checkColl1.length != 1 || textColl0.length != 1 || textColl1.length != 1)
  return;

 var check0 = checkColl0[0], check1 = checkColl1[0];
 var text0 = textColl0[0], text1 = textColl1[0];

 text0.disabled = !check0.checked;
 text1.disabled = !check1.checked;
 if(!check0.checked)
  text0.value = "";

 if(!check1.checked)
  text1.value = "";
}

function onchangecheckbox(indexValue, index, itemCount) {

 var prevElem = null, nextElem = null;
 var selected = 0;
 var i;
 var selectedIndex = 0;
 for(i=0; i < itemCount; i++) {
    nextElem = document.getElementsByName("checkBoxs[" + (i) + "]")[0];
    if (nextElem.checked == true && nextElem.style.visibility != "hidden") {
         selected = selected + 1;
         selectedIndex = i;
    }
 }

 if (selected == 1 && index == selectedIndex)
 for(i=0; i < itemCount; i++)
    if (i < index - 1 || i > index + 1) {
      nextElem = document.getElementsByName("checkBoxs[" + (i) + "]")[0];
      nextElem.disabled = true;
    }

 if(indexValue != 0)
 {
  prevElem = document.getElementsByName("checkBoxs[" + (index - 1) + "]")[0];
 }

 if(indexValue != itemCount -1)
 {
  nextElem = document.getElementsByName("checkBoxs[" + (index + 1) + "]")[0];
 }

 if(indexValue.checked == true) {
    if(nextElem != null && nextElem.disabled == true && nextElem.checked == false && nextElem.style.visibility != "hidden")
      nextElem.disabled = false;
     else
      if(nextElem != null && nextElem.disabled == false && nextElem.checked == true && selected > 2 && nextElem.style.visibility != "hidden")
        nextElem.disabled = true;

    if(prevElem != null && prevElem.disabled == false && prevElem.checked == true && selected > 2 && prevElem.style.visibility != "hidden")
      prevElem.disabled = true;
     else
      if(prevElem != null && prevElem.disabled == true && prevElem.checked == false && prevElem.style.visibility != "hidden")
         prevElem.disabled = false;
 } else {
    if(selected == 0 ) {
      for(i=0; i < itemCount; i++) {
        nextElem = document.getElementsByName("checkBoxs[" + (i) + "]")[0];
        if (nextElem.style.visibility != "hidden") {
          nextElem.checked = false;
          nextElem.disabled = false;
        }
      }
    } else {
       if(nextElem != null && nextElem.disabled == false && nextElem.checked == false && nextElem.style.visibility != "hidden")
         nextElem.disabled = true;
       else
         if(nextElem != null && nextElem.disabled == true && nextElem.style.visibility != "hidden")
            nextElem.disabled = false;
       if(prevElem != null && prevElem.disabled == true && prevElem.style.visibility != "hidden")
          prevElem.disabled = false;
         else
          if(prevElem != null && prevElem.disabled == false && selected > 1 && prevElem.style.visibility != "hidden")
             prevElem.disabled = true;
           else
            if(prevElem != null && prevElem.disabled == false && prevElem.checked == false && prevElem.style.visibility != "hidden")
              prevElem.disabled = true;
    }
 }
}

function enableallcheckboxs(itemCount) {
  var i;
  var nextElem = null;
  for(i=0; i < itemCount; i++) {
   nextElem = document.getElementsByName("checkBoxs[" + (i) + "]")[0];
   nextElem.disabled = false;
  }
}

function isScaleClick(isScale, itemId, pageNo, count) {


  buttonAdd = document.getElementsByName("addScalePosition")[0];
  buttonRemove = document.getElementsByName("removeScalePos")[0];
  buttonEdit = document.getElementsByName("editScalePos")[0];
  combo = document.getElementsByName("scalePos")[0];

  if (isScale.checked == true) {
    buttonAdd.disabled = false;
    if (count > 0 ) {
      buttonRemove.disabled = false;
      buttonEdit.disabled = false;
    }
    combo.disabled = false;
    window.location = "../itemEdit.do?itemId=" + itemId + "&pageNo=" + pageNo +
                     "&isScale=true";
  }
  else {
    buttonAdd.disabled = true;
    buttonRemove.disabled = true;
    buttonEdit.disabled = true;
    combo.disabled = true;
    window.location = "../itemEdit.do?itemId=" + itemId + "&pageNo=" + pageNo +
                     "&removeScale=true";
  }
}

function disableElement(str) {
  elem = document.getElementsByName(str)[0];
  elem.disabled = true;
}

function disableElements() {
  var name;
  var elem;
  for(var i = 0; i < table.length; i++) {
    name = table[i];
    elem = document.getElementsByName(name)[0];
    if(elem != null) {

      if(elem.disabled == false)
      {
       elem.disabled = true;
       if (elem.checked == true)
        elem.checked =false;
      }
    }
   }
}

function disableElementss(col) {
  var name;
  var elem;
  for(var i = 0; i < table[col].length; i++) {
    name = table[col][i];
    elem = document.getElementsByName(name)[0];
    if(elem != null) {
      if(elem.disabled == false)
      {
       elem.disabled = true;
       if (elem.checked == true)
        elem.checked =false;
      }
    }
   }
}

function enableElement(str) {
  elem = document.getElementsByName(str)[0];
  elem.disabled = false;
}

function enableOrDisableElement(str) {
   elem = document.getElementsByName(str)[0];
   if(elem != null) {
    if(elem.disabled == true)
     elem.disabled = false;
    else
     elem.disabled = true;
   }
}


function enableOrDisableElements(eks) {
   var name, nameScaleOpen;
   var elem;
   for(var i = 0; i < table.length; i++) {
    name = table[i];
    elem = document.getElementsByName(name)[0];
    if(elem != null) {
     if(elem.name != eks.name)
     {
      if(elem.disabled == false)
      {
       elem.disabled = true;
       if (elem.checked == true)
        elem.checked =false;
      }
      else
       elem.disabled = false;
     }
    }
   }
   if (eks.checked == true)
   for(var i = 0; i < tableScaleOpen.length; i++) {
    nameScaleOpen = tableScaleOpen[i];
    elem = document.getElementsByName(nameScaleOpen)[0];
    if(elem != null) {
     if(elem.disabled == false)
       elem.disabled = true;
    }
   }
}

function enableOrDisableElementss(eks, col) {
   var name, nameScaleOpen;
   var elem;
   for(var i = 0; i < table[col].length; i++) {
    name = table[col][i];
    elem = document.getElementsByName(name)[0];
    if(elem != null) {
     if(elem.name != eks.name)
     {
      if(elem.disabled == false)
      {
       elem.disabled = true;
       if (elem.checked == true)
        elem.checked =false;
      }
      else
       elem.disabled = false;
     }
    }
   }
   if (eks.checked == true)
   for(var i = 0; i < tableScaleOpen[col].length; i++) {
    nameScaleOpen = tableScaleOpen[col][i];
    elem = document.getElementsByName(nameScaleOpen)[0];
    if(elem != null) {
     if(elem.disabled == false)
       elem.disabled = true;
    }
   }
}

function checkScale(isScale, scaleCount, str)
{
  if(isScale == "true" && scaleCount == "0")
  {
   alert(str);
   return false;
  }
  else
   return true;

}

function onChangeScalePos(scalePos, itemId, pageNo) {

 window.location = "../itemEdit.do?itemId=" + itemId + "&pageNo=" + pageNo +
                    "&scalePos=" + scalePos.value + "&changeScalePos=true";
}

function editScalePosition(itemId, scenPos , pageNo) {
 str = "../editScaleEnums.do?itemId=" + itemId + "&scenId=" + scenPos + "&pageNo=" + pageNo;
 window.open(str,"","width=350, height=140,resizable=0,scrollbars=yes,menubar=no,left=340,top=150");
}

function addScalePos(itemId, pageNo) {
 str = "../editScaleEnums.do?itemId=" + itemId + "&pageNo=" + pageNo;
 window.open(str,"","width=350, height=140,resizable=0,scrollbars=yes,menubar=no,left=340,top=150");
}

function isOk(strLabel, strRecord) {
  label = document.getElementsByName("scenLabel")[0];
  record = document.getElementsByName("scenValue")[0];

  if(label == null || label.value.length < 0) {
    alert(strLabel);
    return false;
  }

  if(record == null || record.value.length < 0) {
    alert(strRecord);
    return false;
  }
  return true;
}

function isRecordExist(strRecord) {
 record = document.getElementsByName("scenValue")[0];
  if(record == null || record.value.length < 0) {
    alert(strRecord);
    return false;
  }
  return true;
}

function onchangecol(colId, str) {
   window.location=str + "&colId=" + colId.value + "&complex=true";
}

function onchangerow(rowId, str) {
   window.location=str + "&rowId=" + rowId.value + "&complex=true";
}

function rowOk(row, str) {
  if (row.value > 0) {
    return true;
  }
  else {
   return false;
  }
}

function colOk(col, str) {
  if (col.value > 0) {
   return true;
  }
  else {
   return false;
  }
}

/*function acceptChanges(col, row, strAlert) {
 var cols = document.getElementsByName("cols")[0];
 var rows = document.getElementsByName("rows")[0];
 var bConfirmed;
 if(cols.value != col || rows.value != row) {
    bConfirmed = window.confirm(strAlert)
     if(bConfirmed == true)
       return true;
      else {
       rows.innerText = row;
       cols.innerText = col;
       return false;
     }
  }
  else
   return true;
}*/

function acceptChanges(col, strAlert) {
 var cols = document.getElementsByName("cols")[0];
 var bConfirmed;
 if(cols.value != col) {
    bConfirmed = window.confirm(strAlert)
     if(bConfirmed == true)
       return true;
      else {
       cols.innerText = col;
       return false;
     }
  }
  else
   return true;
}

var lw=null;
function initialFunc(str) {
 var left = getMiddleWidth(790);
 var top = getMiddleHeight(550);
 var _d="<html><head><title>Loading...</title></head><body  style=\"background-color:#F2EDEC;\"><table width=\"100%\" height=\"100%\"><tr><td valign=middle align=center><b>"
         + str + "</b></td></tr></table></body></html>";
    lw = window.open("", "_targetLW", "width=790,height=550,resizable=1,scrollbars=yes,menubar=no,left=" + left+ ",top=" + top);
    lw.document.open();
	   lw.document.write(_d);
	   lw.document.close();
    lw.focus();
}

function closeFunc(){if(lw){lw.close();lw=null;}}
// taking an interview

function onclicktakeinterview(str) {
 var left = getMiddleWidth(790);
 var top = getMiddleHeight(550);
 if(lw)
  lw.location=str;
 else
   window.open(str,"displayWindow","width=790,height=550,resizable=1,scrollbars=yes,menubar=no,left=" + left+ ",top=" + top);
}

function reloadPage(str) {
//  window.location = str;
 delay(700);
 window.location.reload(true);
}

function delay(gap){ /* gap is in millisecs */
 var then,now; then=new Date().getTime();
 now=then;
 while((now-then)<gap)
  {
    now=new Date().getTime();
  }
 }

function confirmRemove(str)
{
 return confirm(str);
}

function printCurrentDate()
{

 var spanName = "currDate";
 //var spanElemColl = document.getElementsByName(spanName);
 //alert(spanElemColl.length);
 //if(spanElemColl.length != 1)
  //return;
 //var spanElem = spanElemColl[0];
 var spanElem = document.getElementById(spanName);

 if(spanElem == null)
  return;

 var d = new Date();
 var tmp, result = "";

 tmp = d.getDate();
 if(tmp < 10)
  result += "0" + tmp;
 else
  result += tmp;

 result += "-";

 tmp = d.getMonth();
 if(tmp < 10)
  result += "0" + tmp;
 else
  result += tmp;

 result += "-" + d.getFullYear();

 if(IsIE())
 {
  result += ", ";

  tmp = d.getHours();
  if(tmp < 10)
   result += "0" + tmp;
  else
   result += tmp;

  result += ":";

  tmp = d.getMinutes();
  if(tmp < 10)
   result += "0" + tmp;
  else
   result += tmp;

  result += ":";

  tmp = d.getSeconds();
  if(tmp < 10)
   result += "0" + tmp;
  else
   result += tmp;

 }

 spanElem.innerText = result;
}

function enableRespDBColsChecks(maxId)
{
  var i;
  var nextElem = null;
  for(i=0; i <= maxId; i++)
  {
    nextElem = document.getElementsByName("colImport[" + (i) + "]")[0];
    nextElem.disabled = false;
  }
}

 // copying questions
function onchangesurvey(id, str) {str
   window.location="../../questionCopyUpdate.do?reload=survey&surId=" + id.value + str;
}

function onchangesurveywave(id, str) {
   window.location="../../questionCopyUpdate.do?reload=surveyWave&srwId=" + id.value + str;
}

// copying items
function changesurvey(id, str) {str
   window.location="../../itemCopyUpdate.do?reload=survey&surId=" + id.value + str;
}

function changesurveywave(id, str) {
   window.location="../../itemCopyUpdate.do?reload=surveyWave&srwId=" + id.value + str;
}

function changequestion(id, str) {
   window.location="../../itemCopyUpdate.do?reload=question&questId=" + id.value + str;
}

function changerow(id, str) {
   window.location="../../itemCopyUpdate.do?reload=row&rowId=" + id.value + str;
}

function changecol(id, str) {
   window.location="../../itemCopyUpdate.do?reload=col&colId=" + id.value + str;
}

function onchangequestgroup(groupId, str) {
   window.location="questRotGroupEdit.do?groupId=" + groupId.value + str;
}

function removequote(str) {
 window.location=str;
}

function validateQuoteValue(quoteValue, str) {
 var iValue = parseInt(quoteValue.value);
 if(isNaN(iValue) || (iValue <= 0))
  {
    alert(str);
    return false;
  }
  else
    return true;
}

function validateQuoteConVariantPercent(percent, str) {
 var iValue = parseFloat(percent.value);
 if(isNaN(iValue) || (iValue <= 0) || (iValue > 100))
  {
    alert(str);
    return false;
  }
  else
    return true;
}

function validatePercent(percentElem, str) {
 var elem = document.getElementsByName(percentElem)[0];
 return validateQuoteConVariantPercent(elem, str);
}

function addnewquote(str) {
// window.showModalDialog(str, "", "dialogHeight:140px;");
 window.open(str,"","width=350, height=140,resizable=0,scrollbars=yes,menubar=no,left=340,top=150");
}

function addquotecon(str) {
// window.showModalDialog(str, "", "dialogHeight:330px;dialogWidth:550px;");
   OpenWindow(str, 550,330);
}

function editquotecon(str) {
 //window.showModalDialog(str, "", "dialogHeight:350px;dialogWidth:550px;");
   OpenWindow(str, 550,330);
}

function onchangereportlist(poz, str1, str2, width, height,str3){
  if (poz.value != 0){
    if (poz.value == 54){
//      OpenWindow("tableResults.do?surId="+str1+"&srwId="+str2, width, height);
      initialWindowLoadingFunc(str3);
      OpenWindow("tableResultEdit.do?surId="+str1+"&srwId="+str2, width, height);
    }

    if (poz.value == 55){
      initialWindowLoadingFunc(str3);
      OpenWindow("questReportSelectEdit.do?surId="+str1+"&srwId="+str2, width, height);
    }

    if (poz.value == 56){
      initialWindowLoadingFunc(str3);
      OpenWindow("connStats.do?surId="+str1+"&srwId="+str2, width, height);
    }
    if (poz.value == 57){
      initialWindowLoadingFunc(str3);
      OpenWindow("questionnairePrint.do?surId="+str1+"&srwId="+str2, width, height);
    }
    if (poz.value == 60){
      OpenWindow("genAsciiEdit.do?genAscii=true&surId=" + str1 + "&srwId=" + str2, 700, 590);
    }
    if (poz.value == 84){
      OpenWindow("genAsciiEdit.do?genRd=true&surId=" + str1 + "&srwId=" + str2, 700, 590);
    }
    if (poz.value == 85){
      OpenWindow("genAsciiEdit.do?genGesamt=true&surId=" + str1 + "&srwId=" + str2, 700, 400);
    }
    if (poz.value == 74){
      OpenWindow("quoteView.do?srwId=" + str2 + "&manager=true", 800, 600);
    }
    if (poz.value == 82){
      OpenWindow("workReportEdit.do?srwId=" + str2, 800, 600);
    }
    if (poz.value == 103){
      initialWindowLoadingFunc(str3);
      OpenWindow("noAnswerConnEdit.do?surId="+str1+"&srwId="+str2, width, height);
    }
    if (poz.value == 104){
      OpenWindow("InterviewList.jsp?managerIntvlist=true&surId=" + str1 + "&srwId=" + str2, 800, 600);
    }
  }
}
function onclicktablereport(poz, str1, str2, width, height){

  if (poz != 0){
    if (poz == 54){
      OpenWindow("tableResults.do?surId="+str1+"&srwId="+str2, width, height);
    }
    if (poz == 55){
      OpenWindow("ReportSurveyList.jsp", width, height);
    }
  }
}
// click on history of CATI
function onclickhistory(str1,str2) {
   OpenWindow("historyList.do?srwId="+str1+"&surId="+str2, 800,530);
}
// click on surweywaves - category
function onclickcategorylink(str) {
   OpenWindow(str, 800,530);
}

function checkColClick(clicked, str)
{

  if(clicked.checked == true)
   window.location=str + "&addItemToNewCol=true";
  else
   window.location=str + "&removeItemFromCol=true";
}

function onclickaddnewrespnumber(str, name)
{
 var elem = null;
 elem = document.getElementsByName(name)[0];
 if(elem.value.length > 0)
  window.location=str + "&newRespNumber=" + elem.value;

}

function onchangeitemtype(itemType, str)
{
  window.location = str + "&changeItemType=" + itemType.value;
}

 function isValidDate(day, month, year) {
	        if (month < 1 || month > 12) {
                    return false;
                }
                if (day < 1 || day > 31) {
                    return false;
                }
                if ((month == 4 || month == 6 || month == 9 || month == 11) &&
                    (day == 31)) {
                    return false;
                }
                if (month == 2) {
                    var leap = (year % 4 == 0 &&
                               (year % 100 != 0 || year % 400 == 0));
                    if (day>29 || (day == 29 && !leap)) {
                        return false;
                    }
                }
                return true;
            }

function checkopenitem(openType, openValue, str)
{
 if(openValue.value.length > 0)
 {
 if(openType=="Int")
 {
  var iValue = parseInt(openValue.value);
  if(isNaN(iValue) || (iValue < 0))
   {
     alert(str);
     return false;
   }
 }
 else
 if(openType=="Float" || openType=="Money")
 {
  var iValue = parseFloat(openValue.value);
  if(isNaN(iValue) || (iValue < 0))
   {
     alert(str);
     return false;
   }
 }
 else
 if(openType=="Date")
 {
  var day = parseInt(openValue.value.substring(0,2));
  var month = parseInt(openValue.value.substring(3,5));
  var year = parseInt(openValue.value.substring(6,10));
  if(isNaN(day) || isNaN(month) || isNaN(year) || !isValidDate(day, month, year))
   {
     alert(str);
     return false;
   }
 }
 }
 else
  return false;
}

function categoryonchange(obj, str)
{
 window.location=str + obj.value;
}

function tableresultsonchange(obj, str)
{
 window.location=str + obj.value;
}

function editcategory(str)
{
 window.open(str,"","width=450, height=230,resizable=0,scrollbars=yes,menubar=no,left=340,top=150");
}

function editopenrec(str)
{
 window.open(str,"","width=430, height=350,resizable=0,scrollbars=yes,menubar=no,left=340,top=150");
}

function openasciifile(str)
{
OpenWindowR(str, window.screen.Width, window.screen.Height, 1);
// window.open(str,"","width=" + window.screen.Width + ", window.screen.Height,resizable=0,scrollbars=yes,menubar=yes,left=0,top=0");
}

function onchangeselectreportlist(obj, str2,str)
{
 if(obj.value == 75){
 initialWindowLoadingFunc(str2);
// window.location=str + obj.value;
 window.location=str + 75;
 }
 if(obj.value == 76){
  initialWindowLoadingFunc(str2);
  window.location=str + 76;
 }
 if(obj.value == 77){
  initialWindowLoadingFunc(str2);
  window.location=str + 77;
 }
}

function onchangequestionlist(obj, str)
{
 window.location=str + obj.value;
}

function onchangecrossquestionlist(obj, str)
{
 window.location=str + obj.value;
}

function onclickremove(str)
{
 window.location=str;
}

function onchangegrouplist(obj, str)
{
 window.location=str + obj.value;
}

function saveAsMe(filename)
{
	document.execCommand('SaveAs',null,filename)
}

function printingReport(str)
{
//alert(str);
 window.open(str,"","width=670,height=330, resizable=1,scrollbars=yes,menubar=no,left=0,top=0");
// OpenWindowR(str, 700, 600, 0);
}

function printPage(but1, str, str1)
{
 var but2 = null;
 var but3 = null;
 but2 = document.getElementsByName(str)[0];
 but3 = document.getElementsByName(str1)[0];
	but1.style.display="none";
 if(but2 != null)
 	but2.style.display="none";
 if(but3 != null)
 	but3.style.display="none";
 window.print();
 but1.style.display="inline";
 if(but2 != null)
	 but2.style.display="inline";
	if(but3 != null)
  but3.style.display="inline";
}

function printQuestionnaire(str1, str2, width, height)
{
 OpenWindow("questionnairePrint.do?surId="+str1+"&srwId="+str2, width, height);
}

function getMiddleWidth(width)
{
var resWidth;
  if (browse() == 1){    // IE
    resWidth = window.screen.Width/2;
  }else{
    resWidth = screen.availWidth/2;
  }
  resWidth = resWidth - (width/2);
  return resWidth;
}

function getMiddleHeight(height)
{
var resHeight;
  if (browse() == 1){
    // IE
    resHeight = window.screen.Height/2;
  }else{
    resHeight = screen.availHeight/2;
  }
  resHeight = resHeight - (height/2);
  return resHeight;
}

function showRespInfo(respDBId)
{
 var left = getMiddleWidth(400);
 var top = getMiddleHeight(200);
 var str = "respondentInfo.do?id=" + respDBId + "&surveyor=true&returnURI=Content/ContentRespInfo.jsp";
 window.open(str,"","width=400,height=200, resizable=1,scrollbars=yes,menubar=no,left=" + left+ ",top=" + top);
}

function onchangeconnstatuser(str1,str2,str3)
{
  window.location="connStats.do?surId="+str2+"&srwId="+str3+"&userId="+str1.value;
}

function printingQuestCrossReport(str)
{
 window.open(str,"","width=800,height=530, resizable=1,scrollbars=yes,menubar=no,left=0,top=0");
}

function onchangenoanswerconnuser(str1,str2,str3)
{
  window.location="noAnswerConnUpdate.do?surId="+str2+"&srwId="+str3+"&userId="+str1.value;
}

function printingNoAnswerConn(str)
{
 window.open(str,"","width=800,height=530, resizable=1,scrollbars=yes,menubar=no,left=0,top=0");
}

var rmlw=null;
function initialWindowLoadingFunc(str) {
 var left = getMiddleWidth(800);
 var top = getMiddleHeight(530);
 var _d="<html><head><title>Loading...</title></head><body  style=\"background-color:#F2EDEC;\"><table width=\"100%\" height=\"100%\"><tr><td valign=middle align=center><b>"
         + str + "</b></td></tr></table></body></html>";
    rmlw = window.open("", "displayWindow", "width=800,height=530,resizable=1,scrollbars=yes,menubar=no,left=" + left+ ",top=" + top);
    rmlw.document.open();
	   rmlw.document.write(_d);
	   rmlw.document.close();
    rmlw.focus();
}
function closeWindowLoadingFunc(){if(rmlw){rmlw.close();rmlw=null;}}
function onclicktakecrossquestreport(str) {
 var left = getMiddleWidth(800);
 var top = getMiddleHeight(530);
 if(rmlw)
  rmlw.location=str;
 else
   window.open(str,"displayWindow","width=800,height=530,resizable=1,scrollbars=yes,menubar=no,left=" + left+ ",top=" + top);
}