$(function()
{
	$('.play-video-large').click(function()
	{
		var id = $(this).attr('rel');

		if (id && swfobject && swfobject.hasFlashPlayerVersion('9'))
		{
			swfobject.embedSWF('/bazment/teknikdelegationen/flash/tdvideoplayer.swf', 'flashcontent', '598px', '336px', '9', '/bazment/Centrum/flash/flash/expressinstall.swf', 
							   { autoplay:true, url:'/uploads/files/' + id + '.flv'}, { menu:false, wmode:'transparent', allowFullScreen:true });
		}

		return false;
	});

	$('.play-video-small, a.iframe').prettyPhoto();
});

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function validateFaqForm(nameId, emailId, textId)
{
	var valid = false;
	var regex = new RegExp('^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$');

	var name = document.getElementById(nameId);
	var email = document.getElementById(emailId);
	var text = document.getElementById(textId);

	if (name.value.trim().length > 0 && regex.test(email.value) && text.value.trim().length > 0)
		valid = true;
		
	if (!valid)
		document.getElementById('lblError').style.display = 'block';
	else
		document.getElementById('lblError').style.display = 'none';
		
	return valid;
}

function validateSubscriptionForm(nameId, emailId, phoneId, addressId, titleId, label)
{
	var valid = false;
	var regex = new RegExp('^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$');

	if (checkField(nameId) && regex.test(document.getElementById(emailId).value) && checkField(phoneId) && checkField(addressId) && checkField(titleId))
		valid = true;
		
	if (!valid)
		document.getElementById('lblError').style.display = 'block';
	else
		document.getElementById('lblError').style.display = 'none';
		
	return valid;
}

function checkField(id)
{
	return document.getElementById(id).value.trim().length > 0;
}