// JavaScript Document
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (var i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function getAncestor(element, type) { 
    var ancestor = element;
    while(ancestor && ancestor.tagName.toUpperCase()!=type.toUpperCase()) { ancestor=ancestor.parentNode; } 
    return ancestor; 
}

function getAncestorByClass(element, theclass) {
    var ancestor = element; 
    while(ancestor && ancestor.getAttribute("class") != null && ancestor.getAttribute("class").toUpperCase()!=theclass.toUpperCase()) { ancestor=ancestor.parentNode; } 
    return ancestor; 
}

function displayAddress(idAddress) {
	var world = document.getElementById("worldmap");
	if (!world) return;
	var dls = world.getElementsByTagName("dl");
	for (var i = 0; i < dls.length; i++) {
		dls[i].style.display = "none";
	}
	document.getElementById(idAddress).style.display = "inline";
}

function decrypt(s) {
	document.write(s.rot13());
}

function send(s) {
	window.location=s.rot13();
}

String.prototype.rot13 = function(){ //v1.0
	return this.replace(/[a-zA-Z]/g, function(c){
		return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
	});
};

function openPopup(pagename, windowname) {
	window.open (pagename, windowname, config='height=800, width=666, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
}


function ringcentralPopup() {
	var wind = window;
	var winop = wind.open;
	winop("http://www.ringcentral.com/ringme/?uc=57251931,0,&s=no&v=2", "Callback_RingMe", "resizable=no,width=380,height=360");
	return false;
}