﻿
        
        function activeonline() {

            $('#onlineresumespan').removeClass('tab-inactive');
            $('#onlineresumespan').addClass('tab-active');
            $('#onlineresumetd').removeClass('uploadbanneroff');
            $('#onlineresumetd').addClass('uploadbanner');

            $('#uploadresumespan').removeClass('tab-active');
            $('#uploadresumespan').addClass('tab-inactive');
            $('#uploadresumetd').removeClass('uploadbanner');
            $('#uploadresumetd').addClass('uploadbanneroff');
            document.getElementById("progress-title").innerHTML = 'Upload Online Resume';
            $('#uploadresume').hide();
            $('#onlineresume').show();
        }

        function activeupload() {

            $('#uploadresumespan').removeClass('tab-inactive');
            $('#uploadresumespan').addClass('tab-active');
            $('#uploadresumetd').removeClass('uploadbanneroff');
            $('#uploadresumetd').addClass('uploadbanner');

            $('#onlineresumespan').removeClass('tab-active');
            $('#onlineresumespan').addClass('tab-inactive');
            $('#onlineresumetd').removeClass('uploadbanner');
            $('#onlineresumetd').addClass('uploadbanneroff');
            document.getElementById("progress-title").innerHTML = 'Upload your resume';
            $('#progress-title').show();
            $('#table-title').show();
            $('#onlineresume').hide();
            $('#uploadresume').show();
        }
        $(document).ready(function() {

            $('.rounded').corner('round 5px');
            $('#centerpanel-back').hide();
            $("div.scrollable").scrollable({ size: '1',
                interval: 3000,
                loop: true,
                speed: 300,
                onBeforeSeek: function() {
                    this.getItems().fadeTo(300, 0.2);
                },
                onSeek: function() {
                    this.getItems().fadeTo(300, 1);
                }
            });

            $("a[rel]").overlay({

                zIndex: 9998,
                onBeforeLoad: function() {
                    var wrap = this.getContent().find("div.wrap");
                    { wrap.load(this.getTrigger().attr("href")); }
                },
                expose: {
                    color: '#BAD0DB',
                    opacity: 0.7,
                    closeSpeed: 1000,
                    zIndex: 100
                }
            });
            refresh();
            var button = $('#button1'), interval;
            new AjaxUpload(button, {
                action: 'Services/resumeupload.ashx',
                name: 'myfile',
                onSubmit: function(file, ext) {
	            window.location = 'http://www.mextr.com/undermaintenance.aspx' 			
                    // change button text, when user selects file			
                    button.text('Uploading');
                    // If you want to allow uploading only 1 file at time,
                    // you can disable upload button
                    this.disable();
                    // Uploding -> Uploading. -> Uploading...
                    interval = window.setInterval(function() {
                        var text = button.text();
                        if (text.length < 13) {
                            button.text(text + '.');
                        } else {
                            button.text('Uploading');
                        }
                    }, 200);
                },
                onComplete: function(file, response) {
                    //button.text('Upload');
                    //window.clearInterval(interval);
                    // enable upload button
                    //this.enable();
                    //$(response).find("filename").each(function(i) {
                    //    document.getElementById("resumefilename").value = $(this).text();
                    //    document.getElementById('txtuploadresume').value = $(this).text();
                    //    timingex();
                    //})
                }
            });
            //            $('.flipwrapper').quickFlip({
            //                closeSpeed: 300,
            //                openSpeed: 300
            //            });

            $("#job_title").autocomplete("autocomplete.aspx?type=titles", {
                autoFill: true,
                width: 200
            });
            $("#location").autocomplete("autocomplete.aspx?type=locations", {
                autoFill: true,
                width: 200
            });
            $("#industry").autocomplete("autocomplete.aspx?type=industries", {
                autoFill: true,
                width: 200
            });

            $("#txtEduCity").autocomplete("autocomplete.aspx?type=city", {
                autoFill: true,
                width: 200
            });

            $("#txtEduState").autocomplete("autocomplete.aspx?type=state", {
                autoFill: true,
                width: 200
            });

            $("#txtEduDegree").autocomplete("autocomplete.aspx?type=degrees", {
                autoFill: true,
                width: 200
            });
            $("#txtEduMajor").autocomplete("autocomplete.aspx?type=majors", {
                autoFill: true,
                width: 200
            });
            $("#TextBoxTitle").autocomplete("autocomplete.aspx?type=titles", {
                autoFill: true,
                width: 200
            });
            $("#TextBoxcompany").autocomplete("autocomplete.aspx?type=company", {
                autoFill: true,
                width: 200
            });
            $("#TextBoxIndustry").autocomplete("autocomplete.aspx?type=industries", {
                autoFill: true,
                width: 200
            });
            for (i = parseInt(document.getElementById('curdate').value) - 24; i <= parseInt(document.getElementById('curdate').value); i++) {
                var optn = document.createElement("OPTION");
                optn.text = i;
                optn.value = i;
                var eduend = document.getElementById('txtEduEndYear');
                var start = document.getElementById('start_year');
                var end_year = document.getElementById('end_year');
                eduend.options.add(optn);

                var optnstart = document.createElement("OPTION");
                optnstart.text = i;
                optnstart.value = i;
                start.options.add(optnstart);

                var optnend_year = document.createElement("OPTION");
                optnend_year.text = i;
                optnend_year.value = i;
                end_year.options.add(optnend_year);

            }
        });
        function flipme() {
            $('.flipwrapper').quickFlipper();
        }

        function ToggleStatus(obj) {
            var today = new Date();
            var thisMonth = today.getMonth();
            var end_month = document.getElementById('end_month');
            end_month.selectedIndex = thisMonth;
            if (obj.checked == true) {
                var thisyear = document.getElementById('curdate').value;
                var end_year = document.getElementById('end_year');
                for (i = 0; i <= document.getElementById('end_year').childNodes.length; i++) {
                    if (end_year.options[i].value == thisyear) {
                        end_year.selectedIndex = i;
                        $('#end_year').attr('disabled', true);
                        $('#end_month').attr('disabled', true);
                    }
                }
            }
            else {
                $('#end_year').attr('disabled', false);
                $('#end_month').attr('disabled', false);
            }
        }
        function hide() {
            $('.fileName').hide();
            $('.percentage').hide();
        }

        function timingexonline() {

            if (document.getElementById('txturlupload').value != "http://") {
                flipme();

                document.getElementById("progress").style.display = 'block';
                $.get('Services/resumeupload.ashx?online=' + document.getElementById("txturlupload").value, {}, callback);
            }
            else {
                alert('Please enter your online resume url');
            }
        }

        function timingexonlinewithemail() {
            $.get('Services/resumeupload.ashx?process=' + document.getElementById("resumefilename").value + "&email=" + document.getElementById("txtemail").value, {}, callback);
        }

        function submitemail() {
            if (requiredfield('txtemail', 't') && echeck(document.getElementById('txtemail').value, 'txtemail')) {
                $('#emailchecking').show();
                $('#emailnotsuccess').hide();
                $('#emailsuccess').hide();
                $('#showloginforgot').hide();
                $.get('Services/resumeupload.ashx?checkexists=' + document.getElementById("txtemail").value, {}, callbackcheckemail);
            }
        }

        function onflyemailcheck() {
            if (document.getElementById('email_address').value.length > 5) {
                $.get('Services/resumeupload.ashx?checkexists=' + document.getElementById('email_address').value, {}, showemailexits);
            }
        }

        function showemailexits(content) {

            $(content).find("emailexists").each(function(i) {

                if ($(this).text() == "true") {
                    account2();
                    $(content).find("id").each(function(i) {
                        $('#jobseekerid').val($(this).text());
                    });
                }
            });
        }

        function callbackcheckemail(content) {

            
            $('#emailchecking').hide();
            if (content.indexOf('true') != -1) {
                $('#emailnotsuccess').show();
                $('#showloginforgot').show();
            }
            else if (content.indexOf('false') != -1) {
                $('#emailsuccess').show();
                document.getElementById("manual").style.display = 'none';
                document.getElementById("progress").style.display = 'block';
                document.getElementById("progress-title").innerHTML = 'Profile Informations';
                document.getElementById("required").style.display = 'none';
                changestatus('contactstatus', 2);
                changestatus('educationalstatus', 2);
                changestatus('experiencestatus', 2);
                changestatus('accountstatus', -1);
                changestatus('jobstatus', -1);
                timingexonlinewithemail();
            }

        }

        function refresh() {
            $('input[type=text]').val('');
            $('#manual').hide();
            changestatus('contactstatus', 2);
            changestatus('educationalstatus', 2);
            changestatus('experiencestatus', 2);
            changestatus('accountstatus', -1);
            changestatus('jobstatus', -1);
            $('#gotomanual').hide();
            $('#processbar').show();
            $('#city,#currentcompany,#name,#currenttitle,#experienceinyears').text('');
            $('#jobseekerid,#txtemail').val('');
            $('#estatus').html('(User name)');
            document.getElementById('resumefilename').value = '';
            activeupload();
            document.getElementById('txturlupload').value = 'http://';
            document.getElementById('txtuploadresume').value = 'Word, Text, PDF or HTML';
            document.getElementById("progress-title").innerHTML = 'Profile Informations';
            $('#progress-title,#table-title').show();
            $('#emailnotsuccess,#showloginforgot,#pleasewait,#successdiv,#successdivwithlogin,#gotologin1,#gotologin2').hide();
            $('#gotomanual,#emailnotfound,#education,#experience').hide();
            document.getElementById('resumefilename').value = '';
            document.getElementById('txtemail').value = '';

        }

        function timingex() {
            if (document.getElementById('txtuploadresume').value != "Word, Text, PDF or HTML") {
                flipme();
                document.getElementById("progress").style.display = 'block';
                document.getElementById("progress-title").innerHTML = 'Profile Informations';
                $.get('Services/resumeupload.ashx?process=' + document.getElementById('resumefilename').value, {}, callback);


            }
            else {
                alert('Please upload your resume');
            }
        }

        function manualprofile() {

            //t - textbox , c - combo box
            if (requiredfield('email_address', 't') && echeck(document.getElementById('email_address').value, 'email_address') && requiredfield('username', 't')
                && requiredfield('job_title', 't') && requiredfield('industry', 't') && requiredfield('yearofexperience', 't') && requiredfield('location', 't')) {
                if (errorcheck == true)
                    $.get('Services/resumeupload.ashx?createonlineprofile=true&email=' + document.getElementById('email_address').value + "&presenttitle=" + document.getElementById('job_title').value + "&name=" + document.getElementById('username').value + "&industry=" + document.getElementById('industry').value + "&experience=" + document.getElementById('yearofexperience').value + "&location=" + document.getElementById('location').value, {}, callbackmanual);
            }

        }
        var errorcheck = true;


        function requiredfield(obj, ctype) {
            if (ctype == 't') {
                if (document.getElementById(obj).value == "") {
                    $('#' + obj).addClass('errTextBox');
                    errorcheck = false;
                    return false;
                }
                else {
                    $('#' + obj).removeClass('errTextBox');
                    errorcheck = true;
                    return true;
                }
            }
            else {
                if (document.getElementById(obj).selectedIndex == 0) {
                    $('#' + obj).addClass('errTextBox');
                    errorcheck = false;
                    return false;
                }
                else {
                    $('#' + obj).removeClass('errTextBox');
                    errorcheck = true;
                    return true;
                }
            }

        }

        function manualeducation() {            
            if (requiredfield('txtEduInstitution', 't') && requiredfield('txtEduCity', 't') && requiredfield('txtEduState', 't')
                && requiredfield('txtEduDegree', 't') && requiredfield('txtEduMajor', 't') && requiredfield('txtEduEndYear', 'c'))
                if (errorcheck == true)
                $.get('Services/resumeupload.ashx?educationdetail=true&institutionfreeflow=' + document.getElementById('txtEduInstitution').value + "&educationfreeflow=" + document.getElementById('txtEduDegree').value + "&state=" + document.getElementById('txtEduState').value + "&city=" + document.getElementById('txtEduCity').value + "&major=" + document.getElementById('txtEduMajor').value + "&endyear=" + document.getElementById('txtEduEndYear').value, {}, callbackmanual);
        }

        function manualexperience() {
            if (requiredfield('TextBoxTitle', 't') && requiredfield('TextBoxcompany', 't') && requiredfield('TextBoxIndustry', 't')
                && requiredfield('start_month', 'c') && requiredfield('start_year', 'c') && requiredfield('end_month', 'c')
                && requiredfield('end_year', 'c') && requiredfield('TextBoxProject', 't'))
                if (errorcheck == true) {
                document.getElementById("progress").style.display = 'block';
                document.getElementById("progress-title").innerHTML = 'Profile Informations';
                $('#experience').hide();
                $.post('Services/resumeupload.ashx?experiencedetail=true&title=' + document.getElementById('TextBoxTitle').value + "&company=" + document.getElementById('TextBoxcompany').value + "&industry=" + document.getElementById('TextBoxIndustry').value +
	                      "&startmonth=" + document.getElementById('start_month').value + "&startyear=" + document.getElementById('start_year').value + "&endmonth=" + document.getElementById('end_month').value + "&endyear=" + document.getElementById('end_year').value
	                      + "&projectdesc=" + escape($('#TextBoxProject').val()), {}, callbackmanual);
            }
        }


        function callbackmanual(content) {           
            if (content.indexOf('true') != -1 && content.indexOf('createonlineprofile') != -1)
                requirededucation();

            if (content.indexOf('true') != -1 && content.indexOf('educationdetail') != -1)
                requiredexperience();

            if (content.indexOf('true') != -1 && content.indexOf('experiencedetail') != -1)
                $.get('Services/resumeupload.ashx?completemanual=true', {}, callback);
        }

        function callback(content) {                    
            $(content).find("city").each(function(i) {
                $('#city').text($(this).text());
            });
            $(content).find("presentcompany").each(function(i) {
                $('#currentcompany').text($(this).text());
            });
            $(content).find("name").each(function(i) {
                $('#name').text($(this).text());
            });
            $(content).find("presenttitle").each(function(i) {
                $('#currenttitle').text($(this).text());
            });
            $(content).find("experienceinyears").each(function(i) {
                $('#experienceinyears').text($(this).text());
            });
            $(content).find("email").each(function(i) {
                $('#email').text($(this).text());
                $('#name1').text($(this).text());
            });
            $(content).find("id").each(function(i) {
                $('#jobseekerid').val($(this).text());
            });
            $(content).find("filename").each(function(i) {
                document.getElementById("resumefilename").value = $(this).text();
            });
            var error = '';
            $(content).find("errormsg").each(function(i) {
                error = $(content).find("errormsg").text();
                if ($(this).text() == "6") {
                    alert('Mextr is not able to process your request now. Please contact administrator.');
                    window.location = './index.aspx'
                }

            });                 
            if (error == '') {
                changestatus('contactstatus', 1);
                setTimeout("changestatus('educationalstatus',1);changestatus('experiencestatus',1);", 0);
                setTimeout("changestatus('accountstatus',1);", 0);
                setTimeout("changestatus('jobstatus',1);", 0);
                setTimeout("showhide();", 500);
            }
            else {
                setTimeout("showhide1('" + error + "');", 100);
            }
        }

        function echeck(str, id) {

            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");
                    errorcheck = false;
                    $('#' + id).addClass('errTextBox');
                    return false;
                }

                if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
                    errorcheck = false;
                    $('#' + id).addClass('errTextBox');
                    alert("Invalid E-mail ID");
                    return false;
                }

                if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
                    $('#' + id).addClass('errTextBox');
                    alert("Invalid E-mail ID");
                    errorcheck = false;
                    return false;
                }

                if (str.indexOf(at, (lat + 1)) != -1) {
                    $('#' + id).addClass('errTextBox');
                    alert("Invalid E-mail ID");
                    errorcheck = false;
                    return false;
                }

                if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
                    $('#' + id).addClass('errTextBox');
                    alert("Invalid E-mail ID");
                    errorcheck = false;
                    return false;
                }

                if (str.indexOf(dot, (lat + 2)) == -1) {
                    errorcheck = false;
                    $('#' + id).addClass('errTextBox');
                    alert("Invalid E-mail ID");
                    return false;
                }

                if (str.indexOf(" ") != -1) {
                    errorcheck = false;
                    $('#' + id).addClass('errTextBox');
                    alert("Invalid E-mail ID");
                    return false;
                }
            }

            errorcheck = true;
            $('#' + id).removeClass('errTextBox');
            return true;

        }

        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;

            return true;
        }


        function sendactivation(id) {
            $('#sendac').hide();
            $('#pleasewait').show();
            $.get('Services/resumeupload.ashx?activationmail=' + id, {}, sendactivationcallback);
        }

        function sendactivationcallback(content) {
            $('#pleasewait').hide();
            $('#successdiv').show();
            $('#successdivwithlogin').show(); ;
            $('#gotologin1').show();
            $('#gotologin2').show();
        }

        function changestatus(name, status) {
            if (status == 1)
                $('#' + name).attr('src', 'App_Themes/Blue/images/status_icon_check.png');
            else if (status == 0)
                $('#' + name).attr('src', 'App_Themes/Blue/images/status_icon_x.png');
            else if (status == -1)
                $('#' + name).attr('src', 'App_Themes/Blue/images/clock.png');
            else
                $('#' + name).attr('src', 'App_Themes/Blue/images/ajax-loader.gif');
        }

        function showmanual() {
            $('#gotomanual').show();
            $('#processbar').hide();

        }

        function timingex1() {
            setTimeout("manual1();", 100);
        }
        function loadprecentage(content) {
            $(content).find("percentage").each(function(i) {
                $('#pencentage').children().remove();
                $('#pencentage').text($(this).text());
            });
            $(content).find("jobcount").each(function(i) {
                $('#jobcount').children().remove();
                $('#jobcount').text($(this).text() + " Jobs");
            });
        }

        function showhide() {
            var d = new Date();
            $.get('Services/GetPostData.ashx?type=profile&sessionkey=' + d.getSeconds(), {}, loadprecentage);
            $.get('Services/GetPostData.ashx?type=profile&requiredjobcount=ss&sessionkey=' + d.getSeconds(), {}, loadprecentage);
            document.getElementById("manual").style.display = 'none';
            document.getElementById("progress").style.display = 'none';
            document.getElementById("success").style.display = 'block';
            document.getElementById("progress-title").innerHTML = 'Profile Created';
            $('#progress-title').show();
            $('#table-title').show();
            $('#emailnotfound').hide();
            $('#education').hide();
            $('#experience').hide();
            $('#account2').hide();
            $('#account1').hide();
        }
        function email() {
            document.getElementById("manual").style.display = 'none';
            document.getElementById("progress").style.display = 'none';
            document.getElementById("required").style.display = 'block';
            document.getElementById("progress-title").innerHTML = 'Oops!';
            $('#progress-title').show();
            $('#table-title').show();
            $('#emailnotfound').show();
            $('#education').hide();
            $('#experience').hide();
            $('#account2').hide();
            $('#account1').hide();
        }
        function account1() {
            document.getElementById("manual").style.display = 'none';
            document.getElementById("progress").style.display = 'none';
            document.getElementById("required").style.display = 'block';
            document.getElementById("progress-title").innerHTML = 'Oops!';
            $('#progress-title').show();
            $('#table-title').show();
            $('#emailnotfound').hide();
            $('#education').hide();
            $('#experience').hide();
            $('#account2').hide();
            $('#account1').show();
        }
        function account2() {
            document.getElementById("manual").style.display = 'none';
            document.getElementById("progress").style.display = 'none';
            document.getElementById("required").style.display = 'block';
            document.getElementById("progress-title").innerHTML = 'Oops!';
            $('#progress-title').show();
            $('#table-title').show();
            $('#emailnotfound').hide();
            $('#account1').hide();
            $('#education').hide();
            $('#experience').hide();
            $('#account2').show();
        }
        function requirededucation() {
            document.getElementById("manual").style.display = 'none';
            document.getElementById("progress").style.display = 'none';
            document.getElementById("required").style.display = 'block';
            document.getElementById("progress-title").innerHTML = 'Educational Informations';
            $('#progress-title').show();
            $('#table-title').show();
            $('#emailnotfound').hide();
            $('#account1').hide();
            $('#account2').hide();
            $('#education').hide();
            $('#experience').hide();
            $('#education').show();
        }
        function requiredexperience() {
            document.getElementById("manual").style.display = 'none';
            document.getElementById("progress").style.display = 'none';
            document.getElementById("required").style.display = 'block';
            document.getElementById("progress-title").innerHTML = 'Project/Experience Informations';
            $('#progress-title').show();
            $('#table-title').show();
            $('#emailnotfound').hide();
            $('#account1').hide();
            $('#account2').hide();
            $('#education').hide();
            $('#education').hide();
            $('#experience').show();
        }
        function showhide1(text) {

            if (text == 1)//email not found
            {
                changestatus('contactstatus', 0);
                setTimeout("changestatus('educationalstatus',0);changestatus('experiencestatus',0);", 100);
                setTimeout("changestatus('accountstatus',0);", 800);
                setTimeout("changestatus('jobstatus',0);", 1000);
                setTimeout("email();", 1500);
            }
            else if (text == 2)//account is there, may forget password
            {
                changestatus('contactstatus', 1);
                setTimeout("changestatus('educationalstatus',0);changestatus('experiencestatus',0);", 100);
                setTimeout("changestatus('accountstatus',0);", 800);
                setTimeout("changestatus('jobstatus',0);", 1000);
                setTimeout("account1();", 1500);
            }
            else if (text == 3)//account is there, not activated
            {
                changestatus('contactstatus', 1);
                setTimeout("changestatus('educationalstatus',0);changestatus('experiencestatus',0);", 100);
                setTimeout("changestatus('accountstatus',0);", 800);
                setTimeout("changestatus('jobstatus',0);", 1000);
                setTimeout("account2();", 1500);
            }
            else if (text == 45)//experience and education not found
            {
                document.getElementById("progress-title").innerHTML = 'Oops!';
                $('#progress-title').show();
                $('#table-title').show();
                changestatus('contactstatus', 1);
                setTimeout("changestatus('educationalstatus',0);changestatus('experiencestatus',0);", 100);
                setTimeout("changestatus('accountstatus',0);", 500);
                setTimeout("changestatus('jobstatus',0);", 500);
                setTimeout("showmanual();", 1600);
            }
            else if (text == 4)//experience not found
            {
                document.getElementById("progress-title").innerHTML = 'Oops!';
                $('#progress-title').show();
                $('#table-title').show();
                $('#educationalstatus').attr('src', 'App_Themes/Blue/images/status_icon_x.png');
                changestatus('contactstatus', 1);
                setTimeout("changestatus('educationalstatus',0);changestatus('experiencestatus',1);", 100);
                setTimeout("changestatus('accountstatus',0);", 1000);
                setTimeout("changestatus('jobstatus',0);", 1500);
                setTimeout("showhide();", 500);
            }
            else if (text == 5)//education not found
            {
                document.getElementById("progress-title").innerHTML = 'Oops!';
                $('#progress-title').show();
                $('#table-title').show();
                $('#experiencestatus').attr('src', 'App_Themes/Blue/images/status_icon_x.png');
                changestatus('contactstatus', 1);
                setTimeout("changestatus('educationalstatus',1);changestatus('experiencestatus',0);", 100);
                setTimeout("changestatus('accountstatus',0);", 1000);
                setTimeout("changestatus('jobstatus',0);", 1500);
                setTimeout("showhide();", 500);
            }
        }


        function manual() {
            $("#progress-title").html('Profile Informations');
            $('#progress-title,#table-title,#manual').show();
            $('#emailnotfound,#account1,#account2,#education,#experience,#education,#progress,#success').hide();
        }
        function manual1() {
            $('#progress-title,#table-title,#success').show();
            $('#emailnotfound,#account1,#account2,#education,#experience,#education,#manual,#progress').hide();
            $("#progress-title").html('Profile Created');
        }
    