function de(str)
{
	return document.getElementById(str);
}
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}



function getPosition(theElement,posFor,posEvt) {
	if(posFor == 'x') {
		switch(showElement) {
			case'tooltip':
				var element_width = theElement.offsetWidth;
				if ((posEvt + (2*element_width)) < getWindowWidth()) {
					return 'left';
				} else {
					return 'right';
				}
				break;
			case'dialogBox':
				var show_width = 300;
				if (posEvt < show_width) {
					return 'left';
				} else {
					return 'right';
				}
				break;
		}
	} else {
		var element_height = theElement.offsetHeight;
		if ((element_height + posEvt) >= (getWindowHeight() - 15) ) {
			posEvt = posEvt + getScrollYOffset() - 15;
		} else {
			posEvt = posEvt + getScrollYOffset() + 15;
		} 
		return posEvt;
	}
}

function getWindowWidth(){
	if (window.innerWidth) {
		theWidth = window.innerWidth
	} else if (document.documentElement && document.documentElement.clientWidth) {
		theWidth = document.documentElement.clientWidth
	} else if (document.body) {
		theWidth = document.body.clientWidth
	}
	return theWidth;
}

function getWindowHeight(){
	if (window.innerHeight) {
		theHeight = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		theHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		theHeight = document.body.clientHeight;
	}
	return theHeight;
}

function getScrollYOffset() {
	if (window.pageYOffset) {
		  pos = window.pageYOffset
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	} else if (document.body) {
		  pos = document.body.scrollTop
	}
	return pos;
}


function showFriendType(linkElement,e) {
	var theDiv = document.getElementById('confirm');
	var topPos = getPosition(linkElement,'y',e.clientY);

	theDiv.style.position = "absolute";
	theDiv.style.top = (topPos-15)+"px";
	theDiv.style.zIndex = 101;
	theDiv.style.display = "";
}
