﻿var puserid = "";
function ShowBasicInfo() {
}
//This function is used to set current class for the active tab on lobby wall
function SetCurrentProfileTabClass(element,tabid) {
    try {
        if ($('#ulprofiletabs li').length > 0) {
            for (var k = 0; k < $('#ulprofiletabs li').length; k++) {
                $('#ulprofiletabs li')[k].className = "";
            }
            if (tabid == "") {
                $("#" + element.id).addClass("SelectRace");
            }
            else {
                $("#" + tabid).addClass("SelectRace");
            }
        }
    }
    catch (Error) {
        LogError("wall.js", "SetCurrentClass", Error.message);
    }
}
function showloader() {
    $("#ProfileTabsloader").show();
}
function hideloader() {
    $("#ProfileTabsloader").hide();
}
function LinkedLogin() {
    if ($("#MainContent_LinkedInXml").val() != "") {
        if ($("#MainContent_LinkedInXml").val().indexOf("<Response>Failed</Response>") == -1) {
        }
        else {
            LinkedLoginPopup();
            return false;
        }
    }
    else {
        LinkedLoginPopup();
        return false;
    }
}
//Linkedin Section starts Here
//This Function used to Generate HTML for Linkedin Data from The Linked in XML
function GetLinkedinProfile(uid) {
    try {
        var LinkedInProfile = $("#MainContent_LinkedInXml").val();
        var userid = uid;
        if (puserid != uid && puserid != "") {
            userid = puserid;
        }
        var results = "";
        var lnjhtml = "";
       if ($.trim(LinkedInProfile) != "") {

           if ($.trim(LinkedInProfile).indexOf("<Response>Failed</Response>") == -1) {
                var xml = LoadXMLBrowser(LinkedInProfile);

                lnjhtml += "<div class='Lnk_UserImgWkCt'>";
                lnjhtml += "<div class='Lnk_UsrlftCt' style='width:350px'>";


                lnjhtml += "<H1>" + $(xml).find('first-name').text() + " " + $(xml).find('last-name').text() + "</H1>";
                if ($(xml).find('headline').length > 0) {
                    if (xml.getElementsByTagName("headline")[0].childNodes.length > 0) {

                        lnjhtml += "<H2 style='width:350px' >" + $(xml).find('headline').text() + "</H2>";
                    }
                }
                xml.GetElementsByTagName
                lnjhtml += "<H3>" + $(xml).find('location').text() + "</H3>";

                lnjhtml += "</div>";
                lnjhtml += "<div class='Rgt_UserRghCt' >";
                if ($(xml).find('url').length > 0 && $(xml).find('picture-url').length > 0) {
                    lnjhtml += "<div class='Lnk_UserRghCt'><a href=" + $(xml).find('url').text() + " target='blank'><img src='" + $(xml).find('picture-url').text() + "' /></a></div>";
                }

                if (puserid == uid || puserid == "") {
                    lnjhtml += "<div><a onclick=LinkedLogin() style='cursor:pointer;margin-top:2px;margin-left:2px;' title='Update linkedin profile'><img src='" + SiteImages + "updated_butprof.png'></a></div>";
                }
                lnjhtml += "</div>";
                lnjhtml += "</div>";

                lnjhtml += "<div class='Crt_OuterMainCt'>";
                if (xml.getElementsByTagName("positions")[0].attributes[0].nodeTypedValue > 0) {
                    var k = 0;
                    if ($(xml).find('positions').length > 0) {
                        $(xml).find('positions').each(function () {
                            $(this).find('position').each(function () {
                                if ($(this).find('is-current').text() == "true") {
                                    lnjhtml += "<div class='Crnt_WkMnCt'>";
                                    lnjhtml += "<div class='Crnt_LftCtwok'>";
                                    if (k == 0) {
                                        lnjhtml += "<strong>Current</strong>";
                                        k = 1;
                                    }
                                    lnjhtml += "</div>";
                                    lnjhtml += "<div class='Crnt_DotWkCt'><img src='" + SiteImages + "dotprfimg.png' /></div>";
                                    lnjhtml += "<div class='Crnt_RghCtwok'><strong>" + $(this).find('title').text() + " at " + $(this).find('company').text() + "</strong></div>";
                                    lnjhtml += "</div>";
                                }
                            });
                        });


                    }
                    k = 0;

                    $(xml).find('positions').each(function () {
                        $(this).find('position').each(function () {
                            if ($(this).find('is-current').text() == "false") {
                                lnjhtml += "<div class='Crnt_WkMnCt'>";
                                lnjhtml += "<div class='Crnt_LftCtwok'>";
                                if (k == 0) {
                                    lnjhtml += "<strong>Past</strong>";
                                    k = 1;
                                }
                                lnjhtml += "</div>";
                                lnjhtml += "<div class='Crnt_DotWkCt'><img src='" + SiteImages + "dotprfimg.png' /></div>";
                                lnjhtml += "<div class='Crnt_RghCtwok'>" + $(this).find('title').text() + " at " + $(this).find('company').text() + "</div>";
                                lnjhtml += "</div>";
                            }
                        });
                    });

                }
                k = 0;
                $(xml).find('educations').each(function () {
                    $(this).find('education').each(function () {
                        lnjhtml += "<div class='Crnt_WkMnCt'>";
                        lnjhtml += "<div class='Crnt_LftCtwok'>";

                        if (k == 0) {
                            lnjhtml += "<strong>Education</strong>";
                            k = 1;
                        }
                        lnjhtml += "</div>";
                        lnjhtml += "<div class='Crnt_DotWkCt'><img src='" + SiteImages + "dotprfimg.png' /></div>";
                        lnjhtml += "<div class='Crnt_RghCtwok'>" + $(this).find('school-name').text() + "</div>";
                        lnjhtml += "</div>";
                    });
                });

                lnjhtml += "<div class='Crnt_WkMnCt'>";
                lnjhtml += "<div class='Crnt_LftCtwok'><strong>Connections</strong></div>";
                lnjhtml += "<div class='Crnt_DotWkCt'></div>";
                lnjhtml += "<div class='Crnt_RghCtwok'><img src='" + SiteImages + "contimg.jpg' /> <strong>" + xml.getElementsByTagName("connections")[0].attributes[0].childNodes[0].data + "</strong> Connections</div>";
                lnjhtml += "</div>";

                if ($(xml).find('industry').length > 0) {
                    if (xml.getElementsByTagName("industry")[0].childNodes.length > 0) {
                        lnjhtml += "<div class='Crnt_WkMnCt'>";
                        lnjhtml += "<div class='Crnt_LftCtwok'><strong>Industry</strong></div>";
                        lnjhtml += "<div class='Crnt_DotWkCt'></div>";
                        lnjhtml += "<div class='Crnt_RghCtwok'>" + $(xml).find('industry').text() + "</div>";
                        lnjhtml += "</div>";
                        lnjhtml += "</div>";
                    }
                }

                if ($(xml).find('summary').length > 0 || $(xml).find('specialties').length > 0) {
                    if (xml.getElementsByTagName("summary")[0].childNodes.length > 0) {
                        lnjhtml += "<div class='Exp_MnWkCt'>";
                        lnjhtml += "<H1>" + $(xml).find('first-name').text() + " " + $(xml).find('last-name').text() + "'s Summary</H1>";
                        lnjhtml += "<div class='ExpoIntWrkTxt'>";
                        if (xml.getElementsByTagName("summary").length > 0) {
                            if (xml.getElementsByTagName("summary")[0].childNodes.length > 0) {
                                var val = xml.getElementsByTagName("summary")[0].childNodes[0].nodeValue;
                                lnjhtml += "<p>" + val.replace(/\n/g, "<br/>").replace(/\r/g, "") + "<p>";

                            }
                        }
                        if ($(xml).find('specialties').length > 0) {
                            if (xml.getElementsByTagName("specialties")[0].childNodes.length > 0) {
                                lnjhtml += "<H3>(" + $(xml).find('specialties').text() + ")</H3>";
                            }
                        }
                        lnjhtml += "</div></div>";
                    }
                }
                $(xml).find('positions').each(function () {
                    lnjhtml += "<DIV class=Exp_MnWkCt><H1>" + $(xml).find('first-name').text() + " " + $(xml).find('last-name').text() + "'s  Experience</H1>";
                    $(this).find('position').each(function () {
                        lnjhtml += "<DIV class=ExpoIntWrkTxt style='width:725px'>";
                        lnjhtml += "<H2 style='width:725px' ><STRONG>" + $(this).find('title').text() + "</STRONG></H2>";
                        lnjhtml += "<H2 style='width:725px' ><STRONG>" + $(this).find('company').text() + "</STRONG></H2>";

                        lnjhtml += "<H3 style='width:725px'>";
                        $(this).find('start-date').each(function () {
                            lnjhtml += months($(this).find('month').text()) + " " + $(this).find('year').text();
                        });
                        if ($(this).find('is-current').text() == "true") {
                            lnjhtml += " - " + "Present";
                            $(this).find('start-date').each(function () {
                                var st = parseInt(new Date().getFullYear()) - parseInt($(this).find('year').text());
                                lnjhtml += " ( " + st + " years ";
                                lnjhtml += $(this).find('month').text() + " months )";
                            });

                        }
                        else {
                            $(this).find('end-date').each(function () {
                                lnjhtml += " - " + months($(this).find('month').text()) + " " + $(this).find('year').text();
                            });
                        }
                        lnjhtml += "</H3>";
                        lnjhtml += "<p style='width:725px' >" + $(this).find('summary').text().replace(/\n/g, "<br/>").replace(/\r/g, "") + "</p></DIV>";

                    });
                    lnjhtml += "</DIV>";
                });
                k = 0;
                $(xml).find('educations').each(function () {

                    $(this).find('education').each(function () {

                        if (k == 0) {
                            lnjhtml += "<DIV class=Exp_MnWkCt>";
                            lnjhtml += "<H1>" + $(xml).find('first-name').text() + " " + $(xml).find('last-name').text() + "'s Education</H1>";
                            k = 1;
                        }
                        lnjhtml += "<DIV class=ExpoIntWrkTxt>";
                        lnjhtml += "<H2 style='width:725px' ><STRONG>" + $(this).find('school-name').text() + "</STRONG></H2>";
                        if ($(this).find('degree').text() != "") {
                            lnjhtml += "<H2 style='width:725px' >" + $(this).find('degree').text();
                        }
                        if ($(this).find('field-of-study').text() != "") {
                            lnjhtml += " , ";
                            lnjhtml += $(this).find('field-of-study').text() + "</H2>";
                        }

                        lnjhtml += "<H4>";
                        $(this).find('start-date').each(function () {
                            lnjhtml += $(this).find('year').text();
                        });
                        $(this).find('end-date').each(function () {
                            lnjhtml += " - " + $(this).find('year').text();
                        });

                        lnjhtml += "</H4>";
                        lnjhtml += "</DIV>";
                        if (k == 0) {
                            lnjhtml += "</DIV>";
                        }

                    });
                });



            }
            else {

                lnjhtml += "<div class='Pr_LftCt'>";
                lnjhtml += "<div class='nofedstwt' style='width:438px'>";
                lnjhtml += "<div class='NoTwtFeeds' style='font-size:13px'>";
                if (puserid != uid && puserid != "") {
                    lnjhtml += "<b style='font-family:tahoma;'>To get your linkedin profile</b>";
                }
                else {
                    lnjhtml += "<b style='font-family:tahoma;'>To get your linkedin profile</b> <a onclick=LinkedLogin() style='cursor:pointer' >Click here</a>";
                }
                lnjhtml += "</div>";
                lnjhtml += "</div>";
                lnjhtml += "</div>";

            }
        }
        else {

            lnjhtml += "<div class='Pr_LftCt'>";
            lnjhtml += "<div class='nofedstwt' style='width:438px'>";
            lnjhtml += "<div class='NoTwtFeeds' style='font-size:13px'>";
            if (puserid != uid && puserid != "") {
                lnjhtml += "<b style='font-family:tahoma;'>Attendee has not used this feature yet.</b>";
            }
            else {
                lnjhtml += "To get your linkedin Profile <a onclick=LinkedLogin() style='cursor:pointer' >Click here</a>";
            }
            lnjhtml += "</div>";
            lnjhtml += "</div>";
            lnjhtml += "</div>";
        }
        $("#LinkedInFeeds").attr("innerHTML", lnjhtml + "<div id='attendee' style='margin-top:50px'></div>");
    }
    catch (Error) {
        LogError("UserProfile.js", "GetLinkedinProfile:on Success Result", Error.message);
    }
}




function months(index) {
    var month = new Array("January", "Jan", "Feb", "March", "April", "May", "June", "July", "August", "September", "Oct", "Nov", "Dec");
    return month[index];
}

//Linkedin Section ends  Here

//Twitter Section Starts here
//function ShowTwitterFeeds() {
//    if ($("#MainContent_hdntwttype").val() != "" && $("#MainContent_hdntwttype").val() != "0") {
//        GetTwtFeed($("#MainContent_hdntwttype").val(),"", $("#MainContent_hdTWToken").val(), $("#MainContent_hdTWSctToken").val(), 1, $("#MainContent_userId").val(), 7, 15);
//    
//    }
//    else {
//        LoginTwit();
//    }
//}

//function LoginTwit() {

//    try {
//        var url = "";
//        url = "TwitterLogin.aspx?act=ut";
//        window.open(url, "TwitterLogin", "toolbar=no,status=no,menubar=no,location=center,scrollbars=no,height=400;width=800;left=200;");
//        return false;
//    }
//    catch (Error) {
//        LogError(Error.message, 'UserProfile.js:LoginTwit');
//        return false;
//    }
//}

//Twitter Section Ends here 

///This Function Just return the Value
//function GetBasicInfo(userid,ConfId) {
//    try {
//        var obj = {
//            UserID: userid,
//            ConferenceID: ConfId
//        };
//        var reqParams_Serialized = Sys.Serialization.JavaScriptSerializer.serialize(obj);
//        var results = "";
//        $.ajax({
//            url: Domain_Path + 'ProxyWcf.aspx/GetUserBasicInfo',
//            type: 'Post',
//            contentType: 'application/json;charset=utf-8',
//            data: reqParams_Serialized,
//            success: function (response) {
//                try {
//                    if (response.d != null) {
//                        var data = response.d;
//                        showBasicInfoDetails(data);
//                    }
//                }
//                catch (Error) {

//                }
//            },
//            failure: function (response) {


//            }
//        });

//    }
//    catch (Error) {

//    }
//}

//function showBasicInfoDetails(response) {

//    var htm = "<div class='info_main'>";
//    htm += "<ul class='main_infoul'>";

//    htm += "<li>";
//    htm += "<div class='info_heading'>Basic Info";
//    htm += "<div class='right_edit'>";



//    htm += "</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>First Name</div>";
//    htm += "<div class='second_fld'>Prabhjot</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Last Name</div>";
//    htm += "<div class='second_fld'>Description</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Description</div>";
//    htm += "<div class='second_fld'>Description</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Title</div>";
//    htm += "<div class='second_fld'>Title</div>";
//    htm += "</div>";

//    htm += "</li>";

//    htm += "<li>";
//    htm += "<div class='info_heading'>Company Info";
//    htm += "<div class='right_edit'>";



//    htm += "</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Company</div>";
//    htm += "<div class='second_fld'>Company</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>City</div>";
//    htm += "<div class='second_fld'>City</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>State</div>";
//    htm += "<div class='second_fld'>State</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Zip Code</div>";
//    htm += " <div class='second_fld'>Zip Code</div> ";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Country</div>";
//    htm += "<div class='second_fld'>Country</div>";
//    htm += "</div>";

//    htm += "</li>";



//    htm += "<li>";
//    htm += "<div class='info_heading'>Tags";
//    htm += "<div class='right_edit'>";



//    htm += "</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Tags of Yourself</div>";
//    htm += "<div class='second_fld'>Tags</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Tags for Interest</div>";
//    htm += "<div class='second_fld'>Tags</div>";
//    htm += "</div>";

//    htm += "</li>";


//    htm += "<li>";
//    htm += "<div class='info_heading'>Personal Links";
//    htm += "<div class='right_edit'>";

//    htm += "</div>";
//    htm += "</div>";

//    htm += "<div class='info_fields'>";
//    htm += "<div class='first_fld'>Linkedin Url</div>";
//    htm += "<div class='second_fld'>Linked-In</div>";
//    htm += "</div>";

//    htm += "</li>";


//    htm += "</ul>";
//    htm += "</div>";
//    $("#dvUserProfileData").attr("innerHTML", htm);
//    $("#dvUserProfileData").show();
//}

//Twitter
function LoginTwit() {

    try {
        var url = "";
        if ($("#MainContent_TwitterToken").val() != "" && $("#MainContent_TwitterSecretToken").val() != "") {
            ShowTwitterFeeds();
            return true;
        }
        else {
            url = Domain_Path+"TwitterLogin.aspx?act=ut";
            window.open(url, "TwitterLogin", "toolbar=no,status=no,menubar=no,location=center,scrollbars=no,height=400;width=800;left=200;");
        }
        return false;
    }
    catch (Error) {
        //  TraceError(Error.message, 'UserProfile.js:LoginTwit');
    } 
}


function ShowTwitterUpdates() {
    $("#MainContent_ProfileData").attr("innerHTML", "");
    $("#MainContent_ProfileData").attr("innerHTML", "Twitter Updates");
    $("#MainContent_ProfileData").show();
}
function ShowTwitterFeeds() {
    $("#MainContent_lnkTwitter").click();
}


