function collapse(target, section, videos, test) {
	var div = document.getElementById(section);
	if(test == true) {
		target2 = document.getElementById(target);
	} else {
		target2 = target;
	}
	
	if(videos != "true") {
		if(target2.style.backgroundPosition == '' || target2.style.backgroundPosition == 'left top') {
			target2.style.backgroundPosition = 'left bottom';
			div.getElementsByTagName("div").item(0).style.display = 'none';
		}
		else {
			target2.style.backgroundPosition = 'left top';
			div.getElementsByTagName("div").item(0).style.display = '';
		}
	}
	else {
		if(target2.style.backgroundPosition == 'left top') {
			target2.style.backgroundPosition = 'left bottom';
			div.style.display = 'none';
		}
		else {
			target2.style.backgroundPosition = 'left top';
			div2.style.display = 'block';
		}
	}
	
	if(!test) {
		var file = "checkLeft.php";
		var ajaxRequest23;
		var queryString = "a=section&type=" + section + "1";

		try {
			// Opera 8.0+, Firefox, Safari
			ajaxRequest23 = new XMLHttpRequest();
		}
		catch (e) {
			// Internet Explorer Browsers
			try {
				ajaxRequest23 = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					ajaxRequest23 = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					// Request Failed
					alert("An error occured while processing your request.");
					return false;
				}
			}
		}

	
		ajaxRequest23.open("GET", "/ajax/"+file + "?" + queryString, true);
		ajaxRequest23.send(null);
	}
}	

function league_toggle(target, test) {
	target_dt = document.getElementById('dt_'+target);
	target_a = document.getElementById('a_'+target);
	target_ul = document.getElementById('ul_'+target);
	
	if(target_dt.style.fontWeight == 'bold') {
		target_dt.style.fontWeight = 'normal';
		target_a.style.backgroundPosition = "top left";
		target_ul.style.display = 'none';
	}
	else {
		target_dt.style.fontWeight = 'bold';
		target_a.style.backgroundPosition = "bottom left";
		target_ul.style.display = 'block';
	}
	if(!test) {
		var file = "checkLeft.php";
		var ajaxRequest24;
		var queryString = "a=league&league_id=" + target;


		try {
			// Opera 8.0+, Firefox, Safari
			ajaxRequest24 = new XMLHttpRequest();
		}
		catch (e) {
			// Internet Explorer Browsers
			try {
				ajaxRequest24 = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					ajaxRequest24 = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					// Request Failed
					alert("An error occured while processing your request.");
					return false;
				}
			}
		}

	
		ajaxRequest24.open("GET", "/ajax/"+file + "?" + queryString, true);
		ajaxRequest24.send(null);
	}
}

function page() {
	var page = document.getElementById("page");
	var content = document.getElementById("content");
	
	if(document.getElementById("right")) {
		page.style.backgroundPosition = 'left';
		content.style.width = '451px';
	}
	else {
		page.style.backgroundPosition = 'right';
		content.style.width = '682px';
	}
}

function applyFilter(get2, get3, get4, get5) {
	var game = document.getElementById("game_select");
	var platform = document.getElementById("game_system_select");
	var league = document.getElementById("ie_leagues_rel");
	
	var url = "/list/"+get2+"/"+(get2 == "articles" ? get3 + "/" : "")+(get2 == "releases" ? (platform.value != "no_system" ? platform.value : "") : (game.value != "no_game" ? game.value+"/" : "/")+(get2 == "upcoming" || get2 == "past" || get2 == "demos" ? (league.value != "no_league" ? league.value : "") : (platform.value != "no_system" ? platform.value : "")));
	
	window.location = url;
}

function fileAdd() {
	var x = eval(document.getElementsByTagName("input").length);
	document.getElementById("multi_file_"+x).innerHTML = '<input type="file" name="img'+x+'" /><div id="multi_file_'+(x+1)+'"></div>';
}

function showVideoForm(userid) {
	var div = document.getElementById("video_upload_form");
	div.style.display = 'block';
}

function showGalleryImage(image, gid, file, owner) {
	div = document.getElementById("gallery_image");
	div.innerHTML = '<div><a href="'+image+'" target="_blank"><img src="'+image+'" alt="" /></a></div><a href="#gallery" onclick="div.innerHTML = \'\';">Hide</a>'+(owner == "true" ? ' - <a href="/profile/gallery/delete/'+gid+'/'+file+'">Delete</a>' : "")+'<br /><br />';
}

function editGallery(id) {
	span = document.getElementById("ajax_gallery_"+id);
	span.innerHTML = '<form method="post" id="gallery_change" action=""><input type="text" id="gid" name="gid" value="'+span.innerHTML+'" /> <input type="button" name="gid_save" value="Save" onclick="gallerySave('+id+');" /> <input type="button" name="gid_add" value="Add Images" onclick="window.location = \'/profile/gallery/'+id+'\';" /> <input type="button" name="gid_close" value="Close" onclick="span.innerHTML = \''+span.innerHTML+'\';" /></form>';
}
