﻿<!-- 

function init() {
	stripeTables();
	insertArrows();
	insertBars();
	addOpeners();
	addHrefs();
	toggle_init();
	jsinit();
	ky_backTop_init(1000);
}

function jsinit() {
	var jselements = document.getElementsByTagName('div');
	for (var i = 0; i < jselements.length; i++) {
		if (/\bjsshow\b/.exec(jselements[i].className)) {
			jselements[i].style.display = "block";
		}
		if (/\bjshide\b/.exec(jselements[i].className)) {
			jselements[i].style.display = "none";
		}
	}
}


function Anthem_PreCallBack() 
{ 
	document.body.style.cursor='wait'; 
	window.status = 'Querying Server, Please wait ...'; 
	// Hide some "loading" label if you want 

} 

function Anthem_PostCallBack() 
{ 
	document.body.style.cursor='auto'; 
	window.status = ''; 
	// Show some "loading" label if you want 
} 

// based on easytoggle2.js at http://simon.incutio.com/archive/2003/11/06/easytoggle

var EDSCookie; 
var toggle_toggleElements = [];
function toggle_init() {
    var i, link, id, target, defaultexist, counter;
	defaultexist = false;
    for (i = 0; (link = document.links[i]); i++) {  // loop through all links
        if (/\btoggle\b/.exec(link.className)) {  // looking for classes than include "toggle"
            id = link.href.split('#')[1];
            target = document.getElementById(id);
            toggle_toggleElements[toggle_toggleElements.length] = target;
			if (EDSCookie) {  // if there is a cookie
				if (id == EDSCookie) {  // and this panel is the cookie default
					target.className = "panel show";  // then display it
				} else {
					target.className = "panel hide";  // otherwise, make sure it's hidden
				}
			}
			if (defaultexist == false) { // if there is no declared default yet	
				if (/\bshow\b/.exec(target.className)) {  // and this panel is already displayed
					link.className = "toggle on";  // then highlight the corresponding link
					defaultexist = true;  // and declare that we have a default
				}
			} else {
				target.className = "panel hide"; // we probably have a default, so hide any extra "show" panels
			}
        	link.onclick = toggle;  
			counter = document.links[i]; // save the location in the array of the last toggle link
		}
    }
	if (defaultexist == false) {  // if there is no declared default yet
		if (target) {
			target.className = "panel show";  // turn on the last panel
			for (i = 0; (link = document.links[i]); i++) {  // and loop through all links
				if (link.href == counter) {  // looking for the last toggle link
					link.className = link.className + " on";  // and highlight it
				}
			}
		}
	}
}
function toggle(e) {
	/* We need to know which link was activated when the function was called
	   this will allow us to identify the panel which should be displayed.
       Adapted from http://www.quirksmode.org/js/events_properties.html */
	if (typeof e == 'undefined') {
        var e = window.event;
    }
    var source;
    if (typeof e.target != 'undefined') {
        source = e.target;
    } else if (typeof e.srcElement != 'undefined') {
        source = e.srcElement;
    } else {
        return true;
    }
    /* For most browsers, targ would now be a link element; Safari however
       returns a text node so we need to check the node type to make sure */
    if (source.nodeType == 3) {
        source = source.parentNode;
    }
	for (i = 0; (link = document.links[i]); i++) {
		if (/\btoggle\b/.exec(link.className)) {
			link.className="toggle";
		}
	}
	source.className="toggle on";
    var id = source.href.split('#')[1];
    var elem;
    for (var i = 0; (elem = toggle_toggleElements[i]); i++) {
        if (elem.id != id) {
            elem.style.display = 'none';
        } else {
            elem.style.display = 'block';
        }
    }
    return false; // overrides the href for javascript-enabled browsers
}

function addHrefs() {
	var mainarea = document.getElementById('content');
	var bodylinks = mainarea.getElementsByTagName('a');
	for (var i = 0; i < bodylinks.length; i++) {
		if (/\bmailto:\b/.exec(bodylinks[i].href)) {
			var urlspan = document.createElement('span');
    		urlspan.className = 'url';
			urltext = bodylinks[i].href.split(':')[1];
			if (/\b=\b/.exec(urltext)) {
				urltext = urltext.split("?")[0];
			}	
			var linkurl = document.createTextNode(" ("+urltext+")");
			urlspan.appendChild(linkurl);
    		bodylinks[i].appendChild(urlspan);	
		}
		if (/\burlprint\b/.exec(bodylinks[i].className)) {
			var urlspan = document.createElement('span');
    		urlspan.className = 'url';
			urltext = bodylinks[i].href;	
			var linkurl = document.createTextNode(" ("+urltext+")");
			urlspan.appendChild(linkurl);
    		bodylinks[i].appendChild(urlspan);	
		}		
	}
}

function addOpeners() {
	var newwinb_features = 'menubar=no,toolbar=no,location=no,status=no,width=400,height=425,resizable=yes,scrollbars=yes';
	var newwinc_features = 'menubar=no,toolbar=no,location=no,status=yes,width=640,height=480,resizable=yes,scrollbars=yes';
	var links = document.getElementsByTagName('a');
	for (var i = 0; i < links.length; i++) {
    	if (/\b.pdf\b/.exec(links[i].href) || 
			/\b.doc\b/.exec(links[i].href) ||
			/\bnewwina\b/.exec(links[i].className)) {
    		links[i].target="_blank";
    	}
		if (!links[i].href.match("localhost") && !links[i].href.match("eds.com.cn") && !links[i].href.match("eds.com.tw") && !links[i].href.match("edskorea.co.kr") && !links[i].href.match("eds.com") && !links[i].href.match("edscareers.com") && !links[i].href.match("javascript:")) {
			links[i].target="_blank";
		}
		if (/\bnewwinb\b/.exec(links[i].className)) {
			links[i].onclick = function() {
				var destination = this.href;
				var newwin = window.open(destination,"newwinb",newwinb_features);
				newwin.focus();
				return false;
			}
		}
		if (/\bnewwinc\b/.exec(links[i].className)) {
			links[i].onclick = function() {
				var destination = this.href;
				var newwin = window.open(destination,"newwinc",newwinc_features);
				newwin.focus();
				return false;
			}
		}
  	}
}

function WritePageTools(sRestricted) {
	var title = document.title;
	var subj = title;
	var sToolProfile = "ALL";

	if (sRestricted != null)
	{
		if (sRestricted != "")
		{
			sToolProfile = sRestricted.toUpperCase();
		}
	}

	subj = escape(subj);
	var bodyTxt = "I thought you might like to see this page on " + lang__domain + ": " + title + ", found at: " + document.URL;
	bodyTxt = escape(bodyTxt);	
	document.write ("<div id='pagetools'>");
	document.write ("<ul>");
	
	switch (sToolProfile)
	{
		case "RESTRICTED":
			document.write ("<li><a href='#' onclick='print(); return false;' id='printthis' title='" + lang__printThis + "'>" + lang__printThis + "</a></li>");
			break;
		case "ALL":
		default:
			document.write ("<li><a href='#' onclick='print(); return false;' id='printthis' title='" + lang__printThis + "'>" + lang__printThis + "</a></li>");
			// document.write ("<li><a href='mailto:\?subject=" + subj + "\&body\=" + bodyTxt + "' id='emailthis' title='" + lang__emailThis + "'>" + lang__emailThis + "</a></li>");
			document.write ("<li><a href='email_to_a_friend.aspx' id='emailthis' title='" + lang__emailThis + "'>" + lang__emailThis + "</a></li>");
			break;
	}
		
	document.write ("</ul>");
	document.write ("</div>");	
}

function WriteClose() {
	document.write ("<a id='closethis' href='javascript:window.close()'>Close</a>");
}

function insertArrows() {
	var ptags = document.getElementsByTagName('p');
	var action_ptags = [];
	for (var i = 0; i < ptags.length; i++) {
    	if (/\baction\b/.exec(ptags[i].className)) {
    		action_ptags[action_ptags.length] = ptags[i];
    	}
  	}
  	for (var i = 0; i < action_ptags.length; i++) {
    	var arrow = document.createElement('span');
    	arrow.className = 'arrow';
		arrow.innerHTML = "&nbsp;&#187;";
		// var symbol = document.createTextNode(" &#187;");
		// arrow.appendChild(symbol);
    	action_ptags[i].appendChild(arrow);
  	}
	var ultags = document.getElementsByTagName('ul');
	var action_ultags = [];
	for (var i = 0; i < ultags.length; i++) {
    	if (/\baction\b/.exec(ultags[i].className)) {
			for ( var x = 0; x < ultags[i].childNodes.length; x++ ){
				if ( ultags[i].childNodes[x].tagName == 'LI' ) {
    				action_ultags[action_ultags.length] = ultags[i].childNodes[x];
				}
			}
    	}
  	}
  	for (var i = 0; i < action_ultags.length; i++) {
    	var arrow = document.createElement('span');
    	arrow.className = 'arrow';
		arrow.innerHTML = "&nbsp;&#187;";
		// var symbol = document.createTextNode(' »');
		// arrow.appendChild(symbol);
    	action_ultags[i].appendChild(arrow);
  	}
	var spantags = document.getElementsByTagName('span');
	var arrow_spantags = [];
	for (var i = 0; i < spantags.length; i++) {
    	if (/arrow/.exec(spantags[i].className)) {
    		arrow_spantags[arrow_spantags.length] = spantags[i];
    	}
  	}
  	for (var i = 0; i < arrow_spantags.length; i++) {
		if (/\barrowleft\b/.exec(arrow_spantags[i].className)) {
			arrow_spantags[i].innerHTML = "&#171;&nbsp;";
		} else {
    		arrow_spantags[i].innerHTML = "&nbsp;&#187;";
		}
  	}
}

function insertBars() {
	var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

	var ultags = document.getElementsByTagName('ul');
	for (var i = 0; i < ultags.length; i++) {
    	if (/\bseparators\b/.exec(ultags[i].className)) {
			if (is_ie)
			{
				for ( var x = 0; x < ultags[i].childNodes.length - 1; x++ ){
					if ( ultags[i].childNodes[x].tagName == 'LI' ) {
						barhtml (ultags[i].childNodes[x]);
					}
				}
			}
			else
			{
				for ( var x = 0; x < ultags[i].childNodes.length - 1; x++ ){
					if ( ultags[i].childNodes[x].tagName == 'LI' ) {
						barhtml (ultags[i].childNodes[x]);
					}
				}
			}
    	}
  	}
}
function barhtml (childNode) {
	var bar = document.createElement('span');
	bar.innerHTML = "&nbsp;&#124; ";
	// var symbol = document.createTextNode('&nbsp;| ');
	// serparators.appendChild(symbol);
    childNode.appendChild(bar);
}

function stripeTables() {
	var even = false;
    var evenColor = arguments[1] ? arguments[1] : "rowon";
    var oddColor = arguments[2] ? arguments[2] : "rowoff";
   	var tabletags = document.getElementsByTagName('table');
	for (var i = 0; i < tabletags.length; i++) {
    	if (/\bstriped\b/.exec(tabletags[i].className)) {
    		var trs = tabletags[i].getElementsByTagName("tr");
    		for (var t = 0; t < trs.length; t++) {
				if (hasClass(trs[t]) || trs[t].style.backgroundColor) {
 					even = false;
					continue;			
				} else {
       				var mytr = trs[t];
       				mytr.className = even ? evenColor : oddColor;
					even =  ! even;
       			}
       		}        
    	}
  	}
}

function toggleDisplay(targetid) {
	if (document.getElementById) {
		target = document.getElementById(targetid);	
		if (target.style.display == "none") {
			target.style.display = "";
		} else { target.style.display = "none" }
	}
}

function hasClass(obj) {
	var result = false;
	//if (obj.getAttributeNode("class") != null) {	
	//	result = obj.getAttributeNode("class").value;
    if (obj.className != null) {
		result = obj.className;	
	}
	return result;
}

function searchsubmit(form) {
	if (form.qt.value=='') {
		alert("Please type in a keyword");
		form.qt.focus();
		return false;
	}
}

function advancedsearchsubmit() {
	var form = document.advancedsearchform;
	if (form.tx0.value=='' && form.tx1.value=='' && form.tx2.value=='' && form.tx3.value=='' ) {
		alert("Please type in a keyword");
		form.tx0.focus();
		return false;
	}
}



/* KY put back to top */
var backTopHTML = "<a href='#top' title='" + lang__backTop + "'><img src='img/ico_backTop.gif' alt='[^]' /> " + lang__backTop + "</a>";
var const__ky_backTop;
function ky_backTop_init(interval) {
	const__ky_backTop = $$('.backTop');
	if(const__ky_backTop.length>0) {
		setInterval('ky_backTop()',interval);
	}
}
function ky_backTop() {
	const__ky_backTop.each( function(node) {
		if($(node).offsetTop > displaySize('height') + 20) {
			if($(node).innerHTML.indexOf("#top") == -1) {	// use meaningful substring in your backTopHTML for indexOf
				$(node).innerHTML = backTopHTML;
			}
		} else {
			$(node).innerHTML = "";
		}
	} );
}

/* get browser display size */
function displaySize(type) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(type.toLowerCase()=='width') return myWidth;
  else if(type.toLowerCase()=='height') return myHeight;
  else return null;
}
