/****************************************************\
| TVG UI 1.0                                         |
| Copyright by BonaSource Inc. (bonasource.com) 2003 |
\****************************************************/


function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//========================================================

var mmItems = new Array();
var coMMItem = 0;
var mmTM, mmOverTM;
var mmGeneralOverId;

function addMenuItem(id, lnk, txt, has_child) {
	mmItems[coMMItem] = new Array();
	mmItems[coMMItem][0] = id;
	mmItems[coMMItem][1] = layer(id);
	document.write('<div id="' + id + 'd" class="bgMMDivO" onMouseOver="if(mmTM) clearTimeout(mmTM); showMenuLI(\'' + id + '\'); return false" onMouseOut="mmOver(this, 0); hideMenuLI(); return false" onClick="mmGo(this); return false"><table width="169" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="/images/z.gif" width="1" height="1" /></td><td><img src="/images/z.gif" width="1" height="1" /></td><td><img src="/images/z.gif" width="1" height="1" /></td><td><img src="/images/z.gif" width="1" height="1" /></td></tr><tr><td width="13"><img src="/images/z.gif" width="13" height="1"></td><td width="100%" class="bgMMItemO"><a href="' + lnk + '" class="mmItemLinkO">' + txt + '</a></td><td width="9" align="center" valign="middle">');
	if (has_child) {
	  document.write('<img src="/images/mm-item-arr-l.gif" width="9" height="21">');
	}
	document.write('</td><td width="4"><img src="/images/z.gif" width="4" height="1"></td></tr><tr><td><img src="/images/z.gif" width="1" height="1" /></td><td><img src="/images/z.gif" width="1" height="1" /></td><td><img src="/images/z.gif" width="1" height="1" /></td><td><img src="/images/z.gif" width="1" height="1" /></td></tr></table></div>');
	coMMItem++;
}

function mmInit() {
	var i;
	for(i = 0; i < coMMItem; i++) {
		mmItems[i][2] = layer(mmItems[i][0] + "d");
	}
}

function mmOverGo(mmOverId) {
  if(self.mmOverTM) clearTimeout(mmOverTM);
	mmGeneralOverId = mmOverId;
	mmOverTM = setTimeout("mmOverDo()", curTM);
}

function mmOverDo(mmOverId) {
  mmOver(document.getElementById(mmGeneralOverId), 0);
}

function mmOver(obj, st) {
  var i, objTemp, objX = 0, objY = 0, objA;
	if(st) {
		if(mmTM) clearTimeout(mmTM);
		for(i = 0; i < coMMItem; i++) {
			if(!mmItems[i][0]) continue;
			if(mmItems[i][0] == obj.id) {
				if(mmItems[i][2] && mmItems[i][2].isExist()) {
					mmItems[i][2].moveTo(mmItems[i][1].getAbsoluteLeft(), mmItems[i][1].getAbsoluteTop() - 1);
					mmItems[i][2].show();
				}
			}
			else {
				if(mmItems[i][2] && mmItems[i][2].isExist() && mmItems[i][2].isVisible()) {
					mmItems[i][2].hide();
				}
			}
		}
	}
	else {
		if(mmTM) clearTimeout(mmTM);
		mmTM = setTimeout(mmClose, 10);
	}
}

function mmClose(id) {
	var i;
	if(mmTM) clearTimeout(mmTM);
	for(i = 0; i < coMMItem; i++) {
		if(mmItems[i][2] && mmItems[i][2].isExist() && mmItems[i][2].isVisible()) {
			mmItems[i][2].hide();
		}
	}
}

function mmGo(obj) {
	if(!isDOM) return;
	event.cancelBubble = true;
	var objA = obj.getElementsByTagName("A");
  window.location = objA[0].href;
}

//========================================================

var smOverColorN = "#000000";
var smOverColorO = "#CEBF00";

function smOver(obj, st) {
  if(!isDOM) return;
	var i, objStyle;
	var objA = obj.getElementsByTagName("A");
	for(i = 0; i < objA.length; i++) {
		objStyle = (objA[i].style) ? objA[i].style : objA[i];
		objStyle.color = (st) ? smOverColorO : smOverColorN;
	}
}

//========================================================

function BSMenu() {
  this.div = new Array();
  this.dcounter = 0;
}

BSM = BSMenu.prototype;

BSM.add = function(bsdObj) {
  this.div[this.dcounter++] = bsdObj;
}

BSM.render = function() {
  var bsdc, i, j, obj, ls, rs, str, resstr, arr, arItem, nstrb, nstre, coLt, coClt, coItem;
  arLt = new Array();
  arClt = new Array();
  for(bsdc = 0; bsdc < this.dcounter; bsdc++) {
    obj = this.div[bsdc];
	str = obj.lt; coLt = 0;
	nstrb = 0;
	while((nstre = str.indexOf("##", nstrb)) != -1) {
	  arLt[coLt++] = str.substring(nstrb, nstre);
	  arLt[coLt++] = str.substring(nstre, nstre + 8);
	  nstrb = nstre + 8;
	}
	arLt[coLt] = str.substring(nstrb);
	str = obj.clt; coClt = 0;
	nstrb = 0;
	while((nstre = str.indexOf("##", nstrb)) != -1) {
	  arClt[coClt++] = str.substring(nstrb, nstre);
	  arClt[coClt++] = str.substring(nstre, nstre + 8);
	  nstrb = nstre + 8;
	}
	arClt[coClt] = str.substring(nstrb);
	arr = obj.links;
	resstr = "";
    for(i = 0; i < obj.counter; i++) {
	  if(arr[i].state) {
	    arItem = arLt;
		coItem = coLt;
	  }
	  else {
	    arItem = arClt;
		coItem = coClt;
	  }
	  for(j = 0; j <= coItem; j++) {
	    switch (arItem[j]) {
		  	case '##DVID##': resstr += obj.id; break;
		  	case '##ITID##': resstr += 't' + i + obj.id; break;
		  	case '##LINK##': resstr += arr[i].url; break;
		  	case '##TEXT##': resstr += arr[i].text; break;
		  	case '##TRGT##': resstr += arr[i].target; break;
		  	default: resstr += arItem[j];
			}
	  }
    }
	str = obj.dt;
	nstrb = str.indexOf("##DVID##");
    ls = str.substring(0, nstrb);
    rs = str.substring(nstrb + 8);
    str = ls + obj.id + rs;
    nstrb = str.indexOf("##ITMS##");
    ls = str.substring(0, nstrb);
    rs = str.substring(nstrb + 8);
    str = ls + resstr + rs;
    document.write(str);
  }
}

function BSDiv(id, level, divTempl, linkTempl, curLinkTempl) {
  this.id = "d" + level + id;
  this.level = level;
  this.links = new Array();
  this.counter = 0;
  this.dt = divTempl;
  this.lt = linkTempl;
  this.clt = curLinkTempl;
}

BSD = BSDiv.prototype;

BSD.add = function(state, url, text, target) {
  this.links[this.counter++] = new BSItem(state, url, text, target);
}

BSD.itemOff = function(itm) {
  this.links[itm-1][0] = 0;
}

function BSItem(state, url, text, target) {
  this.state = state;
  this.url = url;
  this.text = text;
  this.target = (!target || target == "") ? "_top" : target;
}

BSI = BSItem.prototype;

divTempl = '<div id="##DVID##" style="position:absolute; left:-1000px; top:-1000px; z-index:101; visibility: hidden" onMouseOver="if(mmTM) clearTimeout(mmTM); flClose=1; cancelCloseMenuLI(); return true" onMouseOut="mmOverGo(this.id.substring(2, this.id.length)); flClose=0; hideMenuLI(); return true"><table width="200" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">##ITMS##<tr><td class="bgDMItemLastEnd"><img src="/images/z.gif" width="1" height="3"></td></tr></table></div>';

linkTempl = '<tr><td width="100%" class="bgDMItemN" onMouseOver="this.firstChild.style.color=\'#FFFFFF\'; this.style.backgroundColor=\'#7B832A\'; return false" onMouseOut="this.firstChild.style.color=\'#454001\'; this.style.backgroundColor=\'#DFE0CC\'; return false" onClick="window.location=this.firstChild.href; return false"><a href="##LINK##" class="dmItemLinkN"><nobr>##TEXT##</nobr></a></nobr></td></tr>';

curLinkTempl = '<tr><td width="100%" class="bgDMItemLast" onMouseOver="this.firstChild.style.color=\'#FFFFFF\'; this.style.backgroundColor=\'#7B832A\'; return false" onMouseOut="this.firstChild.style.color=\'#454001\'; this.style.backgroundColor=\'#DFE0CC\'; return false" onClick="window.location=this.firstChild.href; return false"><a href="##LINK##" class="dmItemLinkN"><nobr>##TEXT##</nobr></a></nobr></td></tr>';

//========================================================

var tm, flClose = 0, coM = 0, curTM = 1000;
upMenuIni = new Array();
for(i=0; i<100; i++) {
  upMenuIni[i] = 0;
}
upMenu = new Array();
for(i=0; i<100; i++) {
  upMenu[i] = 0;
}

function initMenuLI(nm) {
  upMenuIni[coM] = new Array();
  upMenuIni[coM][0] = nm;
  coM++;
}

function renderMenuLI() {
  var i;
  for(i = 0; i < coM; i++) {
    upMenu[i] = new Array();
    upMenu[i][0] = upMenuIni[i][0];
    upMenu[i][1] = layer('d1' + upMenuIni[i][0]);
		upMenu[i][2] = layer(upMenuIni[i][0]);
  }
}

function showMenuLI(mItemName) {
  var i, p, mPosX, mPosY;
  imPos = new Array();
  for(i=0; i<coM; i++) {
		if(!upMenu[i][0]) continue;
    if(mItemName != upMenu[i][0]) {
      if(upMenu[i][1] && upMenu[i][1].isExist()) upMenu[i][1].hide();
    }
    else {
      cancelCloseMenuLI();
      if(upMenu[i][1] && upMenu[i][2] && upMenu[i][1].isExist()) {
        mPosX = upMenu[i][2].getAbsoluteLeft() + upMenu[i][2].getWidth() - 1;
        if(mPosX + upMenu[i][1].getWidth() > getWindowWidth())
          if((mPosX = getWindowWidth() - upMenu[i][1].getWidth()) < 0) mPosX = 0;
        mPosY = upMenu[i][2].getAbsoluteTop();
        if(mPosY + upMenu[i][1].getHeight() > getWindowHeight())
          if((mPosY = (imPos[1] - 24 < 0)) < 0) mPosY = 0;
        upMenu[i][1].moveTo(mPosX, mPosY);
				if(!isOpera) {
					document.getElementById('d1' + upMenu[i][0]).firstChild.width = upMenu[i][2].getWidth();
				}
        upMenu[i][1].show();
        curTM = 1000;
      }
      else {
        curTM = 0;
      }
    }
  }
}

function hideMenuLI() {
  if(self.tm) clearTimeout(tm);
  if(!flClose) tm=setTimeout("totalHideMenuLI()", curTM);
}

function totalHideMenuLI(){
  var i;
  for(i=0; i<coM; i++) {
    if(upMenu[i][1] && upMenu[i][1].isExist()) upMenu[i][1].hide();
  }
}

function cancelCloseMenuLI(){
  if(self.tm) clearTimeout(tm);
}

//========================================================

var isOK;

function checkEmail(fld) {
  var i = 0, coS = 0, cStr, flDot = true;
  var str = document.forms['form3'].elements[fld].value;
  while((i = str.indexOf('@', i + 1)) != -1) coS++;
  while((i = str.indexOf('.', i + 1)) != -1)
    if(str.indexOf('.', i + 1) != -1 && (str.indexOf('.', i + 1) - i) == 1) flDot = false;
  if(coS == 1 && flDot && str.indexOf(' ') == -1 && str.charAt(0) != '.') {
    var lStr = str.substring(0, str.indexOf('@'));
	var rStr = str.substring(str.indexOf('@') + 1, str.length);
	if(lStr.charAt(lStr.length - 1) != '.' && rStr.charAt(0) != '.') {
	  if((coS = rStr.lastIndexOf('.')) != -1) {
	    if((str.lastIndexOf('.') - str.indexOf('@')) > 1) {
	      rStr = rStr.substring(coS + 1, str.length);
	      if(rStr.length > 1) {
		    isOK = true;
		    return true;
		  }
	    }
      }
	}
  }
  isOK = false;
  alert('Please enter valid email');
  return false;
}



dWriteDiv = '<div id="zoomDIVfix" class="divFixSize">WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW</div>';
dWriteDiv += '<div id="zoomDIV" class="divSize" onresize="resDoc();">WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW</div>';

function resDoc() {
  var cz = Math.round(document.all.zoomDIV.offsetWidth / document.all.zoomDIVfix.offsetWidth * 100);
  if(cz > 95 && cz < 105) cz = 100;
  document.body.style.zoom = cz + "%";
}

function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);