﻿
    function fncInputNumericValuesOnly() {
        if ((event.keyCode < 45) || (event.keyCode > 57)) {
            event.returnValue = false;
        }
    }
    
    function ShowContactDetails() {
        document.getElementById('dvContent').style.display = "block";
        document.getElementById('txtName').focus();
        document.getElementById('dvMainBanner').style.display = "none";
    }
    function HideContactDetails() {
            ResetControlValues(); 
            document.getElementById('dvContent').style.display = "none";
             document.getElementById('dvMainBanner').style.display = "block";
        }

    function SendContactDetails() {
    
        var CustomerName = document.getElementById('txtName').value;
        var PhoneNumber = document.getElementById('txtPhoneNo').value;
        var Email = document.getElementById('txtEmail').value;
       
       
        var PreferedDate;
        var cmbMonthAndYear = document.getElementById("cmbMonthAndYear");
        var PreferredMonthAndYear = cmbMonthAndYear.options[cmbMonthAndYear.selectedIndex].text

        var cmbDays = document.getElementById("cmbDays");
        var PreferredDay = cmbDays.options[cmbDays.selectedIndex].text

        PreferedDate = PreferredDay + " " + PreferredMonthAndYear
        var cmbProduct = document.getElementById("cmbProduct");
        var Product = cmbProduct.options[cmbProduct.selectedIndex].text

        var cmbTimeFormat = document.getElementById("cmbTime");
        var TimeFormat = cmbTimeFormat.options[cmbTimeFormat.selectedIndex].text

        var cmbSelectedTime = document.getElementById("cmbSelectedTime");
        var SelectedTime = cmbSelectedTime.options[cmbSelectedTime.selectedIndex].text


        if (CustomerName == "") {
            alert("Please Enter Contact Name");
            document.getElementById('txtName').focus();
            return false;
        }
       if (PhoneNumber == "") {
            alert("Please Enter Phone Number");
            document.getElementById('txtPhoneNo').focus();
            return false;
        }
      else if (PhoneNumber.length < 13) {        
                alert("Enter Valid Phone Number");
                document.getElementById('txtPhoneNo').focus();
                return false;
        
        }
        if (Email == "") {
            alert("Please Enter Email Id");
            document.getElementById('txtEmail').focus();
            return false;
        }
        else if (Email.length > 0) 
        {
            if (validateEmail(Email) == false) 
            {
                alert("Enter Valid Email ID");
                document.getElementById('txtEmail').focus();
                return false;
            }
    }

    PreferedDate = PreferedDate + ' ' + SelectedTime + ' ' + TimeFormat;
      
        
 document.getElementById('ifrm').src = 'http://www.xlntidea.com/html/XiSupportConcierge.aspx' + "?CustomerName=" + (CustomerName ? CustomerName : '') + "&PhoneNumber=" + (PhoneNumber ? PhoneNumber : '') + "&Email=" + (Email ? Email : '') + "&PreferedDate=" + (PreferedDate ? PreferedDate : '') + "&Product=" + (Product ? Product : '')
//        document.getElementById('ifrm').src = 'http://localhost:2509/XLNTIDEA/html/XiSupportConcierge.aspx' + "?CustomerName=" + (CustomerName ? CustomerName : '') + "&PhoneNumber=" + (PhoneNumber ? PhoneNumber : '') + "&Email=" + (Email ? Email : '') + "&PreferedDate=" + (PreferedDate ? PreferedDate : '') + "&Product=" + (Product ? Product : '')
        document.getElementById('dvContent').style.display = "none";
        document.getElementById('dvFinalBanner').style.display = "block";
        
        document.getElementById('FinalResult').innerHTML = "Thank you for contacting XLNTIdea Support Concierge. Our expert technical support specialist will contact you by phone on " + PreferedDate;        
        setTimeout("BannerChange();", 7000);


    }
    function ValidateDate(PreferedDate) {
        var date1 = new Date();
        var date2Str = PreferedDate;
        var date2 = new Date();
        var date2 = new Date(date2Str);
        if (date1.getFullYear() >= date2.getFullYear())
            if (date1.getMonth() >= date2.getMonth())
            if (date1.getDate() > date2.getDate())
            return false;
        else
            return true; 
    }
    function ResetControlValues() {
        document.getElementById('txtName').value = "";
          document.getElementById('txtPhoneNo').value = "";
        document.getElementById('txtEmail').value = "";      
    
         
    }
    function BannerChange() {
        ResetControlValues();
        document.getElementById('dvFinalBanner').style.display = "none";
        document.getElementById('dvMainBanner').style.display = "block";
    } 

    function validateEmail(email) {
        var splitted = email.match("^(.+)@(.+)$");
        if (splitted == null) {
            return false;
        }
        if (splitted[1] != null) {
            var regexp_user = /^\"?[\w-_\.]*\"?$/;
            if (splitted[1].match(regexp_user) == null) {

                return false;
            }
        }
        if (splitted[2] != null) {
            var regexp_domain = /^[\w-\.]*\.[A-Za-z]{2,4}$/;
            if (splitted[2].match(regexp_domain) == null) {
                var regexp_ip = '/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/';
                if (splitted[2].match(regexp_ip) == null) {
                    return false;
                }
            }
            return true;
        }
        return true;
    }
    function validateSupportTime(txtTime, Meridian, TimeFormat) {
        var hrsFiled = parseInt(txtTime.split(":")[0])
        var minsFiled = parseInt(txtTime.split(":")[1])
        if (minsFiled == "") minsFiled=0
        var fromhrs = '';
        

        if (TimeFormat == "EST") {
            fromhrs = 9

        }
        else if (TimeFormat == "CST") {
            fromhrs = 8
        }
        else if (TimeFormat == "MST") {
            fromhrs = 7
        }
        else if (TimeFormat == "PST") {
            fromhrs = 6
        }
            if (Meridian =="AM") {
                var toHrs = 12;
                if ((hrsFiled >= fromhrs) && (hrsFiled <= toHrs )) {
                    if ((hrsFiled == 6) && (minsFiled  > 0)) {
                        return false; 
                    }

                }
                else
                    return false;
                
            }
            else {
                if (hrsFiled == 12) hrsFiled=0
                var toHrs = 0;
                if ((hrsFiled >= toHrs ) && (hrsFiled <= fromhrs )) {
                    if ((hrsFiled == 6) && (minsFiled > 0)) {
                        return false;
                    }

                }
                else
                    return false;
            
            }

        
        return true;
    }



    var n;
    var p;
    var p1;
    function ValidatePhone() {

        p = p1.value
        if (p.length == 3) {
            //d10=p.indexOf('(')
            pp = p;
            d4 = p.indexOf('(')
            d5 = p.indexOf(')')
            if (d4 == -1) {
                pp = "(" + pp;
            }
            if (d5 == -1) {
                pp = pp + ")";
            }
            //pp="("+pp+")";
            document.getElementById('txtPhoneNo').value = "";
            document.getElementById('txtPhoneNo').value = pp;
        }
        if (p.length > 3) {
            d1 = p.indexOf('(')
            d2 = p.indexOf(')')
            if (d2 == -1) {
                l30 = p.length;
                p30 = p.substring(0, 4);
                //alert(p30);
                p30 = p30 + ")"
                p31 = p.substring(4, l30);
                pp = p30 + p31;

                document.getElementById('txtPhoneNo').value = "";
                document.getElementById('txtPhoneNo').value = pp;
            }
        }
        if (p.length > 5) {
            p11 = p.substring(d1 + 1, d2);
            if (p11.length > 3) {
                p12 = p11;
                l12 = p12.length;
                l15 = p.length
                //l12=l12-3
                p13 = p11.substring(0, 3);
                p14 = p11.substring(3, l12);
                p15 = p.substring(d2 + 1, l15);
                document.getElementById('txtPhoneNo').value = "";
                pp = "(" + p13 + ")" + p14 + p15;
                document.getElementById('txtPhoneNo').value = pp;
            }
            l16 = p.length;
            p16 = p.substring(d2 + 1, l16);
            l17 = p16.length;
            if (l17 > 3 && p16.indexOf('-') == -1) {
                p17 = p.substring(d2 + 1, d2 + 4);
                p18 = p.substring(d2 + 4, l16);
                p19 = p.substring(0, d2 + 1);

                pp = p19 + p17 + "-" + p18;

                document.getElementById('txtPhoneNo').value = "";
                document.getElementById('txtPhoneNo').value = pp;


            }
        }
        //}
        setTimeout(ValidatePhone, 100)
    }
    function getPhoneNumber(m) {

      //  n = m.name;
       p1 = m
       ValidatePhone()
    }







   
    var pTime;
    var p1Time;
    function ValidateTime() 
    {

        pTime = p1Time.value
        if (pTime.length == 2) 
        {            
            ppTime = pTime;
            d4 = pTime.indexOf(':')            
            
            if (d4 == -1) {
                ppTime = ppTime + ":";
            }                     
            document.getElementById('txtTime').value = "";
            document.getElementById('txtTime').value = ppTime;
        }
       
        setTimeout(ValidateTime, 100)
    }
    function getTime(m) {

        //  n = m.name;
        p1Time = m
        ValidateTime()
    }

    function FillTimings() {
        var opt

        var cmbTimeFormat = document.getElementById("cmbTime");
        var TimeFormat = cmbTimeFormat.options[cmbTimeFormat.selectedIndex].text

        while (document.getElementById("cmbSelectedTime").options.length > 0) {
            document.getElementById("cmbSelectedTime").options[0] = null;

        }
        if (TimeFormat == "EST") {

            opt = document.createElement("option");

            opt.text = "09:00 AM";
            opt.value = "09:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "10:00 AM";
            opt.value = "10:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "11:00 AM";
            opt.value = "11:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "12:00 AM";
            opt.value = "12:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "01:00 PM";
            opt.value = "01:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "02:00 PM";
            opt.value = "02:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "03:00 PM";
            opt.value = "03:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "04:00 PM";
            opt.value = "04:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "05:00 PM";
            opt.value = "05:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "06:00 PM";
            opt.value = "06:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "07:00 PM";
            opt.value = "07:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);



            opt = document.createElement("option");
            opt.text = "08:00 PM";
            opt.value = "08:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "09:00 PM";
            opt.value = "09:00 PM";

            document.getElementById("cmbSelectedTime").options.add(opt);
        }

        else if (TimeFormat == "PST") {

            opt = document.createElement("option");

            opt.text = "06:00 AM";
            opt.value = "06:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");

            opt.text = "07:00 AM";
            opt.value = "07:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");

            opt.text = "08:00 AM";
            opt.value = "08:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");

            opt.text = "09:00 AM";
            opt.value = "09:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "10:00 AM";
            opt.value = "10:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "11:00 AM";
            opt.value = "11:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "12:00 AM";
            opt.value = "12:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "01:00 PM";
            opt.value = "01:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "02:00 PM";
            opt.value = "02:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "03:00 PM";
            opt.value = "03:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "04:00 PM";
            opt.value = "04:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "05:00 PM";
            opt.value = "05:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "06:00 PM";
            opt.value = "06:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

        }
        else if (TimeFormat == "CST") {


            opt = document.createElement("option");

            opt.text = "08:00 AM";
            opt.value = "08:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");

            opt.text = "09:00 AM";
            opt.value = "09:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "10:00 AM";
            opt.value = "10:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "11:00 AM";
            opt.value = "11:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "12:00 AM";
            opt.value = "12:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "01:00 PM";
            opt.value = "01:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "02:00 PM";
            opt.value = "02:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "03:00 PM";
            opt.value = "03:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "04:00 PM";
            opt.value = "04:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "05:00 PM";
            opt.value = "05:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "06:00 PM";
            opt.value = "06:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "07:00 PM";
            opt.value = "07:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "08:00 PM";
            opt.value = "08:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

        }
        else if (TimeFormat == "MST") {


            opt = document.createElement("option");

            opt.text = "07:00 AM";
            opt.value = "07:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "08:00 AM";
            opt.value = "08:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");

            opt.text = "09:00 AM";
            opt.value = "09:00 AM";

            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "10:00 AM";
            opt.value = "10:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "11:00 AM";
            opt.value = "11:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "12:00 AM";
            opt.value = "12:00 AM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "01:00 PM";
            opt.value = "01:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "02:00 PM";
            opt.value = "02:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "03:00 PM";
            opt.value = "03:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);


            opt = document.createElement("option");
            opt.text = "04:00 PM";
            opt.value = "04:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "05:00 PM";
            opt.value = "05:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "06:00 PM";
            opt.value = "06:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);

            opt = document.createElement("option");
            opt.text = "07:00 PM";
            opt.value = "07:00 PM";
            document.getElementById("cmbSelectedTime").options.add(opt);
           

        }
    }


    function LoadPrefrredDays() {

        var month = new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC");
        var CurrentDay = new Date();
        var CurrnetMonthIndex = CurrentDay.getMonth();
        var CurrentYear = CurrentDay.getFullYear();
        var nextYear;

        var NextMonthIdex;
        if (CurrnetMonthIndex == 11) {
            NextMonthIndex = 0;
            nextYear = CurrentYear + 1
        }
        else {
            NextMonthIndex = CurrnetMonthIndex + 1;
            nextYear = CurrentYear
        }

        var currentMonthYear = month[CurrnetMonthIndex] + ' ' + CurrentYear;
        var NextMonthYear = month[NextMonthIndex] + ' ' + nextYear;

        var CurrentMonthDays = 32 - new Date(CurrentYear, CurrnetMonthIndex, 32).getDate();
        //  var NextMonthDays = 32 - new Date(nextYear, NextMonthIndex, 32).getDate();       


        opt = document.createElement("option");
        opt.text = currentMonthYear;
        opt.value = currentMonthYear;
        document.getElementById("cmbMonthAndYear").options.add(opt);

        opt = document.createElement("option");
        opt.text = NextMonthYear;
        opt.value = NextMonthYear;
        document.getElementById("cmbMonthAndYear").options.add(opt);

        var curr_date = CurrentDay.getDate();


        for (curr_date; curr_date <= CurrentMonthDays; curr_date++) {
            var weekDays = new Date(CurrentYear, CurrnetMonthIndex, curr_date);

            if ((weekDays.getDay() == 0) || (weekDays.getDay() == 6))//weekdays             
                continue;

            opt = document.createElement("option");
            opt.text = curr_date;
            opt.value = curr_date;

            document.getElementById("cmbDays").options.add(opt);
        }

    }
    function OnPrefrredDayChanged() {
        var CurrentDate = new Date();
        var CurrentDay = CurrentDate.getDate();
        var CurrnetMonthIndex = CurrentDate.getMonth();
        var SlectedMonthIndex;
        var month = new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC");
        var cmbSelectedDate = document.getElementById("cmbMonthAndYear");
        var SelectedDate = cmbSelectedDate.options[cmbSelectedDate.selectedIndex].text;
        var selectedMonth = SelectedDate.substring(0, 3);
        var selectedYear = SelectedDate.substring(4);
        for (SlectedMonthIndex = 0; SlectedMonthIndex < month.length; SlectedMonthIndex++) {
            if (month[SlectedMonthIndex] == selectedMonth)
                break;
        }
        var CurrentMonthDays = 32 - new Date(selectedYear, SlectedMonthIndex, 32).getDate();

        while (document.getElementById("cmbDays").options.length > 0) {
            document.getElementById("cmbDays").options[0] = null;
        }
        if (SlectedMonthIndex != CurrnetMonthIndex) {
            CurrentDay = 1
            CurrnetMonthIndex = SlectedMonthIndex
        }

        for (CurrentDay; CurrentDay <= CurrentMonthDays; CurrentDay++) {
            var weekDays = new Date(selectedYear, CurrnetMonthIndex, CurrentDay);

            if ((weekDays.getDay() == 0) || (weekDays.getDay() == 6)) {
                continue;
            }
            opt = document.createElement("option");
            opt.text = CurrentDay;
            opt.value = CurrentDay;

            document.getElementById("cmbDays").options.add(opt);
        }
    }

