if (top.location != location) top.location.href = document.location.href;

var w3c = (document.getElementById) ? 1:0
var ns4 = (document.layers) ? 1:0
var ie4 = (document.all) ? 1:0
var ver4 = (parseInt(navigator.appVersion) >= 4) ? true: false;

var p="img/nav/",s=new Array("_out.png","_over.png");

for(i in Array("front","about","my","newsdesk","object_browser")) {
	eval(""+this[i]+"=new Image();"+this[i]+".src='"+p+this[i]+s[1]+"'");
}

function m(i,n) {
  if (document.getElementById) document.getElementById(i).src=p+i+s[n];
  else document.images[i].src=p+i+s[n];
	window.status='';return true
}

function checkSForm() {
	x = document.searchForm;
	returnVal = true;
	if ((x.q.value.length < 2) || x.q.value == '[ Enter search keywords ]') returnVal = false;
	return returnVal;
}

function popupWin(url,w,h,opt) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	if (!opt) {
		winprops = 'width='+w+',height='+h+',left='+winl+',top='+wint+',scrollbars=0,status=0'
	} else if (opt == "s") {
		winprops = 'width='+w+',height='+h+',left='+winl+',top='+wint+',scrollbars=yes,status=0'
	} else if (opt == "rs") {
		winprops = 'width='+w+',height='+screen.height+',left='+winl+',top='+wint+',scrollbars=yes,status=0,resizable=1'
	}
	var win4=window.open(url,"modern_dk_curr",winprops);
	if (parseInt(navigator.appVersion) >= 4) { win4.window.focus(); }
}
function showDiv(whatDiv) {
	if (w3c) {
		document.getElementById(whatDiv).style.visibility='visible';
	} else if (ns4) {
		whatDiv.visibility='show';
	} else if (ie4) {
		document.all.whatDiv.style.visibility='visible';
	}
}

function hideDiv(whatDiv) {
	if (w3c) {
		document.getElementById(whatDiv).style.visibility='hidden';
	} else if (ns4) {
		whatDiv.visibility='hide';
	} else if (ie4) {
		document.all.whatDiv.style.visibility='hidden';
	}
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,5}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

var retVal=true;
function checkForm() {
	retVal=true;
	if (!isEmail(document.forms.sendForm.temail.value)) {
		if (ie4||w3c) { document.forms.sendForm.temail.style.background = "#ffdddd"; }
		retVal=false;
	} else {
		if (ie4||w3c) { document.forms.sendForm.temail.style.background = "#ebede9";}
	}
	if (!isEmail(document.forms.sendForm.femail.value)) {
		if (ie4||w3c) { document.forms.sendForm.femail.style.background = "#ffdddd"; }
		retVal=false;
	} else {
		if (ie4||w3c) { document.forms.sendForm.femail.style.background = "#ebede9";}
	}
	return retVal;
}

function checkIForm() {
	retVal=true;
	if (!isEmail(document.forms.inquireForm.femail.value)) {
		if (ie4||w3c) { document.forms.inquireForm.femail.style.background = "#ffdddd"; }
		retVal=false;
	} else {
		if (ie4||w3c) { document.forms.inquireForm.femail.style.background = "#ebede9";}
	}
	if (document.forms.inquireForm.fname.value.length < 3) {
		if (ie4||w3c) { document.forms.inquireForm.fname.style.background = "#ffdddd"; }
		retVal=false;
	} else {
		if (ie4||w3c) { document.forms.inquireForm.fname.style.background = "#ebede9";}
	}
	return retVal;
}

var limit=255;
function textCounter(field) {
	if (field.value.length > limit) field.value = field.value.substring(0,limit);
}