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


mmPics = new Array();
var mmPicsCnt = 0;
function mmPreload(nm, norm, over, bnorm, bover) {  
  mmPics[mmPicsCnt] = new Array(3);
  mmPics[mmPicsCnt][0] = new Image();
  mmPics[mmPicsCnt][0].src = norm;
  mmPics[mmPicsCnt][1] = new Image();
  mmPics[mmPicsCnt][1].src = over;
  mmPics[mmPicsCnt][2] = new Image();
  mmPics[mmPicsCnt][2].src = bnorm;
  mmPics[mmPicsCnt][3] = new Image();
  mmPics[mmPicsCnt][3].src = bover;
  mmPics[mmPicsCnt][4] = nm;
  mmPicsCnt++;
}
function mmOverOn(nm){
  for (i = 0; i < mmPicsCnt; i++) {
    if (document.images[mmPics[i][4]] != null) {
      if (nm != mmPics[i][4]) { 
        document.images[mmPics[i][4]].src = mmPics[i][0].src;
		document.images[mmPics[i][4]+'B'].src = mmPics[i][2].src;
      } else {
        document.images[mmPics[i][4]].src = mmPics[i][1].src;
		document.images[mmPics[i][4]+'B'].src = mmPics[i][3].src;
      }
	}
  }
}
function mmOverOff(){
  for (i = 0; i < mmPicsCnt; i++) {
    document.images[mmPics[i][4]].src = mmPics[i][0].src;
	document.images[mmPics[i][4]+'B'].src = mmPics[i][2].src;
  }
}

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

buPics = new Array();
buPics[0] = new Image();
buPics[0].src = 'images/sm-bulet-n.gif';
buPics[1] = new Image();
buPics[1].src = 'images/sm-bulet-o.gif';

buPicsId = new Array();
var coBuPicsId = 0;

function smInit() {
  var i;
  for(i=0; i<document.images.length; i++)
    if(document.images[i].src == buPics[0].src)
	  buPicsId[coBuPicsId++] = document.images[i].id;
}

function smOver(obj, st) {
  var i, nid, obja, objs, colorBG, colorF;
  colorF = (st) ? '#3A8064' : '#000000';
  if(!isNC4) {
    nid = obj.id + 'a';
	if(isIE)
      obja = document.all[nid];
    else
      obja = document.getElementById(nid);
	if(obja.style) objs = obja.style;
	objs.color = colorF;
  }
  nid = obj.id + 'i';
  if(st) {
    for(i=0; i<coBuPicsId; i++)
	  if(document.images[buPicsId[i]].src == buPics[1].src)
	    document.images[buPicsId[i]].src = buPics[0].src;
	  document.images[nid].src = buPics[1].src;
  }
  else {
    for(i=0; i<coBuPicsId; i++)
	  if(document.images[buPicsId[i]].src == buPics[1].src)
	    document.images[buPicsId[i]].src = buPics[0].src;
  }
}

function tmOver(obj, st) {
  var i, nid, obja, objs, colorBG, colorF;
  colorF = (st) ? '#3A8064' : '#000000';
  if(!isNC4) {
    nid = obj.id + 'a';
	if(isIE)
      obja = document.all[nid];
    else
      obja = document.getElementById(nid);
	if(obja.style) objs = obja.style;
	objs.color = colorF;
  }
}

function mmGo(url) {
  window.location = url;
}

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

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##" class="dropDiv" onMouseOver="flClose=1; cancelCloseMenuLI(); return true" onMouseOut="flClose=0; hideMenuLI(); return true"><table width="10" border="0" cellspacing="0" cellpadding="0"><tr><td width="9" class="bgTM"><img src="images/tm-cotl.gif" width="9" height="9"></td><td width="100%" class="bgTMTop"><img src="images/z.gif" width="1" height="1"></td><td width="9" class="bgTM"><img src="images/tm-cotr.gif" width="9" height="9"></td></tr><tr><td class="bgTMLeft"><img src="images/z.gif" width="1" height="1"></td><td class="bgTM"><table width="100%" border="0" cellspacing="0" cellpadding="0">##ITMS##</table></td><td class="bgTMRight"><img src="images/z.gif" width="1" height="1"></td></tr><tr><td class="bgTM"><img src="images/tm-cobl.gif" width="9" height="9"></td><td class="bgTMBottom"><img src="images/z.gif" width="1" height="1"></td><td class="bgTM"><img src="images/tm-cobr.gif" width="9" height="9"></td></tr></table></div>';

linkTempl = '<tr id="##ITID##" class="tmItemN" onMouseOver="tmOver(this, 1); return false" onMouseOut="tmOver(this, 0); return false" onClick="mmGo(\'##LINK##\'); return false"><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/z.gif" width="1" height="2"></td></tr><tr><td nowrap="nowrap" class="noBrStr"><nobr><a id="##ITID##a" href="##LINK##" class="tmItemLinkN">##TEXT##</a><nobr></td></tr><tr><td><img src="images/z.gif" width="1" height="1"></td></tr></table></td></tr>';

curLinkTempl = '<tr class="tmItemC"><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/z.gif" width="1" height="2"></td></tr><tr><td nowrap="nowrap" class="noBrStr"><nobr><span class="tmItemLinkC">##TEXT##</a><nobr></td></tr><tr><td><img src="images/z.gif" width="1" height="1"></td></tr></table></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] + 'a');
  }
}

function showMenuLI(mItemName) {
  var i, p, mPosX, mPosY;
  imPos = new Array();
  for(i=0; i<coM; i++) {
    if(mItemName != upMenu[i][0]) {
      if(upMenu[i][1].isExist()) upMenu[i][1].hide();
    }
    else {
      cancelCloseMenuLI();
      if(upMenu[i][1].isExist()) {
        mPosX = upMenu[i][2].getAbsoluteLeft() + upMenu[i][2].getWidth() + 3;
        if(mPosX + upMenu[i][1].getWidth() > getWindowWidth())
          if((mPosX = getWindowWidth() - upMenu[i][1].getWidth()) < 0) mPosX = 0;
        mPosY = upMenu[i][2].getAbsoluteTop() + (upMenu[i][2].getHeight() / 2);
        if(mPosY + upMenu[i][1].getHeight() > getWindowHeight())
          if((mPosY = (imPos[1] - 24 < 0)) < 0) mPosY = 0;
        upMenu[i][1].moveTo(mPosX, mPosY);
        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].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);
