var ratings = ['UGLY','BAD','DECENT','HOOD','CERTIFIED HEAT'];

function checkReview(form) {
  var comment = form.elements['comments'];
  var rating = form.elements['rating'];
  var txt = comment.value;
  var rval = rating.options[rating.selectedIndex].value;
  if(txt.length < 50 || /(http|www\.|\.com|<|>|href|\.net|\.org)/.test(txt) || /\S{30,}/.test(txt)) {
    alert('The comment you wrote is too short or contains invalid characters!\nPlease check your comment and try again.');
	comment.focus();
	return false;
  }
  else if(!/^(1|2|3|4|5)$/.test(rval)) {
    alert('Please select a rating for this mixtape.');
	rating.focus();
	return false;
  }
  else {
    return true;
  }
}

function toggleReviewView(type) {
  var lyr = document.getElementById('reviewlink');
  var rlyr = document.getElementById('rinner');
  var txt = '';
  if(type == 1) {
    txt = '<a href="javascript:void(0)" onclick="toggleReviewView(2)" title="Hide Reviews">Hide Reviews</a><b>&nbsp;&laquo;</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	rlyr.className = 'rview_open';
  }
  else if(type == 2) {
    txt = '<a href="javascript:void(0)" onclick="toggleReviewView(1)" title="View All Reviews">View All Reviews</a><b>&nbsp;&laquo;</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	rlyr.className = 'rview_collapse';
  }
  lyr.innerHTML = txt;
}

if(li && uhd && uhc!=1) {
  var cmtext = '';
  cmtext += '<BR><a name="review"></a>';
  cmtext += '<table cellpadding=0 cellspacing=0 border=0><tr><td width=425 height=24 background="/images/mtp_subcathead4.gif" class=pagesub valign=bottom>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Review This Mixtape</td></tr><tr><td width=425 height=5><img src="/images/spacer.gif" width=1 height=1 border=0></td></tr></table>';
  cmtext += '<table cellpadding=5 cellspacing=0 border=0 width=100% align=center>';
  cmtext += '<tr>';
  cmtext += '<td width=100% valign=top>';
  cmtext += '<table cellpadding=5 cellspacing=0 border=0 width=100% align=center>';
  if(!uhc) { cmtext += '<form action="/review_mixtape.php" method=POST onsubmit="return checkReview(this)">'; }
  cmtext += '<tr class=signuptext>';
  cmtext += '<td>';
  if(uhc) {
    cmtext += 'Your comment has been submitted and is waiting to be approved by one of our editors. Once approved your review will appear on this page and you will receive your FREE 1,000 Rewards Points!<BR><BR>';
	cmtext += '<center><a href="http://www.mixtapepass.com/#reviews" title="Review More Mixtapes I Have Downloaded">Review More Mixtapes I Have Downloaded</a><BR><BR></center>';
  }
  else { 
    cmtext += 'To leave your review of this mixtape, please enter in your comments, select a rating and then click the Submit button below. Once your comment has been approved, you will receive 1,000 REWARDS POINTS and it will appear on this page for all visitors to see.<BR><BR>';
    cmtext += '** No HTML, URL references or profanity allowed! **<BR><BR><table cellpadding=4 cellspacing=0 border=0>';
    cmtext += '<tr class=signuptext>';
    cmtext += '<td align=right valign=middle><b>Mixtape Rating:&nbsp;</b><select name="rating" class=formfield2><option value="">Please Select One</option>';
    for(var x=1; x<6; x++) {
	  var disp = x + ' - ' + ratings[x-1];
      cmtext += '<option value="' + x + '">' + disp + '</option>';
    }
    cmtext += '</select></td></tr>';
    cmtext += '<tr class=signuptext>';
    cmtext += '<td align=center>';
    cmtext += '<textarea name=comments rows=10 cols=45></textarea>';
    cmtext += '<BR><BR><input type=hidden value="' + aid + '" name="aid"><input type=image src="/images/submit_review.gif" name="s5"><BR>';
	cmtext += '</td></tr></table>';
  }
  cmtext += '</td></tr></table>';
  cmtext += '</td></tr></table>';
  cmtext += '<table cellpadding=0 cellspacing=0 border=0 width=100%>';
  cmtext += '<tr><td class=midtext align=right height=29><img src="/images/mtp_subcathead4a.jpg" width=425 height=29></td>';
  cmtext += '</tr></table><BR>';
  document.writeln(cmtext);
}