

function loginSubmit()
{
	Form1.action="http://adkanit.tamal.co.il/htmls/login1.aspx?t=22";
	Form1.target="_self";
	Form1.method="post";
	Form1.submit();
}

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

//   TRIm FUNCTION

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function
function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
////////////////////   END OF TRIM
	// TOP BAR
	// Check if any of the tabs is selected, if not check the default tab

// onmouseout ="this.style.textDecoration='none'"
// onmouseover="this.style.textDecoration='underline'"
function ChangePWD_cancelclick() {
  document.Form1.hdnJvSubmited.value = '2';
  document.forms[0].submit();
}

function ChangePWD_okclick(){
  if (document.getElementById("inpEMAIL2") != null) {// change pwd/email
    if (document.getElementById("lblNewValue").innerHTML == lblNewValuetext) {
// change pwd
      if (Trim(document.getElementById("UserId").value) == "")   {
        alert(loginmsg1);
        document.Form1.UserId.focus();
        exit;
      }
      if (Trim(document.getElementById("inpEMAIL").value) == "") {
        alert(loginmsg2);
        document.Form1.inpEMAIL.focus();
      exit;
      }
      if (Trim(document.getElementById("inpEMAIL2").value) == "") {
        alert(loginmsg3);
        document.Form1.inpEMAIL2.focus();
      exit;
      }
    }
    else { // change email
      if (Trim(document.getElementById("UserId").value) == "")   {
        alert(loginmsg1a);
        document.Form1.UserId.focus();
        exit;
      }
      var str = Trim(document.getElementById("inpEMAIL").value);
      if ((str.length < 5) | (str.search(/@/) == -1)) {
        alert(loginmsg2a);
        document.Form1.inpEMAIL.value = '';
        document.Form1.inpEMAIL2.value = '';
        document.Form1.inpEMAIL.focus();
        exit;
      }
      if (Trim(document.getElementById("inpEMAIL2").value) == "") {
        alert(loginmsg3a);
        document.Form1.inpEMAIL2.focus();
      exit;
      }
    }
    if (Trim(document.getElementById("inpEMAIL2").value) != Trim(document.getElementById("inpEMAIL").value)) {
      document.Form1.inpEMAIL.value = '';
      document.Form1.inpEMAIL2.value = '';
      document.Form1.inpEMAIL.focus();
      alert(loginmsg4);
      exit;
    }
  }
  else {// FORGOT PWD
      if (Trim(document.getElementById("UserId").value) == "")   {
        alert(loginmsg1c);
        document.Form1.UserId.focus();
        exit;
      }
      if (Trim(document.getElementById("inpEMAIL").value) == "") {
        alert(loginmsg2c);
        document.Form1.inpEMAIL.focus();
      exit;
      }
  }
  document.Form1.hdnJvSubmited.value = '1';
  document.forms[0].submit();
}


function cust_register_okclick(){
  if (Trim(document.getElementById("UserId").value) == "")   {
    alert(loginmsg1);
    document.Form1.UserId.focus();
    exit;
  }
  if (Trim(document.getElementById("inpEMAIL").value) == "") {
    alert(loginmsg2);
    document.Form1.inpEMAIL.focus();
  exit;
  }
  var str = Trim(document.getElementById("inpEMAIL").value);
  if ((str.length < 5) | (str.search(/@/) == -1)) {
    alert(loginmsg2a);
    document.Form1.inpEMAIL.value = '';
    document.Form1.inpEMAIL2.value = '';
    document.Form1.inpEMAIL.focus();
    exit;
  }
  if (Trim(document.getElementById("inpName").value) == "") {
    alert(loginmsg3);
    document.Form1.inpName.focus();
  exit;
  }
  if (Trim(document.getElementById("inpEMAIL2").value) == "") {
    alert(loginmsg4);
    document.Form1.inpEMAIL.focus();
  exit;
  }
  if (Trim(document.getElementById("inpEMAIL2").value) != Trim(document.getElementById("inpEMAIL").value)) {
    document.Form1.inpEMAIL.value = '';
    document.Form1.inpEMAIL2.value = '';
    document.Form1.inpEMAIL.focus();
    alert(loginmsg5);
    exit;
  }
  if (Trim(document.getElementById("lstThumIsuk").value) == "0")   {
    alert(loginmsg6);
    document.Form1.lstThumIsuk.focus();
    exit;
  }
  document.Form1.hdnJvSubmited.value = '1';
  document.forms[0].submit();
}

function dwnld_admin_getcustnum_okclick(){
//  if (document.getElementById("UserId") != null) {// change pwd/email
      if (Trim(document.getElementById("UserId").value) == "")   {
        alert(loginmsg1);
        document.Form1.UserId.focus();
        exit;
      }
      document.Form1.hdnJvSubmited.value = '1';
      document.forms[0].submit();
//  }
}

function dwnld_admin_savedata() {
  document.Form1.hdnJvSubmited.value = '1';
  document.forms[0].submit();
}
function dwnld_admin_emlpwd() {
  document.Form1.hdnJvSubmited.value = '2';
  document.forms[0].submit();
}

function dwnld_admin_nextcust() {
  document.Form1.hdnJvSubmited.value = '5';
  document.forms[0].submit();
}

function dwnld_admin_deletecust() {
  if (confirm(loginmsg6))
  {
  document.Form1.hdnJvSubmited.value = '4';
  document.forms[0].submit();
  }
}



function login_okclick(){
  if (Trim(document.getElementById("UserId").value) == "")   {
    alert(loginmsg1b+document.getElementById("Label6").innerHTML);
    document.Form1.UserId.focus();
    exit;
  }
  if (Trim(document.getElementById("UserPass").value) == "") {
    alert(loginmsg2);
    document.Form1.UserPass.focus();
  exit;
  }
  document.Form1.hdnJvSubmited.value = '1';
  document.forms[0].submit();
}
///////////////////////////////////////////////////////
//
//    Hagdarot
//

function logon_CustRgstrtion() {
  document.Form1.hdnJvSubmited.value = '3';
  document.forms[0].submit();
}

function hgdrt_Back() {
  document.Form1.hdnJvSubmited.value = '3';
  document.forms[0].submit();
}

function hgdrt_ForgotEmail(){
  document.Form1.hdnJvSubmited.value = '4';
  document.forms[0].submit();
}

function hgdrt_ChangePWD(){
  document.Form1.hdnJvSubmited.value = '2';
  document.forms[0].submit();
}
//
//
//////////////////////////////////////////////////////////////////

function ChangePWD_Backclick(){
  document.Form1.hdnJvSubmited.value = '2';
  document.forms[0].submit();
}


function Blinkext() {
  if (document.getElementById("lblEmpId").innerHTML.length == 0) {
  document.getElementById("lblEmpId").innerHTML = dwmldmsg2
  setTimeout("Blinkext()",1750);
  }
  else {
  document.getElementById("lblEmpId").innerHTML = ''
  setTimeout("Blinkext()",250);
  }
}

function rlst_ChoosProd(evt) {
  var el;
  if (confirm(dwmldmsg1)) {
  (typeof window.event!="undefined")? el=event.srcElement : el=evt.target;
  InitProdDetails(el);
  if (document.Form1.hdnChosenDate.value.indexOf(hsltstr) > -1) {
    Blinkext();
    }
  document.forms[0].submit();
  }
}
//rlst_ChoosRep()
function rlst_ChoosRep(evt) {
  var el;
  (typeof window.event!="undefined")? el=event.srcElement : el=evt.target;
  InitRepsDetails(el);
  document.forms[0].submit();
}

function InitProdDetails(el){
  var tde = el.parentNode;
  var tre = tde.parentNode;
  var lbls = tre.getElementsByTagName("span");
  for (var j = 0 ; j < lbls.length; j++)  {
    var tmpstr = lbls[j].id.slice(lbls[j].id.length-1,lbls[j].id.length);
    if (tmpstr=='0') { // hdnChosenCstN - have to be hidden name
      document.Form1.hdnChosenDate.value = lbls[j].innerHTML;
      document.Form1.hdnJvSubmited.value = '1';
    }
  }
}

function hgdrt_Exit() {
 location = "http://www.tamal.co.il";
}

function InitRepsDetails(el) {
  var tde = el.parentNode;
  var tre = tde.parentNode;
  var lbls = tre.getElementsByTagName("span");
  for (var j = 0 ; j < lbls.length; j++)  {
    var tmpstr = lbls[j].id.slice(lbls[j].id.length-1,lbls[j].id.length);
    if (tmpstr=='0') { // hdnChosenCstN - have to be hidden name
      document.Form1.hdnChosenDate.value = lbls[j].innerHTML;
      document.Form1.hdnJvSubmited.value = '1';
    }
    else if (tmpstr=='1') { // hdnChosenCstN - have to be hidden name
      document.Form1.hdnChosenCompName.value = lbls[j].innerHTML;
      document.Form1.hdnJvSubmited.value = '1';
    }
  }
//  alert(document.Form1.hdnChosenDate.value);
}

function EmpRepListOnLoad(){
// with out this - "back" from customerEdit to custList and sorting -> instead of sort opend custedit again
  document.Form1.hdnChosenCompName.value = '';
  document.Form1.hdnChosenDate.value = '';
//  ResetScrollPosition();
  if (document.Form1.hdnLogInMssg.value == '')
  {
  }
  else if (document.Form1.hdnLogInMssg.value == 101) // changepwd = ok
  {     alert(emplstmsg3);   }
  else if (document.Form1.hdnLogInMssg.value == 100) // changepwd = unnown error
  {     alert(emplstmsg4);   }
  else if (document.Form1.hdnLogInMssg.value == 301) // changepwd = unnown error
  {     alert(emplstmsg5);   }
  else
  {     alert(document.Form1.hdnLogInMssg.value);   }
  document.Form1.hdnLogInMssg.value = '';
}

function Admin_NoKibuz(evt){
  document.Form1.hdnJvSubmited.value = "";
  var el;
  (typeof window.event!="undefined")? el=event.srcElement : el=evt.target;
/*  if ((el.id != "lblDelete") && (el.id != "btnBack")&& (el.id != "btnDelete"))
  {
      if (Trim(document.getElementById("txtFromDate").value) == "")
      {
        alert(changepwd_msg1)
        document.Form1.txtFromDate.focus();
        EXIT;
      }
      if (Trim(document.getElementById("txtToDate").value) == "")
      {
        alert(changepwd_msg1)
        document.Form1.txtToDate.focus();
        EXIT;

  }   }*/
  document.Form1.hdnJvSubmited.value = el.id;
  document.forms[0].submit();
}

function onmouseoverlink(evt) {
  var el;
  (typeof window.event!="undefined")? el=event.srcElement : el=evt.target;
  el.style.color = "red"
}

function onmouseoutlinkblue() {
  var el;
  (typeof window.event!="undefined")? el=event.srcElement : el=evt.target;
  if ((document.getElementById("lblKtrt") != null) &&
    (document.getElementById("lblKtrt").innerHTML == lblktrt_idknthn)) {
    document.getElementById("lblLink1Right").style.color = "red";
    document.getElementById("lblLink2Right").style.color = "#218CCE";
  }
  else {
    el.style.color = "#218CCE"
  }
}

function onclicklink() {
  if (document.getElementById("lblLink1Right").innerHTML == labellinkwantedtml) {
    location = "http://www.tamal.co.il/tamal_he_wanted.aspx";
  }
  else if (document.getElementById("lblLink1Right").innerHTML == labellinkidkunim) {
    location = "https://adkanit.tamal.co.il/htmls/login1.aspx?t=2";
  }
  else {
    alert(document.getElementById("lblLink1Right").innerHTML)
  }
}

function onclicklink2() {
  if (document.getElementById("lblLink2Right").innerHTML == labellinkwanted) {
    location = "http://www.tamal.co.il/tamal_he_wanted_general.aspx";
  }
  else {
    alert(mssgbniya);
  }
}

function ForgotPWD(){
/*  if (Trim(document.getElementById("UserId").value) == "")   {
    alert(loginmsg1a)
    document.Form1.UserId.focus();
    EXIT;
  }
  if (confirm(loginmsg3))*/
  {
    document.Form1.hdnJvSubmited.value = '2';
    document.forms[0].submit();
  }
}

function ChangePwdOnLoad() {
  if (document.Form1.hdnLogInMssg.value == '')
  {
  }
  else if (document.Form1.hdnLogInMssg.value == '2') // wrong pwd
  {     alert(changepwd_msg6)   }
  document.Form1.hdnJvSubmited.value = '';
  document.Form1.hdnLogInMssg.value = '';
  document.Form1.OldPwd.focus();
}

function chngpwd_onkeyup(e) {
  if (window.event.keyCode == 13) {
    ChangePWD_okclick();
  }
}

function custrstr_onkeyup(e) {
//  alert(window.event.keyCode);
  if (window.event.keyCode == 13) {
    cust_register_okclick();
  }
}
function login_onkeyup(e) {
  if (window.event.keyCode == 13) {
    login_okclick();
  }
}
function dwnld_admin_onkeyup(e) {
  if (window.event.keyCode == 13) {
    dwnld_admin_getcustnum_okclick();
  }
}

function rlst_hagdarot(){
  document.Form1.hdnJvSubmited.value = '2';
  document.forms[0].submit();
}

function rlst_hitnatek(){
  document.Form1.hdnJvSubmited.value = '5';
  document.forms[0].submit();
}

function rlst_ezra(){
  alert('ezra?');
}
/////////////////////////////////////////////////////////
//
//     GetEmail
//
function getemail_backclick(){
  document.Form1.hdnJvSubmited.value = '2';
  document.forms[0].submit();
}

function getemail_okclick(){
  if (Trim(document.getElementById("emailtxtbx").value) == "")   {
    alert(msg3)
    document.Form1.emailtxtbx.focus();
    EXIT;
  }
  document.Form1.hdnJvSubmited.value = '1';
  document.forms[0].submit();
}

function GetEmail_OnLoad() {
  document.Form1.emailtxtbx.focus();
}
//
//
/////////////////////////////////////////////////////////

function SaveScrollXY() {   // not executing this if this in tmlfunction.js
  var I = document.body.scrollTop;
    document.Form1.ScrollX.value = document.body.scrollLeft;
    document.Form1.ScrollY.value = document.body.scrollTop;
//    alert('save y = '+document.Form1.ScrollY.value);
}
function ResetScrollPosition() {
//      alert('here');
    var hidx, hidy;
    hidx = document.Form1.ScrollX;
    hidy = document.Form1.ScrollY;
    if (typeof hidx != 'undefined' && typeof hidy != 'undefined') {
  //	alert('set = '+hidx.value + ' -- ' + hidy.value);
        window.scrollTo(hidx.value, hidy.value);
    }
}


function dwnldAdminOnLoad() {
  LogIn1OnLoad();
  ResetScrollPosition();
}


function LogIn1OnLoad() {
  if (document.Form1.hdnLogInMssg.value == '')
  {
  }
  else if ((document.Form1.hdnLogInMssg.value == '1') ||
   (document.Form1.hdnLogInMssg.value == '201')) // forgot pwd
  {     alert(loginmsg3)   }
  else if (document.Form1.hdnLogInMssg.value.length == 8)
  {     alert(loginmsg3+'\n'+document.Form1.hdnLogInMssg.value);   }
  else if ((document.Form1.hdnLogInMssg.value == 103) || // changepwd = wrong empid
    (document.Form1.hdnLogInMssg.value == 203)) // forgot pwd
  {     alert(loginmsg6);   }
  else if (document.Form1.hdnLogInMssg.value == 205) // forgot pwd
  {     alert(loginmsg7+'\n'+loginmsg7_1+'\n'+loginmsg7_2);   }
  else if (document.Form1.hdnLogInMssg.value == 301) // forgot pwd
  {     alert(loginmsg7+'\n'+loginmsg7_1);
        location = "http://www.tamal.co.il";
  }
  else
  {     alert(document.Form1.hdnLogInMssg.value);   }
  document.Form1.hdnJvSubmited.value = '';
  document.Form1.hdnLogInMssg.value = '';
  document.Form1.UserId.focus();
}


