function showCode(num, linkEl)
{
	codeEl = document.getElementById('code' + num);
	codeEl.style.display = codeEl.style.display=='block'?'none':'block';
}



var ns = (navigator.appName == 'Netscape');
var ie = (navigator.appName == 'Microsoft Internet Explorer');
var ns4 = (ns && parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5);
var ie4 = (ie && parseInt(navigator.appVersion) >= 4);
var ns5 = (ns && parseInt(navigator.appVersion) >= 5);
var oper = (window.opera != null);

var DOCloaded = true;
var FormArray = new Array();
var prev;

cOBJ = "object";
cUNDEF = "undefined";
var fuLYOFF = 0;

function ViewProp(obj) {
  var str;
  for (var propName in obj) {
   if (obj[propName])
   str +=propName+"="+obj[propName]+"<br>";
  }
  var win = window.open();
  win.document.writeln(str);
}

function AreaWidth(){
	return getCurrentWinWidth();
}

function AreaHeight(){
	return getCurrentWinHeight();
}

function LMoveTo(ly,X,Y){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) moveEltTo(el, X, Y);
}

function LMoveBy(ly,X,Y){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) moveEltBy(el, X, Y);
}

function LGetX(ly){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) return getEltPageLeft(el);
}

function LGetY(ly){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) return getEltPageTop(el);
}

function LShow(ly){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) showElt(el);
}

function LGetVis(ly){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) return getEltVisibility(el);
}

function LHide(ly){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) hideElt(el);
}

function LSetClip(ly,l,t,r,b){
	if (typeof(ly) == cOBJ) el = ly; else el = getElt(ly);
	if (el && typeof(el) != cUNDEF) setEltClip (el, t, r, b, l);
}

var layertimer = 0;
var lastmenues;
var active = 0;

function killMenus(strWen){
	lastmenues=null;
	if (arguments.length == 2 && arguments[1] == "now") showMenus(strWen, 'off');
	else layertimer = setTimeout("showMenus('"+strWen+"', 'off')", 1000);
	return false;
}

function showMenus(strWen, strStatus, strCoord) {
	if(strStatus == "on"){
		if(layertimer){ clearTimeout(layertimer);}
		layertimer = 0;
	}
	var tempWen = strWen.split(",");
	var strOut="";

	if(DOCloaded){
		clearTimeout(active);
		if(lastmenues && lastmenues!=strWen){
			tempLastmenues = lastmenues.split(",");
			for (i=0;i<tempLastmenues.length;i++) { LHide(tempLastmenues[i]); }
			lastmenues = null;
		}
		if(strStatus=="on"){
		    if(strCoord!=null && strCoord!="") tempCoord = strCoord.split("|");
			tempActualLayers=strWen.split(",");
			for (i=0;i<tempWen.length;i++){
				if(strCoord!=null && strCoord!=""){
				    T = tempCoord[i].split(",");
				    if (T[0]!="" && T[1]!="") LMoveTo(tempActualLayers[i], T[0], T[1]);
				}
				LShow(tempActualLayers[i]);
          }
			lastmenues = strWen;
		}
		if(strStatus=="off"){
			tempActualLayers=strWen.split(",");
			for (i=0;i<tempWen.length;i++) LHide(tempActualLayers[i]);
		}
	} else {
		active = setTimeout("showMenus('" + strWen + "','" + strStatus + "','"+strCoord+")",2000);
	}
	return false;
}

function changeColorON(id) {
	if (typeof(id) == cOBJ) el = id;
	else el = getElt(id);
	if (typeof(el) != cUNDEF) setEltBackgroundColor(el, "#A1B57D");
	el = getElt('d' + id);
	if (typeof(el) != cUNDEF && el) el.src = "/images/image1.gif";
	el = getElt('a' + id);
	if (typeof(el) != cUNDEF && el) setEltColor(el, "White");
}

function changeColorOFF(id) {
	if (typeof(id) == cOBJ) el = id; else el = getElt(id);
	if (typeof(el) != cUNDEF) setEltBackgroundColor(el, "#D9E1CB");
	el = getElt('d' + id);
	if (typeof(el) != cUNDEF && el) el.src = "/images/image3.gif";
	el = getElt('a' + id);
	if (typeof(el) != cUNDEF && el) setEltColor(el, "#567341");
}

function changeBgColor(e,c) {
	var ae = e.split(","), ac = c.split(","), el;
	for (i=0;i<ae.length;i++) {
		el = getElt(ae[i]);
		if (typeof(el) != cUNDEF) setEltBackgroundColor(el, ac[i]);
	}
}

function show(a,id,layer,idt) {
	clearTimeout(layertimer);
	if (!idt) {idt = id};
	changeColorON(idt);
	var tempWen = a.split(",");
	var lx = 0, ly = 0, mx = '';
	for (i = 0; i < tempWen.length; i++) {
		aw = true;
		if (!i && tempWen[i].substr(1) == id.substr(1)) {
			el = getElt(id);
		} else if (!i && tempWen[i] == layer) {
			el = getElt(layer);
			aw = false;
		} else {
			el = getElt(tempWen[i]);
		}
		if (typeof(el) != cUNDEF) {
			if (!i) {
				lx = getEltPageLeft(el);
				ly = getEltPageTop(el);
			}
			if (aw) lx += getEltWidth(el) + ((ns4 && !i) ? 5 : 3);
			if (tempWen[i].substr(1) == id.substr(1)) {
				el = getElt(id);
				if (typeof(el) != cUNDEF) {
				    ly = getEltPageTop(el);
				}
			}
			aly = ly;
			if (arguments.length > 4 && i && arguments[4] && typeof(arguments[4].y) != cUNDEF) fuLYOFF = arguments[4].y
			if (i) aly += fuLYOFF;
			mx += lx + "," + aly;
			if (i + 1 < tempWen.length) mx += "|";
		}
	}
	//alert(a + ";" + id + ";" + layer + ";" + idt + "; = " + mx);
	HideAll(a);
	showMenus(a,'on',mx);
}

function Check(this1,type) {
  if (this1) {
   if ((this1.value.indexOf('@') != -1 && this1.value.indexOf('.') != -1)
	|| (this1.value.length && type == 'notnull')) {
    for(var j = 0;j < FormArray.length;j++) {
     if(FormArray[j] == this1) {
      FormArray[j] = 0;
     }
    }
    return true;
   } else {
    if (prev != this1 ) {
     window.alert((type == 'notnull') ? 'Field must be filled.' : 'Not valid EMail value');
     prev = this1;
    }
    for(var j = 0;j < FormArray.length;j++) {
     if(FormArray[j] == this1) {return true;}
    }
    FormArray[FormArray.length] = this1;
    return true;
   }
  } else {
   window.alert("Called for unsipported element");
   return true;
  }
}

function SubmitForm() {
  for(var i = 0;i< 100;i++) {
   if (document.forms[0].elements[i]) {
    if ((!document.forms[0].elements[i].value) && document.forms[0].elements[i].onblur) {
     window.alert("One or more required field do not filled. ");
     return false;
    }
   }
  }
  for(var i = 0;i< FormArray.length;i++) {
   if (FormArray[i]) {
    window.alert("Check this field.");
    FormArray[i].focus();
    return false;
   }
  }
  return true;
}
