function $(id) {
	return document.getElementById(id);
}

function ajax() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

function writemovie(file) { 
	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="551" height="481"> <param name="movie" value="/flash/videoplayer.swf?vidfile=' + file + '"> <param name="quality" value="high"><embed src="/flash/videoplayer.swf?vidfile=' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="551" height="481"></embed></object>');

}

function writevuploader(type) {

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="420" height="120"> <param name="movie" value="/flash/vupload.swf?filetype=' + type + '"> <param name="wmode" value="transparent"> <param name="quality" value="high"> <embed src="/flash/vupload.swf?filetype=' + type + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="420" height="120"></embed></object>');

}

function writemoruploader(type) {

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="420" height="120"> <param name="movie" value="/flash/morupload.swf?filetype=' + type + '"> <param name="wmode" value="transparent"> <param name="quality" value="high"> <embed src="/flash/morupload.swf?filetype=' + type + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="420" height="120"></embed></object>');

}

function writevuploader2(type) {

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="420" height="120"> <param name="movie" value="/flash/pupload.swf?filetype=' + type + '"> <param name="wmode" value="transparent"> <param name="quality" value="high"> <embed src="/flash/pupload.swf?filetype=' + type + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="420" height="120"></embed></object>');

}

function writepuploader() {

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="420" height="120"> <param name="movie" value="/flash/pupload.swf"> <param name="quality" value="high"> <embed src="/flash/vupload.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="420" height="120"></embed></object>');

}

function writelogo() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="255" height="105"> <param name="movie" value="/flash/logo.swf"> <param name="wmode" value="transparent"><param name="quality" value="high"> <embed src="/flash/logo.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="255" height="105" wmode="transparent"></embed></object>');	
}

function setfilename(fname) {

	document.forms['subform'].filename.value = fname;

}

function fileuploaded() {

	document.forms['subform'].subbutt.disabled = false;
	document.forms['subform'].submit();

}

function fileuploadednonsub() {

	document.forms['subform'].subbutt.disabled = false;

}

function pfileuploaded() {

	document.forms['subform'].subbutt.disabled = false;

}

function selectCat(int) {
	switch(int) {
		case "1":
			destination = 155;
			product = "Boards";
		break;
		case "2":
			destination = 242;
			product = "Skis";
		break;
		case "3":
			destination = 345;
			product = "Boots";
		break;
		case "4":
			destination = 449;	
			product = "Bindings";
		break;
		case "5":
			destination = 569;		
			product = "Outerwear";
		break;
		case "6":
			destination = 696;	
			product = "Accessories";
		break;			
	}
	
	loadProducts(int);
	
}

function loadProducts(type) {
	
	$('prod_content').innerHTML = '<div class="header" align="center" style="padding:15px; padding-left:25px; padding-bottom:65px; font-size:18px; padding-top:25px;"><br><img src="/images/indicator.gif"><br>Loading ' + product + '...</div>';

	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=load&type=products&id=' + type + '&random=' + Math.random(9999999), true);
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
		
			$('prod_content').innerHTML = '<div class="header" align="left" style="padding:15px; padding-left:25px; font-size:18px;">' + product + '</div>';
			$('prod_content').innerHTML += ajx.responseText;
		
		}
	}
	ajx.send(null);

}

destination = 151;

function movearrow() {
	
	var curpos = parseInt($('product_selected').style.left);
	
	if(destination > curpos) {
		
		var trvl = (destination - curpos) * .30;
		$('product_selected').style.left = (curpos + Math.round(trvl)) + "px";
		
	} else if(destination < curpos) {
		var trvl = ((destination - curpos)*-1) * .30;
		$('product_selected').style.left = (curpos - Math.round(trvl)) + "px";
	}
	
	setTimeout("movearrow()", 50);
	
}

function comment(int, section) {
	
	if(section == "products") {
		$('commentbox').innerHTML = '<div align="center"><form action="/v_product.php?update=1&itemid=' + int + '&id=' + int +'" method="post"><table><tr><td>Name:</td><td><input type="text" name="username"></td></tr><tr><td>Comment:</td><td><textarea name="comment" style="width:300px; height:250px;"></textarea></td></tr><tr><td></td><td><input type="submit" style="padding:4px;" value="Add Comment"></td></tr></table></form></div>';
	} else if(section == "photo") {
		$('commentbox').innerHTML = '<div align="center"><form action="/v_photo.php?update=1&itemid=' + int + '&id=' + int +'" method="post"><table><tr><td>Name:</td><td><input type="text" name="username"></td></tr><tr><td>Comment:</td><td><textarea name="comment" style="width:300px; height:250px;"></textarea></td></tr><tr><td></td><td><input type="submit" style="padding:4px;" value="Add Comment"></td></tr></table></form></div>';
	} else if(section == "resorts") {
		$('commentbox').innerHTML = '<div align="center"><form action="/v_resort.php?update=1&itemid=' + int + '&id=' + int +'" method="post"><table><tr><td>Name:</td><td><input type="text" name="username"></td></tr><tr><td>Comment:</td><td><textarea name="comment" style="width:300px; height:250px;"></textarea></td></tr><tr><td></td><td><input type="submit" style="padding:4px;" value="Add Comment"></td></tr></table></form></div>';
	} else if(section == "video") {
		$('commentbox').innerHTML = '<div align="center"><form action="/v_video.php?update=1&itemid=' + int + '&id=' + int +'" method="post"><table><tr><td>Name:</td><td><input type="text" name="username"></td></tr><tr><td>Comment:</td><td><textarea name="comment" style="width:300px; height:250px;"></textarea></td></tr><tr><td></td><td><input type="submit" style="padding:4px;" value="Add Comment"></td></tr></table></form></div>';
	}

}

function writemainrot() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="700" height="190">');
		document.write('<param name="movie" value="flash/usMap.swf" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<param name="quality" value="high" />');	
		document.write('<embed src="flash/usMap.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="190"></embed>');	
	document.write('</object>');	
}

function writeBandName(name, citystate, image) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="700" height="120">');
      document.write('<param name="movie" value="flash/bandtitle.swf?bandname=' + name + '&citystate=' + citystate + '&bandimage=images/userimages/bl_' + image + '" />');
      document.write('<param name="quality" value="high" />');
	  document.write('<param name="wmode" value="transparent" />');
      document.write('<embed src="flash/bandtitle.swf?bandname=' + name + '&citystate=' + citystate + '&bandimage=images/userimages/bl_' + image + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="120" wmode="transparent"></embed>');
    document.write('</object>');	
}

function writeResortSearchBox(theState, sortBy) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="900" height="190">');
		document.write('<param name="movie" value="flash/usMap_resorts.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<PARAM NAME=FlashVars VALUE="theState='+theState+'&sortBy='+sortBy+'">');
		document.write('<embed src="flash/usMap_resorts.swf?theState=' + theState + '&sortBy=' + sortBy + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="900" height="190"></embed>');	
	document.write('</object>');
}

function addAlert(type) {
	if($('alert_email').value == "" && $('alert_phone').value == "" || validalert == 0) {
		alert('You don\'t have a email address or phone number set.\nPlease input one to start recieving alerts.');
	} else {
		switch(type) {
			
			case "powder":
				var oldcontents = $('palerts').innerHTML;
				
				$('palerts').innerHTML =  '<img src="images/indicator.gif" style="padding:10px;">';
				
				var ajx = new ajax();
				
				ajx.open('get', '/includes/ajax.php?action=loadstates&random=' + Math.random(9999999), true);
				ajx.onreadystatechange = function() {
					if(ajx.readyState == 4) {
						$('palerts').innerHTML = '<div style="font-size:12px; padding-left:5px; padding-top:5px; padding-bottom:5px; width:100%;" align="left"><i style="font-size:13px; padding-left:12px;">Powder Alert for:</i>&nbsp;<div align="left" style="">';
						$('palerts').innerHTML += ajx.responseText;
						$('palerts').innerHTML += '<div style="float:left; font-size:12px; padding-left:5px;" id="resortnames"></div><br><div style="float:left; font-size:12px; padding-left:5px; padding-top:5px; width:97%;" id="alertoptions"></div></div></div>';
						$('palerts').innerHTML += oldcontents;
					}
				}
				ajx.send(null);
			break;
			
			case "resort":
				var oldcontents = $('ralerts').innerHTML;
				alert(oldcontents);
			break;		
			
		}
	}
}

currentstate = "";

function loadres(state) {

	$('resortnames').innerHTML = '<span style="vertical-align:-6px; padding-left:45px;"><img src="images/indicator.gif" style="padding-right:5px;"></span> <span style="vertical-align:-3px;">Loading ' + state + ' Resorts...</span>';
	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=loadresorts&state=' + state + '&random=' + Math.random(9999999), true);
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			$('resortnames').innerHTML = ajx.responseText;
			alerttext = 0;
			alertemail = 0;
			currentstate = state;
		}
	}
	ajx.send(null);

}

function loaddetails() {

	$('alertoptions').innerHTML = '<span style="vertical-align:-6px; padding-left:45px;"><img src="images/indicator.gif" style="padding-right:5px;"></span> <span style="vertical-align:-3px;">Loading...</span>';
	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=loadoptions&random=' + Math.random(9999999), true);
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			$('alertoptions').innerHTML = ajx.responseText;
		}
	}
	ajx.send(null);
}

function updateAlertInfo() {
	
	var ajx = new ajax();
	ajx.open('get','/includes/ajax.php?action=updatealerts&email=' + $('alert_email').value + '&phone=' + $('alert_phone').value + '&random=' + Math.random(99999999999));
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			validalert = 1;	
			$('infoup').style.display = "block";
		}
	}
	ajx.send(null);
	
}

alertemail = 0;
alerttext = 0;

function setStatus(type, item) {

	if(item.getAttribute("selected") == "0") {
		item.setAttribute("selected", "1");
		item.style.border = "3px solid #000000";
		if(type == "email") {
			alertemail = 1;
		} 
		if(type == "text") {
			alerttext = 1;
		} 		
		
	} else {
		item.setAttribute("selected", "0");
		item.style.border = "3px solid #CCCCCC";
		if(type == "email") {
			alertemail = 0;
		} 
		if(type == "text") {
			alerttext = 0;
		} 			

	}
	if($('depth').value != "") {
		if(alerttext == 0 && alertemail == 0 ) {
			$('savebutton').setAttribute("disabled","disabled");	
		} else {
			$('savebutton').removeAttribute("disabled");
		}
	} else {
		$('savebutton').setAttribute("disabled","disabled");
	}
}

function cancelalrt() {
	$('palerts').innerHTML = '';	
}

function savealert() {
	// Pull vars
	var state = currentstate;
	var resort = $('resort').value;
	var alertwhen = $('alertwhen').value;
	var depth = $('depth').value;
	var txt = alerttext;
	var eml = alertemail;
	
	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=savealert&state=' + state + '&resort=' + resort + '&alertwhen=' + alertwhen + '&depth=' + depth + '&text=' + txt + '&email=' + eml + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			$('palerts').innerHTML = '<img src="images/indicator.gif" style="padding-right:5px;">';
			
			var totres = ajx.responseText.split("|");
			
			for(i=0;i<=totres.length;i++) {
				var ajx1 = new ajax();
				ajx.open('open', '/includes/ajax.php?action=loadalert&id=' + totres[i] + '&random=' + Math.random(9999999));
				ajx.onreadystatechange = function() {
					if(ajx.readyState == 4) {
							
						var oldcontents = $('epalerts').innerHTML;
						$('epalerts').innerHTML = ajx.responseText;
						$('epalerts').innerHTML += oldcontents;
						
					}
				}
				ajx.send(null);
			}
			$('palerts').innerHTML = "";
			
		}
	}
	ajx.send(null);
}

function writemasthead() {
	var currentTime = new Date();
	var hour = currentTime.getHours();
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="900" height="114">');
		document.write('<param name="movie" value="/flash/masthead.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<PARAM NAME=FlashVars VALUE="hour='+hour+'">');
		document.write('<embed src="/flash/masthead.swf?hour='+hour+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="900" height="114"></embed>');	
	document.write('</object>');
}

function deletealert(id) {
	var verify = confirm("Are you sure you want to delete this alert?");
	if(verify) {

		$('alert_' + id).style.display = "none";
	
		var ajx = new ajax();
		ajx.open('get','/includes/ajax.php?action=delalert&id=' + id + '&random=' + Math.random(999999999));
		ajx.onreadystatechange = function() {
			if(ajx.readyState == 4) {
			
				// Deleted.
			
			}
		}
		ajx.send(null);
		
	}
}

function editmember(id) {
	
	memberid = id;
	mode = "edit";
	$('addbutton').value = "Edit Member";
	
	var ajx = new ajax();	
	
	ajx.open('get','includes/ajax.php?action=getmember&id=' + memberid + '&random=' + Math.random(9999999));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			var meminfo = ajx.responseText.split("||");
			$('first').value = meminfo[0];
			$('last').value = meminfo[1];
			$('age').value = meminfo[2];			
			$('role').value = meminfo[3];
			$('bio').value = meminfo[4];				
			
		}
	
	}
	ajx.send(null);	
	
}

function editmemberupdate() {

	var first = $('first').value;
	var last = $('last').value;
	var role = $('role').value;
	var age = $('age').value;
	var bio = $('bio').value;
		
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=editmember&id=' + memberid + '&first=' + first + '&last=' + last + '&role=' + role + '&age=' + age + '&bio=' + bio + '&random=' + Math.random(9999999));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			$('members_' + memberid).innerHTML = '' + first + '&nbsp;' + last + '&nbsp;[ <a href="javascript:deletemember(' + ajx.responseText + ');">delete</a> ] [ <a href="javascript:editmember(' + ajx.responseText + ');">edit</a> ]';
			$('first').value = '';
			$('last').value = '';
			$('role').value = '';
			$('age').value = '';
			$('bio').value = '';				
			mode = "add";
			$('addbutton').value = "Add Member";				
			
		}
	
	}
	ajx.send(null);	

}

function addmember() {

	if($('first').value == "" || $('last').value == "") {
		
		alert("You must enter a first and last name");
		return;
	} else if(mode == "edit") {
		editmemberupdate();
		return;
	}

	//get values from form fields
	var first = $('first').value;
	var last = $('last').value;
	var role = $('role').value;
	var age = $('age').value;
	var bio = $('bio').value;
	
	$('first').value = '';
	$('last').value = '';
	$('role').value = '';
	$('age').value = '';
	$('bio').value = '';	
	
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=addmember&first=' + first + '&last=' + last + '&role=' + role + '&age=' + age + '&bio=' + bio + '&random=' + Math.random(9999999));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			$('members').innerHTML += '<div class="memberbox" id="members_' + ajx.responseText + '" align="left">' + first + '&nbsp;' + last + '&nbsp;[ <a href="javascript:deletemember(' + ajx.responseText + ');">delete</a> ] [ <a href="javascript:editmember(' + ajx.responseText + ');">edit</a> ]</div>';
			
		}
	
	}
	ajx.send(null);

}

function deletemember(id) {
	
	if(confirm("Are you sure you want to delete this member?")) {
	
		var ajx = new ajax();
		
		ajx.open('get','includes/ajax.php?action=deletemember&id=' + id + '&random=' + Math.random(9999999));
		ajx.onreadystatechange = function() {
		
			if(ajx.readyState == 4) {
				
				$('members_' + id).style.display = "none";
				
			}
		
		}
		ajx.send(null);

	}

}

function createAlbum() {
	if($('addalbum').style.display == "none") {
		$('addalbum').style.display = "block";
	} else {
		$('addalbum').style.display = "none";		
	}
}

function createAlbumFunction() {
	if($('albumname').value == "") {
		alert("No Album Title entered.");
		return;
	} else if(albumaction == "edit") {
		editalbumupdate();
		return;
	}
			 
	
	var albumtitle = $('albumname').value;
	
	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=addalbum&title=' + albumtitle + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
		
			$('albumname').value = '';
			$('albums').innerHTML += '<div class="albumbox" id="album_' + ajx.responseText + '" align="left">' + albumtitle + '&nbsp;&nbsp;&nbsp;[ <a href="javascript:deletealbum(' + ajx.responseText + ');">delete</a> ] [ <a href="javascript:editalbum(' + ajx.responseText + ');">edit</a> ]</div>';
			$('addalbum').style.display = "none";
			getAlbums();
		
		}
	
	}
	ajx.send(null);
}

function deletealbum(id) {

	
	if(confirm("Are you sure you want to delete this album?")) {
		
		$('album_' + id).style.display = "none";
		
		var ajx = new ajax();
		ajx.open('get','includes/ajax.php?action=deletealbum&id=' + id + '&random=' + Math.random(888888888));
		ajx.onreadystatechange = function() {
		
			if(ajx.readyState == 4) {
				
				// Album deleted
				getAlbums();
			}
		
		}
		ajx.send(null);			
	}
}

function editalbum(id) {

	$('addalbum').style.display = "block";
	$('addalbumbutton').value = "Edit";
	
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=getalbum&id=' + id + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			editid = id;
			albumaction = "edit";
			$('albumname').value = ajx.responseText;
		
		}
		
	}
	ajx.send(null);

}

function editalbumupdate() {

	var title = $('albumname').value;
	$('album_' + editid).innerHTML = title + '&nbsp;&nbsp;&nbsp;[ <a href="javascript:deletealbum(' + editid + ');">delete</a> ] [ <a href="javascript:editalbum(' + editid + ');">edit</a> ]';

	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=updatealbum&id=' + editid + '&title=' + title + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			$('albumname').value = "";
			$('addalbum').style.display = "none";
			$('addalbumbutton').value = "Add";
			albumaction = "";
			getAlbums();			
		
		}
		
	}
	ajx.send(null);

}

function addSong() {
	
	if($('addsong').style.display == "none") {
		$('addsong').style.display = "block";
	} else {
		$('addsong').style.display = "none";		
	}
	getAlbums();
	
}

function getAlbums() {

	$('albumdropdown').innerHTML = '<b>Loading Albums...</b>';
	$('valbumdropdown').innerHTML = '<b>Loading Albums...</b>';

	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=getalbums&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			
			var albs = ajx.responseText.split("||");
			$('albumdropdown').innerHTML = albs[0];
			$('valbumdropdown').innerHTML = albs[1];
		}
	}
	ajx.send(null);

}

function addSongFunction() {

	if($('songname').value == "") {
		alert("No Song Title entered.");
		return;
	} else if(songaction == "edit") {
		editsongupdate();
		return;
	}
	
	var songtitle = $('songname').value;
	var songyear = $('songyear').value;
	var songalbum = $('songalbums').selectedIndex;
	var songalbumid = $('songalbums').value;
	
	if(songyear == "")
		songyear = "2008";
	
	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=addsong&title=' + songtitle + '&year=' + songyear + '&album=' + songalbum + '&albumid=' + songalbumid + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
		
			$('songname').value = '';
			$('songyear').value = '';
			$('songalbums').selectedIndex = 0;			
			
			$('songs').innerHTML += '<div class="albumbox" id="song_' + ajx.responseText + '" align="left"><span id="songtitle_' + ajx.responseText + '">' + songtitle + '</span>&nbsp;&nbsp;&nbsp;[ <a href="upload.php?action=uploadsong&id=' + ajx.responseText + '">upload audio</a> ] [ <a href="javascript:deletesong(' + ajx.responseText + ');">delete</a> ] [ <a href="javascript:editsong(' + ajx.responseText + ');">edit</a> ]</div>';
			$('addsong').style.display = "none";
		
		}
	
	}
	ajx.send(null);

}

function deletesong(id) {

	if(confirm("Are you sure you want to delete this song?")) {
	
		$('song_' + id).style.display = "none";
		
		var ajx = new ajax();
		ajx.open('get','includes/ajax.php?action=deletesong&id=' + id + '&random=' + Math.random(888888888));
		ajx.onreadystatechange = function() {
		
			if(ajx.readyState == 4) {
				
				// Album deleted
				
			}
		
		}
		ajx.send(null);	
		
	}

}


function editsong(id) {

	$('addsong').style.display = "block";
	$('addsongbutton').value = "Edit Song";
	
	getAlbums();
	
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=getsong&id=' + id + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			editid = id;
			songaction = "edit";
			
			var songitems = ajx.responseText.split("||");
			
			$('songname').value = songitems[0];
			$('songyear').value = songitems[1];
			$('songalbums').selectedIndex = songitems[2];	
		
		}
		
	}
	ajx.send(null);

}

function editsongupdate() {

	var title = $('songname').value;
	var year = $('songyear').value;
	var album = $('songalbums').selectedIndex;
	var albumid = $('songalbums').value;
	$('songtitle_' + editid).innerHTML = title;
	
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=updatesong&id=' + editid + '&title=' + title + '&year=' + year + '&album=' + album + '&albumid=' + albumid + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			$('addsong').style.display = "none";
			$('addsongbutton').value = "Add Song";
			$('songname').value = "";
			$('songyear').value = "";
			$('songalbums').selectedIndex = 0;			
			songaction = "";
		
		}
		
	}
	ajx.send(null);

}


//----------------------------------------


function addVideo() {
	
	if($('addvideo').style.display == "none") {
		$('addvideo').style.display = "block";
	} else {
		$('addvideo').style.display = "none";		
	}
	getAlbums();	
	
}

function addImage() {
	
}

function addVideoFunction() {

	if($('videoname').value == "") {
		alert("No Video Title entered.");
		return;
	} else if(videoaction == "edit") {
		editvideoupdate();
		return;
	}
	
	var videotitle = $('videoname').value;
	var videoyear = $('videoyear').value;
	var videoalbum = $('videoalbums').selectedIndex;	
	
	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=addvideo&title=' + videotitle + '&year=' + videoyear + '&album=' + videoalbum + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
		
			$('videoname').value = '';
			$('videoyear').value = '';
			$('videoalbums').selectedIndex = 0;			
			
			$('videos').innerHTML += '<div class="albumbox" id="video_' + ajx.responseText + '" align="left"><span id="videotitle_' + ajx.responseText + '">' + videotitle + '</span>&nbsp;&nbsp;&nbsp;[ <a href="upload.php?action=uploadvideo&id=' + ajx.responseText + '">upload video</a> ] [ <a href="javascript:deletevideo(' + ajx.responseText + ');">delete</a> ] [ <a href="javascript:editvideo(' + ajx.responseText + ');">edit</a> ]</div>';
			$('addvideo').style.display = "none";
		
		}
	
	}
	ajx.send(null);

}

function deletevideo(id) {

	if(confirm("Are you sure you want to delete this video?")) {
	
		$('video_' + id).style.display = "none";
		
		var ajx = new ajax();
		ajx.open('get','includes/ajax.php?action=deletevideo&id=' + id + '&random=' + Math.random(888888888));
		ajx.onreadystatechange = function() {
		
			if(ajx.readyState == 4) {
				
				// Album deleted
				
			}
		
		}
		ajx.send(null);			

	}

}

function editvideo(id) {

	$('addvideo').style.display = "block";
	$('addvideobutton').value = "Edit Video";
	
	getAlbums();
	
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=getvideo&id=' + id + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			editid = id;
			videoaction = "edit";
			
			var songitems = ajx.responseText.split("||");
			
			$('videoname').value = songitems[0];
			$('videoyear').value = songitems[1];
			$('videoalbums').selectedIndex = songitems[2];	
		
		}
		
	}
	ajx.send(null);

}

function editvideoupdate() {

	var title = $('videoname').value;
	var year = $('videoyear').value;
	var album = $('videoalbums').selectedIndex;
	$('videotitle_' + editid).innerHTML = title;
	
	var ajx = new ajax();
	
	ajx.open('get','includes/ajax.php?action=updatevideo&id=' + editid + '&title=' + title + '&year=' + year + '&album=' + album + '&random=' + Math.random(99999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			$('addvideo').style.display = "none";
			$('addvideobutton').value = "Add Video";
			$('videoname').value = "";
			$('videoyear').value = "";
			$('videoalbums').selectedIndex = 0;			
			videoaction = "";
		
		}
		
	}
	ajx.send(null);

}


function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

//-----------------------------------------

function adminListen(file) {
	file = addslashes(file);
	document.write('<object type="application/x-shockwave-flash" data="/flash/mini_mp3.swf?mp3=/audio/' + file + '&autoplay=0&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451" width="200" height="20" wmode="transparent">');
	document.write('<param name="movie" value="/flash/mini_mp3.swf?mp3=/audio/' + file + '&autoplay=0&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="/flash/mini_mp3.swf?mp3=/audio/' + file + '&autoplay=0&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="20"></embed>');
	document.write('</object>');

}

function listen(file) {

	$('mp3preview').style.display = "block";
	$('mp3preview').innerHTML = '<object type="application/x-shockwave-flash" data="flash/mini_mp3.swf?mp3=audio/' + file + '&autoplay=1&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451" width="200" height="20" wmode="transparent">';
	$('mp3preview').innerHTML += '<param name="movie" value="flash/mini_mp3.swf?mp3=audio/' + file + '&autoplay=0&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451" />';
	$('mp3preview').innerHTML += '<param name="wmode" value="transparent" />';
	$('mp3preview').innerHTML += '<embed src="flash/mini_mp3.swf?mp3=audio/' + file + '&autoplay=1&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="20"></embed>';
	$('mp3preview').innerHTML += '</object>';

}

function bandplayer(file) {

	document.write('<object type="application/x-shockwave-flash" data="flash/norm_mp3.swf?mp3=audio/' + file + '&autoplay=1&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451&showvolume=1" width="200" height="20" wmode="transparent">');
	document.write('<param name="movie" value="flash/norm_mp3.swf?mp3=audio/' + file + '&autoplay=1&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451&showvolume=1" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="flash/norm_mp3.swf?mp3=audio/' + file + '&autoplay=1&slidercolor=215AB4&buttoncolor=215AB4&loadingcolor=1C3451&showvolume=1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="20"></embed>');
	document.write('</object>');

}

function siteplayer(file,title) {

	document.write('<object type="application/x-shockwave-flash" data="flash/multi_mp3.swf?mp3=' + file + '&title=' + title + '&autoplay=0&bgcolor1=162D49&bgcolor2=162D49&slidercolor=215AB4&buttoncolor=215AB4&loop=0&currentmp3color=ffffff&textcolor=999999&showplaylistnumbers=0&loadingcolor=1C3451&showvolume=1&shuffle=1&width=320" width="320" height="100" wmode="transparent">');
	document.write('<param name="movie" value="flash/multi_mp3.swf?mp3=' + file + '&title=' + title + '&autoplay=0&bgcolor1=162D49&bgcolor2=162D49&slidercolor=215AB4&loop=0&buttoncolor=215AB4&currentmp3color=ffffff&textcolor=999999&showplaylistnumbers=0&loadingcolor=1C3451&showvolume=1&shuffle=1" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="flash/multi_mp3.swf?mp3=' + file + '&title=' + title + '&autoplay=0&bgcolor1=162D49&bgcolor2=162D49&slidercolor=215AB4&loop=0&buttoncolor=215AB4&currentmp3color=ffffff&textcolor=999999&showplaylistnumbers=0&loadingcolor=1C3451&showvolume=1&shuffle=1&width=320" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="320" height="100"></embed>');
	document.write('</object>');

}

function watchVideo(file,image) {
	$('vidpreview').style.display = "block";	
	$('vidpreview').innerHTML = '<object type="application/x-shockwave-flash" data="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" width="200" height="170" wmode="opaque" allowfullscreen="true">';
	$('vidpreview').innerHTML += '<param name="movie" value="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" />';
	$('vidpreview').innerHTML += '<param name="wmode" value="opaque" />';
	$('vidpreview').innerHTML += '<param name="allowfullscreen" value="true" />';
	$('vidpreview').innerHTML += '<embed src="flash/multi_mp3.swf?mp3=' + file + '&title=' + title + '&autoplay=1&bgcolor1=162D49&bgcolor2=162D49&slidercolor=215AB4&loop=0&buttoncolor=215AB4&currentmp3color=ffffff&textcolor=999999&showplaylistnumbers=0&loadingcolor=1C3451&showvolume=1&shuffle=1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="170"></embed>';	
	$('vidpreview').innerHTML += '</object>';
}

function watchVideoAdmin(file,image) {

	document.write('<object type="application/x-shockwave-flash" data="/mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" width="225" height="191" wmode="opaque" allowfullscreen="true">');
	document.write('<param name="movie" value="/mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<embed src="/mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="225" height="191"></embed>');		
	document.write('</object>');
}

function watchVideoLarge(file,image) {

	document.write('<object type="application/x-shockwave-flash" data="mediaplayer/player.swf?file=/videos/' + file + '&autostart=true&image=/videos/' + image + '" width="300" height="255" wmode="opaque" allowfullscreen="true">');
	document.write('<param name="movie" value="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<embed src="mediaplayer/player.swf?file=/videos/' + file + '&autostart=true&image=/videos/' + image + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="255"></embed>');		
	document.write('</object>');
}
function watchVideoProfile(file,image) {

	document.write('<object type="application/x-shockwave-flash" data="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" width="262" height="222" wmode="opaque" allowfullscreen="true">');
	document.write('<param name="movie" value="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<param name="allowfullscreen" value="true" />');
	document.write('<embed src="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="262" height="222"></embed>');		
	document.write('</object>');
}

function switchVideoLarge(file,image) {
	
	$('vidboxband').innerHTML = '<object type="application/x-shockwave-flash" data="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" width="300" height="255" wmode="opaque" allowfullscreen="true">';
	$('vidboxband').innerHTML += '<param name="movie" value="flash/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" />';
	$('vidboxband').innerHTML += '<param name="wmode" value="opaque" />';
	$('vidboxband').innerHTML += '<param name="allowfullscreen" value="true" />';
	$('vidboxband').innerHTML += '<embed src="mediaplayer/player.swf?file=/videos/' + file + '&image=/videos/' + image + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="255"></embed>';	
	$('vidboxband').innerHTML += '</object>';

}

function deleteImage(id,div) {

	if(confirm("Are you sure you want to delete this image?")) {
		$('imgbox_' + div).style.display = "none";
		
		var ajx = new ajax();
		ajx.open('get','includes/ajax.php?action=deletebandimage&id=' + id + '&random=' + Math.random(888888888));
		ajx.onreadystatechange = function() {
		
			if(ajx.readyState == 4) {
				
				// Album deleted
				
			}
		
		}
		ajx.send(null);			

		
	}

}

function deleteMemberImage(id) {

	if(confirm("Are you sure you want to delete this image?")) {
		$('img_' + id).style.display = "none";
		
		var ajx = new ajax();
		ajx.open('get','includes/ajax.php?action=deletememberimage&id=' + id + '&random=' + Math.random(888888888));
		ajx.onreadystatechange = function() {
		
			if(ajx.readyState == 4) {
				
				// Album deleted
				
			}
		
		}
		ajx.send(null);			

		
	}

}

function setFeatured(id,div) {

	$('img_' + div).style.border = "8px solid #2AAE00";				
	
	resetFeatured(div);		
	
	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=setbandimage&id=' + id + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			// Album deleted
			
		}
	
	}
	ajx.send(null);			


}

function resetFeatured(id) {
	
	//id is the id to ignore
	for(i=1;i<=totalimages;i++) {
	
		if(i != id)
			$('img_' + i).style.border = "8px solid #1C3451";	
	
	}
	
}

function vote(band) {
	
	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=vote&band=' + band + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			if(ajx.responseText != "") {
			
				alert(ajx.responseText);
			
			} else {
			
				$('votebutton').src = 'images/thanksforvoting.jpg';
			
			}
			
		}
	
	}
	ajx.send(null);		
	
}

function addcomment(id) {

	if($('commentbox').style.display != "block") {
		$('commentbox').style.display = "block";
		$('addcommentbutton').innerHTML = "close comment box";
	} else {
		$('commentbox').style.display = "none";	
		$('addcommentbutton').innerHTML = "add comment";
	}

}

function becomefan(id) {
	
	var ajx = new ajax();
	ajx.open('get','includes/ajax.php?action=fan&band=' + id + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			if(ajx.responseText != "") {
			
				alert(ajx.responseText);
			
			} else {
			
				alert("You are now a fan of this artist!");
				$('fanbutton').src = 'images/currentfan.jpg';
				document.location = '/band.php?id=' + id;
			
			}
			
		}
	
	}
	ajx.send(null);		
	
}

function submitComment(id) {

	var comment = $('comment').value;
	$('commentbox').style.display = "none";	
	
	var ajx = new ajax();	
	ajx.open('get','includes/ajax.php?action=comment&band=' + id + '&comment=' + comment + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			if(ajx.responseText == "NOLOGIN") {
				
				$('addcommentbutton').innerHTML = "add comment";
				alert("You must be logged in to post comments.");
			
			} else {
				
				$('addcommentbutton').innerHTML = "add comment";
				alert("Thanks for your comment.\n\nAll comments are moderated for content and are not displayed immediately.");
				//var comcon = $('commentsdisplay').innerHTML;
				//$('commentsdisplay').innerHTML = ajx.responseText;
				//$('noComments').display = "none";
				//$('commentsdisplay').innerHTML += comcon;
				$('comment').value = '';
				
			}
			
		}
	
	}
	ajx.send(null);		

}

function submitCommentMor(id) {

	var comment = $('comment').value;
	$('commentbox').style.display = "none";	
	
	var ajx = new ajax();	
	ajx.open('get','includes/ajax.php?action=commentmor&vid=' + id + '&comment=' + comment + '&random=' + Math.random(888888888));
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {

			window.location.reload();
			
		}
	
	}
	ajx.send(null);		

}

function uploadingdisable() {
	document.forms['subform'].subbutt.disabled = true;
}
function pDeny (id,type) {
	if(confirm("Are you sure you want to Deny this item?")) {
		var ajx = new ajax();
		ajx.open('get', '../includes/ajax.php?action=admin&type=' + type + '&function=pendingdeny&id=' + id + '&random=' + Math.random(9999999999), true);
		switch(type) {
			case "band":
				$('band_' + id).style.display = "none";		
			break;
			case "album":
				$('album_' + id).style.display = "none";		
			break;
			case "bio":
				$('bio_' + id).style.display = "none";		
			break;
			case "gallery":
				$('gallery_' + id).style.display = "none";		
			break;
			case "song":
				$('song_' + id).style.display = "none";		
			break;
		}
		ajx.onreadystatechange = function() {
			if(ajx.readyState == 4) {
				// Complete
			}
		}
		ajx.send(null);
	}
}
function pApprove(id,type) {
	var ajx = new ajax();
	ajx.open('get', '../includes/ajax.php?action=admin&type=' + type + '&function=pending&id=' + id + '&random=' + Math.random(9999999999), true);
	switch(type) {
		case "band":
			$('band_' + id).style.display = "none";		
		break;
		case "album":
			$('album_' + id).style.display = "none";		
		break;
		case "bio":
			$('bio_' + id).style.display = "none";		
		break;
		case "gallery":
			$('gallery_' + id).style.display = "none";		
		break;
		case "song":
			$('song_' + id).style.display = "none";		
		break;
	}
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			// Complete
		
		}
		
	}
	ajx.send(null);
}
function approve(id,type) {

	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=admin&type=' + type + '&function=approve&id=' + id + '&random=' + Math.random(9999999999), true);

	switch(type) {
	
		case "video":
		
			$('vid_' + id).style.display = "none";
		
		break;
		
		case "photo":
		
			$('pho_' + id).style.display = "none";
		
		break;
		
		case "comment":
	
			$('com_' + id).style.display = "none";	
	
		break;
		
		case "audio":
		
			$('aud_' + id).style.display = "none";		
		
		break;
		case "band":
		
			$('band_' + id).style.display = "none";		
		
		break;	
		case "album":
			$('album_' + id).style.display = "none";		
		break;
		case "bio":
			$('bio_' + id).style.display = "none";		
		break;
		case "gallery":
			$('gallery_' + id).style.display = "none";		
		break;
		case "song":
			$('song_' + id).style.display = "none";		
		break;
	
	}

	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			// Complete
		
		}
		
	}
	ajx.send(null);

}

function deny(id,type) {
	
	if(confirm("Are you sure you want to Deny this item?")) {
	
		var ajx = new ajax();
		ajx.open('get', '/includes/ajax.php?action=admin&type=' + type + '&function=deny&id=' + id + '&random=' + Math.random(9999999999), true);
	
		switch(type) {
		
			case "video":
			
				$('vid_' + id).style.display = "none";
			
			break;
			
			case "photo":
			
				$('pho_' + id).style.display = "none";
			
			break;
			
			case "comment":
		
				$('com_' + id).style.display = "none";	
		
			break;
			
			case "audio":
			
				$('aud_' + id).style.display = "none";		
			
			break;
			case "album":
				$('album_' + id).style.display = "none";		
			break;
			case "bio":
				$('bio_' + id).style.display = "none";		
			break;
			case "gallery":
				$('gallery_' + id).style.display = "none";		
			break;
			case "song":
				$('song_' + id).style.display = "none";		
			break;
		
		}
	
		ajx.onreadystatechange = function() {
			
			if(ajx.readyState == 4) {
			
				// Complete
			
			}
			
		}
		ajx.send(null);

	}

}

function shoutOpen() {
	document.getElementById("shoutButton").innerHTML = '[ <a href="#" onclick="shoutClose();">close shout</a> ]';
	document.getElementById("shoutBox").style.display = "block";
}
function shoutClose() {
	document.getElementById("shoutButton").innerHTML = '[ <a href="#" onclick="shoutOpen();">add shout</a> ]';	
	document.getElementById("shoutBox").style.display = "none";
}

searchtimer = '';

function searchTimeout() {
	searchtimer = setTimeout("searchmor()", 500); // reset the timer each time a key is pressed.
}

function searchmor() {

	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=searchmor&query=' + $('query').value + '&category=' + $('category').value + '&random=' + Math.random(9999999999), true);

	ajx.onreadystatechange = function() {
			
		if(ajx.readyState == 4) {
		
			$('search_results').innerHTML = ajx.responseText;
		
		}
		
	}
	ajx.send(null);

}

function vote(stars, id) {
	var ajx = new ajax();
	ajx.open('get', '/includes/ajax.php?action=votemor&stars=' + stars + '&id=' + id + '&random=' + Math.random(9999999999), true);

	ajx.onreadystatechange = function() {
			
		if(ajx.readyState == 4) {
		
			//
			if(ajx.responseText != "-1") {
				alert("Vote Cast.");	
				totstars = ajx.responseText;
				resetStars();
			} else {
				alert("You must be logged in to vote.");
				resetStars();
			}
		
		}
		
	}
	ajx.send(null);
}

function changeStars(num) {

	for(i=1;i<=5;i++) {
	
		$('star_' + i).src = '/images/noratestar.jpg';
	
	}

	for(i=1;i<=num;i++) {
	
		$('star_' + i).src = '/images/ratestar.jpg';
	
	}

}

function resetStars() {

	for(i=1;i<=5;i++) {
	
		$('star_' + i).src = '/images/noratestar.jpg';
	
	}

	for(i=1;i<=totstars;i++) {
	
		$('star_' + i).src = '/images/ratestar.jpg';
	
	}

}