function getXpos(theElement) {
	xPos = theElement.offsetLeft;
	tempEl = theElement.offsetParent;
	while (tempEl != null) {
	  	xPos += tempEl.offsetLeft;
	  	tempEl = tempEl.offsetParent;
		}
	return xPos;
	}

function getYpos(theElement) {
	yPos = theElement.offsetTop;
	tempEl = theElement.offsetParent;
	while (tempEl != null) {
	  	yPos += tempEl.offsetTop;
	  	tempEl = tempEl.offsetParent;
		}
	return yPos;
	}

function showInfoDiv(theDiv,theImage,moveRightPixels,moveDownPixels) {
	var testImg = document.images[theImage];
    if (!testImg) testImg = document.getElementById(theImage);
	if(moveRightPixels)document.getElementById(theDiv).style.left = getXpos(testImg) + moveRightPixels + 'px';
	else document.getElementById(theDiv).style.left = getXpos(testImg) + testImg.width + 5 + 'px';
    if(moveDownPixels)document.getElementById(theDiv).style.top = getYpos(testImg) + moveDownPixels + 'px';
    else document.getElementById(theDiv).style.top = getYpos(testImg) + testImg.height - 17 + 'px';
	document.getElementById(theDiv).style.visibility = 'visible';
    //testImg.style.visibility = 'hidden';
	}

function hideInfoDiv(theDiv,theImage) {
	var testImg = document.images[theImage];
    if (!testImg) testImg = document.getElementById(theImage);
	document.getElementById(theDiv).style.visibility = 'hidden';
    //testImg.style.visibility = 'visible';
	}

function HideContent(d) {
	document.getElementById(d).style.display = "none";
	}

function ShowContent(d) {
	document.getElementById(d).style.display = "block";
	}

function ReverseDisplay(d) {
	if(document.getElementById(d).style.display == "none") {
		document.getElementById(d).style.display = "block";
		} else {
		document.getElementById(d).style.display = "none";
		}
	}

function updateImage(mid, img) {
	var url = 'http://www.h3don.com/ajax.php?mid=' + mid + '&img=' + img;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    	} else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    req.onreadystatechange = processImage;
    req.open("GET", url, true);
    req.send(null);
	}

function changeRoom() {
	document.forms[0].r.value = document.getElementById("room").value;
	}

function submitMsg(mid) {
	msg = document.forms[0].Post.value;
	msg = msg.replace(/#/g,"_____");
	var recip = document.getElementById("recip").value;
	if(recip) {
		msg = "/" + recip + "/ " + msg;
		}
	room = document.forms[0].r.value;
	var url = 'http://www.h3don.com/ajax.php?mid=' + mid + '&chat=' + room +'&msg=' + msg;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    req.onreadystatechange = processMsg;
    req.open("GET", url, true);
    req.send(null);
	}
	
function delMsg(mid, id) {
	var url = 'http://www.h3don.com/ajax.php?mid=' + mid + '&del=' + id;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    req.onreadystatechange = processDel;
    req.open("GET", url, true);
    req.send(null);
	}
	
function getRecip() {
	var recip = document.getElementById("recip").value;
	}
	
var arImages=new Array();
function Preload() {
	var temp = Preload.arguments; 
	for(x=0; x < temp.length; x++) {
		arImages[x]=new Image();
		arImages[x].src=Preload.arguments[x];
		}
	}

function roll(link,id,overIm) {
	if(document.images) {
		im = document.images[id];
		im.outIm = new Image();
		im.overIm = new Image();
		im.outIm.src = document.images[id].src;
		im.overIm.src = overIm;
		im.src =im.overIm.src;
		}
	}
	
function SetLangCookie(value) {
	var expDays = 365; 
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*30*24*60*60));
	document.cookie = "h3_lang"+"="+escape(value)+";path="+"/"+";domain="+".h3don.com"+";expires="+exp;
	top.location=self.location;
	}
	
function delCheck(mess) {
	var message=unescape(mess);
	var agree=confirm(message);
	if (agree)
		return true;
	else
		return false;
	}
	
function processImage() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			return true;
			}
		}
	}

function processDel() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			return true;
			}
		}
	}
	
function processMsg() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.forms[0].Post.value = "";
			return true;
			}
		}
	}
	
function delImage(mess, type) {
	if(type == 'Del') {
		var message=unescape(mess);
		var agree=confirm(message);
		if (agree) {
			document.forms[0].submit();
			} else {
			document.forms[0].reset();
			return false;
			}
		} else {
		document.forms[0].submit();
		}
	}
	
var MaxChars = 10000;
var UsedChars = 0;
var warned = 'n';
function countChars(history, mess) {
	UsedChars = parseInt(document.forms[0].Post.value.length) + history;
	MaxChars = 10000 - UsedChars;
	if(MaxChars < 0) {
		if (warned == 'n') {
			var message=unescape(mess);
			alert(message);
			warned = 'y';
			}
		document.forms[0].charsLeft.style.color="#9E0B0E";
		document.forms[0].limit.value = "Y";
		} else {
		//document.forms[0].charsLeft.style.color="#000000";
		document.forms[0].limit.value = "N";
		}
	document.forms[0].charsLeft.value = MaxChars;
	}

function get_cookie(cookiename) {
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
	}

function invert() {
	for(i=0;i<document.messenger.elements.length;i++) {
		var e = document.messenger.elements[i];
		if(e.type=='checkbox') {
			eval("e.checked=!e.checked;");
			}
		}
	}
	
function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
	}
					
function set_cookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
		}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
	}
	
function jumpTo(id) {
	if(id) {
		location.href="http://www.h3don.com/profile.php?id="+id;
		}
	}
	
function removeAccount(del1, del2) {
	var message=unescape(del1);
	if(confirm(message)==false) {
		return false;
		} else {
		var message=unescape(del2);
		if(confirm(message)==true) {
			document.forms.deleteAcc.submit();
			}
		}
	}
	
function PopUp(url, name, width,height,center,resize,scroll,posleft,postop) {
	if (posleft != 0) { x = posleft }
	if (postop != 0) { y = postop }
	if (!scroll) { scroll = 1 }
	if (!resize) { resize = 1 }
	if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
		X = 20;
		Y = 20;
		}
	if (scroll != 0) { scroll = 1 }
		var Win = window.open( url, name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
		}
		
function getStyleObject(objectId) {
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	    } else if (document.all && document.all(objectId)) {
			return document.all(objectId).style;
		} else if (document.layers && document.layers[objectId]) {
			return document.layers[objectId];
		} else {
		return false;
		}
	}

function changeObjectVisibility(objectId, newVisibility) {
	var styleObject = getStyleObject(objectId);
    if(styleObject) {
		styleObject.visibility = newVisibility;
		return true;
		} else {
		return false;
		}
	}

function moveObject(objectId, newXCoordinate, newYCoordinate) {
	var styleObject = getStyleObject(objectId);
    if(styleObject) {
		styleObject.left = newXCoordinate;
		styleObject.top = newYCoordinate;
		return true;
		} else {
		return false;
		}
	}
	
var xOffset = -400;
var yOffset = -250;

function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
		hideCurrentPopup();
		eventObj.cancelBubble = true;
		var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0);
		var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
		moveObject(targetObjectId, newXCoordinate, newYCoordinate);
		if( changeObjectVisibility(targetObjectId, 'visible') ) {
			window.currentlyVisiblePopup = targetObjectId;
			return true;
			} else {
			return false;
			}
		} else {
		return false;
		}
	}

function hideCurrentPopup() {
	if(window.currentlyVisiblePopup) {
		changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
		window.currentlyVisiblePopup = false;
		}
	}

//window.onload = initializeHacks;
document.onclick = hideCurrentPopup;

function initializeHacks() {
	if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
		window.onresize = explorerMacResizeFix;
		}
    resizeBlankDiv();
	createFakeEventObj();
	}

function createFakeEventObj() {
	if (!window.event) {
		window.event = false;
		}
	}

function resizeBlankDiv() {
	if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
		getStyleObject('blankDiv').width = document.body.clientWidth - 20;
		getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    	}
	}

function explorerMacResizeFix () {
	location.reload(false);
	}
	
// MOBILE MONEY

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
	};

function rand(number) {
	return Math.ceil(rnd()*number);
	};

function mobilemoneysale(ordernumber,pos) {
	mmrefname = 'flirt';
	mmlanguage = 'xx';
	mmpskin = 'flirt';
	window.open('http://www.mobilemoney.com/salespopup.asp?pos='+escape(pos)+'&ordernumber='+escape(ordernumber)+'&refname='+escape(mmrefname)+'&language='+escape(mmlanguage)+'&popupskin='+escape(mmpskin),'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=468,height=550,left='+eval((screen.availWidth/2)-234)+',top=50');
	}

function listenwindow(listenurl) {
	window.open(listenurl, 'Listen', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=150,height=150,left='+eval((screen.availWidth/2)-75)+',top=50');
	}

function getparam(lookfor) {
	var st  = new String(document.location);
	var start  = st.indexOf (lookfor);
	if(lookfor == "mmstart27_10" && start == -1) {
		st = rand(10);
		return st;
		}
	if (start != -1) {
		st = st.substring (start);
		start = st.indexOf ('=');
		st = st.substring (start+1);
		eind = st.indexOf ('&');
		if (eind == -1) {
			eind = st.length;
			}
		st = st.replace (/\+/g, ' ');
		var st = unescape (st.substring (0, eind));
		} else {
		st = ""
		}
	return st;
	}
	
function setZoom(img, dir, width, height, margin, zIndex, delay) {
	setTimeout(function() {
		if (img.dir==dir) {
			img.style.width=width;
			img.style.height=height;
			img.style.margin=margin;
			img.style.zIndex=zIndex;
			}
		}, delay);
	}

function larger(img, width, height) {
	img.dir='rtl';
	now=parseInt(img.style.zIndex);
	for (i=now+1; i<=10; i++) {
		w=(width*(10+i))/20+'px';
		h=(height*(10+i))/20+'px';
		m=(-i)+'px 0 0 '+(-width*i/40)+'px';
		setZoom(img, 'rtl', w, h, m, i, 20*(i-now));
		}
	}

function smaller(img, width, height) {
	img.dir='ltr';
	now=parseInt(img.style.zIndex);
	for (i=now-1; i>=0; i--) {
		w=(width*(10+i))/20+'px';
		h=(height*(10+i))/20+'px';
		m=(-i)+'px 0 0 '+(-width*i/40)+'px';
		setZoom(img, 'ltr', w, h, m, i, 20*(now-i));
		}
	}