// required ****************** //
var doc = document;
String.prototype.trim = function () {
	return this.replace(/^\s+|\s+$/g,"");
}

// getID ********************* //
function getID(element) {
	if (arguments.length > 1) {
		for (var i = 0, elements = [], length = arguments.length; i < length; i++) {
			elements.push(getID(arguments[i]));
			return elements;
		}
	}
	if (typeof element == "string") {
	    if (doc.getElementById) {
	        element = doc.getElementById(element);
	    } else if (doc.all) {
	        element = doc.all[element];
	    } else if (doc.layers) {
	        element = doc.layers[element];
	    } else if (doc[element]) {
	        element = doc[element];
	    }
	}
	return element;
}

// **************************** //
if(top.location != location) {
	top.location.href = document.location.href;
}

// **************************** //
sitedomain = calendario[2];
if (sitedomain && document.domain.replace('www.','') != sitedomain) {
	document.location.href = "http://www."+sitedomain+"/";
}

// **************************** //
function stopEvent(e) {
	if(!e) var e = window.event;
	
	//e.cancelBubble is supported by IE - this will kill the bubbling process.
	e.cancelBubble = true;
	e.returnValue = false;

	//e.stopPropagation works only in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
	return false;
}

// **************************** //
function openPopup(e) {
	pop_url = this.href;
	pop_width = 380;
	pop_height = 400;
	pop_left = (screen.width - pop_width)/2;
	pop_top = (screen.height - pop_height)/2;
	window.open(pop_url, "contato", "width="+pop_width+", height="+pop_height+", left="+pop_left+", top="+pop_top+", location=0, menubar=0, toolbar=0, scrollbars=1");
	stopEvent(e);
}

// **************************** //
(function openContact() {
	if (!document.getElementsByTagName) {
		return;
	}
	links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		link = links[i];
		if (link.href) {
			if (link.href.indexOf("/contato") != -1) {
				link.onclick = openPopup;
			}
		}
	}
})();
