var WindowManager = null;

function checkBoxes(idsName, value)
{
	var e = document.all(idsName)
	if (!e.length){
		e.checked = value
	} else {
		for (var i=0; i<e.length; i++){
			e[i].checked = value
		}
	}
}

function rowover(r,c){
	r.style.backgroundColor = c?c:'#dfe6e9';
}

function rowout(r,c){
	r.style.backgroundColor = c?c:'';
}

function wscheck(idx, link)
{
	var jbox = $('#wcb'+idx)
	var status = jbox.attr('checked')
	jbox.attr('checked',!status);
	if (link) link.blur();
	return false;
}

function getPosition(e){
	var left = 0;
	var top  = 0;
	while (e.offsetParent){
		left += e.offsetLeft// + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
		top  += e.offsetTop//  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
		e     = e.offsetParent;
	}
	left += e.offsetLeft// + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
	top  += e.offsetTop//  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
	return {x:left, y:top};
}

var timer = [];
var activesub = null;

function popupshow(id,from,toright)
{
	if (timer[id]) clearTimeout(timer[id])
	timer[id] = null

	var offset = getPosition(from)
	var menu = $('#'+id)
	if (toright){
		var browser = $.browser.name
		var xplus, yplus;
		if (browser == 'msie'){
			xplus = -5;
			yplus = -7;
		} else {
			xplus = 0;
			yplus = -2;
		}
		menu.css("top", offset.y+yplus);
		menu.css("left", offset.x+menu.width()+xplus-3);
	} else {
		menu.css("top", offset.y+28);
		menu.css("left", offset.x);
	}
	menu.stop(true,true);
	if (toright){
		menu.animate({opacity:"show"},{ queue:false, duration:250 })
	} else {
		menu.animate({opacity:"show",height:"show"},{ queue:false, duration:250 })
	}
}


function popuphide(id,index,now)
{
	var menu = $('#'+id)
	var r = new RegExp("[0-9]","g")
	var parentid = r.test(id)?id.replace(r, ""):null;

	if (parentid != null && timer[parentid] && !now)
		{clearTimeout(timer[parentid]); timer[parentid]=0;}

	if (timer[id]) {clearTimeout(timer[id]); timer[id]=0;}
	menu.stop(true,true);

	if (now){
		menu.hide(0)
	} else {
		var slide = (parentid!=null)?"width":"height"
		timer[id] = setTimeout(function(){
			menu.animate({opacity:"hide",slide:"hide"},{queue:false, duration:250 })
		},200)

		if (parentid != null){
			timer[parentid] = setTimeout(function(){
				$('#'+parentid).animate({opacity:"hide",slide:"hide"},{queue:false, duration:250 })
			},200)
		}
	}

	if (index != null)
		timer[id+index] = setTimeout(function(){popuphide(id+index,null,'now')},1)
}

function popupover(id,index,item)
{
	var r = new RegExp("[0-9]","g")
	var parentid = r.test(id)?id.replace(r, ""):null;

	if (timer[id]){clearTimeout(timer[id]);timer[id] = null}
	if (timer[parentid]) {clearTimeout(timer[parentid]);timer[parentid]=null;}

	if (index != null){
		if (activesub != index){
			$('#'+id+activesub).hide(0)
		}
		popupshow(id+index,item,'toright')
		activesub = index
	}
}

/* fix background blinking :) */
(function(){
  /*Use Object Detection to detect IE6*/
  var  m = document.uniqueID /*IE*/
  && document.compatMode  /*>=IE6*/
  && !window.XMLHttpRequest /*<=IE6*/
  && document.execCommand ;
  try{
    if(!!m){
      m("BackgroundImageCache", false, true) /* = IE6 only */
    }
  }catch(oh){};
})();
