/*=======================================================================
 *
 * searchLists.js
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/


function searchAddress(mode) {
  var f_street = document.forms[0].f_ad_street.value;
  var f_zipcode = document.forms[0].f_ad_zipcode.value;
  var f_city = document.forms[0].f_ad_city.value;
  
  if (mode == 'cs') {
     var customerId = document.forms[0].customerId.value;
     var cscIdRoot = document.forms[0].cscIdRoot.value;
     var cscIdActual = document.forms[0].cscIdActual.value;  
  } else {
     var customerId = '';
     var cscIdRoot = '';
     var cscIdActual = '';
  }
  
  var f_act = 'search';

  var widthPopupWin = 800;
  var heightPopupWin = 600;
  var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
  var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
  var popupWin;
  popupWin = window.open("../admin/ad_list.php?f_act=" + f_act + "&f_street=" + myEncodeURI(f_street) + "&f_zipcode=" + f_zipcode + "&f_city=" + myEncodeURI(f_city) + "&customerId=" + customerId + "&cscIdRoot=" + cscIdRoot + "&cscIdActual=" + cscIdActual, "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};

function searchCsCsc() {
  var f_comp = document.forms[0].f_cmp_comp.value;
  var f_comp2 = document.forms[0].f_cmp_comp2.value;
  var f_name = document.forms[0].f_usr_name.value;
  var f_phone = document.forms[0].f_usr_phone.value;
  var f_email = document.forms[0].f_usr_email.value;
  var f_act = 'search';

  var widthPopupWin = 1000;
  var heightPopupWin = 700;
  var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
  var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
  var popupWin;
  popupWin = window.open("../admin/cs_csc_list.php?f_act=" + f_act + "&f_cmp_comp=" + f_comp + "&f_cmp_comp2=" + f_comp2 + "&f_name=" + f_name + "&f_usr_phone=" + f_phone + "&f_usr_email=" + f_email, "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};

function searchCsCscGeneric(genericStr, callOpenerFunctionStr, jsParName) {
	if (jsParName == undefined) {jsParName = ''};
  var f_act = 'search';
  var widthPopupWin = 1000;
  var heightPopupWin = 700;
  var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
  var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
  var popupWin;
  popupWin = window.open("../admin/cs_csc_list.php?f_act=" + f_act + "&generic=" + genericStr + "&callOpenerFunction=" + callOpenerFunctionStr + "&genJsParName=" + jsParName + "&allowAllCustomerTypes=1",
    "","dependent=yes,width=" + widthPopupWin + ",height=" +
    heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin +
    ",scrollbars=yes");
};

function searchCourier(mode) {
  var f_act = 'search';
  var widthPopupWin = 850;
  var heightPopupWin = 600;
  var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
  var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
  var popupWin;
  popupWin = window.open("../admin/courier_list.php?deactivateMenu=1&f_act=" + f_act + "&f_mode=" + mode, "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};

function searchCourierGeneric(jsParName) {
  var f_act = 'search';
  var widthPopupWin = 850;
  var heightPopupWin = 600;
  var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
  var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
  var popupWin;
  popupWin = window.open("../admin/courier_list.php?deactivateMenu=1&f_act=" + f_act + "&f_mode=0" + "&genJsParName=" + jsParName, "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};

function myEncodeURI(aString) {
  var aStringNew = "";
  for (i = 0; i < aString.length; i++) {
    aStringNew = aStringNew + '%' + aString.charCodeAt(i).toString(16);
  }
  return aStringNew;
};
