
var linkColors = new Array (
	/*         type         out        over, out speed, over speed*/
	new Array('leftMenu', '#FFFFFF', '#AAAAAA', '12', '12'), 
	new Array('topMenu', '#87ABC6', '#FFFFFF', '8', '8'), 
	new Array('normal', '#013C66', '#000000', '4', '10'), 
	new Array('webcast', '#CCCCCC', '#FFFFFF', '4', '10'), 
	new Array('downloads', '#CCCCCC', '#FFFFFF', '4', '10')
);

function unobJs() {
	if (bytefxLoaded == false) {
		setTimeout("unobJs()", 250);
		return false;
	}
	addEvent(window, 'load', setupLinks);
	addEvent(window, 'load', setupUnderlineLinks);
	addEvent(window, 'load', setupDeltaHrs);
}
				
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	}
	else if (obj.attachEvent) { 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} 
	else { 
		return false; 
	} 
}

function setupLinks() {
	if (!document.getElementsByTagName) { return; }
	var defaultFadeOverSpeed = 10;
	var defaultFadeOutSpeed = 10;
	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		anchor = anchors[i];
		if (anchor.getAttribute("href") && (anchor.getAttribute("link"))) {
			for (j = 0; j < linkColors.length; j++) {
				if (linkColors[j][0] == anchor.getAttribute("link")) {
					anchor.setAttribute('outColor', linkColors[j][1]);
					anchor.setAttribute('overColor', linkColors[j][2]);
					anchor.setAttribute('speedOut', linkColors[j][3]);
					anchor.setAttribute('speedOver', linkColors[j][4]);
					if (anchor.getAttribute("link") == 'leftMenu') {
						anchor.onmouseover = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('outColor'), this.getAttribute('overColor'), parseInt(this.getAttribute('speedOver')), null); bytefx.color(this.parentNode, 'background', '#963745', '#003C66', parseInt(this.getAttribute('speedOver')), null); } };
						anchor.onmouseout = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('overColor'), this.getAttribute('outColor'), parseInt(this.getAttribute('speedOut')), null); bytefx.color(this.parentNode, 'background', '#003C66', '#963745', parseInt(this.getAttribute('speedOut')), function() { this.style.background = "none"; this.style.background = "url(img/menu_square.gif)"; this.style.backgroundRepeat = "no-repeat"; }); } };
						if (typeof bytefx != 'undefined') {
							bytefx.color(anchor, 'color', anchor.getAttribute('outColor'), anchor.getAttribute('outColor'), 100, null); 
							bytefx.color(anchor.parentNode, 'background', '#963745', '#963745', 100, function() { this.style.background = "none"; this.style.background = "url(img/menu_square.gif)"; this.style.backgroundRepeat = "no-repeat"; });
						}
					}
					else if (anchor.getAttribute("link") == 'topMenu') {
						anchor.onmouseover = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('outColor'), this.getAttribute('overColor'), parseInt(this.getAttribute('speedOver')), null); this.parentNode.style.background = "url(img/delta_logo_mini_over.gif)"; this.parentNode.style.backgroundRepeat = "no-repeat"; } };
						anchor.onmouseout = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('overColor'), this.getAttribute('outColor'), parseInt(this.getAttribute('speedOut')), null); bytefx.color(this.parentNode, 'background', '#003C66', '#013C66', parseInt(this.getAttribute('speedOut')), function() { this.style.background = "none"; this.style.background = "url(img/delta_logo_mini.gif)"; this.style.backgroundRepeat = "no-repeat"; }); } };
						if (typeof bytefx != 'undefined') {
							bytefx.color(anchor, 'color', anchor.getAttribute('outColor'), anchor.getAttribute('outColor'), 100, null); 
							bytefx.color(anchor.parentNode, 'background', '#013C66', '#013C66', 100, function() { this.style.background = "none"; this.style.background = "url(img/delta_logo_mini.gif)"; this.style.backgroundRepeat = "no-repeat"; });
						}
					}
					else if (anchor.getAttribute("link") == 'webcast') {
						anchor.onmouseover = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('outColor'), this.getAttribute('overColor'), parseInt(this.getAttribute('speedOver')), null); bytefx.color(this, 'background', '#963745', '#6F2933', parseInt(this.getAttribute('speedOver')), null); } };
						anchor.onmouseout = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('overColor'), this.getAttribute('outColor'), parseInt(this.getAttribute('speedOut')), null); bytefx.color(this, 'background', '#6F2933', '#963745', parseInt(this.getAttribute('speedOut')), function() { this.style.background = "none"; }); } };
						if (typeof bytefx != 'undefined') {
							bytefx.color(anchor, 'color', anchor.getAttribute('outColor'), anchor.getAttribute('outColor'), 100, null); 
							bytefx.color(anchor, 'background', '#963745', '#963745', 100, function() { this.style.background = "none"; });
						}
					}
					else if (anchor.getAttribute("link") == 'downloads') {
						anchor.onmouseover = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('outColor'), this.getAttribute('overColor'), parseInt(this.getAttribute('speedOver')), null); bytefx.color(this, 'background', '#963745', '#6F2933', parseInt(this.getAttribute('speedOver')), null); } };
						anchor.onmouseout = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('overColor'), this.getAttribute('outColor'), parseInt(this.getAttribute('speedOut')), null); bytefx.color(this, 'background', '#6F2933', '#963745', parseInt(this.getAttribute('speedOut')), function() { this.style.background = "none"; }); } };
						if (typeof bytefx != 'undefined') {
							bytefx.color(anchor, 'color', anchor.getAttribute('outColor'), anchor.getAttribute('outColor'), 100, null); 
							bytefx.color(anchor, 'background', '#963745', '#963745', 100, function() { this.style.background = "none"; });
						}
					}
					else if (anchor.getAttribute("link") == 'normal') {
						anchor.onmouseover = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('outColor'), this.getAttribute('overColor'), parseInt(this.getAttribute('speedOver')), null); bytefx.color(this, 'background', '#FFFFFF', '#ddefff', parseInt(this.getAttribute('speedOver')), null); } };
						anchor.onmouseout = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('overColor'), this.getAttribute('outColor'), parseInt(this.getAttribute('speedOut')), null); bytefx.color(this, 'background', '#ddefff', '#FFFFFF', parseInt(this.getAttribute('speedOut')), function() { this.style.background = "none"; }); } };
						if (typeof bytefx != 'undefined') {
							bytefx.color(anchor, 'color', anchor.getAttribute('outColor'), anchor.getAttribute('outColor'), 100, null); 
							bytefx.color(anchor, 'background', '#FFFFFF', '#FFFFFF', 100, function() { this.style.background = "none"; });
						}
					}
					else {
						anchor.onmouseover = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('outColor'), this.getAttribute('overColor'), defaultFadeOverSpeed, null); } };
						anchor.onmouseout = function () { if (typeof bytefx != 'undefined') { bytefx.color(this, 'color', this.getAttribute('overColor'), this.getAttribute('outColor'), defaultFadeOutSpeed, null); } };
						if (typeof bytefx != 'undefined') {
							bytefx.color(anchor, 'color', anchor.getAttribute('outColor'), this.getAttribute('outColor'), defaultFadeOutSpeed, null);
						}
					}
					break;
				}
			}
		}
	}
}

function setupUnderlineLinks() {
	if (!document.getElementsByTagName) { return; }
	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		anchor = anchors[i];
		if (anchor.getAttribute("href") && (anchor.getAttribute("underline")) && (anchor.getAttribute("underline") == "true")) {
			anchor.style.textDecoration = 'underline';
		}
	}
}

function setupDeltaHrs() {
	if (!document.getElementsByTagName) { return; }
	var imgs = document.getElementsByTagName("img");
	for (var i = 0; i < imgs.length; i++) {
		img = imgs[i];
		if (img.getAttribute("deltahr") == 'deltahr') {
			img.src = 'img/delta_hr.gif';
			img.style.display = 'inline';
			img.style.width = '638px';
			img.style.height = '27px';
			img.style.border = 'none';
			img.style.margin = '10px 0px 0px 0px';
		}
	}
}

function toggle(what) {
	if (document.getElementById(what).style.display == 'none') {
		document.getElementById(what).style.display = 'block';
	}
	else {
		document.getElementById(what).style.display = 'none';
	}
}

function hide(what) {
	if (document.getElementById(what).style.display != 'none') {
		document.getElementById(what).style.display = 'none';
	}
}

function show(what) {
	if (document.getElementById(what).style.display != 'block') {
		document.getElementById(what).style.display = 'block';
	}
}

function killUlDiscs(where) {
	var uls = document.getElementsByTagName("ul");
	var killTheseUls = Array();
	for (var i = 0; i < uls.length; i++) {
		if (uls[i].parentNode.id == where) {
			killTheseUls[killTheseUls.length] = uls[i];
		}
	}
	uls = null;
	for (var i = 0; i < killTheseUls.length; i++) {
		killTheseUls[i].style.listStyleType = 'none';
	}
}

function getAjaxObject() {
	var xmlHttp = false;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				
			}
		}
	}
	return xmlHttp;
}

function ajaxObject(div, url) {
	var that = this;
	var updating = false;
	this.callback = function() {}
	
	this.update = function(passData) {
		if (updating == true) { return false; }
		if (passData === null) { passData = ''; }
		updating = true;
		var AJAX = getAjaxObject();
		if (AJAX === false) {
			alert("Your browser doesn't support AJAX.");
			return false;
		}
		else {
			AJAX.onreadystatechange = function() {
				if (AJAX.readyState == 4 || AJAX.readyState == "complete") {
					divId.innerHTML = AJAX.responseText;
					delete AJAX;
					updating = false;
					that.callback();
				}
			}
			var timestamp = new Date();
			var uri = '';
			if (passData.length > 0) {
				uri = urlCall + '?' + passData + '&nocache=' + (timestamp * 1);
			}
			else {
				uri = urlCall + '?nocache=' + (timestamp * 1);
			}
			AJAX.open("GET", uri, true);
			AJAX.send(null);
			return true;
		}
	}
	var divId = document.getElementById(div);
	var urlCall = url;
}

function stockInfo(which) {
	hide('pleaseMake');
	killUlDiscs('ulHere');
	switch (which) {
		case "quote":
			document.getElementById('stockiframe').src = 'loading.php';
			setTimeout("document.getElementById('stockiframe').src = 'http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=DLA&script=200'", 500);
			document.getElementById('ulquote').style.listStyleType = 'disc';
			break;
		case "chart":
			document.getElementById('stockiframe').src = 'loading.php';
			setTimeout("document.getElementById('stockiframe').src = 'http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=DLA&script=300'", 500);
			document.getElementById('ulchart').style.listStyleType = 'disc';
			break;
		case "advanced":
			document.getElementById('stockiframe').src = 'loading.php';
			setTimeout("document.getElementById('stockiframe').src = 'http://www.corporate-ir.net/ireye/ir_site.zhtml?ticker=DLA&script=950'", 500);
			document.getElementById('uladvanced').style.listStyleType = 'disc';
			break;
		case "dividend":
			document.getElementById('stockiframe').src = 'loading.php';
			setTimeout("document.getElementById('stockiframe').src = 'if_dividend_history.php'", 500);
			document.getElementById('uldividend').style.listStyleType = 'disc';
			break;
	}
	show('stockiframe');
	setTimeout("document.getElementById('stockiframe').focus()", 500);
}

function faqInfo(which) {
	document.getElementById('faqTarget').innerHTML = '<div style="margin: 20px 0px 0px 50px;"><img src="img/wait_white_32.gif" width="32" height="32" border="0" align="absmiddle" style="margin-right: 10px;" /><h3 style="display: inline;">Loading...</h3></div>';
	killUlDiscs('ulHere');
	switch (which) {
		case "faq":
			document.getElementById('ulfaq').style.listStyleType = 'disc';
			var faqAjax = new ajaxObject('faqTarget', 'ajax_faq.php');
			faqAjax.callback = function() { setupLinks(); setupUnderlineLinks(); };
			faqAjax.update(null);
			break;
		case "fast":
			document.getElementById('ulfast').style.listStyleType = 'disc';
			var faqAjax = new ajaxObject('faqTarget', 'ajax_fast_facts.php');
			faqAjax.callback = function() { setupLinks(); setupUnderlineLinks(); };
			faqAjax.update(null);
			break;
	}
}
