function reloadtrick(intialize){
	if (!$("mainTD")){return;}
	if (intialize === true){
		Event.observe(window, 'resize', reloadtrick, false);			
	}
	else{
		var h1,h2,h3;
		h1=findHeight("headerflash");
		h2=findHeight("adminflashfooter");
		h3=findHeight("headerflashimg");
		//alert(window.getHeight()+'='+h1+'='+h2+'='+h3);

		//h3=window.getHeight()-h3-h1-h2;
		$("mainTD").setStyle({"height":(window.getHeight()-h3-h1-h2)+"px"});
	//return [   document.documentElement.clientHeight,document.body.clientHeight  ].find(function(s) {return (s!==undefined && s!==0);}) || 0;
		if($("adminblocks")){
			if(findHeight("mainTD")<findHeight("adminblocks")){
				h1=findHeight("adminblocks");
				h2=findHeight("mainTD");
				h3=h1-h2;
				h2=h2-h3;
		//alert(h2);
				$("mainTD").setStyle({"height":h2+"px"});
				$("adminblocks").setStyle({"height":h2+"px"});
			}
		}
		setpreloader();
	}//window.status=findHeight("mainTD")+"="+h1;
}
function pause2(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime){
			return;}
	}
}
function setpreloader(){
	if (!$("preloader_div")){return;}
	$("preloader_div").setStyle({"height":window.pageHeight()+"px","width":window.pageWidth()+"px"});
}

function findHeight(obj){
	obj=$(obj);
	if (!obj){return 0;}
	var ret=obj.getHeight();
    ret=parseInt(ret);
   	if (isNaN(ret)){ret=0;}
	return ret;
}

function reloadtricks(intialize){
	if (!$("centerTD")){return;}
	if (intialize === true){
		Event.observe(window, 'resize', reloadtricks, false);			
	}
	else{
		var h1,h2,h2b,h3,h4,h5,h6,h7;
		h1=findHeight("globalNav");
		h2=findHeight("header_flash_id");
		h2b=findHeight("header_flash_br");
		h3=findHeight("header_scroller_id");
		h4=findHeight("headerflashimg");
		h5=findHeight("centerTD");
		h6=findHeight("footer_msg_id");
		h7=findHeight("footer_flash_id");
		h7=window.getHeight()-h1-h2-h2b-h3-h4-h6-h7;
		$("centerTD").setStyle({"height":h7+"px"});
		if($("leftTD")){$("leftTD").setStyle({"height":h7+"px"});}
		if($("rightTD")){$("rightTD").setStyle({"height":h7+"px"});}
		setpreloader();
		//window.status =$("centerTD").getHeight()+'-'+window.getHeight()+'-'+(window.getHeight()-h1-h2-h2b-h3-h4-h6-h7) + '-'+document.body.clientHeight ;
	}
}








////////////////////////////////
var FloatZIndex_ = Class.create();
FloatZIndex_.prototype = {
  initialize: function(startfrom) {
	this.zindex=parseInt(startfrom);
  },
  increase: function() {
	this.zindex=this.zindex+1;
  },
  decrease: function() {
	this.zindex=this.zindex-1;
  },
  display: function() {
	return this.zindex;
  },
  next: function() {
	this.increase();
	return this.display();
  },
  previous: function() {
	this.decrease();
	return this.display();
  }
};
var FloatZIndex =new FloatZIndex_ (22000);

var FloatObject = Class.create();
FloatObject.prototype = {
  initialize: function(options) {
    this.forstatus="";
	this.setOptions(options);
	this.setdefaults();
  },
  setOptions: function(options){
	this.options = Object.extend({
		ftype: 'float',
		divid: 'FloatDivForID2',
		fwidth: undefined,
		fhtml:undefined,
		nostart:undefined,
		frefresh:10,
		fps:4,
		floattime:2000,
		startX:0,
		startY:0,
		onTOP:false,
		flytype:{x:"left-middle-right",y:"top-center-bottom"}
	}, options || {});
  },
  recalculatedefaults: function(x,y) {
  	if (this.initremovestay===true){return;}
  	switch(this.options.ftype){
  		case "until":
		case "float":
			if (this.options.nostart===undefined){
				this.startX=this.divid.CenterElement("x")-window.getScrollLeft();
				this.startY=this.divid.CenterElement("y")-window.getScrollTop();
				if(x!==undefined){this.startX=Element.CenterElement(0,"x",x)-window.getScrollLeft();}
				if(y!==undefined){this.startY=Element.CenterElement(0,"y",y)-window.getScrollTop();}
			}else{
				this.startY=parseInt(this.divid.getStyle('top'));//+window.getScrollTop();
				this.startX=parseInt(this.divid.getStyle('left'));//+window.getScrollLeft();;
			}
 		break;
		case "for":
			this.startX=this.divid.CenterElement("x");
			this.startY=this.options.startY;
			this.endY=0;
			this.endX=0;
			this.endX=this.divid.CenterElement("x");
			if (this.forstatus=="init"){
				if (this.flytypeY[0]=="top"){this.currenty=window.getScrollTop()-this.divid.getHeight()-10;}
				if (this.flytypeY[0]=="center"){this.currenty=this.divid.CenterElement("y")-window.getScrollTop();}
				if (this.flytypeY[0]=="bottom"){this.currenty=window.pageHeight()-this.divid.getHeight()+10;}
				if (this.flytypeX[0]=="left"){this.currentx=window.getScrollLeft()-this.divid.getWidth()-10;}
				if (this.flytypeX[0]=="middle"){this.currentx=this.divid.CenterElement("x")-window.getScrollLeft();}
				if (this.flytypeX[0]=="right"){this.currentx=window.pageWidth()-this.divid.getWidth();}
			}
			if (this.forstatus=="setdefault" || this.forstatus=="wait"){
				if (this.flytypeY[1]=="top"){this.endY=window.getScrollTop();}
				if (this.flytypeY[1]=="center"){this.endY=this.divid.CenterElement("y")-window.getScrollTop();}
				if (this.flytypeY[1]=="bottom"){this.endY=window.pageHeight()-this.divid.getHeight();}
				if (this.flytypeX[1]=="left"){this.endX=window.getScrollLeft();}
				if (this.flytypeX[1]=="middle"){this.endX=this.divid.CenterElement("x")-window.getScrollLeft();}
				if (this.flytypeX[1]=="right"){this.endX=window.pageWidth()-this.divid.getWidth();}
			}
			if (this.forstatus=="removestay"){
				if (this.flytypeY[2]=="top"){this.endY=window.getScrollTop()-this.divid.getHeight()-10;}
				if (this.flytypeY[2]=="center"){this.endY=this.divid.CenterElement("y")-window.getScrollTop();}
				if (this.flytypeY[2]=="bottom"){this.endY=window.pageHeight()-this.divid.getHeight()+10;}
				if (this.flytypeX[2]=="left"){this.endX=window.getScrollLeft();}
				if (this.flytypeX[2]=="middle"){this.endX=this.divid.CenterElement("x")-window.getScrollLeft();}
				if (this.flytypeX[2]=="right"){this.endX=window.pageWidth()-this.divid.getWidth();}
			}
		break;
	}
 },
  setdefaults: function() {
	if (this.options.onTOP===true){
		this.cuZindex=32400;
	}else{
		if (this.options.onTOP!==false && this.options.onTOP!==undefined){
			this.cuZindex=this.options.onTOP;
		}else{
			this.cuZindex=FloatZIndex.next();
		}
	}
  	switch(this.options.ftype){
  		case "until":
		case "float":		
			this.divid=$(this.options.divid);
			if (!this.divid){
				this.divid=$CE('div').insertionInside(document.body);
			}
			if (this.options.fhtml!==undefined){
				this.divid.innerHTML=this.options.fhtml;
			}
			this.divid.setStyle({position:"absolute",display:'block',zIndex:this.cuZindex});
			if (this.options.fwidth!==undefined){this.divid.setStyle({width:this.options.fwidth+"px"});}
			if($(this.options.divid+"_mFki2")){$(this.options.divid+"_mFki2").remove();}
			if (this.options.nostart===undefined){
				this.startY=this.divid.CenterElement("y")-window.getScrollTop();
				this.startX=this.divid.CenterElement("x")-window.getScrollLeft();
			}else{
				this.startY=parseInt(this.divid.getStyle('top'));//+window.getScrollTop();
				this.startX=parseInt(this.divid.getStyle('left'));//+window.getScrollLeft();;
			}
			if (this.options.ftype=="until"){this.divid.singleStyle('display','none');}
		break;
		case "for":
			if ($("FloatDivForID2")){$("FloatDivForID2").remove();}
			this.divid=$CE('div').setStyle({display:'none'}).insertionInside(document.body);
			this.divid.id="FloatDivForID2";
			if (this.options.fhtml!==undefined){
				this.divid.innerHTML=this.options.fhtml;
			}
			this.divid.setStyle({position:"absolute",zIndex:this.cuZindex});
			if (this.options.fwidth!==undefined){this.divid.setStyle({width:this.options.fwidth+"px"});}
			this.flytypeY=this.options.flytype.y.split('-');
			this.flytypeX=this.options.flytype.x.split('-');
			this.startX=this.divid.CenterElement("x");
			this.startY=this.options.startY;
			this.endY=0;
			this.endX=0;
			this.endX=this.divid.CenterElement("x");
			if (this.flytypeY[1]=="top"){this.endY=0;}
			if (this.flytypeY[1]=="center"){this.endY=this.divid.CenterElement("y")-window.getScrollTop();}
			if (this.flytypeY[1]=="bottom"){this.endY=window.getHeight()-this.divid.getHeight();}
			if (this.flytypeX[1]=="left"){this.endX=window.getScrollLeft();}
			if (this.flytypeX[1]=="middle"){this.endX=this.divid.CenterElement("x")-window.getScrollLeft();}
			if (this.flytypeX[1]=="right"){this.endX=window.pageWidth()-this.divid.getWidth();}
			this.forstatus="setdefault";
		break;
	}
	if (is_ie){
		this.mFki2=$CE("iframe");
		this.mFki2.id=this.options.divid+"_mFki2";
		this.mFki2.scrolling="no";
		this.mFki2.frameborder="0";
		this.mFki2.src="javascript:'';";
		//this.mFki2.className="vm-sub-iframe";
		this.mFki2.style.filter="progid:DXImageTransform.Microsoft.Shadow(color='#ffffff', Direction=180, Strength=5)"; 		
		this.mFki2.setStyle({top:"0px",
		left:"0px",
		height:parseInt(this.divid.offsetHeight)+"px",
		allowtransparency:"true",
		position:"absolute",
		display:"none",
		width:((this.options.fwidth)>0)?(this.options.fwidth)+"px":parseInt(this.divid.offsetWidth)+"px",
		scrolling:"no"});
		this.mFki2.singleStyle('zIndex',(this.cuZindex-1));
		if (this.options.fwidth!==undefined){
			this.mFki2.setStyle({width:((this.options.fwidth)>0)?(this.options.fwidth)+"px":parseInt(this.divid.offsetWidth)+"px"});
		}else{
			this.mFki2.setStyle({width:parseInt(this.divid.offsetWidth)+"px"});
		}
		this.mFki2.insertionBefore(this.divid);
	}else{
		this.mFki2=false;
	}//this.mFki2=false;
  },
  removestay: function() {
	//this.timeTimer2.stop();
	if (this.flytypeY[2]=="top"){this.endY=0;}
	if (this.flytypeY[2]=="center"){this.endY=this.divid.CenterElement("y")-window.getScrollTop();}
	if (this.flytypeY[2]=="bottom"){this.endY=window.getHeight()-this.divid.getHeight();}
	if (this.flytypeX[2]=="left"){this.endX=0;}
	if (this.flytypeX[2]=="middle"){this.endX=this.divid.CenterElement("x");}
	if (this.flytypeX[2]=="right"){this.endX=window.getWidth()-this.divid.getWidth();}
	this.forstatus="removestay";
	this.initremovestay=true;
  },
 
  init: function() {
	if (this.options.nostart===undefined){
		this.currentx = this.startX;
		this.currenty = this.divid.offsetTop;
	}else{
		this.currenty =parseInt(this.divid.getStyle('top'));
		this.currentx =parseInt(this.divid.getStyle('left'));
	}
	if(this.options.ftype=="for"){
		if (this.flytypeY[0]=="top"){this.currenty=window.getScrollTop();}
		if (this.flytypeY[0]=="center"){this.currenty=this.divid.CenterElement("y");}
		if (this.flytypeY[0]=="bottom"){this.currenty=window.getHeight()+window.getScrollTop()-this.divid.getHeight();}
		if (this.flytypeX[0]=="left"){this.currentx=window.getScrollLeft()-this.divid.getWidth();}
		if (this.flytypeX[0]=="middle"){this.currentx=this.divid.CenterElement("x")-window.getScrollLeft();}
		if (this.flytypeX[0]=="right"){this.currentx=window.getWidth()-this.divid.getWidth();}
		this.forstatus="init";
	}
  },
  change: function(x,y) {
    if (this.isstopping===true){return;}
	x=Math.round(x);
	y=Math.round(y);
	this.divid.setStyle({top:y+"px",left:x+"px",display:"block"});
	//window.status +="="+this.timeTimer;
	if (this.mFki2){
		//this.mFki2.style.display=this.divid.style.display;
		this.mFki2.setStyle({width:this.divid.getWidth()+"px",height:this.divid.getHeight()+"px",top:(y)+"px",left:(x)+"px",display:"block"});
	}
  },
  start: function() {
	this.init();
	this.forstatus="wait";
	//this.currenty += ((window.getScrollTop() + this.startY - this.currenty )/this.options.fps);
	//this.change(this.currentx, this.currenty );
	if (this.mFki2){
		this.mFki2.setStyle({width:this.divid.getWidth()+"px",height:this.divid.getHeight()+"px",top:(this.currenty)+"px",left:(this.currentx)+"px"});
	}
	this.obsfunc=function(e){this.recalculatedefaults();}.bind(this);
	Event.observe(window,'resize',this.obsfunc,false);
	this.Periodfunc=this.start2.bind(this);
	this.timeTimer=new PeriodicalExecuter(this.Periodfunc, this.options.frefresh/1000);

  },
  start2: function() {
	if(this.options.ftype=="for"){
		var ch1=Math.abs(this.currenty-this.endY-window.getScrollTop());
		var ch2=Math.abs(this.currentx-this.endX-window.getScrollLeft());
		if (this.initremovestay===true){
			if (ch1<0.01 && ch2<0.01){
				this.stop();
			}
		}else{
			if (ch1<0.01 && ch2<0.01 && this.initsecondtimer!==true){
				this.forstatus="wait";
				this.initsecondtimer=true;
				this.timeTimer2=new PeriodicalExecuter(this.removestay.bind(this), this.options.floattime/1000);
			}
		}
		this.currenty += ((window.getScrollTop() + this.endY - this.currenty )/this.options.fps);
		this.currentx += ((window.getScrollLeft() + this.endX - this.currentx )/this.options.fps);
	}else{
		if (this.options.nostart===undefined){
			this.currenty += ((window.getScrollTop() + this.startY - this.currenty )/this.options.fps);
			this.currentx += ((window.getScrollLeft() + this.startX - this.currentx )/this.options.fps);
		}else{
			this.currenty += ((window.getScrollTop() + this.startY - this.currenty )/this.options.fps);
			this.currentx += ((window.getScrollLeft() + this.startX - this.currentx )/this.options.fps);
		}
	}
	this.change(this.currentx, this.currenty );
  },
  stop: function() {
    this.isstopping=true;
   	Event.stopObserving(window,'resize',this.obsfunc);
	this.timeTimer.stop();
	//var imageEffect = new fx.Opacity(this.divid, { duration: 100, onComplete: function() { this.divid.setStyle({display:"none"}); }.bind(this)});
    //imageEffect.custom(1,0.1);
	this.divid.setStyle({display:"none"});
	if (this.mFki2){this.mFki2.remove();this.mFki2=false;}
    //this.isstopping=false;
  }
};


var FloatDivFor=function (divHTML,ctime){
	var timeTimer1=new FloatObject ({frefresh:10,fwidth:300,flytype:{x:"middle-middle-middle",y:"top-center-top"},fhtml:divHTML,ftype:"for",floattime:ctime});
	timeTimer1.start();
};
var FloatDiv=function (divid,isontop){
	var timeTimer2=new FloatObject ({divid:divid,onTOP:isontop});
	timeTimer2.start();
};
var timeTimer3;
var RemoveFloatDivUntil=function (){
	timeTimer3.stop();
};
var FloatDivUntil=function (divid,wi,nostart2){
	timeTimer3=new FloatObject ({divid:divid,fwidth:wi,nostart:nostart2,onTOP:32510});
	timeTimer3.start();
};
////////////////////////////////
function highlightrow(row,light){
	if (light===undefined){light=1;}
	if (light==1){
		$(row).immediateDescendants().each(function(td){td.addClassName('tdhighlight');});
		$(row).siblings().each(function(sib){$(sib).immediateDescendants().each(function(td){td.removeClassName('tdhighlight');});});
	}else{
		$(row).immediateDescendants().each(function(td){td.removeClassName('tdhighlight');});
	}
}


var j_system_loaded=true;
