var ajaxContentId;
var ajaxFormName;
var fromFormName;
var removeElement;
var scriptToBeExecuted=null;
var objectToBeLoaded=0;
var j4fajaxonload;
var ajaxBaseResourceUrl;
function ajaxResponse(contentId){
if (removeElement) {
r=document.getElementById('_j4fajaxToBeDeleted');
if (r!=null) r.parentNode.removeChild(r);}
try {
if (window.frames[contentId+'__jeniaTemplate'].document.location.href.indexOf("jenia4faces/template/images/x.gif")!=-1) return;
if(navigator.userAgent.indexOf('Gecko')>0){
ctx=window.frames[contentId+'__jeniaTemplate'].frameElement.contentDocument.firstChild.textContent;
}else{
ctx=window.frames[contentId+'__jeniaTemplate'].document.documentElement.outerText;}
if (ctx==null || ctx.length=="") {
ctx="<form id='"+contentId+"_form'>Unreachable server.<form/>"
}else{
init=ctx.indexOf('<!--jenia4facesTemplateInit-->');
if (init==-1) {
ctx="<form id='"+contentId+"_form'>"+window.frames[contentId+'__jeniaTemplate'].document.body.innerHTML+"<form/>";
}else{
end=ctx.indexOf('<!--jenia4facesTemplateEnd-->');
if (init>=0 && end>=0 && end>init) {
ctx=ctx.substring(init+30,end);
}else{
ctx="<form id='"+contentId+"_form'>"+window.frames[contentId+'__jeniaTemplate'].document.body.innerHTML+"<form/>";
}}}} catch (error) {
ctx="<form id='"+contentId+"_form'>Unreachable server.<form/>"}
window.onload=null;
j4fajaxonload=null;
if (ctx!=null) {
container=document.getElementById(contentId+'__jeniaTemplate_container');
container.innerHTML=ctx;
manageObj(contentId);
}else{
window.top.focus();
try {
window.top.status="Finished";
}catch(error){}}
window.frames[contentId+'__jeniaTemplate'].document.location.href=ajaxBaseResourceUrl;}
function manageObj(contentId) {
var lis = getObjToBeLoaded(contentId);
for (i=0;i<lis.length;i++) {
manageHtmlObj(lis[i],contentId);}
if (objectToBeLoaded==0){
if (scriptToBeExecuted!=null) {
eval(scriptToBeExecuted);
scriptToBeExecuted=null;}
j4fajaxonload=window.onload;
window.onload=null;
if (j4fajaxonload!=null) {
j4fajaxonload();}
window.top.focus();
try {
window.top.status="Finished";
}catch(error){}}
window.frames[contentId+'__jeniaTemplate'].document.location.href=ajaxBaseResourceUrl;}
function manageHtmlObj(obj,contentId) {
if (obj.tagName == 'SCRIPT') {
if (obj.src==null || obj.src=='') {
if (!obj.j4floaded) {
script=document.createElement("script");
if(navigator.userAgent.indexOf('Gecko')>0){
txt=obj.innerHTML;
if (txt.indexOf("<!--")==0) {
txt=txt.substring(4);
txt=txt.substring(0,txt.length-3);}
script.innerHTML=txt;
} else {
script.text=obj.text;}
script.type=obj.type;
script.language=obj.language;
script.id=obj.id;
script.j4floaded=true;
try {
obj.parentNode.replaceChild(script,obj);
} catch(error){
document.getElementsByTagName("head").item(0).appendChild(script);}
obj.j4floaded=true;
}} else {
if (!isLoadedInHead(obj.src,'script')) {
loadObj(obj,contentId);
return;}}} else if (obj.tagName=='LINK') {
if (!isLoadedInHead(obj.href,'link')) {
loadObj(obj,contentId);
return;}} else if (obj.tagName=='STYLE') {
if (obj.href==null || obj.href=='') {
x=document.getElementById(contentId+'_form');
x.appendChild(obj);
} else {
if (!isLoadedInHead(obj.href,'style')) {
loadObj(obj,contentId);
return;}}}}
function loadObj(oldObj,contentId) {
if(navigator.userAgent.indexOf('Gecko')>0){
if (oldObj.tagName=='SCRIPT') {
objectToBeLoaded++;}}else{
objectToBeLoaded++;}
newObj = createObj(oldObj);
newObj.j4fcontentId=contentId;
oldObj.parentNode.removeChild(oldObj);
newObj.onload = newObj.onreadystatechange = objLoaded;
var head = document.getElementsByTagName('head').item(0);
head.appendChild(newObj);
if (newObj.tagName=='SCRIPT') {
var ntip='script';
} else if (newObj.tagName=='LINK') {
var ntip='link';
} else if (newObj.tagName=='STYLE') {
var ntip='style';}
var litip=document.getElementsByTagName(ntip);
for (j=0;j<litip.length;j++) {
if ((ntip=='script' && !isChildOfHead(litip[j]) && litip[j].src==newObj.src) ||
(ntip=='link'   && !isChildOfHead(litip[j]) && litip[j].href==newObj.href) ||
(ntip=='style'  && !isChildOfHead(litip[j]) && litip[j].href==newObj.href)) {
litip[j].parentNode.removeChild(litip[j]);}}}
function createObj(oldObj) {
if (oldObj.tagName == 'SCRIPT') {
script=document.createElement("script");
script.src=oldObj.src;
script.type=oldObj.type;
script.language=oldObj.language;
script.id=oldObj.id;
return script;
} else if (oldObj.tagName == 'LINK') {
link=document.createElement("link");
link.href=oldObj.href;
link.type=oldObj.type;
link.rel=oldObj.rel;
link.id=oldObj.id;
return link;
} else if (oldObj.tagName == 'STYLE') {
style=document.createElement("style");
style.href=oldObj.href;
style.type=oldObj.type;
style.id=oldObj.id;
return style;}}
function objLoaded(event) {
if(navigator.userAgent.indexOf('Gecko')>0){
var x=event.currentTarget;
if(event.type=='load') {
try {
objectToBeLoaded--;
manageObj(x.j4fcontentId);
} catch(error){}
}} else {
if (!event) var event = window.event
var x=event.srcElement;
if(x.readyState=='complete' || x.readyState=='loaded') {
try {
objectToBeLoaded--;
manageObj(x.j4fcontentId);} catch(error){}}}}
function getObjToBeLoaded(contentId) {
var ret = new Array();
var retI=0;
if(navigator.userAgent.indexOf('Gecko')>0){
retI=addTypes('link',ret,retI,contentId);
retI=addTypes('style',ret,retI,contentId);}
retI=addTypes('script',ret,retI,contentId);
return ret;}
function addTypes(type,ret,retI,contentId) {
if(navigator.userAgent.indexOf('Gecko')>0){
if (type=='script') {
var lis=document.getElementsByTagName(type);
for (k=0;k<lis.length;k++) {
if (isChildOf(lis.item(k),contentId)) {
ret[retI]=lis.item(k);
retI++;
}}} else {
var lis=window.frames[contentId+'__jeniaTemplate'].document.getElementsByTagName(type);
for (k=0;k<lis.length;k++) {
ret[retI]=lis.item(k);
retI++;
}}} else {
var lis=document.getElementsByTagName(type);
for (k=0;k<lis.length;k++) {
if (isChildOf(lis.item(k),contentId)) {
ret[retI]=lis.item(k);
retI++;
}}}
return retI;}
function isChildOf(ele,contentId) {
var p=ele.parentNode;
while (p!=null && p!=document && p.id!=contentId+'_form')  {
p=p.parentNode;}
if (p!=null && p.id==contentId+'_form') 
return true;
else return false;}
function isLoadedInHead(src,type) {
var li=document.getElementsByTagName(type);
isChild=false;
for (j=0;j<li.length;j++) {
if ((type=='script' && isChildOfHead(li[j]) && li[j].src==src) ||
(type=='link'   && isChildOfHead(li[j]) && li[j].href==src) ||
(type=='style'  && isChildOfHead(li[j]) && li[j].href==src)) {
isChild=true;
break;}}
return isChild;}
function isChildOfHead(ele) {
var p=ele.parentNode;
while (p!=null && p!=document && p.nodeName!='HEAD')  {
p=p.parentNode;}
if (p!=null && p.nodeName=='HEAD') return true;
else return false;}
function runInsideAjaxAndExecute(ajaxId,scripttbe,formId) {
scriptToBeExecuted=scripttbe;
runInsideAjax(ajaxId,formId);}
function runInsideAjax(ajaxId,formId) {
if (formId==null) fromFormName='linkDummyForm';
else fromFormName=formId;
form=document.getElementById(fromFormName);
if (form.elements['_j4fajax']==null || form.elements['_j4fajax']=='undefined'){
i=document.createElement("input");
i.type="hidden";
i.name="_j4fajax";
i.id="_j4fajaxToBeDeleted";
i.value=ajaxId;
form.appendChild(i);
removeElement=true;
} else {
form.elements['_j4fajax'].value=ajaxId;
removeElement=false;}
ajaxFormName=ajaxId+'_form';
ajaxContentId=ajaxId;
form.onsubmitAjax=form.onsubmit;
form.onsubmit=submitInsideAjax;
scriptToBeExecuted="document.getElementById('"+fromFormName+"').reset();"+scriptToBeExecuted;}
function submitInsideAjax() {
document.getElementById(fromFormName).target=ajaxContentId+"__jeniaTemplate";
document.getElementById(fromFormName).onsubmit=document.getElementById(fromFormName).onsubmitAjax;
if (document.getElementById(fromFormName).onsubmitAjax) document.getElementById(fromFormName).onsubmitAjax();
document.getElementById(fromFormName).onsubmitAjax=null;
ajaxFormName=null;
ajaxContentId=null;
fromFormName=null;
return true;}
function runOutsideAjax(ajaxId) {
if (ajaxId.indexOf('_form')!=-1) ajaxId=ajaxId.substring(0,ajaxId.length-5);
ajaxContentId=ajaxId;
ajaxFormName=ajaxId+'_form';
form=document.getElementById(ajaxFormName);
if (form.elements['_j4fajax']==null || form.elements['_j4fajax']=='undefined'){
i=document.createElement("input");
i.type="hidden";
i.name="_j4fajax";
i.id="_j4fajaxToBeDeleted";
i.value=ajaxId+'_outsideAjax';
form.appendChild(i);
removeElement=true;
} else {
form.elements['_j4fajax'].value=ajaxId+'_outsideAjax';
removeElement=false;}
form.onsubmitAjax=form.onsubmit;
form.onsubmit=submitOutsideAjax;}
function submitOutsideAjax() {
if (document.getElementById(ajaxFormName).target==ajaxContentId+"__jeniaTemplate") document.getElementById(ajaxFormName).target='';
if (document.getElementById(ajaxFormName).onsubmitAjax) document.getElementById(ajaxFormName).onsubmitAjax();
document.getElementById(ajaxFormName).onsubmit=document.getElementById(ajaxFormName).onsubmitAjax;
document.getElementById(ajaxFormName).onsubmitAjax=null;
ajaxFormName=null;
ajaxContentId=null;
return true;}
function runIntoPopupFrame(ajaxId) {
if (ajaxId.indexOf('_form')!=-1) ajaxId=ajaxId.substring(0,ajaxId.length-5);
myajaxContentId=ajaxId;
myajaxFormName=ajaxId+'_form';
runOutsideAjax(myajaxContentId);
if (PF_postSub==null)
PF_postSub="document.getElementById('"+myajaxFormName+"').elements['_j4fajax'].value='"+myajaxContentId+"';window.frames['__jeniaPopupFrameTarget'].focus();try {window.top.status='Finished';}catch(error){};window.frames['"+myajaxContentId+"__jeniaTemplate'].document.location.href=ajaxBaseResourceUrl;";
else
PF_postSub=PF_postSub+"document.getElementById('"+myajaxFormName+"').elements['_j4fajax'].value='"+myajaxContentId+"';window.frames['__jeniaPopupFrameTarget'].focus();try {window.top.status='Finished';}catch(error){};window.frames['"+myajaxContentId+"__jeniaTemplate'].document.location.href=ajaxBaseResourceUrl;";}