simplePreload(base_url+'images/plus.jpg',base_url+'images/minus.jpg');
var cat_pointer = new Object();
var IE 		=   !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1);
var Opera 	= 	navigator.userAgent.indexOf('Opera') > -1;
var WebKit	=	navigator.userAgent.indexOf('AppleWebKit/') > -1;
var Gecko	=  	navigator.userAgent.indexOf('Gecko') > -1 &&  navigator.userAgent.indexOf('KHTML') === -1;
var Chrome	 = 	navigator.userAgent.indexOf('Chrome') > -1 ;
var Safari	 = 	navigator.userAgent.indexOf('Safari') > -1 ;
var MobileSafari = !!navigator.userAgent.match(/Apple.*Mobile.*Safari/);
var minusval = (WebKit) ? -7 : 0;
var minus_ext	=	(WebKit || Opera ||  MobileSafari) ? 15 : 0;
var minus_right = 8;
var minus_left = navigator.userAgent.indexOf('Safari')>-1  ? 7 : 0;
//alert(navigator.userAgent);
if(Chrome || Safari) minus_right = 16;
//alert(minus_right);
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  var top  = (c["at_position"] == "y") ? p.offsetHeight+minusval : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +minusval : 0;
  var right = (c["at_position"] == "r") ? p.offsetWidth +minusval : 0;
  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  
   if(right){
   	left = 0;
  	 for (; p; p = p.offsetParent)
	  {
	    top  += p.offsetTop;
	    //left += p.offsetLeft;
	    //right+=50;
	  }
  }
  
  if(left>0){
  	c.style.left       = minus_ext+left-minus_left-3+'px';
  } else if(right>0){
  	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
  	var ch		=	document.getElementById('dc_bdy');
  	var ch_height 	= 	ch.offsetHeight;
  	if(ch_height<=myHeight){
  		var scr = 8;
  	} else {
  		var scr = 0;
  	}
  	
  	//c.style.right       = right+'px';
  	//c.style.left       = right+'px';
  	//c.style.right       = ((right*2)+95)+'px';
  	//c.style.paddingRight       = 226+'px';
  	//c.class	=	'test_class';
  	//c.style.float	=	'right';
  	//c.style.marginRight       = 226+'px';
  	var wdth  	=	screen.width;
  	bdy_width 	=	958;
  	diff_wdth 	=	Math.ceil((wdth-bdy_width)/2);
  	tot_width	=	diff_wdth+right;
  	c.style.right       = minus_ext+scr+tot_width-minus_right+'px';
  }
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.visibility = "visible";
  if(cat_pointer){
  	$(cat_pointer).src = 'http://192.168.0.156/artsoftech/trunk/images/minus.jpg';
  }
}
function at_show()
{
  
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  //alert(cat_pointer.length);
  //alert(cat_pointer[p.id]);
  if(cat_pointer[p.id]){
  	var cat_pointer_img	=	cat_pointer[p.id];
  	if($(cat_pointer_img)){
		$(cat_pointer_img).src =  base_url+'images/minus.jpg';
		p.style.background="#EDF7DF";
  	}
  }
  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}
// ***** at_hide *****
function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 0);
  if(cat_pointer[p.id]){
  	var cat_pointer_img	=	cat_pointer[p.id];
  	if($(cat_pointer_img)){
		$(cat_pointer_img).src =  base_url+'images/plus.jpg';
		p.style.background="#FFFFFF";
  	}
  }
}
// ***** at_click *****
function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}
// ***** at_attach *****
// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name
function at_attach(parent, child, showtype, position, cursor,extra_func)
{
  var p = document.getElementById(parent);
  if(extra_func!=''){
  	cat_pointer[p.id] = extra_func;
  }
  var c = document.getElementById(child);
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;
  c.style.position   = "absolute";
  c.style.visibility = "hidden";
  if (cursor != undefined) p.style.cursor = cursor;
  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }

}

function change_class_over(rowid)
{
	change_class_out();
	$(rowid).className = 'menu_over';
}
function change_class_out()
{
	for(var i=1;i<=1;i++)
	{
		$("menu_row"+i).className = 'menu_out';
	}
}
