
var gAllowShowSolRepLink=true;function init(){gS2SolutionStartSession=new S2StartSession({origin:Object.clone(gOrigin)});gS2SolutionStartSession.setOriginType("solutionEstore");gCurrentHeaderMenu=gHeaderMenus.experts;initTabs("dEstoreTabsContainer",gTabName,switchEstoreTab);observeAllEvents();if(gIsExternalStart){gS2StartSession.startSession('dEstorePageLeft',g_experts[0].id,undefined,$("dEstoreExpertActions").down(".startSessionButton"));}
if(gIsExternalMessage){gSecuredAction.execute({ju:g_experts[0].jabberUsername,submitButtonImgPrefix:'leave_message'},function(){redirectToUrl(gCommonUrls.leave_message+g_experts[0].jabberUsername)});}
if(gJoinSession.isJoinSession){gS2StartSession.setWorkflowId(gJoinSession.workflowId);gS2StartSession.setSupportRequestId(gJoinSession.supportRequestId);gJabberConnection.doLogin({onConnect:function(){if(!gJabberConnection.isTryingToReconnect&&this.markCustomerConnectedToSession()){gS2StartSession.openServicePage();}}.bind(gS2StartSession),errorHandler:function(){gS2StartSession.popupStartSession({status:'sorry',reason:'jabber_failure'});}.bind(gS2StartSession)});}}
function observeAllEvents(){if(gConnectButtonEnabled&&canStartSession()){$$(".startSessionButton").each(function(connectBtn){connectBtn.src=gStartSessionUrls.connect_regular;connectBtn.className="startSessionButton linkImg";disableObject(connectBtn,false);Event.observe(connectBtn,'mouseout',function(){this.src=gStartSessionUrls.connect_regular});Event.observe(connectBtn,'mouseup',function(){this.src=gStartSessionUrls.connect_regular});Event.observe(connectBtn,'mouseover',function(){this.src=gStartSessionUrls.connect_over});Event.observe(connectBtn,'mousedown',function(){this.src=gStartSessionUrls.connect_pressed});});}
if($('dEstoreLeftViewMoreLink')){Event.observe($('dEstoreLeftViewMoreLink'),'click',function(){switchEstoreTab('feedback');});}
if($('dServicesTab')){Event.observe($('dServicesTab'),'click',function(){switchEstoreTab('services');});}
if($('dFeedbacksTab')){Event.observe($('dFeedbacksTab'),'click',function(){switchEstoreTab('feedback');});}
if($('dSolutionsTab')){Event.observe($('dSolutionsTab'),'click',function(){switchEstoreTab('solutions');});}
if($('arrowImgProductsList')){Event.observe($('arrowImgProductsList'),'click',function(){toggleText('dEstoreProductsList',$('arrowImgProductsList'));});}
if($('arrowImgCertificationsList')){Event.observe($('arrowImgCertificationsList'),'click',function(){toggleText('dEstoreCertificationsList',$('arrowImgCertificationsList'));});}
if($('arrowImgLanguagesList')){Event.observe($('arrowImgLanguagesList'),'click',function(){toggleText('dEstoreLanguagesList',$('arrowImgLanguagesList'));});}
observeAddThisEvents();}
function observeAddThisEvents(){if(!$('addThisButton')){return;}
Event.observe($('addThisButton'),'mouseover',function(){return addthis_open($('addThisButton'),'','[URL]','[TITLE]');});Event.observe($('addThisButton'),'mouseout',function(){addthis_close();});Event.observe($('addThisButton'),'click',function(){return addthis_sendto();});}
function toggleText(textDivId,img)
{if(img.getAttribute("showText")=="true")
{$(textDivId).style.height='auto';$(textDivId).style.textOverflow='clip';$(textDivId).style.whiteSpace='normal';img.src=gEstoreUrls.arrow_close;img.title=gEstoreStrings.tooltip_hide_text;img.setAttribute("showText","false");}
else
{$(textDivId).style.height='15px';$(textDivId).style.textOverflow='ellipsis';$(textDivId).style.whiteSpace='nowrap';img.src=gEstoreUrls.arrow_open;img.title=gEstoreStrings.tooltip_show_text;img.setAttribute("showText","true");}}
function toggleFeedback(textDivId,hiddenDivId,img)
{if(img.getAttribute("showText")=="true")
{$(textDivId).style.height='auto';$(textDivId).style.textOverflow='clip';$(textDivId).style.whiteSpace='normal';$(hiddenDivId).style.display='block';img.src=gEstoreUrls.arrow_close;img.title=gEstoreStrings.tooltip_hide;img.setAttribute("showText","false");}
else
{$(textDivId).style.height='15px';$(textDivId).style.textOverflow='ellipsis';$(textDivId).style.whiteSpace='nowrap';$(hiddenDivId).style.display='none';img.src=gEstoreUrls.arrow_open;img.title=gEstoreStrings.tooltip_show;img.setAttribute("showText","true");}}
function switchEstoreTab(key){switch(key)
{case'services':$("addSolutionReport").hide();selectTab($('dServicesTab'),'dEstoreBody',0);showByClass($('dEstoreServicesBody'),true);showByClass($('dEstoreFeedbackBody'),false);if($('dEstoreSolutionsBody')){showByClass($('dEstoreSolutionsBody'),false);}
if($('dEstoreLeftViewMoreLink'))
$('dEstoreLeftViewMoreLink').show();break;case'feedback':$("addSolutionReport").hide();selectTab($('dFeedbacksTab'),'dEstoreBody',1);showByClass($('dEstoreServicesBody'),false);showByClass($('dEstoreFeedbackBody'),true);if($('dEstoreSolutionsBody')){showByClass($('dEstoreSolutionsBody'),false);}
if($('dEstoreLeftViewMoreLink'))
$('dEstoreLeftViewMoreLink').hide();break;case'solutions':if(!$('dEstoreSolutionsBody')){return;}
checkAndShowEditSolutionReportLink();selectTab($('dSolutionsTab'),'dEstoreBody',2);showByClass($('dEstoreServicesBody'),false);showByClass($('dEstoreFeedbackBody'),false);showByClass($('dEstoreSolutionsBody'),true);if($('dEstoreLeftViewMoreLink'))
$('dEstoreLeftViewMoreLink').show();break;default:$("addSolutionReport").hide();selectTab($('dServicesTab'),'dEstoreBody',0);showByClass($('dEstoreServicesBody'),true);showByClass($('dEstoreFeedbackBody'),false);showByClass($('dEstoreSolutionsBody'),false);if($('dEstoreLeftViewMoreLink'))
$('dEstoreLeftViewMoreLink').show();}}
function moreFeedbacks(supporterId)
{var url=buildUrl(gEstoreUrls.estore_feedbacks,{'supporterId':supporterId});new Ajax.Request(url,{method:'post',onSuccess:function(response){$('dEstoreFeedbackList').update(response.responseText);},onFailure:function(response){logme('Fail to get more feedbacks for estore (supporterId='+supporterId+'): '+response.statusText);}});}
function onSolutionReportSubmitSuccess(){window.location.reload();}
function checkAndShowEditSolutionReportLink(){if(gIsUserEditor&&g_experts[0].id==gCurrentUser.id){$("addSolutionReport").show();}}
var SolutionReport=Class.create({initialize:function(formUrl,solutionReportId){this.formUrl=formUrl;this.solutionReportId=solutionReportId;this.autoSuggestReport=null;},init:function(){this.sessionReportForm=$("sessionReportForm");this.sessionReportError=$("sessionReportError");this.sessionReportResolution=$("sessionReportResolution");this.whatHappenedUserFreeText=$("whatHappenedUserFreeText");this.reportExpertise=$("reportExpertise");this.expertiseDetails=$("expertiseDetails");this.reportTitle=$("reportTitle");this.expertiseId=$("expertiseId");this.scopeOfWork=$("scopeOfWork");this.problemDetails=$("problemDetails");this.solutionDetails=$("solutionDetails");this.sessionReportNewLink=$("dSessionReportNewLink");this.sessionReportLinks=$("dSessionReportLinks");this.initForm();},initForm:function(){this.autoSuggestReport=new S2AutoSuggest('EXPERTISE',this.reportExpertise,this.buildExpertisesAutosuggest.bind(this),this.setExpertise.bind(this),200,this.sessionReportError);if(this.expertiseId&&this.expertiseId.value)
{this.autoSuggestReport.setSelectedValue(this.expertiseId.value);}},edit:function(displayForm){$('dOverlaySessionReport').update('<img class="preloader" src="'+gCommonUrls.preloader+'" alt="" />');lightBoxOn({rel:"dOverlaySessionReport"});var params={};if(this.sessionId){params["supportSessionId"]=this.sessionId;}
if(this.solutionReportId){params["solutionReportId"]=this.solutionReportId;}
new Ajax.Request(this.formUrl,{parameters:params,method:'get',onSuccess:function(transport){$('dOverlaySessionReport').update(transport.responseText);$('dOverlaySessionReport').show();$('dOverlaySessionReport').style.backgroundColor='transparent';if(displayForm){(function(){this.init()}.bind(this)).defer();}}.bind(this)});},buildExpertisesAutosuggest:function(jsonResultsStr){var resultsArry=eval(jsonResultsStr);var resultsStr=[];var resultsKeys=[];resultsArry.each(function(obj){var display=obj.expertiseName;var id=obj.expertiseId;if(display&&id)
{resultsStr.push(display);resultsKeys.push(id)}});this.autoSuggestReport.setResults(resultsStr)
this.autoSuggestReport.setResultsIds(resultsKeys)
this.autoSuggestReport.displayResults();},retrieveIdOfSelectedExpertise:function(){var selectedValues=this.autoSuggestReport.getSelectedValues();if(!selectedValues['sessionReport.expertise']&&!selectedValues['reportExpertise']){this.autoSuggestReport.setSelectedValue(this.expertiseId.value);}
return selectedValues['sessionReport.expertise']||selectedValues['reportExpertise'];},setExpertise:function(){if(!this.autoSuggestReport)
return
var selectedValues=this.autoSuggestReport.getSelectedValues();if(!selectedValues['sessionReport.expertise']&&!selectedValues['reportExpertise']){this.reportExpertise.value=''}},addLink:function(){var links_length=this.sessionReportLinks.immediateDescendants().length;if(links_length>10)return;var new_link=this.sessionReportNewLink.value;if(!this.validateLink(new_link)){return;}
if(isEltPresent(this.sessionReportLinks,"links[INT].link",new_link))
return;var html='<div class="dSessionReportLinkRow">'+'<div class="linkText ellipsis" style="float:left;">'+new_link+'</div>'+'<img onclick="removeFromList(this)" class="linkImg" src="'+gCommonUrls.remove_btn+'"/>'+'<input type="hidden" namebase="links[INT].link" name="links['+links_length+'].link" value="'+new_link+'"/>'+'</div>';new Insertion.Bottom(this.sessionReportLinks,html)
this.sessionReportNewLink.value=''},validateLink:function(link){this.sessionReportError.innerHTML='';this.sessionReportError.show();if(!link||link==null||link=='')
{this.sessionReportError.innerHTML="links should have value";return false;}
if(!link.match(g_regExpNoHtmlTags))
{this.sessionReportError.innerHTML=gCommonErrors["errors.htmlEscape"].replace('{0}',gSDStrings.session_report_links);return false;}
if(link.length>300){return false;}
return true;},validate:function(){this.sessionReportError.innerHTML='';this.sessionReportError.show();if(!this.autoSuggestReport){this.sessionReportError.innerHTML=gSolutionReportStrings.session_report_validate_3;return false;}
var selectedExpertiseId=this.expertiseId.value;if(isNaN(selectedExpertiseId)||selectedExpertiseId<1)
{if(this.sessionReportError.childNodes.length==0)
this.sessionReportError.innerHTML=gSolutionReportStrings.session_report_validate_3;return false;}
if(this.expertiseDetails&&this.expertiseDetails.value.length>255)
{this.sessionReportError.innerHTML=gSolutionReportStrings.session_report_validate_5;return false;}
if(this.expertiseDetails&&!this.expertiseDetails.value.match(g_regExpNoHtmlTags))
{this.sessionReportError.innerHTML=gCommonErrors["errors.htmlEscape"].replace('{0}',gSolutionReportStrings.session_report_expertise_details);return false;}
var textTitle=this.reportTitle;if(textTitle&&(textTitle.value.length==0||textTitle.value.length>255))
{this.sessionReportError.innerHTML=gSolutionReportStrings.session_report_validate_7;return false;}
if(textTitle&&(!textTitle.value.match(g_regExpNoHtmlTags)||textTitle.value.indexOf('/')>=0))
{this.sessionReportError.innerHTML=gCommonErrors["errors.htmlEscape"].replace('{0}',gSolutionReportStrings.session_report_title);return false;}
var problemDetails=this.problemDetails;if(problemDetails&&problemDetails.value.length==0)
{this.sessionReportError.innerHTML=gCommonErrors["errors.required"].replace('{0}',gSolutionReportStrings.session_report_problem_details);return false;}
if(problemDetails&&problemDetails.value.length>4000)
{this.sessionReportError.innerHTML=gCommonErrors["errors.maxlength"].replace('{0}',gSolutionReportStrings.session_report_problem_details).replace('{1}','4000');return false;}
if(problemDetails&&!problemDetails.value.match(g_regExpNoHtmlTags))
{this.sessionReportError.innerHTML=gCommonErrors["errors.htmlEscape"].replace('{0}',gSolutionReportStrings.session_report_problem_details);return false;}
var solutionDetails=this.solutionDetails;if(solutionDetails&&solutionDetails.value.length==0)
{this.sessionReportError.innerHTML=gSolutionReportStrings.session_report_validate_5;return false;}
if(solutionDetails&&solutionDetails.value.length>4000)
{this.sessionReportError.innerHTML=gCommonErrors["errors.maxlength"].replace('{0}',gSolutionReportStrings.session_report_solution_details).replace('{1}','4000');return false;}
if(solutionDetails&&!solutionDetails.value.match(g_regExpNoHtmlTags))
{this.sessionReportError.innerHTML=gCommonErrors["errors.htmlEscape"].replace('{0}',gSolutionReportStrings.session_report_solution_details);return false;}
this.sessionReportError.hide();return true;},submit:function(){gErrorDivs={ui:this.sessionReportError,msg:this.sessionReportError};this.expertiseId.value=this.retrieveIdOfSelectedExpertise();if(this.validate()){disableObject('bServiceReportSendButton',true);var links_length=this.sessionReportLinks.immediateDescendants().length;this.sessionReportForm.request({parameters:{sessionReportLinksLength:links_length,jabberUsername:g_experts[0].jabberUsername},onSuccess:function(response){if(response.responseText.length>0){this.sessionReportError.innerHTML=response.responseText;}
else{onSolutionReportSubmitSuccess();lightBoxOff();}},onFailure:function(response){this.sessionReportError.innerHTML=response.text;}})}}});if(dwr==null)var dwr={};if(dwr.engine==null)dwr.engine={};if(DWREngine==null)var DWREngine=dwr.engine;if(dwr==null)var dwr={};if(dwr.engine==null)dwr.engine={};if(DWREngine==null)var DWREngine=dwr.engine;if(feedbackAjaxFacade==null)var feedbackAjaxFacade={};feedbackAjaxFacade._path=''+JAWR.jawr_dwr_path+'';feedbackAjaxFacade.submitSupporterFeedback=function(p0,p1,p2,p3,callback){dwr.engine._execute(feedbackAjaxFacade._path,'feedbackAjaxFacade','submitSupporterFeedback',p0,p1,p2,p3,callback);}