var lastMouseX;
var lastMouseY;
var curPopupWindow = null;
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

//-----------------------------------------------------------------------------
// Determine browser.
//-----------------------------------------------------------------------------

var isNS4x  = (navigator.appName.indexOf("Netscape") >= 0 && parseInt(navigator.appVersion) == 4) ? 1 : 0;
var isGecko = (navigator.userAgent.indexOf("Gecko") != -1) ? 1 : 0;
var isOpera = (agt.indexOf("opera") != -1) ? 1 : 0;
var isIE4up = (document.all) ? 1 : 0;
var isIE5   = (isIE4up && navigator.appVersion.indexOf("MSIE 5") != -1) ? 1 : 0;
var isIE6   = (isIE4up && navigator.appVersion.indexOf("MSIE 6") != -1) ? 1 : 0;
var isDOM   = (isGecko || isIE6 || isOpera) ? 1 : 0;//opera doesn't support clipping, however

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up = (is_ie && (is_major >= 4));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

var is_ie5_5_or_higher = is_ie5_5 || is_ie5_5up || is_ie6 || is_ie6up;

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var isNC=navigator.appName=="Netscape";
var isNC4=isNC && !isDOM;
var isNC6=isMozilla=isNC && isDOM;

function setLastMousePosition(e) {
	if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
	lastMouseX = e.screenX;
	lastMouseY = e.screenY;
}

function closePopup() {
	if (curPopupWindow != null) {
		if (!curPopupWindow.closed) {
			curPopupWindow.close();
		}
		curPopupWindow = null;
	}

}
function openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
    //closePopup();
	if (snapToLastMousePosition) {
		if (lastMouseX - pWidth < 0) {
			lastMouseX = pWidth;
		}
		if (lastMouseY + pHeight > screen.height) {
			lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
		}
        lastMouseX -= pWidth;
        lastMouseY += 10;
		features +=	"screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
	} else {
		var winl = (screen.width - pWidth) / 2;
		var wint = (screen.height - pHeight) / 2;
		features += ',top='+wint+',left='+winl;
	}
    if (closeOnLoseFocus) {
        curPopupWindow = window.open(url, name, features, false);
		curPopupWindow.focus()
    } else {
        // assign the open window to a dummy var so when closePopup() is called it won't be assigned to curPopupWindow
        win = window.open(url, name, features, false);
    }
}

function DL_GetElementLeft(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if(eParElement.tagName == "TD")     // if parent a table cell, then...
         {
            nLeftPos += eParElement.clientLeft; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nLeftPos += 1;             // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nLeftPos += nParBorder;       // append the border width to counter
            }
         }
      }

      nLeftPos += eParElement.offsetLeft;    // append left offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nLeftPos;                          // return the number calculated
}

function DL_GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner
   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if(eParElement.tagName == "TD")     // if parent a table cell, then...
         {
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }

      nTopPos += eParElement.offsetTop;      // append top offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}
function showActions(nId,imgID) {
	var holdingImage = document.images[imgID];
	var dvObj = document.getElementById("menu"+nId);
	if(dvObj.style.visibility == 'hidden') {
		dvObj.style.visibility = 'visible';
		dvObj.style.left = DL_GetElementLeft(holdingImage);
		dvObj.style.top = DL_GetElementTop(holdingImage)+holdingImage.height;
		dvObj.style.width = holdingImage.width;
	} else {
		hideActions(nId);
	}
	clearTimeout(Var2[nId]);
}
function hideActions(nId) {
	var dvObj = document.getElementById("menu"+nId);
	dvObj.style.visibility = 'hidden';
	clearTimeout(Var2[nId]);
}
Var2= new Array(10);
function makealert(lokate,divId){
	if (lokate==1){
		clearTimeout(Var2[divId])
	}
	if (lokate==2){
		Var2[divId]=setTimeout("hideActions('"+divId+"')", 600)
	}
}
function showNews (nId) {
	var dvObj = document.getElementById("menu"+nId);
	nWidth = dvObj.offsetWidth;
	clWidth = document.getElementsByTagName("body")[0].clientWidth;
	
	var nLeft = (clWidth/2) - (nWidth/2);

	if (document.documentElement && document.documentElement.scrollTop)
		gnTop = document.documentElement.scrollTop;
	else if (document.body)
		gnTop = document.body.scrollTop;
	else
		gnTop = 0;
	
	lnTop = gnTop + 50;
	dvObj.style.zIndex = 1000;
	dvObj.style.left=nLeft;
	dvObj.style.top=lnTop;
	dvObj.style.visibility = 'visible';
}


//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

if(is_ie5)
    window.onerror = onSiteError;

function onSiteError() {
   return true;
}

function cb_showModalDialog(url, width, height) {
    if(is_ie)
        showModalDialog(url,self,'dialogWidth:'+width+'px;dialogHeight:'+height+'px;center:yes;help:no;status:0;');
    if(is_opera5up) {
        get_center (width, height);
		window.open(url,'opwin','height='+eval(height-50)+',width='+width+', left=' +wleft+ ', top='+wtop+',scrollbars=1');
    }
    if(isNC) {
        get_center (width, height);
        var attr = 'screenX=' + wleft + ',screenY='+wtop+', resizable=no,width='+(width+10)+',scrollbars=1,height='+(height-(isNC4 ? 0 : 50));
        window.open(url, 'dnwin', attr);
    }
}

function get_center (width, height) {
   wleft = window.screenX + ((window.outerWidth - width) / 2);
   wtop = window.screenY + ((window.outerHeight - height) / 2);
   return wleft, wtop;
}

function global_get_file_name(form_name, file_name_form) {
    var file_name = document.getElementById(form_name).value;
    file_name = file_name.split('\\');
    file_name = file_name[file_name.length-1];
    var file_type = file_name.substring(file_name.lastIndexOf('.')+1, file_name.length);
    var file_type_length = file_type.length;
    if(file_type_length == file_name.length) 
        file_type_length = -1;
    file_name = file_name.substring(0, file_name.length - (file_type_length+1));
    document.getElementById(file_name_form).value = file_name;
}

function isEmpty(str){
	var re=new RegExp("^ *(.*) *$","gi")
	var arr = re.exec(str);	
	str=RegExp.$1;
	return (str=='');
}

function isEmail(mailValue)
{
if (mailValue!='')
	{
	  if (mailValue.indexOf('@', 0) == -1 || mailValue.indexOf('.', 0) == -1 || mailValue.indexOf('@.', 0) != -1 || mailValue.indexOf('.@', 0) != -1 || (mailValue.length-mailValue.lastIndexOf('.'))<=2)
			{
					return false
			}
	}
	return true
}