﻿/*
function userLoginFunction(mode, uId, pwd)
{     
//alert(mode + ',' + ProdId + ',' + CatId);
if(mode!="")
{    
if(mode=="1")
{
var objUserId=document.getElementById(uId);
var objUserPassword=document.getElementById(pwd);
if(objUserId ==null || objUserPassword==null)
{
alert("Please insert User Id and Password both, then try again.");                                         
}
else if(objUserId !=null && objUserPassword!=null)
{
if(objUserId.value=="" || objUserPassword.value=="")
{
alert("Please insert User Id and Password both, then try again.");
}
else
{
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) 
{
self.xmlHttpReq = new XMLHttpRequest();        
}
else if (window.ActiveXObject) 
{
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");         
}     
self.xmlHttpReq.open('POST', "ajaxLogin.aspx", true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() 
{        
if (self.xmlHttpReq.readyState == 4) 
{         
                            
var GetValue=new Array();
if(self.xmlHttpReq.responseText.indexOf('~' != -1))
{
GetValue=self.xmlHttpReq.responseText.split("~");
}                        
if(GetValue[0]=="0")
{
alert(GetValue[1].toString());
document.getElementById("dvLoginTable").style.display="block";
}
else if(GetValue[0]=="1")
{
//alert("To Cart");
//alert(GetValue[1].toString());   
document.getElementById("dvLoginTable").style.display="block";
document.getElementById("dvLoginTable").innerHTML=GetValue[1].toString();
//alert(GetValue[1].toString() + "You are redirected to Giftstoindia24x7. Thanks for logging.");
window.location="http://www.giftstoindia24x7.com";
}
                            
document.getElementById("dvAjaxLoad").style.display="none";
}
else
{
document.getElementById("dvLoginTable").style.display="none";
document.getElementById("dvAjaxLoad").style.display="block";
}
}
self.xmlHttpReq.send("Mode="+ mode + "&userId=" + objUserId.value + "&userPwd=" + objUserPassword.value); 
                 
}  // object values are not null
                 
}       //objects are not null
else
{
alert("Error retrieving the objects. Please try later.");
}         
}             // Mode 1
}               // if mode not null
else
{
alert("There is some error on process. Please try later.");
}
}

function clearForm(uId, pwd)
{
var objUserId=document.getElementById(uId);
var objUserPassword=document.getElementById(pwd);
if(objUserId !=null && objUserPassword!=null)
{
objUserId.value="";
objUserPassword.value="";    
}   
else
{
alert("Error retrieving the objects. Please try later.");
}
}

//var redirecturl="http://www.giftstoindia24x7.com"
////specify pause duration before redirection (in seconds)
//var pausefor=5

////DONE EDITING

//function postaction()
//{
//    if (window.timer)
//    {
//        clearInterval(timer)
//        clearInterval(timer_2)
//    }
//    window.location=redirecturl
//}
//setTimeout("postaction()",pausefor*1000)*/

//====================================New javascript============================================================
function IsNumeric(e) { var KeyID = (window.event) ? event.keyCode : e.which; if ((KeyID >= 66 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126)) { return false; } return true; }
function allowedKey(e) { var KeyID = (window.event) ? event.keyCode : e.which; if ((KeyID >= 33 && KeyID <= 47) || (KeyID == 32) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 94) || (KeyID == 96) || (KeyID >= 123 && KeyID <= 126)) { return false; } return true; }
var s = 0;
var interv;
function userLogin(obj) {
    var oui = document.getElementById("Uc_Header_New1_uid");
    var oup = document.getElementById("Uc_Header_New1_pwd");
    var om = document.getElementById("Uc_Header_New1_login1");
    var ajx = document.getElementById("ajxLoad");
    var lggd = document.getElementById("Uc_Header_New1_loggedin");

    //alert("uid: " + oui+ " pwd: " +oup + " main: " +om + " ajx: " + ajx+ " logged:" +lggd); 
    if (oui != null && oup != null && om != null && lggd != null && ajx != null) {
        if (oui.value == "" || oup.value == "") {
            alert("Please mention user Id and Password both, then try again.");
            if (oui.value == null || oui.value == "") { oui.focus(); } else { oup.focus(); }
        }
        else {
            if (validateEmail(oui.value)) {
                var xmlHttpReq = false;
                var self = this;
                if (window.XMLHttpRequest) {
                    self.xmlHttpReq = new XMLHttpRequest();
                }
                else if (window.ActiveXObject) {
                    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
                }
                self.xmlHttpReq.open('POST', "http://www.giftstoindia24x7.com/ajaxLogin.aspx", true);
                self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                self.xmlHttpReq.onreadystatechange = function () {
                    if (self.xmlHttpReq.readyState == 4) {
                        om.disabled = false;
                        ajx.style.display = "none";
                        var GetValue = new Array();
                        if (self.xmlHttpReq.responseText.indexOf('~' != -1)) {
                            GetValue = self.xmlHttpReq.responseText.split("~");
                            if (GetValue[0] == "0") {
                                om.style.display = "block";
                                alert(GetValue[1].toString());
                                oup.value = "";
                                oup.focus();
                            }
                            else if (GetValue[0] == "1") {
                                om.style.display = "none";
                                lggd.style.display = "block";
                                lggd.innerHTML = GetValue[1].toString();
                                oui.value = "";
                                oup.value = "";
                                if (document.URL == "http://www.giftstoindia24x7.com/login.aspx") {
                                    window.location.href = "http://www.giftstoindia24x7.com/mygti.aspx";
                                }
                                else {
                                    window.location.href = document.URL;
                                }
                            }
                        }
                        else {
                            om.disabled = false;
                            //om.style.display="block";
                            alert("Due to some error you are not allowed to log in. Please try later.");
                        }
                    }
                    else {
                        om.disabled = true;
                        //om.style.display="none";
                        ajx.style.display = "block";
                    }
                }
                self.xmlHttpReq.send("Mode=userLogin&userId=" + encodeURIComponent(oui.value) + "&userPwd=" + encodeURIComponent(oup.value));
            }
            else {
                alert("Please mention a valid email address. Then try again!");
                oui.focus();
            }
        }  // object values are not null
    }
    else {
        alert("Due to some error you are not allowed to log in. Please refresh the page and try again.");
    }
}

function red() { s++; if (s == 5) { clearInterval(interv); window.location.href = "http://www.giftstoindia24x7.com"; } }
function clearForm(uId, pwd) {
    var oui = document.getElementById('uid');
    var oup = document.getElementById('pwd');
    if (oui != null && oup != null) {
        oui.value = "";
        oup.value = "";
        oui.focus();
    }
    else {
        alert("Error retrieving the objects. Please try later.");
    }
}
function validateEmail(str) {
    if (str) {
        var at = "@"
        var dot = "."
        var lat = str.indexOf(at)
        var lstr = str.length
        var ldot = str.indexOf(dot)
        if (str.indexOf(at) == -1) {
            //alert("Invalid E-mail ID")
            return false;
        }

        if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
            //alert("Invalid E-mail ID")
            return false;
        }

        if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
            //alert("Invalid E-mail ID")
            return false;
        }

        if (str.indexOf(at, (lat + 1)) != -1) {
            //alert("Invalid E-mail ID")
            return false;
        }

        if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
            //alert("Invalid E-mail ID")
            return false;
        }

        if (str.indexOf(dot, (lat + 2)) == -1) {
            //alert("Invalid E-mail ID")
            return false;
        }

        if (str.indexOf(" ") != -1) {
            //alert("Invalid E-mail ID")
            return false;
        }
        return true
    }
    else {
        return false;
    }
}
function logout(obj) {
    var oa = document.getElementById('ajxLoad');
    var ol = document.getElementById('Uc_Header_New1_login1');
    var olo = document.getElementById('Uc_Header_New1_loggedin');
    //alert("login: " + ol+ " logout: " + olo+ " ajx: " + oa);
    if (oa != null && ol != null && olo != null) {
        var xmlHttpReq = false;
        var self = this;
        if (window.XMLHttpRequest) {
            self.xmlHttpReq = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) {
            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        self.xmlHttpReq.open('POST', "http://www.giftstoindia24x7.com/ajaxLogin.aspx", true);
        self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        self.xmlHttpReq.onreadystatechange = function () {
            if (self.xmlHttpReq.readyState == 4) {
                oa.style.display = "none";
                if (self.xmlHttpReq.responseText.toString() != "") {
                    if (self.xmlHttpReq.responseText.indexOf('~' != -1)) {
                        GetValue = self.xmlHttpReq.responseText.split("~");
                        if (GetValue[0] == "0") {
                            ol.style.display = "none";
                            olo.style.display = "block";
                        }
                        else if (GetValue[0] == "1") {
                            ol.style.display = "block";
                            olo.style.display = "none";
                            if (document.URL == "http://www.giftstoindia24x7.com/mygti.aspx#" || document.URL == "http://www.giftstoindia24x7.com/mygti.aspx") {
                                window.location.href = "http://www.giftstoindia24x7.com/";
                            }
                            else {
                                window.location.href = document.URL;
                            }
                        }
                    }
                    else {
                        alert("Sorry, we cannot you let you logout this time. Please try later.");
                    }
                }
                else {
                    alert("Sorry, we cannot you let you logout this time. Please try later.");
                }
            }
            else {
                ol.style.display = "none";
                olo.style.display = "none";
                oa.style.display = "block";
            }
        }
        self.xmlHttpReq.send("Mode=userLogout");
    }
}
//var redirecturl="http://www.giftstoindia24x7.com"
////specify pause duration before redirection (in seconds)
//var pausefor=5

////DONE EDITING

//function postaction()
//{
//    if (window.timer)
//    {
//        clearInterval(timer)
//        clearInterval(timer_2)
//    }
//    window.location=redirecturl
//}
//setTimeout("postaction()",pausefor*1000)
function checklogin(obj) {
    alert(parent.document.getElementById("Uc_Header_New1_login1").innerHTML);
}

function ForgotPasswordMail(obj) {
    var objemail = document.getElementById("Uc_Header_New1_txtId");
    var lblerror = document.getElementById("Uc_Header_New1_lblError");

    if (objemail != null) {
        var email = objemail.value;
        if (validateEmail(email)) {
            var xmlHttpReq = false;
            var self = this;
            if (window.XMLHttpRequest) {
                self.xmlHttpReq = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            self.xmlHttpReq.open('POST', "http://www.giftstoindia24x7.com/ajaxLogin.aspx", true);
            self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            self.xmlHttpReq.onreadystatechange = function () {
                if (self.xmlHttpReq.readyState == 4) {
                    if (self.xmlHttpReq.responseText.toString() != "") {
                        if (self.xmlHttpReq.responseText.indexOf('~' != -1)) {
                            GetValue = self.xmlHttpReq.responseText.split("~");
                            if (GetValue[0] == "forgotmail") {
                                if (GetValue[1] == "T") {
                                    lblerror.innerHTML = "Mail has been sent. Please check inbox or the bulk mail folder.";
                                }
                                else {
                                    lblerror.innerHTML = "Email not found in database.Please re-type email.";
                                }

                            }

                        }

                    }
                }

            }
            self.xmlHttpReq.send("Mode=forgotmail&email=" + email + "");
        }
        else {
            lblerror.innerHTML = "Please provide valid email address."
        }
    }
    else {
        lblerror.innerHTML = "Please provide valid email address."
    }
}

function ForgotPasswordMail1(obj) {
    var objemail = document.getElementById("txtId1");
    var lblerror = document.getElementById("lblError1");

    if (objemail != null) {
        var email = objemail.value;
        if (validateEmail(email)) {
            var xmlHttpReq = false;
            var self = this;
            if (window.XMLHttpRequest) {
                self.xmlHttpReq = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            self.xmlHttpReq.open('POST', "http://www.giftstoindia24x7.com/ajaxLogin.aspx", true);
            self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            self.xmlHttpReq.onreadystatechange = function () {
                if (self.xmlHttpReq.readyState == 4) {
                    if (self.xmlHttpReq.responseText.toString() != "") {
                        if (self.xmlHttpReq.responseText.indexOf('~' != -1)) {
                            GetValue = self.xmlHttpReq.responseText.split("~");
                            if (GetValue[0] == "forgotmail") {
                                if (GetValue[1] == "T") {
                                    lblerror.innerHTML = "Mail has been sent. Please check inbox or the bulk mail folder.";
                                }
                                else {
                                    lblerror.innerHTML = "Email not found in database.Please re-type email.";
                                }

                            }

                        }

                    }
                }

            }
            self.xmlHttpReq.send("Mode=forgotmail&email=" + email + "");
        }
        else {
            lblerror.innerHTML = "Please provide valid email address."
        }
    }
    else {
        lblerror.innerHTML = "Please provide valid email address."
    }
}


function ForgotPasswordMail2(obj) {
    var objemail = document.getElementById("txtId2");
    var lblerror = document.getElementById("error");

    if (objemail != null) {
        var email = objemail.value;
        if (validateEmail(email)) {
            var xmlHttpReq = false;
            var self = this;
            if (window.XMLHttpRequest) {
                self.xmlHttpReq = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            self.xmlHttpReq.open('POST', "http://www.giftstoindia24x7.com/ajaxLogin.aspx", true);
            self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            self.xmlHttpReq.onreadystatechange = function () {
                if (self.xmlHttpReq.readyState == 4) {
                    if (self.xmlHttpReq.responseText.toString() != "") {
                        if (self.xmlHttpReq.responseText.indexOf('~' != -1)) {
                            GetValue = self.xmlHttpReq.responseText.split("~");
                            if (GetValue[0] == "forgotmail") {
                                if (GetValue[1] == "T") {
                                    lblerror.innerHTML = "Mail has been sent. Please check inbox or the bulk mail folder.";
                                }
                                else {
                                    lblerror.innerHTML = "Email not found in database.Please re-type email.";
                                }

                            }

                        }

                    }
                }

            }
            self.xmlHttpReq.send("Mode=forgotmail&email=" + email + "");
        }
        else {
            lblerror.innerHTML = "Please provide valid email address."
        }
    }
    else {
        lblerror.innerHTML = "Please provide valid email address."
    }
}
