/*
function viewProfile(user_id) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('/user/profile/'+user_id, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=250,left=100,top=100');");
}
*/

function viewProfile(user_id) {
	window.location = '/user/profile/' + user_id;
}

var xmlhttp = false;

try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}	catch (e) {
try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}	catch (E) {
		vvxmlhttp = false;
	}
}

if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}

function makerequest(serverPage, objID) {
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

function psubmit(page, oid) {
	var what = document.getElementById(oid);
	xmlhttp.open("POST", page);
	xmlhttp.open("GET", page);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			what.innerHTML = xmlhttp.responseText;
		}
	}

}

function OpenWeb(site) {
	window.open(site);
}

function checkLines(field_name) {
	var lines = document.getElementById(field_name).value.split(/\n/).length;
	if (lines > 4) {
		alert('You have entered more than four lines!');
		return false;
	}
	return true;
}

function checkLimit(field, maxlen) {
	if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
	}
}

function SubmitExp() {
	var exp = document.getElementById("totalexp").value;
	window.location.href="/user/exp/" + exp.replace(/ /i, "+");
}

function Signup() {
//	var f1 = document.signupf.username.value.length;
//	var f2 = document.signupf.password.value.length;
//	var f3 = document.signupf.c_password.value.length;
//	var f4 = document.signupf.email.value.length;
//	var f5 = document.signupf.confirme.value.length;
	var getToForm = document.signupf;
		var field = new Array(document.signupf.username.value.length, document.signupf.password.value.length, document.signupf.c_password.value.length, document.signupf.email.value.length, document.signupf.confirme.value.length)
	if(field[0] == 0 || field[1] == 0 || field[2] == 0 || field[3] == 0 || field[4] == 0) {
		msg = '\n\nMissing fields:\n\n';
//		if(un == 0) { msg += '+ Username\n';  }
//		if(pass == 0) { msg += '+ Password\n'; }
//		if(passc == 0) { msg += '+ Password Confirmation\n'; }
//		if(email == 0) { msg += '+ Email\n'; }
//		if(emailc == 0) { msg += '+ Email Confirmation'; }
			// try this plz
		for(i=1;i<=5;i++) {
			msg += (f + i == 0 ? 'hi' : '');
		}
		alert('You haven\'t filled out all of the fields!' + msg);
 		return false;
	}
	return true;
}

function doVote(fid, num) {
	var obj = document.getElementById('display_vote');
	// obj.innerHTML = 'Voting...';
	xmlhttp.open("GET", "/flash/vote?v="+num+"&f="+fid, true);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			// obj.innerHTML = xmlhttp.responseText;
			document.getElementById('old_score').innerHTML = 'LOOK DOWN PLZ';
		}
	}
	xmlhttp.send(null);
}

function viewFlash(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=500');");
	}

function displayFlash(swf, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + width + '" height="' + height + '">');
		document.write('<param name="movie" value="' + swf + '" />');
		document.write('<param name="allowscriptaccess" value="never" />');
		document.write('<param name="enablejavascript" value="false" />');
	document.write('<embed src="' + swf + '" quality="high" width="' + width + '" height="' + height + '" allowscriptaccess="never" enablejavascript="false" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object>');
}

// Old voting lol
function Vote(num) {
	document.voting.rating.value = num;
	document.voting.submit();
}

// This doesn't work for a reason
function CheckPost() {
	if(document.postbox.post.value.length == 0) { // Yeah, I know it should be document.post.post, but blank posts are A OK with me
		alert("blank");
		return false;
	}
	return true;
}

function useHTML(tag, field_name) {
	if(tag == 'a') {
		var myurl = window.prompt("What site do you want to link to?", "");
		if(!myurl) {
			exit;
		} else {
			var mytext = window.prompt("What do you want the link to show up as?", "");
		}
			if(!myurl || !mytext) { // Let's check the url again, just for fun!!
				exit;
			} else {
				document.getElementById(field_name).value += "<a href=\"" + myurl + "\">" + mytext + "</a>";
		}
	} else {
		var mytext = window.prompt("Enter the text, baby.", "");
		if(!mytext) {
			exit;
		} else {		
			document.getElementById(field_name).value += "<" + tag + ">" + mytext + "</" + tag + ">";
		}
	}
}

var tipbox, mouseX, mouseY;

function startInfo() {
	tipbox = document.getElementById('tip');
	tipbox.style.visibility = 'visible';
	tipbox.style.display = '';
}

function showFlashInfo(e, id, author, score, views, icon) {

if(!e) {
	e = window.event;
}

if(window.event.clientX || window.event.clientY) {
	mouseX = window.event.clientX+document.documentElement.scrollLeft;
	mouseY = window.event.clientY+document.documentElement.scrollTop;
} else if(window.event.pageX || window.event.pageY) {
	mouseX = window.event.pageX;
	mouseY = window.event.pageY;
}

	tipbox.style.top = mouseY-20 + 'px';
	tipbox.style.left = mouseX+40 + 'px';
	tiptext = '<div class="tipdiv"><div class="showicon"><img class="sub_icon" src="/flash/icon/' + id + '_pic.' + icon + '" alt="icon" /></div>Author:&nbsp;' + author + '<br />Score:&nbsp;' + score + '<br />Views:&nbsp;' + views + '</div>';
	tipbox.innerHTML = tiptext;
	tipbox.style.display = "";
}

function hideInfo(what) {
	what.style.display = 'none';
}

function moveInfo() {
	tipbox.style.top = mouseY;
	tipbox.style.left = mouseX+10;
}

function ChangePosition(bid, xx, yy) {
	document.getElementById(bid).style.backgroundPosition=xx + " " + yy;
	return false;
}

