
// Ajax for pages
var UseAjaxMethod = 0;
var AjaxPageRoot = '';
function ajaxInitPage(){
	if (AjaxPageRoot == 'cms_menu'){
		UseAjaxMethod=0;
		CMSAjaxInit();
	}
	if (UseAjaxMethod){
    ajaxEngine.registerRequest( 'getInfo', '../php/ajax_get.php');
    ajaxEngine.registerAjaxElement("CONTENT");
    ajaxEngine.registerAjaxElement("TITLE1");
    ajaxEngine.registerAjaxElement("TITLE2");
  }
}
var nonAjaxPages=[];
var runTick=0;
var gCurPage;
function ajaxValid(root_name){
	gCurPage = root_name.substr(-3,1) == '_' ? root_name.substr(0,root_name.length-3) : root_name; 
	if (UseAjaxMethod){
		var withAjax=1;
		for(var i=0;i<nonAjaxPages.length;i++){ 
			if(root_name == nonAjaxPages[i]){withAjax=0; break;} 
		}
		if (withAjax){
		  ajaxEngine.requestURLS['getInfo'] = '../ajax/' + root_name +  '.xml?parameter='+runTick;
  	  //PrintHelp('Loading ...'); 
  	  PrintHelp("<img src='../olicms/img/anim/runner_dk.gif' border=0>"); 
  	  ajaxEngine.sendRequestAndUpdate( 'getInfo', 'CONTENT', {evalScripts: true} );
  	  return true;
  	}
  }
  return false;
}

function setLanguage(root_name) { window.location= root_name+ '.php'; }

function ajaxGoToPage(root_name) {
	if (false == ajaxValid(root_name)){ window.location= root_name+ '.php'; }
}

function ajaxBar(root_name){ ajaxValid(root_name); } 
//
// Ajax for CMS-operation
function CMSAjaxInit(){
    ajaxEngine.registerRequest( 'CMSCommand', '../php/cms_operation.php');
    ajaxEngine.registerAjaxElement("CMS-OPERATION");
}
function CMSAjaxExecute(operation){
  PrintHelp('Executing CMS command ...');
  var currentTime = new Date();
  document.getElementById('CMS-OPERATION').innerHTML = "<div align_center width='100%'><img src='../olicms/img/anim/runner.gif' border=0></div>";
  ajaxEngine.requestURLS['CMSCommand'] = '../php/cms_operation.php?operation='+operation+'&tick='+currentTime.getTime();
 	ajaxEngine.sendRequestAndUpdate( 'CMSCommand', 'CMS-OPERATION');
}
//
// Open Assistants (floating) windows
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function open_assistant(){
	var a = _gobj('assistant');
	if (a.style.display == "none"){
		a.style.display="";
		a.style.top=ns6? window.pageYOffset*1+20+"px" : iecompattest().scrollTop*1+20+"px";
		setFloatingframeID('assistant'); // floating bar
	}
	else{
		a.style.display="none";
	}
}

function _gobj(x){ return document.getElementById(x); }

function open_ajaxbar(){
	var o = _gobj('ajaxbar');
	if (o != null){
		o.style.display = o.style.display == "none"  ? "" : "none"; 
	}
}

// ----------------------------------------------------------------------------
// Rico fadeIn/fadeOut

// Help messages
var helpID=null;
function PrintHelp(t){
	if (showHelp == 0)
		return;
	if (helpID == null)
		helpID = _gobj('helpID');
	if (helpID != null)
		helpID.innerHTML=t;
}
function PrintEvents(t){
	if (showEvent == 0)
		return;
	if (helpID == null)
		helpID = document.getElementById('helpID');
	if (helpID != null)
		helpID.innerHTML='<font class=eventtext>'+t+'</font>';
}

// Over-Effect on table <td> element (having 'ove' class) =====================
var oldFg = '#6C000A'; 
var oldBg = '#FFF99D';
var oldTarget, oldTarget1;
function ove_check(flag, source4){
if (flag == 1){
	oldTarget = source4;
	oldFg=source4.style.color; 
	oldBg=source4.style.backgroundColor;
	source4.style.color='#6C000A'; 
	source4.style.backgroundColor ='#FFF99D';
}
else{
	oldTarget.style.color=oldFg; oldTarget.style.backgroundColor=oldBg;
}
}
function ove(e, flag){
source4=document.all ? event.srcElement : e.target;
if (source4.className=="ove")
	ove_check(flag, source4); 
else if(source4.parentNode.className=='ove')
	ove_check(flag, source4.parentNode); 
}

// Highlight form element =====================================================
var highlightcolor="#E6E6E6"
var foregroundcolor="#121C46"
var previous=''
var eventobj;
//Regular expression to highlight only form elements
var intended=/INPUT|SELECT|OPTION|TEXTAREA/
//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName) && which.id != 'cmsarea'){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}
//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
eventobj.style.color=foregroundcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
eventobj.style.color=foregroundcolor
previous=eventobj
}
}
// ============================================================================
var Z_Protect=0; // Protect right click
function z_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.z_pgW=innerWidth; document.z_pgH=innerHeight; onresize=z_reloadPage; }}
  else if (innerWidth!=document.z_pgW || innerHeight!=document.z_pgH) location.reload();
}
z_reloadPage(true);

function z_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=z_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function z_swapImgRestore() {
  var i,x,a=document.z_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function z_preloadImages() {
	if (Z_Protect)
		z_trap();
  var d=document; if(d.images){ if(!d.z_p) d.z_p=new Array();
    var i,j=d.z_p.length,a=z_preloadImages.arguments; for(i=0; i<a.length; i++) 
    if (a[i].indexOf("#")!=0){ d.z_p[j]=new Image; d.z_p[j++].src=a[i];}}
}

function z_swapImage() {
  var i,j=0,x,a=z_swapImage.arguments; document.z_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=z_findObj(a[i]))!=null){document.z_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// [*]
function z_protect(e) {
alert("Sorry, you don't have permission to right-click.");
return false;
}

function z_trap() {
if(document.images)
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown = z_protect;
}
