// JavaScript Document
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;
var preImage = [];
var preImages = 0;

function showWeeBox(idx_, title_) {
		$.weeboxs.open(idx_, {
		  title: title_,
		  draggable: true,
			position: 'center',
			modal: true,
			trigger: 'test',
			clickClose: true,
			showTitle: true,
			showButton: false,
			animate: false,
			zIndex: 1001,
			type: 'prompt'
		});
//		$.weebox.setTitle(title);
}
function showWeeAction(idx_, title_) {
		$.weeboxs.open(idx_, {
		  title: title_,
		  draggable: true,
		  position: 'center',
		  modal: true,
		  trigger: 'test',
		  clickClose: true,
		  showTitle: true,
		  showButton: false,
		  animate: false,
		  zIndex: 1001,
		  type: 'dialog'
		});
//		$.weebox.setTitle(title);
}
function showWeeFeedback(idx_, title_) {
		$.weeboxs.open(idx_, {
		  title: title_,
		  draggable: true,
		  position: 'center',
		  modal: true,
		  trigger: 'test',
		  clickClose: true,
		  showTitle: true,
		  showButton: false,
		  animate: false,
		  zIndex: 1001,
		  type: 'prompt'
		});
//		$.weebox.setTitle(title);
}
function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

function pmGotoFunc(url) {
  window.location.replace(url);
}

function pmClickFunc(rel) {
    $('ul.leftmenuitem').css('visibility', 'hidden');
    $('ul.leftmenuitem').css('display', 'none');
    $('li.pm_level > a').css('font-weight', 'normal');
    $('img.pm_img').attr('src', '/img/pm-level.gif');
    
    var arel = rel.split('.');
    var crel = 'pm';
    for (prel in arel) {
      if (prel > 0) crel += '_';
      crel += arel[prel];
      var lm_ul = $('#'+crel);
      var lm_a  = $('a[@rel='+crel+']');
      lm_ul.css('visibility', 'visible');
      lm_ul.css('display', 'block');
      lm_a.css('font-weight', 'bold');
      var lm_img = lm_a.find('img');
      lm_img.attr('src', '/img/pm-open.gif');
    }
}
  
$(document).ready(function(){	
//  $(document).pngFix();
  $('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);
	if (! $.browser.msie) {
    $('ul.leftmenu > li > a').css('display', 'block');
    $('ul.leftmenuitem > li > a').css('display', 'block');
  } else {
    $('ul.leftmenu > li > a').css('display', 'inline-block');
    $('ul.leftmenuitem > li > a').css('display', 'inline-block');
  }
  preImage[preImages] = new Image;
  preImage[preImages].src = '/img/pm-open.gif';
  preImages ++;
  if ($('div.show_message').length) {
      sm = $('div.show_message');
      showWeeBox('#'+sm.attr('id'), sm.attr('name'));
  }
  $('img.footer_link').each(function(){
    preImage[preImages] = new Image;
    preImage[preImages].src = $(this).attr('name')+'.jpg';
    preImages ++; 
  });
  $('img.footer_link').hover(function(){
    $(this).attr('src', $(this).attr('name')+'.jpg');
  }, function(){
    $(this).attr('src', $(this).attr('name')+'B.jpg');
  });
  $('ul.leftmenu > li > a').eq(0).css('border', 'none');
  $('ul.leftmenu > li > a:last').css('border-bottom', '1px solid #456280');
  
  var lm = $('td.leftmenu_main').height() - 260;
  var cn = $('div.content_div').height();
  if (lm > cn) {
    $('#empty').height(lm-cn);
  }
});

document.onclick = jsddm_close;
