// reflow page for correct cross-browser footer positioning

function reflow() {
    var bodydiv = document.getElementById("body");
    if (bodydiv != null) {
        bodydiv.style.minHeight = "100%";
    }
}



// workaround for absence of target attributes in xhtml strict

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}



function inputFocus(input, value) {
    if (input.value == value)
        input.value = "";
}
function inputBlur(input, value) {
    if (input.value == "")
        input.value = value;
}
function validateMailingList() {
	var aMsg = new Array();
	var aMandatory = new Array('Name','Email');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == aMandatory[i]) {
			bMissing = true;
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all fields';

	var fEmail = document.getElementById('Email');
	var sEmail = fEmail.value;
	if (sEmail != 'Email' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



// create country select

function createCtrySelect(name) {
   var ctrySelect = '<select name="' + name + '" id="' + name + '">';
   ctrySelect += '<option value="">Select one</option>';

   var countries = new Array("Albania", "Algeria", "Argentina", "Armenia", "Australia", "Austria", "Belarus", "Belgium", "Brazil", "Bulgaria",
"Canada", "Chile", "China", "Cyprus", "Czech", "Denmark", "Finland", "France", "Georgia", "Germany",
"Greece", "Hong Kong", "Hungary", "India", "Indonesia", "Ireland", "Israel", "Italy", "Japan", "Korea, North",
"Korea, Republic of", "Latvia", "Lithuania", "Luxemburg", "Malaysia", "Maldives", "Mexico", "Moldova, Republic of", "Netherlands", "New Zealand",
"Norway", "Pakistan", "Philippines", "Poland", "Portugal", "Romania", "Russian Federation", "Singapore", "Slovakia", "Slovenia",
"South Africa", "Spain", "Sweden", "Switzerland", "Taiwan", "Thailand", "Tunisia", "Turkey", "Ukraine", "United Kingdom",
"United States", "Uruguay");

   for (var i = 0; i < countries.length; i++) {
      ctrySelect += '<option value="' + countries[i] + '">' + countries[i] + '</option>';
   }
   ctrySelect += '</select>';
   document.write(ctrySelect);
}



function toggle(id) {
   var item = document.getElementById(id);

   if (item.style.display == "block")
      item.style.display = "none";
   else
      item.style.display = "block";
}



function validateAdmin() {
	var aMsg = new Array();
	var aMandatory = new Array('admUsername','admEmail','admFirstName','admLastName');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fUsername = document.getElementById('admUsername');
	var sUsername = fUsername.value;
	if (sUsername != '' && (sUsername.length < 4 || sUsername.length > 16)) {
		aMsg[aMsg.length] = 'Username should be between 4 to 16 characters';
		highlightLabel(fUsername.previousSibling);
	}

	var fPassword1 = document.getElementById('admPassword1');
	var sPassword1 = fPassword1.value;
	if (sPassword1 != '' && (sPassword1.length < 8 || sPassword1.length > 32)) {
		aMsg[aMsg.length] = 'Password should be between 8 to 32 characters';
		highlightLabel(fPassword1.previousSibling);
	}

	var fPassword2 = document.getElementById('admPassword2');
	var sPassword2 = fPassword2.value;
	if (sPassword2 != sPassword1) {
		aMsg[aMsg.length] = 'Passwords do not match';
		highlightLabel(fPassword2.previousSibling);
	}

	var fEmail = document.getElementById('admEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email should be less than 255 characters';
		highlightLabel(fEmail.previousSibling);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	var fFirstName = document.getElementById('admFirstName');
	var sFirstName = fFirstName.value;
	if (sFirstName != '' && sFirstName.length > 64) {
		aMsg[aMsg.length] = 'First name should be less than 64 characters';
		highlightLabel(fFirstName.previousSibling);
	}

	var fLastName = document.getElementById('admLastName');
	var sLastName = fLastName.value;
	if (sLastName != '' && sLastName.length > 64) {
		aMsg[aMsg.length] = 'Last name should be less than 64 characters';
		highlightLabel(fLastName.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateUser() {
	var aMsg = new Array();
	var aMandatory = new Array('userUsername','userPassword1','userPassword2');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fUsername = document.getElementById('userUsername');
	var sUsername = fUsername.value;
	if (sUsername != '' && (sUsername.length > 16)) {
		aMsg[aMsg.length] = 'Username should be less than 16 characters';
		highlightLabel(fUsername.previousSibling);
	}

	var fPassword1 = document.getElementById('userPassword1');
	var sPassword1 = fPassword1.value;
	if (sPassword1 != '' && (sPassword1.length > 32)) {
		aMsg[aMsg.length] = 'Password should be less than 32 characters';
		highlightLabel(fPassword1.previousSibling);
	}

	var fPassword2 = document.getElementById('userPassword2');
	var sPassword2 = fPassword2.value;
	if (sPassword2 != sPassword1) {
		aMsg[aMsg.length] = 'Passwords do not match';
		highlightLabel(fPassword2.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateArticle(type) {
	var aMsg = new Array();
	var aMandatory = new Array('artTitle','artText');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fTitle = document.getElementById('artTitle');
	var sTitle = fTitle.value;
	if (sTitle != '' && sTitle.length > 255) {
		aMsg[aMsg.length] = 'Title should be less than 255 characters';
		highlightLabel(fTitle.previousSibling);
	}

	if (type == 'all') {
		var fFile = document.getElementById('fileUpload');
		var sFile = fFile.value;
		if (sFile != '' && !validatePdfExt(sFile)) {
			aMsg[aMsg.length] = 'File to be uploaded should be a PDF file';
			highlightLabel(fFile.previousSibling);
		}
		else if (sFile != '') {
			var fFileTitle = document.getElementById('fileTitle');
			var sFileTitle = fFileTitle.value;
			if (sFileTitle == '') {
				aMsg[aMsg.length] = 'Please fill in all mandatory fields';
				highlightLabel(fFileTitle.previousSibling);
			}
			else if (sFileTitle != '' && sFileTitle.length > 255) {
				aMsg[aMsg.length] = 'File title should be less than 255 characters';
				highlightLabel(fFileTitle.previousSibling);
			}
		}
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateFile(type) {
	var aMsg = new Array();
	if (type == 'all')
		var aMandatory = new Array('fileTitle','fileUpload');
	else
		var aMandatory = new Array('fileTitle');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fFileTitle = document.getElementById('fileTitle');
	var sFileTitle = fFileTitle.value;
	if (sFileTitle != '' && sFileTitle.length > 255) {
		aMsg[aMsg.length] = 'File title should be less than 255 characters';
		highlightLabel(fFileTitle.previousSibling);
	}

	if (type == 'all') {
		var fFile = document.getElementById('fileUpload');
		var sFile = fFile.value;
		if (sFile != '' && !validatePdfExt(sFile)) {
			aMsg[aMsg.length] = 'File to be uploaded should be a PDF file';
			highlightLabel(fFile.previousSibling);
		}
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateSubscribe() {
	var aMsg = new Array();
	var aFields = new Array('subEmail','subFirstName','subLastName','countryID');
	var aMandatory = new Array('countryID');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aFields.length; i++) {
		currField = document.getElementById(aFields[i]);
		unhighlightElement(currField);
	}

	var fEmail = document.getElementById('subEmail');
	var sEmail = fEmail.value;
	if (sEmail == 'Email') {
		bMissing = true;
		highlightElement(fEmail);
	}
	else if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email should be less than 255 characters';
		highlightElement(fEmail);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
		highlightElement(fEmail);
	}

	var fFirstName = document.getElementById('subFirstName');
	var sFirstName = fFirstName.value;
	if (sFirstName == 'First Name') {
		bMissing = true;
		highlightElement(fFirstName);
	}
	else if (sFirstName != '' && sFirstName.length > 64) {
		aMsg[aMsg.length] = 'First Name should be less than 64 characters';
		highlightElement(fFirstName);
	}

	var fLastName = document.getElementById('subLastName');
	var sLastName = fLastName.value;
	if (sLastName == 'Last Name') {
		bMissing = true;
		highlightElement(fLastName);
	}
	else if (sLastName != '' && sLastName.length > 64) {
		aMsg[aMsg.length] = 'Last Name should be less than 64 characters';
		highlightElement(fLastName);
	}

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightElement(currField);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateUnsubscribe() {
	var aMsg = new Array();
	var aMandatory = new Array('subEmail');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		unhighlightElement(currField);
	}

	var fEmail = document.getElementById('subEmail');
	var sEmail = fEmail.value;
	if (sEmail == 'Email') {
		bMissing = true;
		highlightElement(fEmail);
	}
	else if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email should be less than 255 characters';
		highlightElement(fEmail);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
		highlightElement(fEmail);
	}

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightElement(currField);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateAddressee() {
	var aMsg = new Array();
	var aMandatory = new Array('productID','addEmail');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fEmail = document.getElementById('addEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email Address should be less than 255 characters';
		highlightLabel(fEmail.previousSibling);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email Address is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateServiceRequest() {
	var aMsg = new Array();
	var aMandatory = new Array();
	var bMissing = false;
	var currField = '';

	resetLabels();

	var fProductName = document.getElementById('productName');
	var sProductName = fProductName.value;
	if (sProductName == 'Stamping Toolings Design Support')
		aMandatory = new Array('productName','sDateDay','sDateMonth','sDateYear','sCompany','sName','sPosition','sEmail','sContactNo','sLocation','sProductName','sProjectNo','sWarrantyEndDateDay','sWarrantyEndDateMonth','sWarrantyEndDateYear','sRequestorName','sDetails');
	else
		aMandatory = new Array('productName','sDateDay','sDateMonth','sDateYear','sCompany','sName','sPosition','sEmail','sContactNo','sLocation','sProductName','sProjectNo','sWarrantyEndDateDay','sWarrantyEndDateMonth','sWarrantyEndDateYear','sCustMachineNo','sRequestorName','sDetails');

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			if (aMandatory[i].indexOf('sDate') != -1)
				highlightLabel(document.getElementById('sDateDay').previousSibling);
			else if (aMandatory[i].indexOf('sWarrantyEndDate') != -1)
				highlightLabel(document.getElementById('sWarrantyEndDateDay').previousSibling);
			else
				highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fDateDay = document.getElementById('sDateDay');
	var sDateDay = fDateDay.value;
	if (sDateDay != '' && (!validateNumber(sDateDay) || sDateDay < 1 || sDateDay > 31)) {
		aMsg[aMsg.length] = 'Day field of Date should be a number between 1 to 31';
		highlightLabel(fDateDay.previousSibling);
	}

	var fDateMonth = document.getElementById('sDateMonth');
	var sDateMonth = fDateMonth.value;
	if (sDateMonth != '' && (!validateNumber(sDateMonth) || sDateMonth < 1 || sDateMonth > 12)) {
		aMsg[aMsg.length] = 'Month field of Date should be a number between 1 to 12';
		highlightLabel(fDateDay.previousSibling);
	}

	var fDateYear = document.getElementById('sDateYear');
	var sDateYear = fDateYear.value;
	if (sDateYear != '' && (!validateNumber(sDateYear) || sDateYear < 1980 || sDateYear > 2099)) {
		aMsg[aMsg.length] = 'Year field of Date should be a number between 1980 to 2099';
		highlightLabel(fDateDay.previousSibling);
	}

	var fEmail = document.getElementById('sEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email Address is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	var fWarrantyEndDateDay = document.getElementById('sWarrantyEndDateDay');
	var sWarrantyEndDateDay = fWarrantyEndDateDay.value;
	if (sWarrantyEndDateDay != '' && (!validateNumber(sWarrantyEndDateDay) || sWarrantyEndDateDay < 1 || sWarrantyEndDateDay > 31)) {
		aMsg[aMsg.length] = 'Day field of Warranty End Date should be a number between 1 to 31';
		highlightLabel(fWarrantyEndDateDay.previousSibling);
	}

	var fWarrantyEndDateMonth = document.getElementById('sWarrantyEndDateMonth');
	var sWarrantyEndDateMonth = fWarrantyEndDateMonth.value;
	if (sWarrantyEndDateMonth != '' && (!validateNumber(sWarrantyEndDateMonth) || sWarrantyEndDateMonth < 1 || sWarrantyEndDateMonth > 12)) {
		aMsg[aMsg.length] = 'Month field of Warranty End Date should be a number between 1 to 12';
		highlightLabel(fWarrantyEndDateDay.previousSibling);
	}

	var fWarrantyEndDateYear = document.getElementById('sWarrantyEndDateYear');
	var sWarrantyEndDateYear = fWarrantyEndDateYear.value;
	if (sWarrantyEndDateYear != '' && (!validateNumber(sWarrantyEndDateYear) || sWarrantyEndDateYear < 1980 || sWarrantyEndDateYear > 2099)) {
		aMsg[aMsg.length] = 'Year field of Warranty End Date should be a number between 1980 to 2099';
		highlightLabel(fWarrantyEndDateDay.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateEmail(email) {
	var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (regex.test(email))
		return true;
	else
		return false;
}

function validatePdfExt(filename) {
	var dotIndex = filename.lastIndexOf('.');
	var extension = '';

	if (dotIndex != -1) {
		extension = filename.substring(dotIndex+1);
		extension = extension.toLowerCase();
		if (extension == 'pdf')
			return true;
		else
			return false;
	}
	else
		return false;
}

function validateNumber(txt) {
	var regex = /^\d+$/;

	if (regex.test(txt))
		return true;
	else
		return false;
}



function resetLabels() {
	var labels = document.getElementsByTagName('label');
	var currLabel = '';

	for (var i = 0; i < labels.length; i++) {
		currLabel = labels[i];
		currLabel.style.color = '';
	}
}

function highlightLabel(label) {
	if (label.nodeName.toLowerCase() == 'label') {
		label.style.color = 'red';
	}
}

function unhighlightElement(elem) {
	elem.style.color = '';
}

function highlightElement(elem) {
	elem.style.color = 'red';
}



/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var menu_ir=new Array()
//menu_ir[0]='<a href="ir_stock.html">Stock Price &amp; Charts</a>'
menu_ir[1]='<a href="ir_message.html">Group MD Message</a>'
menu_ir[2]='<a href="ir_directors.html">Board of Directors</a>'
menu_ir[3]='<a href="ir_analyst.html">Analyst Report</a>'
menu_ir[4]='<a href="ir_financial.html">Financial Reports</a>'
//menu_ir[5]='<a href="ir_shareholders.html">Substantial Shareholders</a>'
//menu_ir[6]='<a href="ir_insider.html">Insider Trading Rules<br />[for Employees Only]</a>'
//menu_ir[7]='<a href="ir_esos.html">Employee Share Option Scheme (ESOS)<br />[for Employees Only]</a>'
menu_ir[8]='<a href="news.php">Latest News</a>'
menu_ir[9]='<a href="http://rokko.listedcompany.com/newsroom.html">SGX Corporate Filings</a>'
menu_ir[10]='<a href="subscribe.php">Email Alert</a>'
menu_ir[11]='<a href="ir_contact.html">IR Contact</a>'

var menu_about=new Array()
menu_about[0]='<a href="about.html">Corporate Profile</a>'
//menu_about[1]='<a href="about_mission.html">Mission and Vision</a>'
//menu_about[2]='<a href="about_milestones.html">Corporate Milestones</a>'
menu_about[3]='<a href="about_certsawards.html">Certificates and Awards</a>'

var menu_careers=new Array()
menu_careers[0]='<a href="careers.html">Careers</a>'
menu_careers[1]='<a href="ir_insider.html">Insider Trading Rules<br />[for Employees Only]</a>'
menu_careers[2]='<a href="ir_esos.html">Employee Share Option Scheme (ESOS)<br />[for Employees Only]</a>'

// use menu_sub_[submenu name] for subsidiary sites, so that relative link path is correct
// specially added for /rokkotv

var menu_sub_ir=new Array()
//menu_sub_ir[0]='<a href="../ir_stock.html">Stock Price &amp; Charts</a>'
menu_sub_ir[1]='<a href="../ir_message.html">Group MD Message</a>'
menu_sub_ir[2]='<a href="../ir_directors.html">Board of Directors</a>'
menu_sub_ir[3]='<a href="../ir_analyst.html">Analyst Report</a>'
menu_sub_ir[4]='<a href="../ir_financial.html">Financial Reports</a>'
//menu_sub_ir[5]='<a href="../ir_shareholders.html">Substantial Shareholders</a>'
//menu_sub_ir[6]='<a href="../ir_insider.html">Insider Trading Rules<br />[for Employees Only]</a>'
//menu_sub_ir[7]='<a href="../ir_esos.html">Employee Share Option Scheme (ESOS)<br />[for Employees Only]</a>'
menu_sub_ir[8]='<a href="../news.php">Latest News</a>'
menu_sub_ir[9]='<a href="http://rokko.listedcompany.com/newsroom.html">SGX Corporate Filings</a>'
menu_sub_ir[10]='<a href="../subscribe.php">Email Alert</a>'
menu_sub_ir[11]='<a href="../ir_contact.html">IR Contact</a>'

var menu_sub_about=new Array()
menu_sub_about[0]='<a href="../about.html">Corporate Profile</a>'
//menu_sub_about[1]='<a href="../about_mission.html">Mission and Vision</a>'
//menu_sub_about[2]='<a href="../about_milestones.html">Corporate Milestones</a>'
menu_sub_about[3]='<a href="../about_certsawards.html">Certificates and Awards</a>'

var menu_sub_careers=new Array()
menu_sub_careers[0]='<a href="../careers.html">Careers</a>'
menu_sub_careers[1]='<a href="../ir_insider.html">Insider Trading Rules<br />[for Employees Only]</a>'
menu_sub_careers[2]='<a href="../ir_esos.html">Employee Share Option Scheme (ESOS)<br />[for Employees Only]</a>'

var menuwidth='100px' //default menu width
var menubgcolor='#DD2B14'  //menu bgcolor
var disappeardelay=100000  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="no" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu



/***********************************************
* Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var home_banner=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
home_banner[0]=["pics/banner_1.jpg", "", ""]
home_banner[1]=["pics/banner_2.jpg", "", ""]
home_banner[2]=["pics/banner_3.jpg", "", ""]

// use home_banner_sub for subsidiary sites, so that relative image path is correct

var home_banner_sub=new Array()
home_banner_sub[0]=["../pics/banner_1.jpg", "", ""]
home_banner_sub[1]=["../pics/banner_2.jpg", "", ""]
home_banner_sub[2]=["../pics/banner_3.jpg", "", ""]

var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["photo1.jpg", "", ""] //plain image syntax
fadeimages2[1]=["photo2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
fadeimages2[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax

var fadebgcolor="#16486B"

////NO need to edit beyond here/////////////

var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers

var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all

function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}

var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2

if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')

if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}

fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}


fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}

fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}


fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}



// run all necessary functions on page load

function loadAll() {
   reflow();
   externalLinks();
}
window.onload = loadAll;