String.prototype.getPrefix = function() { return this.substr(0, this.indexOf('_'));};
String.prototype.getSuffix = function() { return this.substr(this.lastIndexOf('_')+1);};

function play(el) {
	var table = document.getElementById('media-table');
	var tr = table.getElementsByTagName('tr');
	for(i=0; i<tr.length; i++) {
		if(tr[i].className=='bline') continue;
		tr[i].className = '';
	}
	var td = el.parentNode;
	var parent_tr = td.parentNode;
	parent_tr.className = 'tr-active';
	
	
	var media_file = td.getElementsByTagName('span')[0].innerHTML;
	var image_file = td.getElementsByTagName('em')[0].innerHTML;
	loadFile('mediaplayer', {file:media_file, image:image_file});
	sendEvent('mediaplayer', 'playpause');
}

function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[swf];
  } else {
    return document[swf];
  }
}

function loadFile(swf,obj) { 
  thisMovie(swf).loadFile(obj); 
}

function sendEvent(swf,typ,prm) { 
  thisMovie(swf).sendEvent(typ,prm); 
};

function getURL(el) {
	var redirect = el[el.selectedIndex].value == '' ? '/downloads' : el[el.selectedIndex].value
	window.location.href = redirect;
}
function update_cart_link(select) {
    var event_id = select.id.getSuffix();
    // $('add_to_cart_' + event_id).href = $('add_to_cart_' + event_id).href.replace(/num=\d+/, 'num=' + select.value);
    document.getElementById('add_to_cart_' + event_id).href = document.getElementById('add_to_cart_' + event_id).href.replace(/num=\d+/, 'num=' + select.value);
    //console.log($('add_to_cart_' + event_id).href);
}
function reload_spam_trap() {
    img = $('spam_trap');
    img.src = '/etc/verification/image.php?' + Math.random();
}