﻿//Made by manish to handle request
function getRequestObject() {
    if (!window.XMLHttpRequest) {
        var progIDs = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
        for (var i = 0; i < progIDs.length; i++) {
            try {
                var xmlHttp = new ActiveXObject(progIDs[i]);
                return xmlHttp;
            } catch (ex) { };
        }
    } else {
        xmlHttp = new XMLHttpRequest();
        return xmlHttp;
    }
}
//Made by manish to handle request
function sendemail() {
          var vars;
          username = document.getElementById("ForgotTextbox").value;
          serverName = document.getElementById("domainName").value;
          vars = username + "$|$" + serverName + '$|$' + document.getElementById('HfsiteId').value;
          if (username != "") {

              
              var xmlHttp = getRequestObject();
              xmlHttp.open("POST", "http://" + window.location.host + "/MyDefaultHandler.ashx?fname=EmailPwd&params=" + vars, true);
              xmlHttp.onreadystatechange = function() {
                  if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                      try {
                          var responseoutput = xmlHttp.responseText;
                          LoadCallbackEmailPwd(responseoutput);
                      }
                      catch (ex) {
                      }
                  }
              }
              xmlHttp.send();  
          
                      
              document.getElementById('LoginPanel').style.display = 'block';
              document.getElementById('ForgotPasswordBlock').style.display = 'none';
              hideLoginBox();
          }
          else {
              alert("Please enter the User name");
              document.getElementById('LoginPanel').style.display = 'none';
              document.getElementById('ForgotPasswordBlock').style.display = 'block';
          }
      }
      function LoadCallbackEmailPwd(content) {
          if (content == "1") {
              document.getElementById('loginErrMsg').innerHTML = "Uw wachtwoord is verstuurd.";
          }
          else if (content == "2") {
              document.getElementById('loginErrMsg').innerHTML = "Account bestaat niet.";
          }
          else {
              document.getElementById('loginErrMsg').innerHTML = "Unable to send email";
          }
      }


      if (document.getElementById('loginerrmsg') != null) {
          if (document.getElementById('loginerrmsg').value == "1") {
              document.getElementById('fade').style.display = 'block';
              document.getElementById('loginblock').style.display = 'block';
              document.getElementById('loginerrmsg').value = "0";
              document.getElementById('UserNameTextbox').value = '';
              document.getElementById('Passwordbox').value = '';
          }
      }
      function showForgetPassword() {

          document.getElementById('loginblock').style.display = 'none';
          document.getElementById('ForgotPasswordBlock').style.display = 'block';

      }

      function showLoginBox() {
          document.getElementById('UserNameTextbox').value = '';
          document.getElementById('Passwordbox').value = '';
          document.getElementById('fade').style.display = 'block';
          document.getElementById('loginblock').style.display = 'block';
      }
      function hideLoginBox() {
          document.getElementById('LoginPanel').style.display = 'block';
          document.getElementById('ForgotPasswordBlock').style.display = 'none';
          document.getElementById('fade').style.display = 'none';
          document.getElementById('loginblock').style.display = 'none';

      }
      //##################################### For Contact form    09-05-2011   start   ###################################
      function showContactBox(id, _content) {


          document.getElementById('fade').style.display = 'block';
          document.getElementById('contactblock').style.display = 'block';
          document.getElementById('contactPanelcontent').innerHTML = _content;
          document.getElementById('frmsubmitid').value = "frmsubmit_" + id;
      }
      function hidecontactBox() {

          document.getElementById('fade').style.display = 'none';
          document.getElementById('contactblock').style.display = 'none';

      }
      //##################################### For Contact form    09-05-2011    end   ###################################
      //##################################### For Signup form    27-06-2011   start   ###################################
      function showSignupBox(id, _content) {


          document.getElementById('fade').style.display = 'block';
          document.getElementById('Signupblock').style.display = 'block';
          document.getElementById('SignupPanelcontent').innerHTML = _content;
          document.getElementById('frmsubmitid').value = "frmsubmit_" + id;
      }
      function hideSignupBox() {

          document.getElementById('fade').style.display = 'none';
          document.getElementById('Signupblock').style.display = 'none';

      }
      //##################################### For Signup form    27-06-2011   end   ###################################



      function disableEnterKey(e) {
          var key;

          if (window.event)
              key = window.event.keyCode;     //IE
          else
              key = e.which;     //firefox

          if (key == 13)
              return false;
          else
              return true;

      }
      function frmsubmit(url, id) {
          var sVars = encodeURIComponent(url) + "$|$" + id;
          var xmlHttp = getRequestObject();        
          xmlHttp.open("POST", "http://"+window.location.host + "/MyDefaultHandler.ashx?fname=getContact&params=" + sVars, true);
          xmlHttp.onreadystatechange = function() {
              if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                  try {
                     var responseoutput = xmlHttp.responseText;
                      LoadCallbackgetContact(responseoutput);                      
                  }
                  catch (ex) {
                  }
              }
          }
          xmlHttp.send();    
      }

      function LoadCallbackgetContact(cont) {
          var nm = "";
          var ffid = cont.split("||#||");
          var _fid = ffid[1];
          var _url = ffid[2];
          var values_rows_array = ffid[0].split("|||");
          var msg = values_rows_array[0].split("|$|");
          for (i = 1; i < values_rows_array.length - 1; i++) {
              var rowarr = values_rows_array[i].split("|$|");
              nm = nm + "<tr><td>" + rowarr[0] + "</td>" + " <td>:</td> ";
              var elm = rowarr[1];
              elm = elm.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
              vl = document.getElementById(elm).value;
              nm = nm + "<td>" + vl + "</td></tr>";
          }
          var data_content = "<table style='text-align:left'>" + nm + "</table>";
          var err_dtl = values_rows_array[values_rows_array.length - 1];
          if (err_dtl.length > 4) {

              var _siid = document.getElementById('HfsiteId').value;
              var sVars = _fid + "$|$" + data_content + "$|$" + _siid + "$|$" + encodeURIComponent(_url);
              xmlHttp = getRequestObject();
              xmlHttp.open("POST", "http://" + window.location.host + "/MyDefaultHandler.ashx?fname=sendContact&params=" + sVars, true);            
              xmlHttp.onreadystatechange = function() {
                  if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                      try {
                         var  responseoutput = xmlHttp.responseText;
                          LoadCallbacksendContact(responseoutput);                      
                      }
                      catch (ex) {
                      }
                  }
              }
              xmlHttp.send();     
                
                      
          }
          else {
              var _siid = document.getElementById('HfsiteId').value;
              var sVars = _fid + "$|$" + data_content + "$|$" + _siid + "$|$" + encodeURIComponent(_url);
              xmlHttp = getRequestObject();
              xmlHttp.open("POST", "http://" + window.location.host + "/MyDefaultHandler.ashx?fname=sendContact&params=" + sVars, true);
              xmlHttp.onreadystatechange = function() {
                  if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
                      try {
                          var responseoutput = xmlHttp.responseText;
                          LoadCallbacksendContact(responseoutput);
                      }
                      catch (ex) {
                      }
                  }
              }
              xmlHttp.send();     
          }
      }
      function LoadCallbacksendContact(cont) {
          var temp = cont.split("ln;");
          cont = temp[0];
          if (cont != "") {
              document.getElementById('frmsubmitid').value = "1";

              var re = cont.replace(";", "=");
              re = re.replace(";", "=");
              re = re.replace(";", "=");
              re = re.replace(";", "=");

              window.location = re;

          }
          else {
              document.getElementById('frmsubmitid').value = cont;
          }
      }

      var imgid = 'image';
      //var imgdir = 'uploads/6/galleries/41';
      var imgdir = "";
      var dirid = document.getElementById('hfslidedirpath');

      if (dirid != null) {

          imgdir = dirid.value;
      }

      var imgid = imgdir;
      var imgext = '.jpg';
      var thumbid = 'thumbs';
      var auto = true;
      var autodelay = 3;   


