/*
   DynAPI Distribution
   DynAPI base Object. Empty shell defining common properties and methods

   The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/
snow=0

if(typeof DynObject == "undefined"){

DynObject = function() {
	this.setID("DynObject"+(DynObject.Count++));
	this.isChild = false;
	this.created = false;
	this.parent = null;
	this.children = [];
	//added to counter inheritance bug (#425789)
	this.eventListeners = [];
	this.hasEventListeners = false;
};
DynObject.prototype.getClass = function() { return this.constructor };
DynObject.prototype.setID = function(id) {
	if (this.id) delete DynObject.all[this.id];
	this.id = id;
	DynObject.all[this.id] = this;
};
DynObject.prototype.addChild = function(c) {
	if(c.isChild) c.parent.removeChild(c);
	c.isChild = true;
	c.parent = this;
	if(this.created) c.create()
	this.children[this.children.length] = c;
	return c;
};
DynObject.prototype.removeChild = function(c) {
	var l = this.children.length;
	for(var i=0;i<l && this.children[i]!=c;i++);
	if(i!=l) {
		c.invokeEvent("beforeremove");
		c.specificRemove();
		c.created=false;
		c.invokeEvent("remove");
		c.isChild = false;
		c.parent = null;
		this.children[i] = this.children[l-1];
		this.children[l-1] = null;
		this.children.length--;
	}
};
DynObject.prototype.deleteFromParent = function () {
	if(this.parent) this.parent.deleteChild(this);
};
DynObject.prototype.removeFromParent = function () {
	if(this.parent) this.parent.removeChild(this);
};
DynObject.prototype.create = function() {
	this.flagPrecreate();
	this.specificCreate();
	this.created = true;
	var l = this.children.length;
	for(var i=0;i<l;i++) this.children[i].create()
	this.invokeEvent("create");
};
DynObject.prototype.flagPrecreate = function() {
	if (this.precreated) return;
	var l=this.children.length;
	for (var i=0; i<l;  i++) this.children[i].flagPrecreate();
	this.invokeEvent('precreate');
	this.precreated=true;
};
DynObject.prototype.del = function() {
	this.deleteAllChildren();
	this.invokeEvent("beforeremove");
	this.specificRemove();
	this.precreated = this.created = false;
	this.invokeEvent("remove");
	this.invokeEvent("delete");
};
DynObject.prototype.deleteChild = function(c) {
	var l = this.children.length;
	for(var i=0;i<l && this.children[i]!=c;i++);
	if(i!=l) {
		this.children[i] = this.children[l-1];
		this.children[l-1] = null;
		this.children.length--;
		c.del()
		c = null;
	}
};
DynObject.prototype.deleteAllChildren = function() {
	var l = this.children.length;
	for(var i=0;i<l;i++) {
		this.children[i].del();
		delete this.children[i];
	}
	this.children = [];
};
DynObject.prototype.toString = function() {
	return "DynObject.all."+this.id
};
DynObject.prototype.getAll = function() {
	var ret = [];
	var temp;
	var l = this.children.length;
	for(var i=0;i<l;i++) {
		ret[this.children[i].id] = this.children[i];
		temp = this.children[i].getAll();
		for(var j in temp) ret[j] = temp[j];
	}
	return ret
};
DynObject.prototype.isParentOf = function(obj,equality) {
	if(!obj) return false
	return (equality && this==obj) || this.getAll()[obj.id]==obj
}
DynObject.prototype.isChildOf = function(obj,equality) {
	if(!obj) return false
	return (equality && this==obj) || obj.getAll()[this.id]==this
}
DynObject.prototype.specificCreate	= function() {};
DynObject.prototype.specificRemove	= function() {};
DynObject.prototype.invokeEvent		= function() {};
DynObject.Count = 0;
DynObject.all = [];
Methods = {
	removeFromArray : function(array, index, id) {
		var which=(typeof(index)=="object")?index:array[index];
		if (id) delete array[which.id];
        	else for (var i=0; i<array.length; i++)
			if (array[i] == which) {
				if(array.splice) array.splice(i,1);
				else {	for(var x=i; x<array.length-1; x++) array[x]=array[x+1];
         				array.length -= 1; }
			break;
			}
		return array;
	},
	getContainerLayerOf : function(element) {
		if(!element) return null
		if(is.def&&!is.ie) while (!element.lyrobj && element.parentNode && element.parentNode!=element) element=element.parentNode;
		else if(is.ie) while (!element.lyrobj && element.parentElement && element.parentElement!=element) element=element.parentElement;
		return element.lyrobj
	}
};
DynAPIObject = function() {
	this.DynObject = DynObject;
	this.DynObject();

	this.loaded = false;
	this.librarypath = '';
	this.packages = [];
	this.errorHandling = true;
	this.returnErrors = true;
	this.onLoadCodes = [];
	this.onUnLoadCodes = [];
	this.onResizeCodes = [];
}
DynAPIObject.prototype = new DynObject();
DynAPIObject.prototype.setLibraryPath = function(path) {
	if (path.substring(path.length-1)!='/') path+='/';
	this.librarypath=path;
}
DynAPIObject.prototype.addPackage = function(pckg) {
	if (this.packages[pckg]) return;
	this.packages[pckg] = { libs: [] };
}
DynAPIObject.prototype.addLibrary = function(path,files) {
	var pckg = path.substring(0,path.indexOf('.'));
	if (!pckg) {
		alert("DynAPI Error: Incorrect DynAPI.addLibrary usage");
		return;
	}
	var name = path.substring(path.indexOf('.')+1);
	if (!this.packages[pckg]) this.addPackage(pckg);
	if (this.packages[pckg].libs[name]) {
		alert("DynAPI Error: Library "+name+" already exists");
		return;
	}
	this.packages[pckg].libs[name] = files;
}
DynAPIObject.prototype.include = function(src,pth) {
	src=src.split('.');
	if (src[src.length-1] == 'js') src.length -= 1;
	var path=pth||this.librarypath||'';
	if (path.substr(path.length-1) != "/") path += "/";
	var pckg=src[0];
	var grp=src[1];
	var file=src[2];
	if (file=='*') {
		if (this.packages[pckg]) group=this.packages[pckg].libs[grp];
		if (group) for (var i=0;i<group.length;i++) document.write('<script language="Javascript1.2" src="'+path+pckg+'/'+grp+'/'+group[i]+'.js"><\/script>');
		else alert('include()\n\nThe following package could not be loaded:\n'+src+'\n\nmake sure you specified the correct path.');
	} else document.write('<script language="Javascript1.2" src="'+path+src.join('/')+'.js"><\/script>');
}
DynAPIObject.prototype.errorHandler = function (msg, url, lno) {
	if (!this.loaded || !this.errorHandling) return false;
	if (is.ie) {
		lno-=1;
		alert("DynAPI reported an error\n\nError in project: '" + url + "'.\nLine number: " + lno + ".\n\nMessage: " + msg);
	} else if (is.ns) {
		alert("DynAPI reported an error\n\nError in file: '" + url + "'.\nLine number: " + lno + ".\n\nMessage: " + msg);
	} else return false;
	return this.returnErrors;
}
DynAPIObject.prototype.addLoadFunction = function(f) {
	this.onLoadCodes[this.onLoadCodes.length] = f;
}
DynAPIObject.prototype.addUnLoadFunction = function(f) {
	this.onUnLoadCodes[this.onUnLoadCodes.length] = f;
}
DynAPIObject.prototype.addResizeFunction = function(f) {
	this.onResizeCodes[this.onResizeCodes.length] = f;
}

DynAPIObject.prototype.loadHandler = function() {
	this.create();
	eval(this.onLoadCodes.join(";"));
	if (this.onLoad) this.onLoad();
	this.loaded=true;


}

DynAPIObject.prototype.unloadHandler = function() {
	if (!is.ns4) this.deleteAllChildren();
	eval(this.onUnLoadCodes.join(";"));
	if (this.onUnload) this.onUnload();
}
DynAPIObject.prototype.resizeHandler = function() {
	eval(this.onResizeCodes.join(";"));
	if (this.onResize) this.onResize();
}


// Create base objects
DynAPI = new DynAPIObject();
DynLayer=DynDocument=null

// Native events

onload = function() { DynAPI.loadHandler(); }
onunload = function() { DynAPI.unloadHandler(); }
//onerror = function(msg, url, lno) { DynAPI.errorHandler(msg, url, lno); }
onresize = function() { DynAPI.resizeHandler(); }
//onClick = function() { cancelLink_before_load(); }

// Add base packages
DynAPI.addPackage('dynapi');
DynAPI.addLibrary('dynapi.api'  ,["browser","dyndocument","dynlayer"]);
DynAPI.addLibrary('dynapi.event',["listeners","mouse","dragevent","keyboard"]);
DynAPI.addLibrary('dynapi.ext'  ,["inline","layer","dragdrop","functions"]);
DynAPI.addLibrary('dynapi.gui'  ,["viewport","dynimage","button","buttonimage","label","list","loadpanel","pushpanel","scrollbar","scrollpane","sprite"]);
DynAPI.addLibrary('dynapi.util' ,["circleanim","cookies","debug","thread","hoveranim","imganim","pathanim","console"]);


///// get file_path
pathname11=document.location.pathname
pathname11=pathname11.replace(/arabacademy/i,"")
pathname11=pathname11.replace(/^\/+/i,"")
pathname11_array=new Array()
pathname11_array=pathname11.split(/\//)
file_dot_path=""

for(Path_counter_j=1;Path_counter_j<pathname11_array.length;Path_counter_j++){
	file_dot_path+="../"
}

//////////////

DynAPI.setLibraryPath(file_dot_path + "js/lib/")

DynAPI.include('dynapi.api.*');
DynAPI.include('dynapi.event.listeners.js');
DynAPI.include('dynapi.event.mouse.js');

DynAPI.include('dynapi.ext.inline.js');
DynAPI.include('dynapi.abdo.abdo_layer_ext.js');
//DynAPI.include('dynapi.abdo.abdo_layer_ext.js');



DynAPI.onLoad=function() {

	if(this){
		if(this.document){
			over=this.document.getAll()["overDiv"]

			////////////////
			all_founded_div_layers=this.document.getAll()
			set_layers_names(all_founded_div_layers)
			////////////////////

			myListener11 = new EventListener(DynAPI.document)
			myListener11.onmousemove=function(e) {
			if (snow) {on_mouseMove(e)}
				//over.setBgColor('#ffc000')
			}

		DynAPI.document.addEventListener(myListener11)

		}
	}
}



}






var overwrite_x=0
var overwrite_y=0

	if (typeof fcolor == 'undefined') { var fcolor = "#CCCCFF";}
	if (typeof backcolor == 'undefined') { var backcolor = "#333399";}
	if (typeof textcolor == 'undefined') { var textcolor = "#000000";}
	if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}
	if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}
	if (typeof width == 'undefined') { var width = "200";}
	if (typeof border == 'undefined') { var border = "1";}
	if (typeof offsetx == 'undefined') { var offsetx = 10;}
	if (typeof offsety == 'undefined') { var offsety = 10;}


ie4=0
ns4=0

if(document.all){
ie4=1
}else{
ns4=1
}



var x_of_layer = 0;
var y_of_layer = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
var tr = 1;




function nd() {

	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) ) {
		if ( sw == 0 ) {
			snow = 0;

			if(typeof(over) == "undefined" || over==""){
				return
			}

			hideObject(over);
		} else {
			cnt++;
		}
	}
}


function dts(d,text,add_shift_to_y, external_y_shift) {

	if(typeof(over) == "undefined" || over==""){
		DynAPI.onLoad()
	}

	if(typeof(over) == "undefined" || over==""){
		return
	}


	//txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><FONT FACE=\"Arial,Helvetica\" COLOR=\""+textcolor+"\" SIZE=\"-2\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"

	layerWrite(text);


	dir = d;

	add_shift_to_yy=0

	if(add_shift_to_y==1){
		add_shift_to_yy=-30
	}
	if(add_shift_to_y==2){
		add_shift_to_yy=- (over.getContentHeight() + 5)
	}
	
	if(external_y_shift >0){
		add_shift_to_yy-=external_y_shift
	}

	disp(add_shift_to_yy)
}


function disp(add_shift_to_y) {

	if (snow == 0) 	{

		moveTo(over,overwrite_x,overwrite_y);
		snow = 1;
	}

// Here you can make the text goto the statusbar.
}




function on_mouseMove(e) {

	if (is.ns) {x_of_layer=e.pageX; y_of_layer=e.pageY;}
	if (is.ie5 || is.ie) {x_of_layer=event.x+document.body.scrollLeft; y_of_layer=event.y+document.body.scrollTop;}
	if (is.ie4) {x_of_layer=event.x; y_of_layer=event.y;}


//alert((y_of_layer+offsety) +"--" + add_shift_to_yy)
	if (snow) {



		//alert(44)
		if(overwrite_x>0){
				moveTo(over,overwrite_x,overwrite_y);
		}else{
			if (dir == 2) { // Center
				moveTo(over,x_of_layer+offsetx-(over.getContentWidth()/2),y_of_layer+offsety);
			}
			if (dir == 1) { // Right

				moveTo(over,x_of_layer+offsetx,y_of_layer+offsety+ add_shift_to_yy);
			}
			if (dir == 0) { // Left

				moveTo(over,x_of_layer-offsetx-over.getContentWidth(),y_of_layer+offsety+ add_shift_to_yy);
			}
		}
	}

	showObject(over)

}



function layerWrite(txt) {
over.write(txt)
}

function showObject(obj) {
obj.show()
return
}

function hideObject(obj) {
obj.hide()
}


function moveTo(obj,xL,yL) {
//alert(xL+ "," + yL)
obj.moveTo(xL,yL)
}


