﻿function checkEmail(emailAddress) {

	var foundAtSymbol = 0;
	var foundDot = 0;
	var md;

	// Go through each character in the email address.
	for (var x=0; x<emailAddress.length - 1; x++) {
		md = emailAddress.substr(x, 1);
	
		// Is the character an @ symbol?
		if (md == '@') foundAtSymbol++;
	
		// Count how many dots there are after the @ symbol.
		if (md == '.' && foundAtSymbol == 1) foundDot++;
	}

	// Is there only one @ symbol, and are there more than one dots?
	if (foundDot > 0 && foundAtSymbol == 1) {
		return true;
	} else {
		return false;
	}
}
function checkRegisterForm() {
	if(document.getElementById('e').value == '') {
		alert('\nError: Required Field Empty.\n\nPlease enter your email address.\n\n');
		document.getElementById('e').focus();
		return false;
	}
	if(!checkEmail(document.getElementById('e').value)) {
		alert('\nError: Invalid Email Address.\n\nPlease enter a valid email address.\n\n');
		document.getElementById('e').select();
		return false;
	}
}
function playVideo(v,i) {
	document.getElementById('contentitemvideo'+i).style.display = 'none';
    var s1 = new SWFObject('/interface/player.swf','playerSwf','740','415','9','#000000', true);
    s1.useExpressInstall('/interface/expressinstall.swf');
    s1.addParam('allowfullscreen','true');
    s1.addParam('allowscriptaccess','always');
    s1.addParam('wmode','opaque');
    s1.addParam("quality", "high");
    
    s1.addVariable("skin", "/interface/3deep.swf");
    s1.addVariable("frontcolor", "ffffff");
    s1.addVariable("lightcolor", "cc9900");
    s1.addVariable("controlbar", "bottom");
    s1.addVariable("stretching", "exactfit");
s1.addVariable("autostart", "true");
s1.addVariable("bufferlength", "10");
    // Begin instance variables
    s1.addVariable("image", "/interface/preview.jpg");
    s1.addVariable("file", v);
    // End instance variables
    s1.write('videoplayer'+i);
	document.getElementById('videoplayer'+i).style.display = 'block';
	var tmp = document.createElement('div');
	tmp.className = 'closebutton';
	tmp.innerHTML = '<a class="closebutton menuitem" href="#" onclick="closeVideo\('+i+'\)\;return false\;">X</a>';
	var cont = document.getElementById('videoplayer'+i);
	cont.insertBefore(tmp,cont.firstChild);
}
function playAudio(a,i) {
	document.getElementById('contentitemaudio'+i).style.display = 'none';
    var s1 = new SWFObject('/interface/player.swf','playerSwf','740','440','9','#000000', true);
    s1.useExpressInstall('/interface/expressinstall.swf');
    s1.addParam('allowfullscreen','false');
    s1.addParam('allowscriptaccess','always');
    s1.addParam('wmode','opaque');
    s1.addParam("quality", "high");
    
    s1.addVariable("skin", "/interface/3deep.swf");
    s1.addVariable("frontcolor", "ffffff");
    s1.addVariable("lightcolor", "cc9900");
    s1.addVariable("controlbar", "bottom");
    s1.addVariable("stretching", "exactfit");
s1.addVariable("autostart", "true");
s1.addVariable("bufferlength", "10");
    // Begin instance variables
    s1.addVariable("image", "/interface/preview.jpg");
    s1.addVariable("file", a);
    // End instance variables
    s1.write('audioplayer'+i);
	document.getElementById('audioplayer'+i).style.display = 'block';
	var tmp = document.createElement('div');
	tmp.className = 'closebutton';
	tmp.innerHTML = '<a class="closebutton menuitem" href="#" onclick="closeAudio\('+i+'\)\;return false\;">X</a>';
	var cont = document.getElementById('audioplayer'+i);
	cont.appendChild(tmp);
}
function closeVideo(i) {
	document.getElementById('videoplayer'+i).innerHTML = '';
	document.getElementById('videoplayer'+i).style.display = 'none';
	document.getElementById('contentitemvideo'+i).style.display = 'block';
}
function closeAudio(i) {
	document.getElementById('audioplayer'+i).innerHTML = '';
	document.getElementById('audioplayer'+i).style.display = 'none';
	document.getElementById('contentitemaudio'+i).style.display = 'block';
}
