var _ab_sourcePage='/ABCenter.aspx';
var _ab_activeControl;
var _ab_companyId;
var _ab_companyAreaInited=false;
var _ab_userType;
var _ab_orderNumber;
var _ab_evalArray=new Array();
document.observe("dom:loaded", function()
{
_ab_attachEventsToControlArray($$('input'));
_ab_attachEventsToControlArray($$('textarea'));
Event.observe(window,'scroll', _ab_sendScroll);
_ab_checkSession();
});
function _ab_attachEventsToControlArray(arr)
{
arr.each(function(obj)
{
if(_ab_isValidControl(obj))
{
obj.observe('change', function(e){_ab_sendData(e)});
obj.observe('click', function(e){_ab_sendData(e)});
obj.observe('keyup', function(e){_ab_sendData(e)});
obj.observe('focus', function(){_ab_activeControl=this});
obj.observe('blur', function(){_ab_activeControl=null});
}
}
);
}
function _ab_highlightElement(id)
{
var obj=$(id);
if(obj.type)
{
switch(obj.type)
{
case "checkbox":
obj=obj.up()
break;
case "radio":
obj=_ab_getRadioSelected(id).up();
break;
}
}
new Effect.Highlight(obj,{startcolor:'#DF5E5E',endcolor:'#F5F5F5'});
}
var _ab_sessionCode="";
var _ab_pe=null;
function _ab_showPageImprint(msg,hide)
{
var div = $('_ab_pageImprint');
if(!div)
{
div=new Element('div', {'id':'_ab_pageImprint', 'style':'display:none;'});
document.body.appendChild(div);
}
if(!msg||msg=="")
msg = _ab_shareMessage();
div.update('
Assist Browse
'+msg);
Effect.Appear('_ab_pageImprint');
if(hide)
_ab_hideImprint.delay(3);
else
new Effect.Highlight('_ab_pageImprint',{startcolor:'#DF5E5E',endcolor:'#F5F5F5'});
}
function _ab_hideImprint()
{
Effect.Fade('_ab_pageImprint');
}
function _ab_shareMessage()
{
if(_ab_sessionCode=="")
return 'Sharing is not active on the page.
Click here to start sharing
Click here to join a session
Click here to cancel';
else
return 'Your screen is under share. Sharing code: ' + _ab_sessionCode + '
Click here to stop sharing';
}
function _ab_modify_postelements(hide)
{
var disMsg="[Other Session Controlling]";
$$('input[type="submit"]').each(
function(obj)
{
if(hide)
{
obj.value+=' '+disMsg;
obj.disabled=true;
}
else
{
if(obj.value.substring(obj.value.length-disMsg.length,obj.value.length)==disMsg)
{
obj.disabled=false;
obj.value=obj.value.substring(0,obj.value.length-disMsg.length-1);
}
}
}
);
}
function _ab_joinSession()
{
var sessionCode=prompt("Type in the session code...","");
if(sessionCode!="")
{
new Ajax.Request(_ab_sourcePage, {
method: 'post',
parameters: {action:'joinsession', 'sessionCode':sessionCode, 'location':document.location.href},
onSuccess: function(tr)
{
var tmp=tr.responseXML.documentElement.childNodes[0].nodeValue;
if(tmp=='notfound')
_ab_showPageImprint('Session code is not recognized!
Click here to start sharing
Click here to join a session
Click here to cancel');
else
{
_ab_sessionCode=tmp;
_ab_updateForm();
_ab_modify_postelements(true);
_ab_pe=new PeriodicalExecuter(_ab_updateForm, 2);
_ab_showPageImprint();
}
},
onFailure: function(tr)
{
}
});
}
}
function _ab_stopSession()
{
new Ajax.Request(_ab_sourcePage, {
method: 'post',
parameters: {action:'endsession', 'location':document.location.href},
onSuccess: function(tr)
{
_ab_sessionCode="";
_ab_modify_postelements(false);
_ab_pe.stop();
_ab_showPageImprint();
_ab_companyArea(true);
},
onFailure: function(tr)
{
alert("Can not stop sharing at the moment!\nServer Error Occured: " + tr.status);
}
});
}
function _ab_startSession()
{
new Ajax.Request(_ab_sourcePage, {
method: 'post',
parameters: {action:'startsession', 'location':document.location.href},
onSuccess: function(tr)
{
_ab_sessionCode=tr.responseXML.documentElement.childNodes[0].nodeValue;
//_ab_updateForm();
_ab_sendFormInitial();
_ab_pe = new PeriodicalExecuter(_ab_updateForm, 2);
_ab_showPageImprint();
},
onFailure: function(tr)
{
alert("Can not start sharing at the moment!\nServer Error Occured: " + tr.status);
}
});
}
function _ab_sendFormInitial()
{
$$('input').each(function(obj)
{
if(obj.type!='submit')
{
_ab_sendDataInternal(obj);
}
}
);
$$('textarea').each(function(obj)
{
_ab_sendDataInternal(obj);
});
}
function _ab_checkSession()
{
new Ajax.Request(_ab_sourcePage, {
method: 'post',
parameters: {action:'getNew', 'location':document.location.href},
onSuccess: function(tr)
{
var doc = tr.responseXML;
if(doc.documentElement.nodeName=='elements')
{
_ab_sessionCode=doc.documentElement.attributes[0].value;
if(doc.documentElement.attributes[2]) _ab_userType = doc.documentElement.attributes[2].value;
if(doc.documentElement.attributes[1]&&doc.documentElement.attributes[1].value!='True')
_ab_modify_postelements(true);
_ab_showPageImprint();
_ab_pe=new PeriodicalExecuter(_ab_updateForm, 2);
}
else if(doc.documentElement.nodeName=='location')
{
if(document.location.href!=doc.documentElement.childNodes[0].nodeValue)
document.location.href=doc.documentElement.childNodes[0].nodeValue;
}
else
{
_ab_showPageImprint();
}
}
});
}
function _ab_isValidControl(obj)
{
return (obj.tagName.toLowerCase()=='input' && (obj.readAttribute('type')!='submit'&&obj.readAttribute('type')!='button'&&obj.readAttribute('type')!='hidden'&&obj.readAttribute('name').substring(0,2)!='__'))||(obj.tagName.toLowerCase()=='textarea');
}
function _ab_updateForm()
{
new Ajax.Request(_ab_sourcePage, {
method: 'post',
parameters: {action:'get', 'location':document.location.href},
onSuccess: function(tr)
{
var doc = tr.responseXML;
if(doc.documentElement.nodeName=='elements')
{
//alert(doc.documentElement.childNodes.length);
if(doc.documentElement.attributes[2]) _ab_userType = doc.documentElement.attributes[2].value;
for(var i=0;i