// JavaScript Document

getXPath = function (href, base) {
	
	if (href.indexOf('#') == href.length - 1) {
		href = href.replace('#', '');
	}
	
	var loc = href.split(base)[1];
	
	//
	if (href.indexOf("#") != -1) {
		if (loc.split("#")[0] == "") {
			// case: /#valami and case /#
			var p = base + loc.split("#")[1];
		} else {
			// case: /ize#valami and /ize#
			window.location.href = base+"#"+loc.split("#")[1];
			return;
		}
	} else {
		// case: /valami
		if (loc != "") {
			window.location.href = base+"#"+loc;
			return;
		} else {
			var p = base;
		}
	}
	return p;
}
// -----------
// misc && dh-logo slider
// -----------
/*var wh = 0;
function getHeight() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		wh = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		wh = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		wh = document.body.clientHeight;
	}
	return wh;
}

var scrOfY = 0;
function getScrollY() {
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if( document.body && document.body.scrollTop) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}

var y = 15;
var dy = 0;
function slideMisc() {
	var trg = document.getElementById("misc");
	var t = (y < getScrollY() + 15) ? Math.ceil(y + ((getScrollY() + 15) - y) / 6) : Math.floor(y + ((getScrollY() + 15) - y) / 6);
	(y != t) ? trg.style.top = t + "px" : null;
	y = t;
	//
	var trg = document.getElementById("dh-logo");
	var t = (dy < (getScrollY() + getHeight() - 24-15)) ? Math.ceil(dy + ((getScrollY() + getHeight() - 24-15) - dy) / 6) : Math.floor(dy + ((getScrollY() + getHeight() - 24-15) - dy) / 6);
	(dy != t) ? trg.style.top = t + "px" : null;
	dy = t;
}*/


// ----------------------
// misc && dh-logo slider
// ----------------------

function slideMisc() {
	
	var yTo = 15+window.getScroll().y;	
	var n = $('misc').getStyle('top').toInt() + (yTo - $('misc').getStyle('top').toInt())/4;
	n = (yTo < $('misc').getStyle('top').toInt()) ? Math.floor(n) : Math.ceil(n);
	var dhn = n-15+window.getSize().y-25-$('logos').getSize().y;
	
	if ($('misc').getStyle('top').toInt() == n && $('logos').getStyle('top').toInt() == dhn) return;
	
	//alert($('logos').getSize().y);;
	
	$('misc').setStyle('top', n);
	$('logos').setStyle('top', dhn+'px');
	
}
