function ID(id) {
	return document.getElementById(id);
}
function IDParent(id) {
	return parent.document.getElementById(id);
}
function IDOpener(id) {
	return opener.document.getElementById(id);
}
function IDGo(url) {
	return location.href = url;
	return document.href = url;
}
function IDElement(html) {
	return document.createElement(html);
}
function IDText(text) {
	return document.createTextNode(text);
}
function IDWrite(text) {
	return document.write(text);
}

function IDGetScrollHeight() {
	if (window.pageYOffset) return window.pageYOffset;
	else if (document.documentElement) return document.body.scrollTop + document.documentElement.scrollTop;
	else if (document.body.scrollLeft >= 0) return document.body.scrollTop;
	else return 0;
}

function IDGetPageWidth() {
	if (window.innerHeight && window.scrollMaxY) xScroll = window.innerWidth + window.scrollMaxX;
	else if (document.body.scrollHeight > document.body.offsetHeight) xScroll = document.body.scrollWidth;
	else xScroll = document.body.offsetWidth;

	if (self.innerHeight)
		if(document.documentElement.clientWidth) windowWidth = document.documentElement.clientWidth;
		else windowWidth = self.innerWidth;
	else if (document.documentElement && document.documentElement.clientHeight) windowWidth = document.documentElement.clientWidth;
        else if (document.body) windowWidth = document.body.clientWidth;
        else windowWidth = 0;

	if (xScroll < windowWidth) return xScroll;
	else return windowWidth;
}

function IDGetPageHeight() {
	if (window.innerHeight && window.scrollMaxY) yScroll = window.innerHeight + window.scrollMaxY;
	else if (document.body.scrollHeight > document.body.offsetHeight) yScroll = document.body.scrollHeight;
	else yScroll = document.body.offsetHeight;

	if (self.innerHeight) windowHeight = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) windowHeight = document.documentElement.clientHeight;
        else if (document.body) windowHeight = document.body.clientHeight;
        else windowHeight = 0;

	if (yScroll < windowHeight) return windowHeight;
	else return yScroll;
}


function IDAjaxLoad(id, url) {
	// jQuery
	jQuery('#'+id).load(url);
}

function IDAjaxScript(id, url, func) {
	// jQuery
	jQuery.getScript(url, func);
}

function IDAjaxJSON(id, url, func) {
	// jQuery
	jQuery.getJSON(url, func);
}

function IDMail(encode) {
	// antiSpam
	var email = '';
	var length = encode.length;
	for (var i = length - 1; i >= 0; i--) {
		email += encode.substring(i, i + 1);
	}
	IDWrite('<a href="mailto:' + email + '" rel="nofollow">' + email + '</a>');
}

function IDBoxImage(url, text, width, height) {
	var o = ID('overbox');
	var h = IDGetPageHeight();

	if (typeof text == 'undefined') var text = '';
	if (typeof width == 'undefined') var width = 0;
	if (typeof height == 'undefined') var height = 0;

	text = text == '' ? '' : '<h4 style="padding-top: 10px; ">' + text + '</h4>';
	width = width > 0 ? 'width: ' + width + 'px; ' : '';
	height = height > 0 ? 'height: ' + height + 'px; ' : '';
	var margin = 'margin: ' + (50 + IDGetScrollHeight()) + 'px auto 0 auto; ';

	var html = '';
	html += '<div style="position: absolute; top: 0; left: 0; z-index: 8; display: block; width: 100%; height: ' + h + 'px; background-color: #000000; filter: alpha(opacity=75); opacity: .75; "></div>';
	html += '<div style="position: absolute; top: 0; left: 0; z-index: 9; display: block; width: 100%; height: ' + h + 'px; text-align: center; vertical-align: top; "><table style="' + margin + 'border: 10px solid #ffffff; background-color: #ffffff; "><td><img id="imagebox" src="' + url + '" style="background: #000000 url(\'' + url + '\'); ' + width + height + '" />' + text + '</td></table></div>';

	o.style.height = h + 'px';
	o.style.display = 'block';
	o.innerHTML = html;

	var tag = document.getElementsByTagName('object');
	for (var i = 0; i < tag.length; i++) tag[i].style.visibility = 'hidden';

	o.onclick = function() {
		this.style.display = 'none';
		this.innerHTML = '';
		this.onclick = null;
		for (var i = 0; i < tag.length; i++) tag[i].style.visibility = 'visible';
	}
}

function IDBoxFrame(url, text, width, height) {
	var o = ID('overbox');
	var h = IDGetPageHeight();

	if (typeof text == 'undefined') var text = '';
	if (typeof width == 'undefined') var width = 0;
	if (typeof height == 'undefined') var height = 0;

	text = text == '' ? '' : '<h4 style="padding-top: 10px; ">' + text + '</h4>';
	width = width > 0 ? 'width: ' + width + 'px; ' : '';
	height = height > 0 ? 'height: ' + height + 'px; ' : '';
	var margin = 'margin: ' + (50 + IDGetScrollHeight()) + 'px auto 0 auto; ';

	var html = '';
	html += '<div style="position: absolute; top: 0; left: 0; z-index: 8; display: block; width: 100%; height: ' + h + 'px; background-color: #000000; filter: alpha(opacity=75); opacity: .75; "></div>';
	html += '<div style="position: absolute; top: 0; left: 0; z-index: 9; display: block; width: 100%; height: ' + h + 'px; text-align: center; vertical-align: top; "><table style="' + margin + 'border: 10px solid #ffffff; background-color: #ffffff; "><td><iframe id="framebox" src="' + url + '" style="border: 0 none; ' + width + height + '" /></iframe>' + text + '</td></table></div>';

	o.style.height = h + 'px';
	o.style.display = 'block';
	o.innerHTML = html;

	var tag = document.getElementsByTagName('object');
	for (var i = 0; i < tag.length; i++) tag[i].style.visibility = 'hidden';

	o.onclick = function() {
		this.style.display = 'none';
		this.innerHTML = '';
		this.onclick = null;
		for (var i = 0; i < tag.length; i++) tag[i].style.visibility = 'visible';
	}
}

