function getXHR(){
    if(window.XMLHttpRequest){
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return req;
}

function callback(result,pid){
    clearErrorMessage();
    setErrorMessage(result);
    //document.getElementById(pid).innerHTML = '';
    //document.getElementById(pid).innerHTML=result;
    if(pid != 'Invitepopup' && pid != 'globalErrorMessage'){
        mclosecommontime();
        var TabbedPanels1 = new Spry.Widget.TabbedPanels('TabbedPanels1',3);
    }
}

function callbacktagcloud(result,pid){
    var output='';
    result = result.split("####")[0];
    var jsoncontent = eval('('+result+')');
    output+='<div id="wrapper"><div id="content"><div class="searchsmall" style="width:290px !important"><h3 class="tabtxt" title="Top Searches">what are people searching for</h3></div><div class="boxholder"><div id="tagBox" class="box">';
    for(var i=0;i<jsoncontent.length;i++){        
        output+='<a href='+contextRoot+'/jsp/IndexSearch.do?ezdiadbsearch='+escape(jsoncontent[i].tag)+'&searchtype=index&selected_ezdia_domain=2 class="'+jsoncontent[i].weight+'">'+jsoncontent[i].tag+'</a>';        
    }
    output+='</div></div></div></div>';
    document.getElementById(pid).innerHTML = '';
    document.getElementById(pid).innerHTML=output;
}

function callbackcheckuser(result){
    var myresult = new Array();
    myresult = result.split("####");
    indicator = myresult[1];
    if(indicator == 1)
    {   
        document.getElementById(pid).style.display='none';
        if(pid == 'SUerrordivIndex'){
            document.getElementById('SUerrordivGIndex').style.display='';
            document.getElementById('SUerrordivGIndex').innerHTML = '';
            document.getElementById('SUerrordivGIndex').innerHTML=myresult[0];
        }
        else if(pid == 'SUerrordiv'){
            document.getElementById('SUerrordivG').style.display='';
            document.getElementById('SUerrordivG').innerHTML = '';
            document.getElementById('SUerrordivG').innerHTML=myresult[0];
        }
        else{
            document.getElementById('BEerrordivG').style.display='';
            document.getElementById('BEerrordivG').innerHTML = '';
            document.getElementById('BEerrordivG').innerHTML=myresult[0];
        }
    }
    else{
        if(pid == 'SUerrordivIndex')
            document.getElementById('SUerrordivGIndex').style.display='none';
        else if(pid == 'SUerrordiv')
            document.getElementById('SUerrordivG').style.display='none';
        else
            document.getElementById('BEerrordivG').style.display='none';
        document.getElementById(pid).style.display='';
        document.getElementById(pid).innerHTML = '';
        document.getElementById(pid).innerHTML=myresult[0];
    }
}

function homePage(){
    document.getElementById('output').innerHTML = "";
}

function showDetails(sVariables){
    var PopBox = document.getElementById(sVariables);
    PopBox.style.display="";
}
// Code added by Jagdish

function callbackcommon(result,pid){
    document.getElementById(pid).innerHTML = '';
    document.getElementById(pid).innerHTML=result;
    if(type == 'Content'){
        if(login_user == otheruserid)
            MyContent('KBSearch.do','2','Content',0,'Content',login_user)
        else
            MyContent('KBSearch.do','2','Content',0,'Content',otheruserid)
        tabindexer=0;
    }
    if(profileparam && profileparam == 'profileparam'){
        if(connectionflag && connectionflag == 'editProfile'){
            listUserConnections('MyConnection.do', '0', otheruserid, connectionflag);
        }
        else{
            listUserConnections('MyConnection.do', '0', otheruserid);
        }
    }
    var tabindex12 = new Spry.Widget.TabbedPanels("TabbedPanels1", tabindexer);
}

function callbackcommonsearch(result,pid){
    myresult = result.split("######");
    document.getElementById(pid).innerHTML = '';
    document.getElementById(pid).innerHTML=myresult[0];
    if(pid == 'Content'){
        //document.getElementById('search_string').style.display = 'none';
        //document.getElementById('narrowed_result_center').style.marginTop = '13px';
        if (document.getElementById('kbowner') != null){
            if(login_user == otheruserid)
            {
                document.getElementById('kbowner').innerHTML = '<span style="color: rgb(153, 0, 0);" onclick=showcommondiv("PostALink.jsp","PostLinkPopUp","PostLinkPopUp"); class="action"><b>Add first entry to your knowledge bucket</b></span>';
                document.getElementById('emptyBkt').innerHTML = '<img onclick=showcommondiv("PostALink.jsp","PostLinkPopUp","PostLinkPopUp") style="padding: 40px 0px 20px 240px; cursor: pointer;" alt="Knowledge Bucket Empty" src="../static/images/EmptyKnowledgeBucket.png" title="Add to your Knowledge Bucket"/>';
                document.getElementById('otheruseremptykb').innerHTML = 'You have added no contents yet. Your knowledge bucket is empty.';

            }
            else if(document.getElementById('viewkbname') != null){
                var kbOwner = document.getElementById('viewkbname').innerHTML;
                document.getElementById('kbowner').innerHTML = '<span style="color: rgb(153, 0, 0);" onclick=showComposeMsg("messages/popupcompose.jsp?replyto='+otheruserid+'&firstname='+kbOwner+'","common","compose",event); class="action"><b>-: Suggest '+kbOwner+' to add content in his knowledge bucket :-</b></span>';
                document.getElementById('emptyBkt').innerHTML = '<img onclick=showComposeMsg("messages/popupcompose.jsp?replyto='+otheruserid+'","common","compose",1);" style="padding: 40px 0px 20px 240px; cursor: pointer;" alt="Knowledge Bucket Empty" src="../static/images/EmptyKnowledgeBucket.png" title="Send a message"/>';
                document.getElementById('otheruseremptykb').innerHTML = kbOwner+' has added no contents yet. His knowledge bucket is empty.';
            }
        }
    }
    var jsonContent = eval('('+myresult[1]+')');
    //alert(jsonContent);
    var narrowResults = jsonContent.narrowResults;
    var nAreaCount=0;
    var areaCounts = narrowResults["areaCounts"];
    viewNewAreacount = areaCounts;
    var categoryCounts = narrowResults["categoryCounts"];
    var output='';
    for(var workarea in areaCounts)
    {   
        if (!areaCounts.hasOwnProperty(workarea)) continue;
        //        if(searchFilters.searchType == 'Content'){
        if (categoryCounts[workarea] == 0) continue;
        output+='<div id="area_'+nAreaCount+'" class="drag_cmn" onclick=narrowExpertSearchByCategory("' + escape(workarea) + '","'+escape(areaCounts)+'",1)><a href="javascript:void(0)" style="color:#000;">'+workarea+'('+categoryCounts[workarea]+')</a></div>';
        //        }
        //        else if(searchFilters.searchType == 'Expert'){
        //            output+='<div id="area_'+nAreaCount+'" class="drag_cmn" onclick=narrowExpertSearchByCategory("' + escape(workarea) + '","'+escape(areaCounts)+'",1)><a href="javascript:void(0)" style="color:#000;">'+workarea+'</a></div>';
        //        }
        output+='<span style="margin:0;">';
        output+='<span id="'+escape(workarea)+'"></span>';
        output+='</span>';
        nAreaCount++;
    }
    document.getElementById("browsebycategory").innerHTML = output;
    if (jsonContent.bNoResults) {
        var esrh = document.getElementById("expertSearchResultHeader");
        if (esrh){
            esrh.innerHTML = "No results for your search. Below is the list of top experts."
        }
    }
//var tabindex12 = new Spry.Widget.TabbedPanels("TabbedPanels1", tabindexer);
}
function callbackExpertsExplorers(result,pid){
    
    myresult = result.split("######");
    document.getElementById(pid).innerHTML = '';
    document.getElementById(pid).innerHTML=myresult[0];
}
function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++)
    {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1)
        {
            IsNumber = false;
        }
    }
    return IsNumber;
}

function clearDiv(divid){
    document.getElementById(divid).innerHTML = '';
    document.getElementById(divid).style.display = 'none';
}

function showResult(actionURL,invID){
    pid=invID;
    showResultWithQueryStr(actionURL, invID, callback, null);
    return true;
}

function checkYoutube(){
    var image = new Image();
    image.src = 'http://youtube.com/favicon.ico';
    if (image.height >= 0) {
    // The user can access youtube
    // showResultAct(contextRoot+'/jsp/indexVideo.jsp','tagCloudBox');
    } else {
        // The user can't access youtube
        getTagCloud(contextRoot+'/jsp/GetTagCloud.do','tagCloudBox');
    }
}

function getTagCloud(actionURL,invID){
    showResultWithQueryStr(actionURL, invID, callbacktagcloud, null,true);
    return true;
}
function showResultWithQueryStr(actionURL,invID,callbackfunction,query,ignoreHistory,tabindex,type,page){

    if (ignoreHistory == undefined) ignoreHistory = false;
    if (!ignoreHistory) {
        var arr = [showResultWithQueryStrDo];
        arr.push(arguments);
        dhtmlHistory.add(historyIndex++,arr);
    }
    showResultWithQueryStrDo(actionURL,invID,callbackfunction,query,ignoreHistory,tabindex,type,page);
}
function showResultWithQueryStr1(actionURL,invID,callbackfunction,query,ignoreHistory,clearGlobalMessage){

    if (ignoreHistory == undefined) ignoreHistory = false;
    if (!ignoreHistory) {
        var arr = [showResultWithQueryStrDo1];
        arr.push(arguments);
        dhtmlHistory.add(historyIndex++,arr);
    }
    if (clearGlobalMessage == undefined || clearGlobalMessage == null) clearGlobalMessage = true;
        
    showResultWithQueryStrDo1(actionURL,invID,callbackfunction,query,ignoreHistory,clearGlobalMessage);
}
function showResultWithQueryStrDo(actionURL,invID,callbackfunction,query,ignoreHistory,tabindex,ty,page){

    if(ty)
        mid= ty;
    if(ty)
        type=ty;
    if(tabindex || tabindex == 0){

        tabindexer =tabindex;
    }
    if(page)
        mypage = page;
    //
    pid=invID;
    var ah = new AjaxHandler();
    ah.init(actionURL);
    ah.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    if(invID !=null){
        ah.addCallback(callbackfunction,invID);
        ah.addErrCallback(invitationErrorHandler,invID);
        ah.addUpdateDiv(invID);
    }else{
        ah.addCallback(callbackfunction);
    }
    ah.send(query);       closeAllFreezPopup(freezid);

    return true;
}

function showResultWithQueryStrDo1(actionURL,invID,callbackfunction,query,ignoreHistory,clearGlobalMessage){


    pid=invID;
    var ah = new AjaxHandler();
    ah.init(actionURL);
    ah.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    if(invID !=null){
        ah.addCallback(callbackfunction,invID);
        ah.addErrCallback(invitationErrorHandler,invID);
        ah.addUpdateDiv(invID);
    }else{
        ah.addCallback(callbackfunction);
    }
    ah.setClearGlobalMessage(clearGlobalMessage);
    ah.send(query);       //closeAllFreezPopup(freezid);
    
    return true;
}

function directToReg(id,userid,feedbackUser){
    if ( id == "AddReq") {
        showmyconnectiion("pendingConnection.do?type=0","middle_div","pending",0,1);
    }
    else if( id/id == 1){
        showcommondivIndex('ResetPassword.jsp?id='+id,'SUpopupdiv','SUpopupdiv');
    }
    else if( id == "NewReg"){
        showcommondivIndex('NewReg.jsp','SUpopupdiv','SUpopupdiv');
    }
    else if( id == "Inbox"){
        showResultAct('GetMessages.do', 'middle_div',3);
    }
    else if( id == "Review"){
        showcommondiv('ViewAllReviews.do?username='+feedbackUser+'&skillid=0','ConnectionPopUp','ConnectionPopUp');
    }
    else if( id == "ViewOtherProfile"){
        showviewprofile('ViewOtherProfile.do?uid='+expertId,'middle_div',expertId);
    }
    else if( id == "Content"){
        document.getElementById('selected_ezdia_domain').value=2;
        document.ezdia_domain.submit();
    //showContentInPopUp("ConnectionPopUp","as","http%3A//www.youtube.com/ff.avi","Video",67,"as","Healthcare%20and%20Medicine%23Pharmacology%23Pharmacology","1","0","1000000009");
    }
}
function showResultAct(actionURL,invID,tabindex,tabtype,param,userid,editProfile){
    otheruserid = userid;
    profileparam =param;
    pid=invID;
    if(editProfile){
        connectionflag = editProfile;
    }
    if(login_user == null || login_user == '')
    {        
        if(tabtype == 'Content'){            
            document.getElementById('login_details').value = 'viewkbprofile:'+actionURL+':'+invID+':'+userid+':'+tabindex+':'+tabtype+':'+param;
        }
        else if(tabtype == 'Project'){
            document.getElementById('login_details').value = 'Project:'+actionURL+":"+invID+":"+userid;
        }
        else
            document.getElementById('login_details').value = 'Inbox:';
        ModalPopup('NewLoginpopupdiv','');
        return true;
    }
    else
    {
        type = tabtype;
        tabindexer=tabindex;
        showResultWithQueryStr(actionURL, invID, callbackcommon, null,false,tabindex,tabtype);
    }

    return true;
}
function showProjPages(actionURL,invID,tabindex,tabtype){
    type = tabtype;
    tabindexer=tabindex;
    pid=invID;
    showResultWithQueryStr(actionURL, invID, callbackcommon, null,false,tabindex,tabtype);
    return true;
}
function changeColorOfSubtabs(divid){
    makeAllSubtabsWhite();
    document.getElementById(divid).style.backgroundColor = '#EEF6FA';
}
function makeAllSubtabsWhite(){
    document.getElementById('MyHome').style.backgroundColor = '#FFFFFF';
    document.getElementById('MyMessages').style.backgroundColor = '#FFFFFF';
    document.getElementById('MyProfile').style.backgroundColor = '#FFFFFF';
    document.getElementById('MyKnowledgeBucket').style.backgroundColor = '#FFFFFF';
    document.getElementById('MyExpertise').style.backgroundColor = '#FFFFFF';

    if(!projectFlag)
        document.getElementById('MyProjects').style.backgroundColor = '#FFFFFF';
    
    if(!billingFlag)
        document.getElementById('MyTransactions').style.backgroundColor = '#FFFFFF';

    document.getElementById('FindKnowledge').style.backgroundColor = '#FFFFFF';
    document.getElementById('MyKnowledgeBucketSubTab').style.backgroundColor = '#FFFFFF';
    document.getElementById('AddContenttoYourBucket').style.backgroundColor = '#FFFFFF';
    document.getElementById('FindExperts').style.backgroundColor = '#FFFFFF';
    document.getElementById('MyExpertiseSubTab').style.backgroundColor = '#FFFFFF';
    document.getElementById('BecomeAnExpert').style.backgroundColor = '#FFFFFF';
    document.getElementById('FindProjects').style.backgroundColor = '#FFFFFF';
    if(!projectFlag)
        document.getElementById('MyProjectsSubTab').style.backgroundColor = '#FFFFFF';

    if(!billingFlag){
        document.getElementById('MyTransactionsSubTab').style.backgroundColor = '#FFFFFF';
        document.getElementById('AddFundsSubTab').style.backgroundColor = '#FFFFFF';
        document.getElementById('WithdrawFunds').style.backgroundColor = '#FFFFFF';
    }

    document.getElementById('PostAProjectSubTab').style.backgroundColor = '#FFFFFF';
}
function showRequestResult(actionURL,invID,tabindex,tabtype,param,userid){
    otheruserid = userid;
    profileparam =param;
    pid=invID;
    if(login_user == null || login_user == '')
    {
        ModalPopup('NewLoginpopupdiv','');
        document.getElementById('login_details').value = 'viewkbprofile:'+actionURL+':'+invID+':'+userid+':'+tabindex+':'+tabtype+':'+param;
        return true;
    }
    else
    {
        type = tabtype;
        tabindexer=tabindex;
        showResultWithQueryStr(actionURL, invID, callbackrequests, null,false,tabindex,tabtype);
    }

    return true;
}

//function showRequestCount(actionURL,invID,tabindex,tabtype,param,userid){
//    otheruserid = userid;
//    profileparam =param;
//    pid=invID;
//    type = tabtype;
//    tabindexer=tabindex;
//    showResultWithQueryStr(actionURL, invID, callbackReqCount, null,false,tabindex,tabtype);
//    return true;
//}
//
//function callbackReqCount(result){
//    var i;
//    var jsonContent= eval('('+result+')');
//    i = jsonContent.length;
//    document.getElementById('inboxTabhom').innerHTML='Invitations ('+i+')';
//}
function callbackrequests(result,pid){
    document.getElementById(pid).innerHTML = '';
    var output = document.getElementById(pid).innerHTML;
    var i;
    var jsonContent= eval('('+result+')');
    i = jsonContent.length;
    //    document.getElementById('reqTabhom').innerHTML='Invitations ('+i+')';
    if(i==1 && jsonContent[0].response){
        output+='<span style="font-weight: bold; color: rgb(0, 64, 128);" class="action" onclick=showmyconnectiion("pendingConnection.do?type=0","middle_div","pending",0,1,'+myuserid+')>Invitations (0)</span>';
        output+='<div id="connectionoutput">'+jsonContent[0].response+'</div>';
    }
    else{
        output+='<span style="font-weight: bold; color: rgb(0, 64, 128);" class="action" onclick=showmyconnectiion("pendingConnection.do?type=0","middle_div","pending",0,1,'+myuserid+')>Invitations (<span id="invCountID">'+jsonContent.length+'</span>)</span>';
        if(jsonContent.length > 0){
            output+='<div id="connectionoutput">';

            for(i=0;i<jsonContent.length;i++){
                output+='<div id="inv'+i+'" style="position: relative; width: auto; padding-top: 0px; left: 0px; margin-top: 6px;">';
                output+='<div style="width: 100%; height: auto; left: 0px; margin-top: 0px; position: relative;">';
                output+='<table id="corner_dialog_table" align="left" class="corner_dialog_table" style="width: 100%;">';
                output+='<tr><td class="corner_topleft"></td><td class="top_side_border"></td><td class="corner_topright"></td></tr>';
                output+='<tr><td class="left_side_border"></td><td id="corner_content" class="corner_content">';
                output+='<div style="height: 60px; display: inline; position: relative; float: left; width: 450px;">';

                UserInfoConnDiv[i] = new UserInfo(jsonContent[i].username,jsonContent[i].firstname,jsonContent[i].photo_thumbnail,jsonContent[i].summary,jsonContent[i].expertise,jsonContent[i].country,jsonContent[i].reviews,jsonContent[i].rating,jsonContent[i].rpm,jsonContent[i].category);

                //MyConnectionList[i] = new MyConn(jsonContent[i].userid, jsonContent[i].firstname,jsonContent[i].groupname,jsonContent[i].conid,jsonContent[i].relation,jsonContent[i].tag);
                //output+='<div id="mulpvZ'+i+'" onmouseout="mclosetime()" onmouseover="mcancelclosetime()" style="display:none; left:80px; top:0px; position: absolute; width: 355px; height: auto; z-index: 100;"></div>';
                output+='<div id="ul" style="padding-right: 10px; padding-left: 10px; padding-top: 4px; width: 40px;" >';
                if(jsonContent[i].photo_thumbnail){
                    output+='<img style="border: 0px; cursor: pointer;" alt="uimg" src='+localhost+jsonContent[i].photo_thumbnail+' height="38" />';
                }
                else{
                    output+='<img style="border: 0px; cursor: pointer;" alt="uimg" src="../static/images/newUserImg.png" height="38"/>';
                }
                output+='<div id="available" style="font-size: 12px; margin-top: 5px; margin-left: 20px; float: left; height: 13px;">';
                //                output+='<div class="'+ ((jsonContent[i].presence == PRESENCE_STATUS_ONLINE)?"green-dot-icon":"red-dot-icon");
                output+='<img src="'+PRESENCE_SERVICE_URL.replace('$uid$',jsonContent[i].userid)+ '&rnd=' + Math.random()+'"';
                output+=' />';
                //                output+='" style="float: left; margin-top: -79px; margin-left: -20px;">.</div>';
                //                output+=((jsonContent[i].presence == PRESENCE_STATUS_ONLINE)?"Available":"Offline") + '</div>';
                output+='</div>';
                output+='</div>';
                
                output+='<div style="overflow: hidden; width: 340px; top: 5px; line-height: 20px; position: absolute; left: 90px;">';
                if(login_user == null || login_user == '' || !login_user ){
                    output+='<div id="namediv" style="overflow:hidden; max-height:20px;cursor:pointer;text-decoration:underline" onclick=showviewprofile("ViewOtherProfile.do?uid='+jsonContent[i].username+'&from=index","middle_div","'+escape(jsonContent[i].username)+'") ><h1 style="font-size: 12px;">';
                }
                else{
                    output+='<div id="namediv" style="font-size: 12px; font-weight:bold; overflow:hidden; max-height:20px;cursor:pointer;text-decoration:underline" onclick=showviewprofile("ViewOtherProfile.do?uid='+jsonContent[i].username+'","middle_div","'+escape(jsonContent[i].username)+'") ><h1 style="font-size: 12px;">';
                }
                output+= jsonContent[i].firstname+'</h1></div>';
                //            output+='<div id="statusdiv" style="overflow:hidden; max-height: 20px; color: rgb(0, 64, 128);">';
                //            if(jsonContent[i].summary){
                //                output+= jsonContent[i].summary+'</div>';
                //            }
                //            else{
                //                output+='No summary</div>';
                //            }
                //            //                    output+='<div id="workDetailsdiv" style="overflow:hidden; color: rgb(0, 0, 0); max-height:20px;">';
                //            //                    output+=jsonContent[i].position+'&nbsp;at&nbsp;'+jsonContent[i].mycompany+'</div>';
                //            output+='<div id="ratingAndReview" style="max-height:20px;">';
                //            output+='<img alt="" src="../static/images/'+jsonContent[i].rating+'red.gif"/>&nbsp;<span id="reviewsdiv">( <span class="action">'+jsonContent[i].reviews+' Reviews</span> )</span></div>';
                //            output+='<div id="ratediv" style="color: rgb(51, 51, 51);">';
                //            output+='Rate : $ '+jsonContent[i].rpm+'/minute</div>';
                output+='<div id="sendMsgDiv" style="color: rgb(31, 101, 152);">';
                output+='<table width="180"><tr>';
                output+='<td><span class="action" onclick="openChatWindow(\'';

                output+= jsonContent[i].userid;
                output+="','" + jsonContent[i].category;
                output+='\',\'' +jsonContent[i].firstname+ '\',\'';
                if(jsonContent[i].photo_thumbnail){
                    output+=localhost+jsonContent[i].photo_thumbnail;
                }
                else{
                    output+="../static/images/newUserImg.png";
                }
                output+='\')"><img alt="Chat" border="0" src="../static/images/green-chat-icon.gif" title="Chat"/></span></td><td><span class="action" onclick="openChatWindow(\'';
                output+= jsonContent[i].userid;
                output+="','" + jsonContent[i].category;
                output+='\',\'' +jsonContent[i].firstname+ '\',\'';
                if(jsonContent[i].photo_thumbnail){
                    output+=localhost+jsonContent[i].photo_thumbnail;
                }
                else{
                    output+="../static/images/newUserImg.png";
                }
                output+='\')">Chat</span></td><td width="10"></td>';
                output+='<td><span class="action" onclick=showComposeMsg("messages/popupcompose.jsp?replyto='+escape(jsonContent[i].username)+'&firstname='+escape(jsonContent[i].firstname)+'","common","compose","InvMsg")><img border="0" alt="" src="../static/images/message_ico.gif"/></span></td><td><span class="action" onclick=showComposeMsg("messages/popupcompose.jsp?replyto='+escape(jsonContent[i].userid)+'&firstname='+escape(jsonContent[i].firstname)+'","common","compose","InvMsg")>Send Message</span></td>';
                output+='</tr></table>';
                output+='</div>';
                //Button for Action
                output+='<div class="redSubmitBtn" style="font-size: 12px; position: absolute; left: 250px; top: 14px; padding:0;" onclick=showcommondiv("connection/AddConnections.jsp?username='+escape(jsonContent[i].fromuser)+'&tousername='+escape(jsonContent[i].firstname)+'&reqType=accept&connid='+escape(jsonContent[i].idconnection)+'&index='+i+'","ConnectionPopUp","ConnectionPopUp")>Take Action</div>';
                output+='</div>';                
                output+='</div>';
                output+='</div>';
                output+='</td><td class="right_side_border"></td></tr>';
                output+='<tr><td class="corner_bottomleft"></td><td class="bottom_side_border"></td><td class="corner_bottomright"></td></tr>';
                output+='</table>';
                output+='</div>';
                output+='</div>';
            }
        }
    }

    document.getElementById(pid).innerHTML=output;
//    var tabindex12 = new Spry.Widget.TabbedPanels("TabbedPanels1", 0);
}
function currentUnixTimeStamp(){
    var datum = new Date();
    return (datum.getTime()/1000.0);
}

function commoncallback(result,pid){
    document.getElementById(pid).style.display='';
    document.getElementById(pid).innerHTML = '';
    document.getElementById(pid).innerHTML=result;
    if(document.getElementById('categoryadd1')){
        getAreaAndFill('categoryadd1');
    }
    if(document.getElementById('description_div_wrap')){
        wordWrapDiv('description_div_wrap');
    }
    if(lid){
        ModalPopup(lid,'');
    }
    fillConnectionList('msg_to','forward');
    if(!readdedComment  && contentId !='null'){
        reAddUserComment(contentId, contentComment, user_type);
    }
    
}

function getMailId(){
    var msgto= document.getElementById('msg_to').value;
    if(msgto == 'Other'){
        document.getElementById('fwd_content_mail').style.display='';
        document.getElementById('fwd_content_mail').focus();
    }
    else{
        document.getElementById('fwd_content_mail').style.display='none';
        document.getElementById('Error_Forward').style.display='none';
    }
}

function commoncallbackindex(result,pid){
    document.getElementById(pid).style.display='';
    document.getElementById(pid).innerHTML = '';
    document.getElementById(pid).innerHTML=result;
    if(document.getElementById('categoryadd1')){
        getAreaAndFill('categoryadd1');
    }
    if(lid){
        ModalPopup(lid,'');
    }
}

function showDetailscommon(sVariables){
    var PopBox = document.getElementById(sVariables);
    PopBox.style.display='';
}

function closecommon(){
    document.getElementById('common').innerHTML='';
    document.getElementById('common').style.display='none';
    ModalPopup.Close('common',1);
}

function closecommonconn(){
    document.getElementById('ConnectionPopUp').innerHTML='';
    document.getElementById('ConnectionPopUp').style.display='none';
    ModalPopup.Close('ConnectionPopUp',1);
}

function closeNews(){
    document.getElementById('NewsPopup').innerHTML='';
    document.getElementById('NewsPopup').style.display='none';
    ModalPopup.Close('NewsPopup',1);
}

function closeDeleteConn(id){
    document.getElementById('ConnectionPopUp').innerHTML='';
    document.getElementById('ConnectionPopUp').style.display='none';
    ModalPopup.Close('ConnectionPopUp',1);
    document.getElementById('manageFrnd'+id).innerHTML="<div class=msgYellow style=margin:20px;margin-top:12px;width:80%;>Removed Successfully !!</div>";
    window.setTimeout("cleardiv('manageFrnd"+id+"')",2000);
//showmyconnectiion('MyConnection.do?type=0','middle_div','manage',0);
//clearErrorMessage();
//setErrorMessage("Connection Successfully Deleted");
//storeGlobalErrorMessage();
//document.getElementById('globalErrorMessage').innerHTML='Connection Successfully Deleted';
//document.getElementById('globalErrorMessage').style.display='';
}

function closecommonconn1(){
    document.getElementById('ConnectionPopUp').innerHTML='';
    document.getElementById('ConnectionPopUp').style.display='none';
}

function mclosecommontime()
{
    closetimer = window.setTimeout(closecommon, timeout2);
}

function mclosecommontime1()
{
    closetimer = window.setTimeout(closecommonconn, 2000);
}

function mclosecommontime2()
{
    closetimer = window.setTimeout(closecommonconn1, 2000);
}

function validateFeedbackForm(){
    var email = document.getElementById('feedbackemail').value;
    var feeds = document.getElementById('feedbacktext').value;
    document.getElementById('Feedback_Error').innerHTML = "";
    if(email == '')
    {
        document.getElementById('Feedback_Error').innerHTML += "Please enter your name or email!";
        document.getElementById('feedbackemail').focus();
        document.getElementById('Feedback_Error').style.display = '';
        return false;
    }
    if(feeds == "")
    {
        document.getElementById('Feedback_Error').innerHTML += "Your feedback field is empty!";
        document.getElementById('feedbacktext').focus();
        document.getElementById('Feedback_Error').style.display = '';
        return false;
    }
    return true;
}

function giveEzdiaFeedback(actionURL, invID){
    if(!validateFeedbackForm()){
        return false;
    }
    else {
        pid= invID;
        var emailid = document.getElementById('feedbackemail').value;
        var feedback = document.getElementById('feedbacktext').value;
        var action = document.getElementById('feedback_action').value;
        showResultWithQueryStr1(actionURL, invID, editcallbackcommon, "email="+escape(emailid)+"&feedback="+escape(feedback)+"&action="+escape(action));
        return true;
    }
}

function editcallbackcommon(result,pid){
    document.getElementById("Feedback_Form").innerHTML = '';
    document.getElementById(pid).innerHTML = 'Thank You for the feedback. '+result;
    window.setTimeout('closecommonconn()',5000);
//    document.getElementById('feedbackemail').value='';
//    document.getElementById('feedbacktext').value='';
//    document.getElementById(pid).className = 'errorBlue';
}

function getImagePath()
{
    return thumbnail_base_url;
}

function trim(str) {
    return str.replace(/^\s+|\s+$/g,"");
}
function myPopUp(url){
    popup = window.open( url, "myWindow",
        "status = 1, height = 400, width = 790, resizable = yes, scrollbars = yes" );
    popup.moveTo(0,0);
}
function addFundsWindow(url){
    closecommonconn();
    url = url.replace("&amp;","&");
    if (addFundWindow != null) {
        addFundWindow.location.href = url;
    } else {
        addFundWindow = window.open( url, "myWindow",
            "status = 1, height = 500, width = 900, resizable = yes, scrollbars = yes" );
    }
    if (addFundWindow != null) {
        window.moveTo(0,0);
    } else {
        setErrorMessage('A popup blocker is preventing add funds window. Please disable popup blocker and try again.',1);
    }
}
function getCheckedValue(radioObj){
    if(!radioObj) {
        return "";
    }
    var radioLength = radioObj.length;
    if(radioLength == undefined) {
        if(radioObj.checked) {
            return radioObj.value;
        } else {
            return "";
        }
    }
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}


/***
 * Function to validate a valid url
 */
function isAURL(url)
{
    url=unescape(url);
    var regExpURLAny = /^(((http(s?))|(ftp))\:\/\/)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6})(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-\(\)]+))*$/;
    if(regExpURLAny.test(url))
        return true;
    else
        return false;
}


function updatenavbar(type,type2){
    var html = '';
    if(type == 'Content'){
        html = '<span class="action" onclick="reloadHomePage();" style="color:#2AD;">Home > </span><span class="action" onclick=jsonSearch("ContentSearch.do","2","Content",2,"middle_div","'+token+'") style="color:#2AD;">Knowledge Bucket > </span>';
        document.getElementById('nvbar').innerHTML=html;
    }

}

String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
    var temp = this;
    var index = temp.indexOf(stringToFind);
    while(index != -1){
        temp = temp.replace(stringToFind,stringToReplace);
        index = temp.indexOf(stringToFind);
    }
    return temp;
};
function wordWrapDiv(id){
    var larg_total,larg_carac,quant_quebra,pos_quebra;
    var elementos,quem, caracs, texto, display_orig;

    elementos = document.getElementById(id);

    if(elementos.className=="word-wrap"){
        quem = elementos;

        quem.innerHTML = String(quem.innerHTML).replace(/ /g,"Ø");
        texto = String(quem.innerHTML);

        quem.innerHTML = " ";

        display_orig = quem.style.display;
        quem.style.display="block";
        larg_oficial = quem.offsetWidth;
        if(!document.all) quem.style.display="table";
        quem.innerHTML = texto;
        larg_total = quem.offsetWidth;

        pos_quebra = 0;
        caracs = texto.length;
        texto = texto.replace(/Ø/g," ");
        larg_carac = larg_total / caracs;
        if(larg_total>larg_oficial){
            quant_quebra = parseInt(larg_oficial/larg_carac);
            quant_quebra = quant_quebra - (parseInt(quant_quebra/6)); //quanto menor o num, maior a garantia;
            quem.innerHTML = "";
            while(pos_quebra<=caracs){
                quem.innerHTML = quem.innerHTML + texto.substring(pos_quebra,pos_quebra + quant_quebra) + " ";
                pos_quebra = pos_quebra + quant_quebra;
            }
        }else{
            quem.innerHTML = texto;
        }//end if do larg_total>larg_oficial
        quem.style.display = display_orig;
    }//end if do word wrap

    return texto;

}

function stripHTML(str) {
    if (str) {
        // What a tag looks like
        var matchTag = /<(?:.|\s)*?>/g;
        // Replace the tag
        return str.replace(matchTag, "");
    }
}

function checkForSplChars(str){
    str =  str.replace(/[^a-z A-Z 0-9 + # $ &]/g,'');
    str =  str.replace(new RegExp( "\\+", "g" ),"%2B");
    return str;

}
function uploadFile(actionURL, invID){
    var ah = new AjaxHandler();
    ah.init(actionURL);
    ah.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    if(invID !=null){
        ah.addCallback(callbackUpload,invID);
        ah.addErrCallback(invitationErrorHandler,invID);
        ah.addUpdateDiv(invID);
    }else{
        ah.addCallback(callbackUpload);
    }
    ah.send(actionURL);       //closeAllFreezPopup(freezid);

    return true;
}

function callbackUpload(result){
    var output = eval('('+result+')');
    document.getElementById('Upload_Success').style.display = '';
    document.getElementById('Upload_Files').style.display = 'none';
    document.getElementById('Upload_Success').innerHTML = output[0].response;
    window.setTimeout('closecommonconn()',5000);
}