window.pemco = window.pemco || {};

/*
Creates a widget to view PEMCO commercials
*/

(function($) {

    var pub = pemco.create_profile = {};

    /***** SETTINGS *****/

    var transSpeed = 250;
    var isZoomSet = false;

    // Cache
    //var $img = $([]);
    //var $zoomIn = $([]);
    //var $zoomOut = $([]);
    var $img;
    var $zoomIn;
    var $zoomOut;

    /***** FUNCTIONS *****/

    pub.construct = function() {
        getObjects();
        setDraggable();
        setZoomers();
    }

    pub.deconstruct = function() {
        $img = null;
        $zoomIn = null;
        $zoomOut = null;
    }

    var getObjects = function() {
        //$img = $img[0] ? $img : $('.column2 #my-profile-container .bar #divUserProfileImageContainer.crop-image img');
        //$zoomIn = $zoomIn[0] ? $zoomIn : $('.column2 .zoom-in');
        //$zoomOut = $zoomOut[0] ? $zoomOut : $('.column2 .zoom-out');
        $img = $('.column2 #my-profile-container .bar #divUserProfileImageContainer.crop-image img');
        $zoomIn = $('.column2 .zoom-in');
        $zoomOut = $('.column2 .zoom-out');
    }

    var setDraggable = function() {

        $img.draggable({

    })

}

var setZoomers = function() {
    //Reset Zoomer

    //if (isZoomSet) return;
    //isZoomSet = true;
    var pxStep = 50;

    $zoomIn.click(function() {
        $img.stop().animate({ height: '+=' + pxStep + 'px', left: '-=' + (pxStep / 2) + 'px', top: '-=' + (pxStep / 2) + 'px' }, transSpeed);
    });
    $zoomOut.click(function() {
        $img.stop().animate({ height: '-=' + pxStep + 'px', left: '+=' + (pxStep / 2) + 'px', top: '+=' + (pxStep / 2) + 'px' }, transSpeed);
    })
}

pub.startOver = function() {

    var arrState = window.location.hash.substr(1).split("/");

    if (arrState.length > 1) {
        window.location.href = "#createprofile";
    }
    else {
        window.location.href = "#createprofile/step1";
    }

}

pub.initCreateProfile = function(strAjaxHandler) {

    var data = { 'action': 'create_profile' };

    jQuery.ajax({
        type: "POST",
        url: strAjaxHandler,
        dataType: "text",
        data: data,
        success: function(response) {
            if (response) {
                var objElement = document.getElementById("create_profile_panel");
                if (objElement != null) {
                    objElement.innerHTML = response;

                    pemco.create_profile.deconstruct();

                    pemco.create_profile.construct();

                    var arrState = window.location.hash.substr(1).split("/");

                    var step = arrState[1];

                    if (step) {

                        if (step == "step1") {
                            pemco.create_profile.showStep(1);
                        }
                        else if (step == "step2") {
                            pemco.create_profile.showStep(2);
                        }
                        else if (step == "step3") {
                            pemco.create_profile.showStep(3);
                        }
                        else if (step == "step4") {
                            pemco.create_profile.showStep(4);
                        }
                        else if (step == "step5") {
                            pemco.create_profile.showStep(5);
                        }
                    }
                    pemco.create_profile.applyBoldOnCurrentStep();
                }
            }
        },
        error: function() { pemco.ajax.flash("Fail to process create profile.", "Error"); },
        complete: function() { pemco.bbq.loadComplete('createprofile') }
    });

}

//---- Process Step 1 -----------------------------------------
pub.processUserProfileImage = function(strFileUploadID) {
    var objElement = document.getElementById("chbAgree");
    if (objElement != null) {
        if (!objElement.checked) {
            pemco.ajax.flash("You must be agree to the terms and conditions in order to proceed.", "Error");
            return false;
        }
    }
    else {
        pemco.ajax.flash("Terms and conditions does not existed.", "Error");
        return false;
    }

    //Hide Step 1
    objElement = document.getElementById("divStep1");
    if (objElement != null) {
        objElement.style.display = "none";
    }

    //Show Step 2
    objElement = document.getElementById("divStep2");
    if (objElement != null) {
        objElement.style.display = "";
        pemco.create_profile.updateUserProfileStepInfo(2);
    }

    return false;
}

//----- Process Step 2 -----------------------------------------------------
pub.updateUserProfileName = function() {

    var objElement = document.getElementById("txtUserProfileName");

    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "XXXXXX") {
            pemco.ajax.flash("Please enter profile name.", "Error");
            return false;
        }
        else if (objElement.value.toString().length > 13) {
            pemco.ajax.flash("Profile name cannot have more than 13 characters.", "Error");
            return false;
        }
    }

    pemco.create_profile.nextStep(2);

    pemco.create_profile.applyBoldOnCurrentStep();

    return false;
}

//------ Process Step 3 ----------------------------------------------------
pub.updateUserProfileText = function() {
    var strErrorMessage = "";
    var strPlaceHolderText = "";
    var strFeature1 = "";
    var strFeature2 = "";
    var strFeature3 = "";
    var strSpotted = "";
    var strDiet = "";
    var strVehicle = "";
    var strSong = "";

    //Place Holder Text
    var objElement = document.getElementById("txtUserProfilePlaceHolderText");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "NW Profile Place Holder Text") {
            //strErrorMessage += "Enter place holder text. ";
        }
        else if (objElement.value.length > 50) {
            strErrorMessage += "Place holder text cannot have more than 50 characters. "
        }
    }

    //Feature 1
    objElement = document.getElementById("txtUserProfileFeature1");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Feature 1") {
            // strErrorMessage += "Enter feature # 1. ";
        }
    }

    //Feature 2
    objElement = document.getElementById("txtUserProfileFeature2");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Feature 2") {
            // strErrorMessage += "Enter feature # 2. ";
        }
    }

    //Feature 3
    objElement = document.getElementById("txtUserProfileFeature3");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Feature 3") {
            //strErrorMessage += "Enter feature # 3. ";
        }
    }

    //Spotted
    objElement = document.getElementById("txtUserProfilePlace");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Place") {
            //strErrorMessage += "Enter spotted location. ";
        }
    }

    //Diet
    objElement = document.getElementById("txtUserProfileDiet");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Eats") {
            //strErrorMessage += "Enter diet info. ";
        }
    }

    //Vehicle
    objElement = document.getElementById("txtUserProfileVehicle");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Make of car") {
            //strErrorMessage += "Enter vehicle info. ";
        }
    }

    //Song
    objElement = document.getElementById("txtUserProfileSong");
    if (objElement != null) {
        if (objElement.value == "" || objElement.value == "Favorite") {
            //strErrorMessage += "Enter song name. ";
        }
    }

    //Stop if user has not filled out all required field
    if (strErrorMessage.length > 0) {
        pemco.ajax.flash(strErrorMessage, "Error");
        return false;
    }

    pemco.create_profile.nextStep(3);

    return false;
}

//---- Process Step 4 ------------------------------------------------------
pub.submitNewUserProfile = function(strAjaxHandler) {

    var strProfileImage = "";
    var strProfileName = "";
    var strPlaceHolderText = "";
    var strFeature1 = "";
    var strFeature2 = "";
    var strFeature3 = "";
    var strSpotted = "";
    var strDiet = "";
    var strVehicle = "";
    var strSong = "";
    var strPositionX = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().left;
    var strPositionY = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().top;
    var strWidth = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').width();
    var strHeight = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').height();
    var strHTMLContent = "";

    var strErrorMessage = "";

    //Profile Image
    var objElement = document.getElementById("hfUserProfileImage");
    if (objElement != null) {
        strProfileImage = objElement.value;
        if (strProfileImage == "") {
            strErrorMessage += "Please upload profile image. ";
        }
    }

    //Profile Name
    objElement = document.getElementById("txtUserProfileName");
    if (objElement != null) {
        strProfileName = objElement.value;

        if (strProfileName == "" || strProfileName == "XXXXXX") {
            //strErrorMessage += "Enter profile name in Step 2. ";
        }
        else if (strProfileName.toString().length > 13) {
            strErrorMessage += "Profile name cannot have more than 13 characters. ";
        }
    }

    //Place Holder Text
    objElement = document.getElementById("txtUserProfileName1");
    var strTemp = "";

    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 1 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }
    objElement = document.getElementById("txtUserProfileName2");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 2 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }

    objElement = document.getElementById("txtUserProfileName3");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 3 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }


    if (strPlaceHolderText == "") {
        //strErrorMessage += "Type your profile name. ";
    }

    //Feature 1
    objElement = document.getElementById("txtUserProfileFeature1");
    if (objElement != null) {
        strFeature1 = objElement.value;
        if (strFeature1 == "" || strFeature1 == "Feature 1") {
            strFeature1 = "";
            //strErrorMessage += "Enter feature # 1. ";
        }
        else if (strFeature1.length > 18) {
            strErrorMessage += "Feature 1 cannot exceed 18 characters. "
        }
    }

    //Feature 2
    objElement = document.getElementById("txtUserProfileFeature2");
    if (objElement != null) {
        strFeature2 = objElement.value;
        if (strFeature2 == "" || strFeature2 == "Feature 2") {
            strFeature2 = "";
            //strErrorMessage += "Enter feature # 2. ";
        }
        else if (strFeature2.length > 18) {
            strErrorMessage += "Feature 2 cannot exceed 18 characters. "
        }
    }

    //Feature 3
    objElement = document.getElementById("txtUserProfileFeature3");
    if (objElement != null) {
        strFeature3 = objElement.value;
        if (strFeature3 == "" || strFeature3 == "Feature 3") {
            strFeature3 = "";
            //strErrorMessage += "Enter feature # 3. ";
        }
        else if (strFeature3.length > 18) {
            strErrorMessage += "Feature 3 cannot exceed 18 characters. "
        }
    }

    //Spotted
    objElement = document.getElementById("txtUserProfilePlace");
    if (objElement != null) {
        strSpotted = objElement.value;
        if (strSpotted == "" || strSpotted == "Place") {
            strSpotted = "";
            //strErrorMessage += "Enter spotted location. ";
        }
        else if (strSpotted.length > 16) {
            strErrorMessage += "Spotted place cannot exceed 16 characters. "
        }
    }

    //Diet
    objElement = document.getElementById("txtUserProfileDiet");
    if (objElement != null) {
        strDiet = objElement.value;
        if (strDiet == "" || strDiet == "Eats") {
            strDiet = "";
            //strErrorMessage += "Enter diet info. ";
        }
        else if (strDiet.length > 16) {
            strErrorMessage += "Diet cannot exceed 16 characters. "
        }
    }

    //Vehicle
    objElement = document.getElementById("txtUserProfileVehicle");
    if (objElement != null) {
        strVehicle = objElement.value;
        if (strVehicle == "" || strVehicle == "Make of car") {
            strVehicle = "";
            //strErrorMessage += "Enter vehicle info. ";
        }
        else if (strVehicle.length > 16) {
            strErrorMessage += "Make of car cannot exceed 16 characters. "
        }
    }

    //Song
    objElement = document.getElementById("txtUserProfileSong");
    if (objElement != null) {
        strSong = objElement.value;
        if (strSong == "" || strSong == "Favorite") {
            strSong = "";
            //strErrorMessage += "Enter song name. ";
        }
        else if (strSong.length > 16) {
            strErrorMessage += "Song cannot exceed 16 characters. "
        }
    }

    //HTML Content
    objElement = document.getElementById("divUserProfileImageContainer");
    if (objElement != null) {
        //strHTMLContent = objElement.value;
        strHTMLContent = "";
    }

    if (strErrorMessage.toString().length > 0) {
        pemco.ajax.flash(strErrorMessage, "Error");
        return false;
    }

    var data = {
        'action': 'submit_new_user_profile',
        'profile_image': strProfileImage,
        'profile_name': strProfileName,
        'place_holder_text': strPlaceHolderText,
        'feature1': strFeature1,
        'feature2': strFeature2,
        'feature3': strFeature3,
        'spotted': strSpotted,
        'diet': strDiet,
        'vehicle': strVehicle,
        'song': strSong,
        'positionX': strPositionX,
        'positionY': strPositionY,
        'width': strWidth,
        'height': strHeight,
        'html_content': strHTMLContent
    };

    jQuery.ajax({
        type: "POST",
        url: strAjaxHandler,
        dataType: "json",
        data: data,
        success: function(response) {
            if (response) {
                //pemco.ajax.flash(response.message, response.status);

                if (response.status == "Success") {
                    //Bring back to my account page
                    //window.location.href = '#my_account';
                    //pemco.home.myProfilesMode();
                    window.location.href = "#createprofile/step4/" + response.data["nw_type_id"];
                }
            }
        }
    ,
        error: function() { pemco.ajax.flash("Fail to submit new user profile.", "Error"); }
    });
}

pub.emailNewUserProfile = function(strAjaxHandler) {

    var strRecipientEmail = "";
    var strSenderEmail = "";
    var strEmailMessage = "";
    var strProfileImage = "";
    var strProfileName = "";
    var strPlaceHolderText = "";
    var strFeature1 = "";
    var strFeature2 = "";
    var strFeature3 = "";
    var strSpotted = "";
    var strDiet = "";
    var strVehicle = "";
    var strSong = "";
    var strPositionX = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().left;
    var strPositionY = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().top;
    var strWidth = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').width();
    var strHeight = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').height();
    var strHTMLContent = "";

    var strErrorMessage = "";

    //Get Recipient Email
    var objElement = document.getElementById("txtUserProfileRecipientEmail");
    if (objElement != null) strRecipientEmail = objElement.value;
    if (strRecipientEmail == "") {
        strErrorMessage += "Enter recipient email. ";
    }
    else if (strRecipientEmail.indexOf("@") == -1 && strRecipientEmail.indexOf(".") == -1) {
        strErrorMessage += "Invalid recipient email. ";
    }

    //Get Sender Email
    objElement = document.getElementById("txtUserProfileYourEmail");
    if (objElement != null) strSenderEmail = objElement.value;
    if (strSenderEmail == "") {
        strErrorMessage += "Enter your email. ";
    }
    else if (strSenderEmail.indexOf("@") == -1 && strSenderEmail.indexOf(".") == -1) {
        strErrorMessage += "Invalid sender email. ";
    }

    //Get Email Message
    objElement = document.getElementById("txtUserProfileEmailMessage");
    if (objElement != null) strEmailMessage = objElement.value;

    //Profile Image
    objElement = document.getElementById("hfUserProfileImage");
    if (objElement != null) {
        strProfileImage = objElement.value;
        if (strProfileImage == "") strErrorMessage += "Please upload profile image. ";
    }

    //Profile Name
    objElement = document.getElementById("txtUserProfileName");
    if (objElement != null) {
        strProfileName = objElement.value;

        if (strProfileName == "" || strProfileName == "XXXXXX") {
            //strErrorMessage += "Enter profile name in Step 2. ";
        }
        else if (strProfileName.toString().length > 13) {
            strErrorMessage += "Profile name cannot have more than 13 characters. ";
        }
    }

    //Place Holder Text
    objElement = document.getElementById("txtUserProfileName1");
    var strTemp = "";

    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 1 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }
    objElement = document.getElementById("txtUserProfileName2");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 2 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }

    objElement = document.getElementById("txtUserProfileName3");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 3 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }


    if (strPlaceHolderText == "") {
        //strErrorMessage += "Type your profile name. ";
    }

    //Feature 1
    objElement = document.getElementById("txtUserProfileFeature1");
    if (objElement != null) {
        strFeature1 = objElement.value;
        if (strFeature1 == "" || strFeature1 == "Feature 1") {
            strFeature1 = "";
            //strErrorMessage += "Enter feature # 1. ";
        }
        else if (strFeature1.length > 18) {
            strErrorMessage += "Feature 1 cannot exceed 18 characters. "
        }
    }

    //Feature 2
    objElement = document.getElementById("txtUserProfileFeature2");
    if (objElement != null) {
        strFeature2 = objElement.value;
        if (strFeature2 == "" || strFeature2 == "Feature 2") {
            strFeature2 = "";
            //strErrorMessage += "Enter feature # 2. ";
        }
        else if (strFeature2.length > 18) {
            strErrorMessage += "Feature 2 cannot exceed 18 characters. "
        }
    }

    //Feature 3
    objElement = document.getElementById("txtUserProfileFeature3");
    if (objElement != null) {
        strFeature3 = objElement.value;
        if (strFeature3 == "" || strFeature3 == "Feature 3") {
            strFeature3 = "";
            //strErrorMessage += "Enter feature # 3. ";
        }
        else if (strFeature3.length > 18) {
            strErrorMessage += "Feature 3 cannot exceed 18 characters. "
        }
    }

    //Spotted
    objElement = document.getElementById("txtUserProfilePlace");
    if (objElement != null) {
        strSpotted = objElement.value;
        if (strSpotted == "" || strSpotted == "Place") {
            strSpotted = "";
            //strErrorMessage += "Enter spotted location. ";
        }
        else if (strSpotted.length > 16) {
            strErrorMessage += "Spotted place cannot exceed 16 characters. "
        }
    }

    //Diet
    objElement = document.getElementById("txtUserProfileDiet");
    if (objElement != null) {
        strDiet = objElement.value;
        if (strDiet == "" || strDiet == "Eats") {
            strDiet = "";
            //strErrorMessage += "Enter diet info. ";
        }
        else if (strDiet.length > 16) {
            strErrorMessage += "Diet cannot exceed 16 characters. "
        }
    }

    //Vehicle
    objElement = document.getElementById("txtUserProfileVehicle");
    if (objElement != null) {
        strVehicle = objElement.value;
        if (strVehicle == "" || strVehicle == "Make of car") {
            strVehicle = "";
            //strErrorMessage += "Enter vehicle info. ";
        }
        else if (strVehicle.length > 16) {
            strErrorMessage += "Make of car cannot exceed 16 characters. "
        }
    }

    //Song
    objElement = document.getElementById("txtUserProfileSong");
    if (objElement != null) {
        strSong = objElement.value;
        if (strSong == "" || strSong == "Favorite") {
            strSong = "";
            //strErrorMessage += "Enter song name. ";
        }
        else if (strSong.length > 16) {
            strErrorMessage += "Song cannot exceed 16 characters. "
        }
    }

    //HTML Content
    objElement = document.getElementById("divUserProfileImageContainer");
    if (objElement != null) {
        //strHTMLContent = objElement.value;
        strHTMLContent = "";
    }

    if (strErrorMessage.toString().length > 0) {
        pemco.ajax.flash(strErrorMessage, "Error");
        return false;
    }

    var data = {
        'action': 'email_new_user_profile',
        'profile_image': strProfileImage,
        'profile_name': strProfileName,
        'place_holder_text': strPlaceHolderText,
        'feature1': strFeature1,
        'feature2': strFeature2,
        'feature3': strFeature3,
        'spotted': strSpotted,
        'diet': strDiet,
        'vehicle': strVehicle,
        'song': strSong,
        'positionX': strPositionX,
        'positionY': strPositionY,
        'width': strWidth,
        'height': strHeight,
        'html_content': strHTMLContent,
        'sender_email': strSenderEmail,
        'recipient_email': strRecipientEmail,
        'email_message': strEmailMessage
    };

    jQuery.ajax({
        type: "POST",
        url: strAjaxHandler,
        dataType: "json",
        data: data,
        success: function(response) {
            if (response) {
                pemco.ajax.flash(response.message, response.status);

                if (response.status == "Success") {
                    //Bring back to my account page
                    pemco.home.myProfilesMode();
                }
            }
        }
    ,
        error: function() { pemco.ajax.flash("Fail to email new user profile.", "Error"); }
    });
}

pub.editUserProfile = function(strAjaxHandler, intNWTypeID) {

    var user_profile_id = parseInt(intNWTypeID);

    if (intNWTypeID <= 0) {
        pemco.ajax.flash("Profile ID does not existed.", "Error");
    }
    else {

        var data = { 'action': 'edit_user_profile', 'user_profile_id': user_profile_id }

        pemco.home.editProfileMode();

        jQuery.ajax({
            type: "POST",
            url: strAjaxHandler,
            dataType: "text",
            data: data,
            success: function(response) {
                if (response) {
                    var objElement = document.getElementById("create_profile_panel");
                    if (objElement != null) {
                        objElement.innerHTML = response;
                        //pemco.create_profile.construct();
                        var arrState = window.location.hash.substr(1).split("/");

                        var step = arrState[1];

                        if (step) {

                            if (step == "step1") {
                                pemco.create_profile.showStep(1);
                            }
                            else if (step == "step2") {
                                pemco.create_profile.showStep(2);
                            }
                            else if (step == "step3") {
                                pemco.create_profile.showStep(3);
                            }
                            else if (step == "step4") {
                                pemco.create_profile.showStep(4);
                            }
                            else if (step == "step5") {
                                pemco.create_profile.showStep(5);
                                objElement = document.getElementById("divUserProfileCreateNewProfile");
                                if (objElement != null) {
                                    objElement.style.display = "";
                                }
                            }
                        }
                        pemco.create_profile.applyBoldOnCurrentStep();
                    }
                }
            }
        ,
            error: function() { pemco.ajax.flash("Fail to process edit user profile.", "Error"); }
        });

    }
    return false;
}

pub.updateUserProfile = function(strAjaxHandler) {
    var strRecipientEmail = "";
    var strSenderEmail = "";
    var strProfileImage = "";
    var strProfileName = "";
    var strPlaceHolderText = "";
    var strFeature1 = "";
    var strFeature2 = "";
    var strFeature3 = "";
    var strSpotted = "";
    var strDiet = "";
    var strVehicle = "";
    var strSong = "";
    var strPositionX = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().left;
    var strPositionY = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().top;
    var strWidth = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').width();
    var strHeight = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').height();
    var strHTMLContent = "";
    var strProfileID = "";

    var strErrorMessage = "";

    //Profile Image
    var objElement = document.getElementById("hfUserProfileImage");
    if (objElement != null) {
        strProfileImage = objElement.value;
    }

    //Profile Name
    objElement = document.getElementById("txtUserProfileName");
    if (objElement != null) {
        strProfileName = objElement.value;

        if (strProfileName == "" || strProfileName == "XXXXXX") {
            //strErrorMessage += "Enter profile name in Step 2. ";
        }
        else if (strProfileName.toString().length > 13) {
            strErrorMessage += "Profile name cannot have more than 13 characters. ";
        }
    }

    //Place Holder Text
    objElement = document.getElementById("txtUserProfileName1");
    var strTemp = "";

    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 1 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }
    objElement = document.getElementById("txtUserProfileName2");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 2 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }

    objElement = document.getElementById("txtUserProfileName3");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 3 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }


    if (strPlaceHolderText == "") {
        //strErrorMessage += "Type your profile name. ";
    }

    //Feature 1
    objElement = document.getElementById("txtUserProfileFeature1");
    if (objElement != null) {
        strFeature1 = objElement.value;
        if (strFeature1 == "" || strFeature1 == "Feature 1") {
            strFeature1 = "";
            //strErrorMessage += "Enter feature # 1. ";
        }
        else if (strFeature1.length > 18) {
            strErrorMessage += "Feature 1 cannot exceed 18 characters. "
        }
    }

    //Feature 2
    objElement = document.getElementById("txtUserProfileFeature2");
    if (objElement != null) {
        strFeature2 = objElement.value;
        if (strFeature2 == "" || strFeature2 == "Feature 2") {
            strFeature2 = "";
            //strErrorMessage += "Enter feature # 2. ";
        }
        else if (strFeature2.length > 18) {
            strErrorMessage += "Feature 2 cannot exceed 18 characters. "
        }
    }

    //Feature 3
    objElement = document.getElementById("txtUserProfileFeature3");
    if (objElement != null) {
        strFeature3 = objElement.value;
        if (strFeature3 == "" || strFeature3 == "Feature 3") {
            strFeature3 = "";
            //strErrorMessage += "Enter feature # 3. ";
        }
        else if (strFeature3.length > 18) {
            strErrorMessage += "Feature 3 cannot exceed 18 characters. "
        }
    }

    //Spotted
    objElement = document.getElementById("txtUserProfilePlace");
    if (objElement != null) {
        strSpotted = objElement.value;
        if (strSpotted == "" || strSpotted == "Place") {
            strSpotted = "";
            //strErrorMessage += "Enter spotted location. ";
        }
        else if (strSpotted.length > 16) {
            strErrorMessage += "Spotted place cannot exceed 16 characters. "
        }
    }

    //Diet
    objElement = document.getElementById("txtUserProfileDiet");
    if (objElement != null) {
        strDiet = objElement.value;
        if (strDiet == "" || strDiet == "Eats") {
            strDiet = "";
            //strErrorMessage += "Enter diet info. ";
        }
        else if (strDiet.length > 16) {
            strErrorMessage += "Diet cannot exceed 16 characters. "
        }
    }

    //Vehicle
    objElement = document.getElementById("txtUserProfileVehicle");
    if (objElement != null) {
        strVehicle = objElement.value;
        if (strVehicle == "" || strVehicle == "Make of car") {
            strVehicle = "";
            //strErrorMessage += "Enter vehicle info. ";
        }
        else if (strVehicle.length > 16) {
            strErrorMessage += "Make of car cannot exceed 16 characters. "
        }
    }

    //Song
    objElement = document.getElementById("txtUserProfileSong");
    if (objElement != null) {
        strSong = objElement.value;
        if (strSong == "" || strSong == "Favorite") {
            strSong = "";
            //strErrorMessage += "Enter song name. ";
        }
        else if (strSong.length > 16) {
            strErrorMessage += "Song cannot exceed 16 characters. "
        }
    }

    //HTML Content
    objElement = document.getElementById("divUserProfileImageContainer");
    if (objElement != null) {
        //strHTMLContent = objElement.value;
        strHTMLContent = "";
    }

    //Profile ID
    objElement = document.getElementById("hfUserProfileId");
    if (objElement != null) {
        strProfileID = objElement.value;

        if (strProfileID == "") {
            strErrorMessage += "Profile ID does not exist. ";
        }
    }
    else {
        strErrorMessage += "Profile ID does not exist. ";
    }

    if (strErrorMessage.toString().length > 0) {
        pemco.ajax.flash(strErrorMessage, "Error");
        return false;
    }
    var arrState = window.location.hash.split("/");
    var step = arrState[1];

    // change the submit button to a spinner
    var objButton = document.getElementById("btnSubmitUserProfile");

    if (objButton) {
        objButton.src = "images/ajax-loader-small.gif";
    }

    //Get Recipient Email
    objElement = document.getElementById("txtUserProfileRecipientEmail");
    if (objElement != null) strRecipientEmail = objElement.value;
    if (strRecipientEmail == "") {
        //strErrorMessage += "Enter recipient email. ";
    }
    else if (strRecipientEmail.indexOf("@") == -1 && strRecipientEmail.indexOf(".") == -1) {
        //strErrorMessage += "Invalid recipient email. ";
    }

    //Get Sender Email
    objElement = document.getElementById("txtUserProfileYourEmail");
    if (objElement != null) strSenderEmail = objElement.value;
    if (strSenderEmail == "") {
        strErrorMessage += "Enter your email. ";
    }
    else if (strSenderEmail.indexOf("@") == -1 && strSenderEmail.indexOf(".") == -1) {
        strErrorMessage += "Invalid email address. ";
    }
    
    var data = {
        'action': 'update_user_profile',
        'profile_image': strProfileImage,
        'profile_name': strProfileName,
        'place_holder_text': strPlaceHolderText,
        'feature1': strFeature1,
        'feature2': strFeature2,
        'feature3': strFeature3,
        'spotted': strSpotted,
        'diet': strDiet,
        'vehicle': strVehicle,
        'song': strSong,
        'positionX': strPositionX,
        'positionY': strPositionY,
        'width': strWidth,
        'height': strHeight,
        'html_content': strHTMLContent,
        'user_profile_id': strProfileID,
        'profile_step': step,
        'sender_email': strSenderEmail,
        'recipient_email': strRecipientEmail
    };

    jQuery.ajax({
        type: "POST",
        url: strAjaxHandler,
        dataType: "json",
        data: data,
        success: function(response) {
            if (response) {
                pemco.ajax.flash(response.message, response.status);

                // show the submit button
                var objButton = document.getElementById("btnSubmitUserProfile");

                if (objButton) {
                    objButton.src = "images/btnSubmit.gif";
                }

                if (response.status == "Success") {
                    //Bring back to my account page
                    //pemco.home.myProfilesMode();
                    //window.location.hash = "my_account";

                    if (step) {

                        var start = 1;
                        while (start <= 5) {

                            objElement = document.getElementById("divStep" + start);
                            if (objElement != null) {
                                if (objElement.style.display == "") {
                                    switch (start) {
                                        case 1:
                                            window.location.href = "#createprofile/step2/" + strProfileID;
                                            break;
                                        case 2:
                                            window.location.href = "#createprofile/step3/" + strProfileID;
                                            break;
                                        case 3:
                                            window.location.href = "#createprofile/step4/" + strProfileID;
                                            break;
                                        case 4:
                                            window.location.href = "#createprofile/step5/" + strProfileID;
                                            break;

                                        case 5:
                                            //window.location.hash = "my_account";
                                            objElement = document.getElementById("btnSubmitUserProfile");

                                            if (objElement != null) {
                                                objElement.disabled = true;
                                                objElement.onclick = null;
                                            }
                                            pemco.ajax.flash("You have successfully submitted your profile.", "Success");
                                            break;

                                        default:
                                            window.location.hash = "my_account";
                                            break;
                                    }

                                    break;
                                }
                            }
                            start++;
                        }

                        //--------------------------------------------
                    }
                }
            }
        }
        ,
        error: function() { pemco.ajax.flash("Fail to submit new user profile.", "Error"); }
    });

    return false;
}

pub.emailUpdatedUserProfile = function(strAjaxHandler) {

    var strRecipientEmail = "";
    var strSenderEmail = "";
    var strEmailMessage = "";
    var strProfileImage = "";
    var strProfileName = "";
    var strPlaceHolderText = "";
    var strFeature1 = "";
    var strFeature2 = "";
    var strFeature3 = "";
    var strSpotted = "";
    var strDiet = "";
    var strVehicle = "";
    var strSong = "";
    var strPositionX = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().left;
    var strPositionY = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').position().top;
    var strWidth = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').width();
    var strHeight = $('.column2 #my-profile-container #divUserProfileImageContainer.crop-image img').height();
    var strHTMLContent = "";
    var strProfileID = "";

    var strErrorMessage = "";

    //Get Recipient Email
    var objElement = document.getElementById("txtUserProfileRecipientEmail");
    if (objElement != null) strRecipientEmail = objElement.value;
    if (strRecipientEmail == "") {
        //strErrorMessage += "Enter recipient email. ";
    }
    else if (strRecipientEmail.indexOf("@") == -1 && strRecipientEmail.indexOf(".") == -1) {
        //strErrorMessage += "Invalid recipient email. ";
    }

    //Get Sender Email
    objElement = document.getElementById("txtUserProfileYourEmail");
    if (objElement != null) strSenderEmail = objElement.value;
    if (strSenderEmail == "") {
        strErrorMessage += "Enter your email. ";
    }
    else if (strSenderEmail.indexOf("@") == -1 && strSenderEmail.indexOf(".") == -1) {
        strErrorMessage += "Invalid email address. ";
    }

    //Get Email Message
    objElement = document.getElementById("txtUserProfileEmailMessage");
    if (objElement != null) strEmailMessage = objElement.value;

    //Profile Image
    objElement = document.getElementById("hfUserProfileImage");
    if (objElement != null) {
        strProfileImage = objElement.value;
    }

    //Profile Name
    objElement = document.getElementById("txtUserProfileName");
    if (objElement != null) {
        strProfileName = objElement.value;
        if (strProfileName.toString().length > 13) {
            strErrorMessage += "Profile name cannot have more than 13 characters. ";
        }
    }

    //Place Holder Text
    objElement = document.getElementById("txtUserProfileName1");
    var strTemp = "";

    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 1 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }
    objElement = document.getElementById("txtUserProfileName2");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 2 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }

    objElement = document.getElementById("txtUserProfileName3");
    if (objElement != null) {
        if (objElement.value.toString().length > 13) {
            strErrorMessage += "Line 3 of profile name cannot exceed 13 characters. ";
        }
        else if (objElement.value.toString().length > 0) {
            if (strPlaceHolderText.length > 0) {
                strPlaceHolderText += "||" + objElement.value;
            }
            else {
                strPlaceHolderText = objElement.value;
            }
        }
    }


    if (strPlaceHolderText == "") {
        //strErrorMessage += "Type your profile name. ";
    }

    //Feature 1
    objElement = document.getElementById("txtUserProfileFeature1");
    if (objElement != null) {
        strFeature1 = objElement.value;
        //if (strFeature1 == "") strErrorMessage += "Enter feature # 1. ";
    }

    //Feature 2
    objElement = document.getElementById("txtUserProfileFeature2");
    if (objElement != null) {
        strFeature2 = objElement.value;
        //if (strFeature2 == "") strErrorMessage += "Enter feature # 2. ";
    }

    //Feature 3
    objElement = document.getElementById("txtUserProfileFeature3");
    if (objElement != null) {
        strFeature3 = objElement.value;
        //if (strFeature3 == "") strErrorMessage += "Enter feature # 3. ";
    }

    //Spotted
    objElement = document.getElementById("txtUserProfilePlace");
    if (objElement != null) {
        strSpotted = objElement.value;
        if (strSpotted == "" || strSpotted == "Place") {
            strSpotted = "";
            //strErrorMessage += "Enter spotted location. ";
        }
    }

    //Diet
    objElement = document.getElementById("txtUserProfileDiet");
    if (objElement != null) {
        strDiet = objElement.value;
        if (strDiet == "" || strDiet == "Eats") {
            strDiet = "";
            //strErrorMessage += "Enter diet info. ";
        }
    }

    //Vehicle
    objElement = document.getElementById("txtUserProfileVehicle");
    if (objElement != null) {
        strVehicle = objElement.value;
        if (strVehicle == "" || strVehicle == "Make of car") {
            strVehicle = "";
            //strErrorMessage += "Enter vehicle info. ";
        }
    }

    //Song
    objElement = document.getElementById("txtUserProfileSong");
    if (objElement != null) {
        strSong = objElement.value;
        if (strSong == "" || strSong == "Favorite") {
            strSong = "";
            //strErrorMessage += "Enter song name. ";
        }
    }

    //HTML Content
    objElement = document.getElementById("divUserProfileImageContainer");
    if (objElement != null) {
        //strHTMLContent = objElement.value;
    }


    //Profile ID
    objElement = document.getElementById("hfUserProfileId");
    if (objElement != null) {
        strProfileID = objElement.value;

        if (strProfileID == "") {
            strErrorMessage += "Profile ID does not exist. ";
        }
    }
    else {
        strErrorMessage += "Profile ID does not exist. ";
    }


    if (strErrorMessage.toString().length > 0) {
        pemco.ajax.flash(strErrorMessage, "Error");
        return false;
    }

    // change the send button to a spinner icon
    var objEmailButton = document.getElementById("btnEmailUserProfile");

    objEmailButton.src = "images/ajax-loader-small.gif";

    var data = {
        'action': 'update_user_profile',
        'profile_image': strProfileImage,
        'profile_name': strProfileName,
        'place_holder_text': strPlaceHolderText,
        'feature1': strFeature1,
        'feature2': strFeature2,
        'feature3': strFeature3,
        'spotted': strSpotted,
        'diet': strDiet,
        'vehicle': strVehicle,
        'song': strSong,
        'positionX': strPositionX,
        'positionY': strPositionY,
        'width': strWidth,
        'height': strHeight,
        'html_content': strHTMLContent,
        'sender_email': strSenderEmail,
        'recipient_email': strRecipientEmail,
        'email_message': strEmailMessage,
        'user_profile_id': strProfileID,
        'button_src': objEmailButton.src
    };

    jQuery.ajax({
        type: "POST",
        url: strAjaxHandler,
        dataType: "json",
        data: data,
        success: function(response) {
            if (response) {

                // bring back the button
                var objEmailButton = document.getElementById("btnEmailUserProfile");

                objEmailButton.src = "images/btnSend.gif";

                if (response.status == "Success") {
                    //Bring back to my account page
                    //pemco.home.myProfilesMode();
                    //pemco.ajax.flash("You have successfully sent this profile to " + strRecipientEmail + ".", "Success");
                    pemco.ajax.flash(response.message, response.status);

                    //clear text field
                    objElement = document.getElementById("txtUserProfileYourEmail");
                    if (objElement != null) objElement.value = "Your Email Address";

                    objElement = document.getElementById("txtUserProfileRecipientEmail");
                    if (objElement != null) objElement.value = "Recipient Email Address";

                    objElement = document.getElementById("txtUserProfileEmailMessage");
                    if (objElement != null) objElement.value = "";
                }
                else {
                    pemco.ajax.flash(response.message, response.status);
                }
            }
        }
        ,
        error: function() { pemco.ajax.flash("Fail to update user profile.", "Error"); }
    });

}

//----- Show Previous Step --------------------------------------------------
pub.previousStep = function(intCurrentStep) {

    //Check to see if we're in edit mode
    var objElement = document.getElementById("hfUserProfileId");
    if (objElement != null) {
        //Handle Step 4 Separately
        if (intCurrentStep == 4) {
            window.location.hash = "createprofile/step3/" + objElement.value;
        }
    }

    objElement = document.getElementById("divStep" + intCurrentStep);

    //Hide Current Step
    if (objElement != null) {
        objElement.style.display = "none";
    }

    //Show Previous Step
    objElement = document.getElementById("divStep" + (intCurrentStep - 1));
    if (objElement != null) {
        objElement.style.display = "";
        pemco.create_profile.updateUserProfileStepInfo(intCurrentStep - 1);
    }

    pemco.create_profile.applyBoldOnCurrentStep();

    //Lock Place Holder
    if (intCurrentStep > 2) {
        $("#imgUserProfileImage").draggable("disable");
        objElement = document.getElementById("divZoomBlock");
        if (objElement != null) objElement.style.display = "none";
    }
    else {
        $("#imgUserProfileImage").draggable("enable");
        objElement = document.getElementById("divZoomBlock");
        if (objElement != null) objElement.style.display = "";
    }
}

pub.showStep = function(intShowStep) {

    var objElement = document.getElementById("divStep" + intShowStep);

    //Hide Current Step
    if (objElement != null) {
        objElement.style.display = "";
    }

    var index = 0;

    while (index <= 5) {

        index++;

        if (index != intShowStep) {
            objElement = document.getElementById("divStep" + index);
            if (objElement != null) {
                objElement.style.display = "none";
            }
        }
    }

    //Lock Place Holder
    if (intShowStep >= 2) {
        $("#imgUserProfileImage").draggable("disable");
        objElement = document.getElementById("divZoomBlock");
        if (objElement != null) objElement.style.display = "none";
    }
    else {
        $("#imgUserProfileImage").draggable("enable");
        objElement = document.getElementById("divZoomBlock");
        if (objElement != null) objElement.style.display = "";
    }

    pemco.create_profile.applyBoldOnCurrentStep();

    return false;
}
//----- Show Next Step -------------------------------------------------------
pub.nextStep = function(intCurrentStep) {

    var objElement = document.getElementById("divStep" + intCurrentStep);

    //Hide Current Step
    if (objElement != null) {
        objElement.style.display = "none";
    }

    //update text in profile step
    objElement = document.getElementById("divProfileStepInfo" + intCurrentStep);
    if (objElement != null) {
        switch (intCurrentStep) {
            case 1:
                objElement.innerHTML = "<a href='#createprofile/step" + intCurrentStep + "' onclick='javascript:return pemco.create_profile.showStep(" + intCurrentStep + ");'><b>Upload Photo</b></a> <img src='images/checkmark.gif' />";
                objElement = document.getElementById("divUserProfileCreateNewProfile");
                if (objElement != null) {
                    objElement.style.display = "none";
                }
                break;

            case 2:
                objElement.innerHTML = "<a href='#createprofile/step" + intCurrentStep + "' onclick='javascript:return pemco.create_profile.showStep(" + intCurrentStep + ");'><b>Place photo into layout</b></a> <img src='images/checkmark.gif' />";
                objElement = document.getElementById("divUserProfileCreateNewProfile");
                if (objElement != null) {
                    objElement.style.display = "none";
                }
                break;

            case 3:
                objElement.innerHTML = "<a href='#createprofile/step" + intCurrentStep + "' onclick='javascript:return pemco.create_profile.showStep(" + intCurrentStep + ");'><b>Type new profile text</b></a> <img src='images/checkmark.gif' />";
                objElement = document.getElementById("divUserProfileCreateNewProfile");
                if (objElement != null) {
                    objElement.style.display = "none";
                }
                break;

            case 4:
                objElement.innerHTML = "<a href='#createprofile/step" + intCurrentStep + "' onclick='javascript:return pemco.create_profile.showStep(" + intCurrentStep + ");'><b>Fill in the details</b></a> <img src='images/checkmark.gif' />";
                objElement = document.getElementById("divUserProfileCreateNewProfile");
                if (objElement != null) {
                    objElement.style.display = "none";
                }
                break;

            case 5:
                objElement.innerHTML = "<a href='#createprofile/step" + intCurrentStep + "' onclick='javascript:return pemco.create_profile.showStep(" + intCurrentStep + ");'><b>Share your new profile</b></a> <img src='images/checkmark.gif' />";
                objElement = document.getElementById("divUserProfileCreateNewProfile");
                if (objElement != null) {
                    objElement.style.display = "";
                }
                break;
            default:
                break;
        }

    }

    //Show Next Step
    objElement = document.getElementById("divStep" + (intCurrentStep + 1));
    if (objElement != null) {
        objElement.style.display = "";
        pemco.create_profile.updateUserProfileStepInfo(intCurrentStep + 1);
    }

    pemco.create_profile.applyBoldOnCurrentStep();

    //Lock Place Holder
    if (intCurrentStep >= 2) {
        $("#imgUserProfileImage").draggable("disable");

        //Hide Zoom Option
        objElement = document.getElementById("divZoomBlock");

        if (objElement != null) {
            objElement.style.display = "none";
        }

        objElement = document.getElementById("divZoomDisabledMessage");
        if (objElement != null) { objElement.style.display = ""; }
    }
    else {
        $("#imgUserProfileImage").draggable("enable");

        //Hide Zoom Option
        objElement = document.getElementById("divZoomBlock");

        if (objElement != null) {
            objElement.style.display = "";
        }

        objElement = document.getElementById("divZoomDisabledMessage");
        if (objElement != null) { objElement.style.display = "none"; }
    }
}

pub.applyBoldOnCurrentStep = function() {
    var index = 1;

    var objElement = null;

    while (index <= 5) {

        objElement = document.getElementById("divStep" + index);
        if (objElement != null && objElement.style.display == "") {

            var i = 1;
            while (i <= 5) {
                objElement = document.getElementById("divProfileStepInfo" + i);
                if (objElement != null) {
                    if (i == index) { //bold
                        objElement.style.fontWeight = "bold";

                        objElement = document.getElementById("divProfileStepInfo");
                        if (objElement != null) {
                            //objElement.style.className = "step" + i + "_info";
                            objElement.innerHTML = "<img src='images/step" + i + ".gif' />";
                        }
                    }
                    else {
                        objElement.style.fontWeight = "lighter";
                    }
                }
                i++;
            }

            break;
        }

        index++;
    }
}

pub.resetUserCreationForm = function() {
    pemco.home.createProfileMode();
    pemco.create_profile.construct();
    window.location.hash = "createprofile";

    /*
    //Reset Profile Image
    var objElement = document.getElementById("imgUserProfileImage");
    if (objElement != null) {
    objElement.src = "images/overlays/place-holder.jpg";
    }

    //Reset Hidden Image Name Holder
    objElement = document.getElementById("hfUserProfileImage");
    if (objElement != null) objElement.value = "";

    //Set Draggable ON
    $("#imgUserProfileImage").draggable("enable");

    //Move Back To Step 1
    var index = 1;
    var count = 4;

    while (index <= count) {
    objElement = document.getElementById("divStep" + index);
    if (objElement != null && index == 1) {
    objElement.style.display = "";
    }
    else if (objElement != null) {
    objElement.style.display = "none";
    }
    index++;
    }

    //Iframe
    objElement = document.getElementById("iframeFileUploader");

    if (objElement != null) {
    if (objElement.contentWindow.document.getElmenetById("divThumbImage") != null) {
    objElement.contentWindow.document.getElmenetById("divThumbImage").innerHTML = "";
    }
    }
    */
    return false;
}

pub.updateUserProfileStepInfo = function(newStep) {
    var objElement = document.getElementById('divProfileStepInfo');
    if (objElement != null) {
        objElement.className = "step" + newStep + "_info";
        return true;
    }
    return false;
}

//********************************************************************************

//$(pub.construct);

})(jQuery);
